blob: caf5403de25734642ea0bed0ce27c6495451924a [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#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053073QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
75#endif
76
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053078static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 uint16_t msg_type, void *pMsgBuf);
80
81/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053082QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053084 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085
86 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053087 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053088 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053089 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 }
91
92 return status;
93}
94
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053095QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053097 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
99 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530100 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530101 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530102 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 }
104
105 return status;
106}
107
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700108tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700109{
110 tpAniSirGlobal mac_ctx;
111 tHalHandle h_hal;
112
113 h_hal = cds_get_context(QDF_MODULE_ID_SME);
114 if (NULL == h_hal) {
115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
116 FL("invalid h_hal"));
117 return NULL;
118 }
119
120 mac_ctx = PMAC_STRUCT(h_hal);
121 if (NULL == mac_ctx) {
122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
123 FL("Invalid MAC context"));
124 return NULL;
125 }
126
127 return mac_ctx;
128}
129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130/**
131 * sme_process_set_hw_mode_resp() - Process set HW mode response
132 * @mac: Global MAC pointer
133 * @msg: HW mode response
134 *
135 * Processes the HW mode response and invokes the HDD callback
136 * to process further
137 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530138static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139{
Krunal Sonia8270f52017-02-23 19:51:25 -0800140 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 tSmeCmd *command = NULL;
142 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800143 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700145 enum policy_mgr_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530146 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800147 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 param = (struct sir_set_hw_mode_resp *)msg;
150 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700151 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 /* Not returning. Need to check if active command list
153 * needs to be freed
154 */
155 }
156
Krunal Sonia8270f52017-02-23 19:51:25 -0800157 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700159 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 }
162
163 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
164 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700165 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800166 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 }
168
169 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700170 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800171 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 }
173
174 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530175 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800176 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530177
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700178 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530179 command->u.set_hw_mode_cmd.reason,
180 command->u.set_hw_mode_cmd.session_id);
181
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700182 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700183 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700184 goto end;
185 }
186
187 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700188 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700189 goto end;
190 }
191
192 /* Irrespective of the reason for which the hw mode change request
193 * was issued, the policy manager connection table needs to be updated
194 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
195 * set hw mode was successful.
196 */
197 callback(param->status,
198 param->cfgd_hw_mode_index,
199 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800200 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800201 command->u.set_hw_mode_cmd.next_action,
202 command->u.set_hw_mode_cmd.reason,
203 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800204 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800205 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
206 sme_err("session %d is invalid", session_id);
207 goto end;
208 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800209 session = CSR_GET_SESSION(mac, session_id);
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700210 if (reason == POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700211 /* In the case of hidden SSID, connection update
212 * (set hw mode) is done after the scan with reason
213 * code eCsrScanForSsid completes. The connect/failure
214 * needs to be handled after the response of set hw
215 * mode
216 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800217 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700218 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800219 csr_scan_handle_search_for_ssid(mac,
220 session_id);
221 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700222 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800223 csr_scan_handle_search_for_ssid_failure(mac,
224 session_id);
225 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800226 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 }
228
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530229end:
Krunal Soni72dba662017-02-15 20:13:17 -0800230 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530232 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800234 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800235
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530236 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237}
238
239/**
240 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
241 * @mac: Global MAC pointer
242 * @msg: HW mode transition response
243 *
244 * Processes the HW mode transition indication and invoke the HDD callback
245 * to process further
246 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 uint8_t *msg)
249{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 struct sir_hw_mode_trans_ind *param;
251
252 param = (struct sir_hw_mode_trans_ind *)msg;
253 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700254 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 }
257
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800258 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800259 param->new_hw_mode_index,
260 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800261 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530263 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264}
265
Naveen Rawate7d86052015-11-13 12:01:43 -0800266/**
267 * free_sme_cmds() - This function frees memory allocated for SME commands
268 * @mac_ctx: Pointer to Global MAC structure
269 *
270 * This function frees memory allocated for SME commands
271 *
272 * @Return: void
273 */
274static void free_sme_cmds(tpAniSirGlobal mac_ctx)
275{
276 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530277
Naveen Rawate7d86052015-11-13 12:01:43 -0800278 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
279 return;
280
281 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800283
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530284 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800285 mac_ctx->sme.pSmeCmdBufAddr = NULL;
286}
287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530288static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530290 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 tSmeCmd *pCmd;
292 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800293 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294
295 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530299 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 goto end;
301
Naveen Rawate7d86052015-11-13 12:01:43 -0800302 /* following pointer contains array of pointers for tSmeCmd* */
303 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530304 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800305 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530306 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800307 goto end;
308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530310 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800311 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
312 /*
313 * Since total size of all commands together can be huge chunk
314 * of memory, allocate SME cmd individually. These SME CMDs are
315 * moved between pending and active queues. And these freeing of
316 * these queues just manipulates the list but does not actually
317 * frees SME CMD pointers. Hence store each SME CMD address in
318 * the array, sme.pSmeCmdBufAddr. This will later facilitate
319 * freeing up of all SME CMDs with just a for loop.
320 */
321 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530322 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800323 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530324 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800325 free_sme_cmds(pMac);
326 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800328 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
329 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
330 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 }
332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530334 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700335 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336
337 return status;
338}
339
Krunal Sonia8270f52017-02-23 19:51:25 -0800340void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341{
Krunal Sonia8270f52017-02-23 19:51:25 -0800342 sme_cmd->command = eSmeNoCommand;
343 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530344 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345}
346
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530347static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530349 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 csr_ll_close(&pMac->sme.smeCmdFreeList);
352
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530353 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530354 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700355 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 goto done;
357 }
358
Naveen Rawate7d86052015-11-13 12:01:43 -0800359 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530361 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530362 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700363 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364done:
365 return status;
366}
367
Jeff Johnson49c02f92016-10-07 10:29:09 -0700368static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369{
370 switch (pCmd->command) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700372 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 pCmd->u.roamCmd.roamReason);
374 break;
375
376 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700377 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 pCmd->u.wmStatusChangeCmd.Type);
379 break;
380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700382 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 pCmd->command);
384 break;
385 }
386}
387
388tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
389{
390 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
391 tListElem *pEntry;
392 static int sme_command_queue_full;
393
394 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
395
396 /* If we can get another MS Msg buffer, then we are ok. Just link */
397 /* the entry onto the linked list. (We are using the linked list */
398 /* to keep track of tfhe message buffers). */
399 if (pEntry) {
400 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
401 /* reset when free list is available */
402 sme_command_queue_full = 0;
403 } else {
404 int idx = 1;
405
406 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800407 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530408 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530410
411 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
413 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530414 if (eSmeCsrCommandMask & pTempCmd->command)
415 /* CSR command is stuck. See what the reason
416 * code is for that command
417 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 } /* if(pTempCmd) */
420
421 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800422 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800424 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 LL_ACCESS_NOLOCK);
426 while (pEntry && !sme_command_queue_full) {
427 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
428 /* Print only 1st five commands from pending queue. */
429 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530430 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 idx, pTempCmd->command);
432 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530433 if (eSmeCsrCommandMask & pTempCmd->command)
434 /* CSR command is stuck. See what the reason
435 * code is for that command
436 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800438 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 LL_ACCESS_NOLOCK);
440 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800441 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442
Abhishek Singh5ea86532016-04-27 14:10:53 +0530443 if (pMac->roam.configParam.enable_fatal_event)
444 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
445 WLAN_LOG_INDICATOR_HOST_DRIVER,
446 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
447 false,
448 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530449 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530450 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 }
452
453 /* memset to zero */
454 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530455 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530459 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 }
461
462 return pRetCmd;
463}
464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800466 * sme_ser_handle_active_cmd() - handle command activation callback from
467 * new serialization module
468 * @cmd: pointer to new serialization command
469 *
470 * This API is to handle command activation callback from new serialization
471 * callback
472 *
473 * Return: QDF_STATUS_SUCCESS
474 */
475static
476QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
477{
478 tSmeCmd *sme_cmd;
479 tHalHandle hal;
480 tpAniSirGlobal mac_ctx;
481 QDF_STATUS status = QDF_STATUS_SUCCESS;
482 bool do_continue;
483
484 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700485 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800486 return QDF_STATUS_E_FAILURE;
487 }
488
489 hal = cds_get_context(QDF_MODULE_ID_SME);
490 mac_ctx = PMAC_STRUCT(hal);
491 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700492 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800493 return QDF_STATUS_E_FAILURE;
494 }
495 sme_cmd = cmd->umac_cmd;
496 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700497 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800498 return QDF_STATUS_E_FAILURE;
499 }
500
501 switch (sme_cmd->command) {
502 case eSmeCommandRoam:
503 status = csr_roam_process_command(mac_ctx, sme_cmd);
504 break;
505 case eSmeCommandWmStatusChange:
506 csr_roam_process_wm_status_change_command(mac_ctx,
507 sme_cmd);
508 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800509 case eSmeCommandAddTs:
510 case eSmeCommandDelTs:
511#ifndef WLAN_MDM_CODE_REDUCTION_OPT
512 do_continue = qos_process_command(mac_ctx, sme_cmd);
513 if (do_continue)
514 status = QDF_STATUS_E_FAILURE;
515#endif
516 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800517 case e_sme_command_set_hw_mode:
518 csr_process_set_hw_mode(mac_ctx, sme_cmd);
519 break;
520 case e_sme_command_nss_update:
521 csr_process_nss_update_req(mac_ctx, sme_cmd);
522 break;
523 case e_sme_command_set_dual_mac_config:
524 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
525 break;
526 case e_sme_command_set_antenna_mode:
527 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
528 break;
529 default:
530 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700531 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800532 status = QDF_STATUS_E_FAILURE;
533 break;
534 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800535 return status;
536}
537
538QDF_STATUS sme_ser_cmd_callback(void *buf,
539 enum wlan_serialization_cb_reason reason)
540{
541 struct wlan_serialization_command *cmd = buf;
542 tHalHandle hal;
543 tpAniSirGlobal mac_ctx;
544 QDF_STATUS status = QDF_STATUS_SUCCESS;
545 tSmeCmd *sme_cmd;
546
547 hal = cds_get_context(QDF_MODULE_ID_SME);
548 mac_ctx = PMAC_STRUCT(hal);
549 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700550 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800551 return QDF_STATUS_E_FAILURE;
552 }
553 /*
554 * Do not acquire lock here as sme global lock is already acquired in
555 * caller or MC thread context
556 */
557 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700558 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800559 return QDF_STATUS_E_FAILURE;
560 }
561
562 switch (reason) {
563 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700564 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800565 status = sme_ser_handle_active_cmd(cmd);
566 break;
567 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700568 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800569 break;
570 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700571 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800572 sme_cmd = cmd->umac_cmd;
573 csr_release_command_buffer(mac_ctx, sme_cmd);
574 break;
575 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700576 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800577 break;
578 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700579 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800580 return QDF_STATUS_E_FAILURE;
581 }
582 return status;
583}
584
Wen Gong3f003382018-05-14 14:26:37 +0800585#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Krunal Sonia8270f52017-02-23 19:51:25 -0800586/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530587 * sme_get_sessionid_from_activelist() - gets session id
588 * @mac: mac context
589 *
590 * This function is used to get session id from sme command
591 * active list
592 *
593 * Return: returns session id
594 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700595static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530596{
597 tListElem *entry;
598 tSmeCmd *command;
599 uint32_t session_id = CSR_SESSION_ID_INVALID;
600
Krunal Sonia8270f52017-02-23 19:51:25 -0800601 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530602 if (entry) {
603 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
604 session_id = command->sessionId;
605 }
606
607 return session_id;
608}
609
610/**
611 * sme_state_info_dump() - prints state information of sme layer
612 * @buf: buffer pointer
613 * @size: size of buffer to be filled
614 *
615 * This function is used to dump state information of sme layer
616 *
617 * Return: None
618 */
619static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
620{
621 uint32_t session_id, active_session_id;
622 tHalHandle hal;
623 tpAniSirGlobal mac;
624 uint16_t len = 0;
625 char *buf = *buf_ptr;
626 eCsrConnectState connect_state;
627
628 hal = cds_get_context(QDF_MODULE_ID_SME);
629 if (hal == NULL) {
630 QDF_ASSERT(0);
631 return;
632 }
633
634 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530635
636 active_session_id = sme_get_sessionid_from_activelist(mac);
637 if (active_session_id != CSR_SESSION_ID_INVALID) {
638 len += qdf_scnprintf(buf + len, *size - len,
639 "\n active command sessionid %d", active_session_id);
640 }
641
642 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
643 if (CSR_IS_SESSION_VALID(mac, session_id)) {
644 connect_state =
645 mac->roam.roamSession[session_id].connectState;
646 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
647 connect_state)
648 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
649 connect_state)) {
650 len += qdf_scnprintf(buf + len, *size - len,
651 "\n NeighborRoamState: %d",
652 mac->roam.neighborRoamInfo[session_id].
653 neighborRoamState);
654 len += qdf_scnprintf(buf + len, *size - len,
655 "\n RoamState: %d", mac->roam.
656 curState[session_id]);
657 len += qdf_scnprintf(buf + len, *size - len,
658 "\n RoamSubState: %d", mac->roam.
659 curSubState[session_id]);
660 len += qdf_scnprintf(buf + len, *size - len,
661 "\n ConnectState: %d",
662 connect_state);
663 }
664 }
665 }
666
667 *size -= len;
668 *buf_ptr += len;
669}
670
671/**
672 * sme_register_debug_callback() - registration function sme layer
673 * to print sme state information
674 *
675 * Return: None
676 */
677static void sme_register_debug_callback(void)
678{
679 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
680}
Wen Gong3f003382018-05-14 14:26:37 +0800681#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800682static void sme_register_debug_callback(void)
683{
684}
Wen Gong3f003382018-05-14 14:26:37 +0800685#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687/* Global APIs */
688
689/**
690 * sme_open() - Initialze all SME modules and put them at idle state
691 * @hHal: The handle returned by mac_open
692 *
693 * The function initializes each module inside SME, PMC, CSR, etc. Upon
694 * successfully return, all modules are at idle state ready to start.
695 * smeOpen must be called before any other SME APIs can be involved.
696 * smeOpen must be called after mac_open.
697 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530698 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 * Other status means SME is failed to be initialized
700 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530701QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530703 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705
706 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530707 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530708 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700710 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530711 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 }
713 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530714 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700715 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 return status;
717 }
718
719 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530720 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700721 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 return status;
723 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724
725#ifndef WLAN_MDM_CODE_REDUCTION_OPT
726 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530727 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700728 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 return status;
730 }
731#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530733 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530737 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700738 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 return status;
740 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530742 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700743 wlan_serialization_legacy_init_callback();
744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 return status;
746}
747
748/*
749 * sme_init_chan_list, triggers channel setup based on country code.
750 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530751QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700752 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753{
754 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
755
Amar Singhala297bfa2015-10-15 15:07:29 -0700756 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
758 pmac->roam.configParam.Is11dSupportEnabled = false;
759 }
760
761 return csr_init_chan_list(pmac, alpha2);
762}
763
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530764/*
765 * sme_set11dinfo() - Set the 11d information about valid channels
766 * and there power using information from nvRAM
767 * This function is called only for AP.
768 *
769 * This is a synchronous call
770 *
771 * hHal - The handle returned by mac_open.
772 * pSmeConfigParams - a pointer to a caller allocated object of
773 * typedef struct _smeConfigParams.
774 *
775 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
776 *
777 * Other status means SME is failed to update the config parameters.
778 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530780QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530782 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530784 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
786 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700787 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 return status;
789 }
790
791 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700792 if (!QDF_IS_STATUS_SUCCESS(status))
793 sme_err("csr_set_channels failed with status: %d", status);
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 return status;
796}
797
798/**
799 * sme_set_scan_disable() - Dynamically enable/disable scan
800 * @h_hal: Handle to HAL
801 *
802 * This command gives the user an option to dynamically
803 * enable or disable scans.
804 *
805 * Return: None
806 */
807void sme_set_scan_disable(tHalHandle h_hal, int value)
808{
809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530810
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700811 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530812 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530814/*
815 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
816 * This is a synchronous call
817 *
818 * hHal - The handle returned by HostapdAdapter.
819 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
820 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
821 * Other status means, failed to get the current regulatory domain.
822 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530824QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
825 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530827 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
829
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530830 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
832 NO_SESSION, 0));
833 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700834 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 return status;
836 }
837
838 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530839 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840
841 return status;
842}
843
Krunal Sonie3531942016-04-12 17:43:53 -0700844/**
845 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
846 * incoming val
847 * @hal: Handle for Hal layer
848 * @val: New FTM capability value
849 *
850 * Return: None
851 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530852void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
853 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700854{
855 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530856 QDF_STATUS status;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530857
Naveen Rawatd2657be2017-10-10 14:31:23 -0700858 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700859
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530860 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700861 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
862 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
863 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
864 } else {
865 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
866 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
867 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
868 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530869
870 /* Inform this RRM IE change to FW */
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530871 status = sme_acquire_global_lock(&mac_ctx->sme);
872 if (QDF_IS_STATUS_SUCCESS(status)) {
873 csr_roam_offload_scan(mac_ctx, session_id,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530874 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
875 REASON_CONNECT_IES_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530876 sme_release_global_lock(&mac_ctx->sme);
877 } else {
878 sme_err("Failed to acquire SME lock");
879 }
Krunal Sonie3531942016-04-12 17:43:53 -0700880}
881
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530882/*
883 * sme_update_config() - Change configurations for all SME moduels
884 * The function updates some configuration for modules in SME, CSR, etc
885 * during SMEs close open sequence.
886 * Modules inside SME apply the new configuration at the next transaction.
887 * This is a synchronous call
888 *
889 * hHal - The handle returned by mac_open.
890 * pSmeConfigParams - a pointer to a caller allocated object of
891 * typedef struct _smeConfigParams.
892 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
893 * Other status means SME is failed to update the config parameters.
894 */
895QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
896 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530898 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
900
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530901 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
903 0));
904 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700905 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 return status;
907 }
908
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530909 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
910 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530912 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700913 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530916 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
917 rrmConfig);
918
919 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700920 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530922
923 /* For SOC, CFG is set before start We don't want to apply global CFG
924 * in connect state because that may cause some side affect
925 */
926 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929 /*
930 * If scan offload is enabled then lim has allow the sending of
931 * scan request to firmware even in powersave mode. The firmware has
932 * to take care of exiting from power save mode
933 */
934 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
935
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530936 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530939
940 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 return status;
943}
944
945/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530946 * sme_update_scan_roam_params() - Update the scan roaming params
947 * @mac_ctx: mac ctx
948 *
949 * Return: void.
950 */
951static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
952{
953 struct roam_filter_params scan_params = {0};
954 struct roam_ext_params *roam_params_src;
955 uint8_t i;
956 QDF_STATUS status;
957
958 roam_params_src = &mac_ctx->roam.configParam.roam_params;
959
960 scan_params.num_bssid_avoid_list =
961 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530962
963 if (scan_params.num_bssid_avoid_list >
964 MAX_AVOID_LIST_BSSID)
965 scan_params.num_bssid_avoid_list =
966 MAX_AVOID_LIST_BSSID;
967
968 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
969 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
970 &roam_params_src->bssid_avoid_list[i]);
971 }
972
973 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
974 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700975 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530976 status);
977}
978
979/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 * sme_update_roam_params() - Store/Update the roaming params
981 * @hal: Handle for Hal layer
982 * @session_id: SME Session ID
983 * @roam_params_src: The source buffer to copy
984 * @update_param: Type of parameter to be updated
985 *
986 * Return: Return the status of the updation.
987 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530988QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -0700989 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 int update_param)
991{
992 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
993 struct roam_ext_params *roam_params_dst;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530994 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 uint8_t i;
996
997 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
998 switch (update_param) {
999 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1000 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001001 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001003 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001005 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001007 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001009 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001011 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001013 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 roam_params_dst->is_5g_pref_enabled = true;
1015 break;
1016 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301017 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1019 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001020 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1022 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001023 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301024 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001025 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 roam_params_dst->ssid_allowed_list[i].length);
1027 }
1028 break;
1029 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301030 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1032 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001033 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301035 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001036 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 sizeof(tSirMacAddr));
1038 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001039 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 }
1041 break;
1042 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301043 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301044 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001046 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301048 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001049 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 }
1051 break;
1052 case REASON_ROAM_GOOD_RSSI_CHANGED:
1053 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001054 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 break;
1056 default:
1057 break;
1058 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301059
1060 status = sme_acquire_global_lock(&mac_ctx->sme);
1061 if (QDF_IS_STATUS_SUCCESS(status)) {
1062 csr_roam_offload_scan(mac_ctx, session_id,
1063 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1064 update_param);
1065 sme_release_global_lock(&mac_ctx->sme);
1066 } else {
1067 sme_err("Failed to acquire SME lock");
1068 }
Abhishek Singh158fe252017-03-23 11:09:34 +05301069
1070 sme_update_scan_roam_params(mac_ctx);
1071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 return 0;
1073}
1074
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301075/*
1076 * sme_process_ready_to_suspend() -
1077 * On getting ready to suspend indication, this function calls
1078 * callback registered (HDD callbacks) with SME to inform ready
1079 * to suspend indication.
1080 *
1081 * hHal - Handle returned by mac_open.
1082 * pReadyToSuspend - Parameter received along with ready to suspend
1083 * indication from WMA.
1084 * Return: None
1085 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001086static void sme_process_ready_to_suspend(tHalHandle hHal,
1087 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088{
1089 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1090
1091 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301092 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 "%s: pMac is null", __func__);
1094 return;
1095 }
1096
1097 if (NULL != pMac->readyToSuspendCallback) {
1098 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1099 pReadyToSuspend->suspended);
1100 pMac->readyToSuspendCallback = NULL;
1101 }
1102}
1103
1104#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001106/**
1107 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1108 * @hHal - Handle returned by mac_open.
1109 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1110 * indication from WMA.
1111 *
1112 * On getting ready to Ext WoW indication, this function calls callback
1113 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1114 *
1115 * Return: None
1116 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001117static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1118 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119{
1120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1121
1122 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 "%s: pMac is null", __func__);
1125 return;
1126 }
1127
1128 if (NULL != pMac->readyToExtWoWCallback) {
1129 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1130 pReadyToExtWoW->status);
1131 pMac->readyToExtWoWCallback = NULL;
1132 pMac->readyToExtWoWContext = NULL;
1133 }
1134
1135}
1136#endif
1137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301138/*
1139 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1140 * that the NIC is ready tio run.
1141 * The function is called by HDD at the end of initialization stage so PE/HAL
1142 * can enable the NIC to running state.
1143 * This is a synchronous call
1144 *
1145 * @hHal - The handle returned by mac_open.
1146 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1147 * successfully.
1148 * Other status means SME failed to send the message to PE.
1149 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301150QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151{
Abhishek Singhde410b72017-05-22 15:25:39 +05301152 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301153 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1155
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301156 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1158 do {
1159
Abhishek Singhde410b72017-05-22 15:25:39 +05301160 msg = qdf_mem_malloc(sizeof(*msg));
1161 if (!msg) {
1162 sme_err("Memory allocation failed! for msg");
1163 return QDF_STATUS_E_NOMEM;
1164 }
1165 msg->messageType = eWNI_SME_SYS_READY_IND;
1166 msg->length = sizeof(*msg);
Abhishek Singhde410b72017-05-22 15:25:39 +05301167 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001168 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301170 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1171 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301172 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001174 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 break;
1176 }
1177
1178 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301179 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001180 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 break;
1182 }
1183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 pMac->sme.state = SME_STATE_READY;
1185 } while (0);
1186
1187 return status;
1188}
1189
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001190QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1191{
1192 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1193 QDF_STATUS status = QDF_STATUS_SUCCESS;
1194
1195 if (NULL == mac_ctx) {
1196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1197 FL("Invalid MAC context"));
1198 return QDF_STATUS_E_FAILURE;
1199 }
1200
1201 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1202 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1203 status = QDF_STATUS_E_INVAL;
1204
1205 return status;
1206}
1207
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001208#ifdef WLAN_CONV_SPECTRAL_ENABLE
1209static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1210{
1211 struct spectral_legacy_cbacks spectral_cb;
1212 QDF_STATUS status;
1213
1214 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1215 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1216 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1217 status = spectral_register_legacy_cb(mac_ctx->psoc, &spectral_cb);
1218
1219 return status;
1220}
1221#else
1222static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1223{
1224 return QDF_STATUS_SUCCESS;
1225}
1226#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301227/*
1228 * sme_start() - Put all SME modules at ready state.
1229 * The function starts each module in SME, PMC, CSR, etc. . Upon
1230 * successfully return, all modules are ready to run.
1231 * This is a synchronous call
1232 *
1233 * hHal - The handle returned by mac_open.
1234 * Return QDF_STATUS_SUCCESS - SME is ready.
1235 * Other status means SME is failed to start
1236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301237QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301239 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001241 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
1243 do {
1244 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301245 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001246 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 break;
1248 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001249 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001250 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001251 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1252 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1253 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1254 sme_cbacks.sme_soc_set_dual_mac_config =
1255 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001256 sme_cbacks.sme_change_mcc_beacon_interval =
1257 sme_change_mcc_beacon_interval;
1258 sme_cbacks.sme_get_ap_channel_from_scan =
1259 sme_get_ap_channel_from_scan;
1260 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001261 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1262 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001263 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001264 status);
1265 break;
1266 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001267 sme_register_spectral_cb(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001270 /* START RRM */
1271 status = rrm_start(pMac);
1272 if (!QDF_IS_STATUS_SUCCESS(status)) {
1273 sme_err("Failed to start RRM");
1274 break;
1275 }
1276 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 return status;
1278}
1279
Arif Hussaincd151632017-02-11 16:57:19 -08001280static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1281 struct scheduler_msg *msg)
1282{
1283 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001284 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001285 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1286 uint32_t session_id = 0;
1287 eRoamCmdStatus roam_status;
1288 eCsrRoamResult roam_result;
1289
1290 switch (msg->type) {
1291 case eWNI_SME_DFS_RADAR_FOUND:
1292 {
1293 session_id = msg->bodyval;
1294 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1295 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301296 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001297 "sapdfs: Radar indication event occurred");
1298 break;
1299 }
1300 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1301 {
1302 csa_ie_tx_complete_rsp =
1303 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1304 if (!csa_ie_tx_complete_rsp) {
1305 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1306 return QDF_STATUS_E_FAILURE;
1307 }
1308 session_id = csa_ie_tx_complete_rsp->sessionId;
1309 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1310 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301311 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001312 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1313 session_id);
1314 break;
1315 }
1316 case eWNI_SME_DFS_CAC_COMPLETE:
1317 {
1318 session_id = msg->bodyval;
1319 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1320 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001322 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1323 session_id);
1324 break;
1325 }
1326 default:
1327 {
1328 sme_err("Invalid DFS message: 0x%x", msg->type);
1329 status = QDF_STATUS_E_FAILURE;
1330 return status;
1331 }
1332 }
1333
1334 /* Indicate Radar Event to SAP */
1335 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1336 roam_status, roam_result);
1337 return status;
1338}
1339
1340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301342/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 * Handle the unprotected management frame indication from LIM and
1344 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301345 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301346QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1348{
1349 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001351 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1353
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001354 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1355 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1356 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
1358 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001359 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1361
1362 return status;
1363}
1364#endif
1365
Kapil Gupta8878ad92017-02-13 11:56:04 +05301366QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1367{
1368 QDF_STATUS status = QDF_STATUS_SUCCESS;
1369 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001370 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301371 eRoamCmdStatus roamStatus;
1372 eCsrRoamResult roamResult;
1373
1374 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001375 if (!roamInfo) {
1376 sme_err("mem alloc failed for roam info");
1377 return QDF_STATUS_E_FAILURE;
1378 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301379 roamInfo->dfs_event.sessionId = session_id;
1380
1381 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1382 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301383 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301384 "sapdfs: Updated new channel event");
1385
1386 /* Indicate channel Event to SAP */
1387 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1388 roamStatus, roamResult);
1389
1390 qdf_mem_free(roamInfo);
1391 return status;
1392}
1393
1394
Abhishek Singh518323d2015-10-19 17:42:01 +05301395/**
1396 * sme_extended_change_channel_ind()- function to indicate ECSA
1397 * action frame is received in lim to SAP
1398 * @mac_ctx: pointer to global mac structure
1399 * @msg_buf: contain new channel and session id.
1400 *
1401 * This function is called to post ECSA action frame
1402 * receive event to SAP.
1403 *
1404 * Return: success if msg indicated to SAP else return failure
1405 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301406static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301407 void *msg_buf)
1408{
1409 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301410 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301411 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001412 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301413 eRoamCmdStatus roam_status;
1414 eCsrRoamResult roam_result;
1415
Abhishek Singh518323d2015-10-19 17:42:01 +05301416 ext_chan_ind = msg_buf;
1417 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001418 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301419 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301420 }
1421 session_id = ext_chan_ind->session_id;
1422 roamInfo.target_channel = ext_chan_ind->new_channel;
1423 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1424 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001425 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1426 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301427
1428 /* Indicate Ext Channel Change event to SAP */
1429 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1430 roam_status, roam_result);
1431 return status;
1432}
1433
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001434#ifdef FEATURE_WLAN_ESE
1435/**
1436 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1437 * @hHal: HAL handle
1438 * @sessionId: session id
1439 * @isEseIniFeatureEnabled: ese ini enabled
1440 *
1441 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1442 * isEseIniFeatureEnabled. This is a synchronous call
1443 *
1444 * Return: QDF_STATUS enumeration
1445 */
1446QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1447 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1448{
1449 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301450 QDF_STATUS status;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001451
1452 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1453 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301454 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001455 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1456 __func__,
1457 pMac->roam.configParam.isEseIniFeatureEnabled,
1458 isEseIniFeatureEnabled);
1459 return QDF_STATUS_SUCCESS;
1460 }
1461
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001463 "%s: EseEnabled is changed from %d to %d", __func__,
1464 pMac->roam.configParam.isEseIniFeatureEnabled,
1465 isEseIniFeatureEnabled);
1466 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001467 csr_neighbor_roam_update_fast_roaming_enabled(
1468 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001469
1470 if (true == isEseIniFeatureEnabled)
1471 sme_update_fast_transition_enabled(hHal, true);
1472
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301473 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
1474 status = sme_acquire_global_lock(&pMac->sme);
1475 if (QDF_IS_STATUS_SUCCESS(status)) {
1476 csr_roam_offload_scan(pMac, sessionId,
1477 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1478 REASON_ESE_INI_CFG_CHANGED);
1479 sme_release_global_lock(&pMac->sme);
1480 } else {
1481 sme_err("Failed to acquire SME lock");
1482 return status;
1483 }
1484 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001485 return QDF_STATUS_SUCCESS;
1486}
1487
1488/**
1489 * sme_set_plm_request() - set plm request
1490 * @hHal: HAL handle
1491 * @pPlmReq: Pointer to input plm request
1492 *
1493 * Return: QDF_STATUS enumeration
1494 */
1495QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1496{
1497 QDF_STATUS status;
1498 bool ret = false;
1499 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001500 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001501 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001502 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301503 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1504 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001505
1506 status = sme_acquire_global_lock(&pMac->sme);
1507 if (!QDF_IS_STATUS_SUCCESS(status))
1508 return status;
1509
1510 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001511 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001512 sme_release_global_lock(&pMac->sme);
1513 return QDF_STATUS_E_FAILURE;
1514 }
1515
1516 if (!pSession->sessionActive) {
1517 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1518 FL("Invalid Sessionid"));
1519 sme_release_global_lock(&pMac->sme);
1520 return QDF_STATUS_E_FAILURE;
1521 }
1522
1523 if (!pPlmReq->enable)
1524 goto send_plm_start;
1525 /* validating channel numbers */
1526 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1527 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1528 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001529 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1530 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001531 pPlmReq->plmChList[count])) {
1532 /* DFS channel is provided, no PLM bursts can be
1533 * transmitted. Ignoring these channels.
1534 */
1535 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301536 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001537 FL("DFS channel %d ignored for PLM"),
1538 pPlmReq->plmChList[count]);
1539 continue;
1540 }
1541 } else if (!ret) {
1542 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001544 FL("Unsupported channel %d ignored for PLM"),
1545 pPlmReq->plmChList[count]);
1546 continue;
1547 }
1548 ch_list[valid_count] = pPlmReq->plmChList[count];
1549 valid_count++;
1550 } /* End of for () */
1551
1552 /* Copying back the valid channel list to plm struct */
1553 qdf_mem_set((void *)pPlmReq->plmChList,
1554 pPlmReq->plmNumCh, 0);
1555 if (valid_count)
1556 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1557 valid_count);
1558 /* All are invalid channels, FW need to send the PLM
1559 * report with "incapable" bit set.
1560 */
1561 pPlmReq->plmNumCh = valid_count;
1562
1563send_plm_start:
1564 /* PLM START */
1565 msg.type = WMA_SET_PLM_REQ;
1566 msg.reserved = 0;
1567 msg.bodyptr = pPlmReq;
1568
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001569 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001570 &msg))) {
1571 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1572 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1573 sme_release_global_lock(&pMac->sme);
1574 return QDF_STATUS_E_FAILURE;
1575 }
1576
1577 sme_release_global_lock(&pMac->sme);
1578 return status;
1579}
1580
1581/**
1582 * sme_tsm_ie_ind() - sme tsm ie indication
1583 * @hHal: HAL handle
1584 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 *
1586 * Handle the tsm ie indication from LIM and forward it to HDD.
1587 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001588 * Return: QDF_STATUS enumeration
1589 */
1590static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591{
1592 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301593 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001594 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301596
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001597 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1598 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1599 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001601 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301602 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 return status;
1604}
1605
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001606/**
1607 * sme_set_cckm_ie() - set cckm ie
1608 * @hHal: HAL handle
1609 * @sessionId: session id
1610 * @pCckmIe: Pointer to CCKM Ie
1611 * @cckmIeLen: Length of @pCckmIe
1612 *
1613 * Function to store the CCKM IE passed from supplicant and use
1614 * it while packing reassociation request.
1615 *
1616 * Return: QDF_STATUS enumeration
1617 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301618QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 uint8_t *pCckmIe, uint8_t cckmIeLen)
1620{
1621 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301622 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301625 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1627 sme_release_global_lock(&pMac->sme);
1628 }
1629 return status;
1630}
1631
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001632/**
1633 * sme_set_ese_beacon_request() - set ese beacon request
1634 * @hHal: HAL handle
1635 * @sessionId: session id
1636 * @pEseBcnReq: Ese beacon report
1637 *
1638 * function to set ESE beacon request parameters
1639 *
1640 * Return: QDF_STATUS enumeration
1641 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301642QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 const tCsrEseBeaconReq *pEseBcnReq)
1644{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001645 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1647 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1648 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1649 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301650 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1652
1653 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001654 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301655 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 }
1657
1658 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301659 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 sizeof(tCsrEseBeaconReq));
1661
1662 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301663 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001665 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301666 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 }
1668
1669 pSmeRrmContext->eseBcnReqInProgress = true;
1670
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001671 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672
1673 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1674 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301675 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 pSession->connectedProfile.bssid.bytes,
1677 sizeof(tSirMacAddr));
1678 pSmeBcnReportReq->channelInfo.channelNum = 255;
1679 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1680 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1681
1682 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1683 pBeaconReq =
1684 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1685 pSmeBcnReportReq->fMeasurementtype[counter] =
1686 pBeaconReq->scanMode;
1687 pSmeBcnReportReq->measurementDuration[counter] =
1688 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1689 pSmeBcnReportReq->channelList.channelNumber[counter] =
1690 pBeaconReq->channel;
1691 }
1692
1693 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1694
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301695 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 pSmeRrmContext->eseBcnReqInProgress = false;
1697
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301698 qdf_mem_free(pSmeBcnReportReq);
1699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return status;
1701}
1702
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001703/**
1704 * sme_get_tsm_stats() - SME get tsm stats
1705 * @hHal: HAL handle
1706 * @callback: SME sends back the requested stats using the callback
1707 * @staId: The station ID for which the stats is requested for
1708 * @bssId: bssid
1709 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001710 * @tid: Traffic id
1711 *
1712 * API register a callback to get TSM Stats.
1713 *
1714 * Return: QDF_STATUS enumeration
1715 */
1716QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1717 tCsrTsmStatsCallback callback,
1718 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001719 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001720{
1721 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1723
1724 status = sme_acquire_global_lock(&pMac->sme);
1725 if (QDF_IS_STATUS_SUCCESS(status)) {
1726 status = csr_get_tsm_stats(pMac, callback,
1727 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001728 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001729 sme_release_global_lock(&pMac->sme);
1730 }
1731 return status;
1732}
1733
1734/**
1735 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1736 * @hHal: pointer HAL handle returned by mac_open
1737 * @sessionId: sme session id
1738 * @pChannelList: Output channel list
1739 * @numChannels: Output number of channels
1740 *
1741 * This routine is called to set ese roam scan channel list.
1742 * This is a synchronous call
1743 *
1744 * Return: QDF_STATUS
1745 */
1746QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1747 uint8_t sessionId,
1748 uint8_t *pChannelList,
1749 uint8_t numChannels)
1750{
1751 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1752 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001753 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1754 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001755 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1756 uint8_t newChannelList[128] = { 0 };
1757 uint8_t i = 0, j = 0;
1758
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001759 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1761 FL("Invalid sme session id: %d"), sessionId);
1762 return QDF_STATUS_E_INVAL;
1763 }
1764
1765 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1766 curchnl_list_info =
1767 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1768
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001769 status = sme_acquire_global_lock(&pMac->sme);
1770 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301771 sme_err("Failed to acquire SME lock");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001772 return status;
1773 }
1774 if (NULL != curchnl_list_info->ChannelList) {
1775 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1776 j += snprintf(oldChannelList + j,
1777 sizeof(oldChannelList) - j, "%d",
1778 curchnl_list_info->ChannelList[i]);
1779 }
1780 }
1781 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1782 pChannelList, numChannels,
1783 csr_get_current_band(hHal));
1784 if (QDF_IS_STATUS_SUCCESS(status)) {
1785 if (NULL != curchnl_list_info->ChannelList) {
1786 j = 0;
1787 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1788 j += snprintf(newChannelList + j,
1789 sizeof(newChannelList) - j, "%d",
1790 curchnl_list_info->ChannelList[i]);
1791 }
1792 }
1793 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1794 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1795 newChannelList, oldChannelList,
1796 pNeighborRoamInfo->neighborRoamState);
1797 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301798
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001799 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1800 csr_roam_offload_scan(pMac, sessionId,
1801 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1802 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301803
1804 sme_release_global_lock(&pMac->sme);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001805 return status;
1806}
1807
1808#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
Jeff Johnson49c02f92016-10-07 10:29:09 -07001810static
1811QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1812 tpSirIbssGetPeerInfoRspParams
1813 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001814{
1815 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1816
1817 if (NULL == pMac) {
1818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1819 "%s: pMac is null", __func__);
1820 return QDF_STATUS_E_FAILURE;
1821 }
1822 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1824 "%s: HDD callback is null", __func__);
1825 return QDF_STATUS_E_FAILURE;
1826 }
1827 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1828 &pIbssPeerInfoParams->
1829 ibssPeerInfoRspParams);
1830 return QDF_STATUS_SUCCESS;
1831}
1832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1835 * @mac: Global MAC pointer
1836 * @msg: Dual mac config response
1837 *
1838 * Processes the dual mac configuration response and invokes the HDD callback
1839 * to process further
1840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301841static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 uint8_t *msg)
1843{
1844 tListElem *entry = NULL;
1845 tSmeCmd *command = NULL;
1846 bool found;
1847 dual_mac_cb callback = NULL;
1848 struct sir_dual_mac_config_resp *param;
1849
1850 param = (struct sir_dual_mac_config_resp *)msg;
1851 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001852 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 /* Not returning. Need to check if active command list
1854 * needs to be freed
1855 */
1856 }
1857
Krunal Sonia8270f52017-02-23 19:51:25 -08001858 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001860 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301861 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 }
1863
1864 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1865 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001866 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301867 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 }
1869
1870 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001871 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301872 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 }
1874
1875 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1876 if (callback) {
1877 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001878 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001880 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 callback(param->status,
1882 command->u.set_dual_mac_cmd.scan_config,
1883 command->u.set_dual_mac_cmd.fw_mode_config);
1884 }
1885 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001886 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 }
1888
Krunal Soni72dba662017-02-15 20:13:17 -08001889 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 if (found)
1891 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001892 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301894 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895}
1896
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001897/**
1898 * sme_process_antenna_mode_resp() - Process set antenna mode
1899 * response
1900 * @mac: Global MAC pointer
1901 * @msg: antenna mode response
1902 *
1903 * Processes the antenna mode response and invokes the HDD
1904 * callback to process further
1905 */
1906static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1907 uint8_t *msg)
1908{
1909 tListElem *entry;
1910 tSmeCmd *command;
1911 bool found;
1912 antenna_mode_cb callback;
1913 struct sir_antenna_mode_resp *param;
1914
1915 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301916 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001917 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001918 /* Not returning. Need to check if active command list
1919 * needs to be freed
1920 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001921
Krunal Sonia8270f52017-02-23 19:51:25 -08001922 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001924 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001925 return QDF_STATUS_E_FAILURE;
1926 }
1927
1928 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1929 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001930 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001931 return QDF_STATUS_E_FAILURE;
1932 }
1933
1934 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001935 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001936 return QDF_STATUS_E_FAILURE;
1937 }
1938
1939 callback =
1940 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1941 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301942 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001943 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301944 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001945 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001946 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001947 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001948 }
1949
Krunal Soni72dba662017-02-15 20:13:17 -08001950 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001951 if (found)
1952 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001953 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001954
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001955 return QDF_STATUS_SUCCESS;
1956}
1957
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301958/*
1959 * sme_process_msg() - The main message processor for SME.
1960 * The function is called by a message dispatcher when to process a message
1961 * targeted for SME.
1962 * This is a synchronous call
1963 *
1964 * hHal - The handle returned by mac_open.
1965 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1966 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1967 * Other status means SME failed to process the message to HAL.
1968 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001969QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301973 struct sir_peer_info *peer_stats;
1974 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975
1976 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001977 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 return status;
1979 }
1980 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301981 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001982 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 return status;
1986 }
1987 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001988 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 goto release_lock;
1992 }
1993 switch (pMsg->type) {
1994#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1998 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301999 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 break;
2001#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 case WNI_CFG_SET_CNF:
2003 case WNI_CFG_DNLD_CNF:
2004 case WNI_CFG_GET_RSP:
2005 case WNI_CFG_ADD_GRP_ADDR_CNF:
2006 case WNI_CFG_DEL_GRP_ADDR_CNF:
2007 break;
2008 case eWNI_SME_ADDTS_RSP:
2009 case eWNI_SME_DELTS_RSP:
2010 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 /* QoS */
2013 if (pMsg->bodyptr) {
2014#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2015 status = sme_qos_msg_processor(pMac, pMsg->type,
2016 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018#endif
2019 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002020 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 }
2022 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 case eWNI_SME_NEIGHBOR_REPORT_IND:
2024 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 if (pMsg->bodyptr) {
2026 status = sme_rrm_msg_processor(pMac, pMsg->type,
2027 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302028 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302030 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 }
2032 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 case eWNI_SME_ADD_STA_SELF_RSP:
2034 if (pMsg->bodyptr) {
2035 status = csr_process_add_sta_session_rsp(pMac,
2036 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002039 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 }
2041 break;
2042 case eWNI_SME_DEL_STA_SELF_RSP:
2043 if (pMsg->bodyptr) {
2044 status = csr_process_del_sta_session_rsp(pMac,
2045 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302046 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002048 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2052 if (pMsg->bodyptr) {
2053 status = sme_handle_generic_change_country_code(
2054 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302055 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002057 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 }
2059 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061#ifdef WLAN_FEATURE_11W
2062 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2063 if (pMsg->bodyptr) {
2064 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302065 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002067 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 }
2069 break;
2070#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002071#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 case eWNI_SME_TSM_IE_IND:
2073 if (pMsg->bodyptr) {
2074 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302075 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002077 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 }
2079 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002080#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2082 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2083 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302084 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002086 case eWNI_SME_IBSS_PEER_INFO_RSP:
2087 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002088 sme_ibss_peer_info_response_handler(pMac,
2089 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002090 qdf_mem_free(pMsg->bodyptr);
2091 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002092 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002093 }
2094 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 case eWNI_SME_READY_TO_SUSPEND_IND:
2096 if (pMsg->bodyptr) {
2097 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302098 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002100 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 }
2102 break;
2103#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2104 case eWNI_SME_READY_TO_EXTWOW_IND:
2105 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002106 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302107 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002109 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 }
2111 break;
2112#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2114 case eWNI_SME_AUTO_SHUTDOWN_IND:
2115 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 FL("Auto shutdown notification"));
2118 pMac->sme.pAutoShutdownNotificationCb();
2119 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302120 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 break;
2122#endif
2123 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002124 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002126 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 break;
2129 case eWNI_SME_CHANNEL_CHANGE_RSP:
2130 if (pMsg->bodyptr) {
2131 status = sme_process_channel_change_resp(pMac,
2132 pMsg->type,
2133 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302134 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002136 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 }
2138 break;
2139#ifdef WLAN_FEATURE_STATS_EXT
2140 case eWNI_SME_STATS_EXT_EVENT:
2141 if (pMsg->bodyptr) {
2142 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302143 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002145 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 }
2147 break;
2148#endif
Will Huang558f8082017-05-31 16:22:24 +08002149 case eWNI_SME_GET_PEER_INFO_IND:
2150 if (pMac->sme.pget_peer_info_ind_cb)
2151 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2152 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302153 if (pMsg->bodyptr) {
2154 peer_info_rsp = (struct sir_peer_info_resp *)
2155 (pMsg->bodyptr);
2156 peer_stats = (struct sir_peer_info *)
2157 (peer_info_rsp->info);
2158 if (peer_stats) {
2159 pMac->peer_rssi = peer_stats[0].rssi;
2160 pMac->peer_txrate = peer_stats[0].tx_rate;
2161 pMac->peer_rxrate = peer_stats[0].rx_rate;
2162 }
2163 }
Will Huang558f8082017-05-31 16:22:24 +08002164 qdf_mem_free(pMsg->bodyptr);
2165 break;
2166 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2167 if (pMac->sme.pget_peer_info_ext_ind_cb)
2168 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2169 pMac->sme.pget_peer_info_ext_cb_context);
2170 qdf_mem_free(pMsg->bodyptr);
2171 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 case eWNI_SME_CSA_OFFLOAD_EVENT:
2173 if (pMsg->bodyptr) {
2174 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302175 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 }
2177 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002178 case eWNI_SME_TSF_EVENT:
2179 if (pMac->sme.get_tsf_cb) {
2180 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2181 (struct stsf *)pMsg->bodyptr);
2182 }
2183 if (pMsg->bodyptr)
2184 qdf_mem_free(pMsg->bodyptr);
2185 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186#ifdef WLAN_FEATURE_NAN
2187 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302188 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2189 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (pMsg->bodyptr) {
2191 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302192 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 }
2194 break;
2195#endif /* WLAN_FEATURE_NAN */
2196 case eWNI_SME_LINK_STATUS_IND:
2197 {
2198 tAniGetLinkStatus *pLinkStatus =
2199 (tAniGetLinkStatus *) pMsg->bodyptr;
2200 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302201 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 pMac->sme.linkStatusCallback(
2203 pLinkStatus->linkStatus,
2204 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 pMac->sme.linkStatusCallback = NULL;
2207 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 }
2210 break;
2211 }
2212 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302213 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2215 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 break;
2217 case eWNI_SME_SNR_IND:
2218 {
2219 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 if (pSnrReq) {
2222 if (pSnrReq->snrCallback) {
2223 ((tCsrSnrCallback)
2224 (pSnrReq->snrCallback))
2225 (pSnrReq->snr, pSnrReq->staId,
2226 pSnrReq->pDevContext);
2227 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 }
2230 break;
2231 }
2232#ifdef FEATURE_WLAN_EXTSCAN
2233 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2234 if (pMac->sme.pExtScanIndCb)
2235 pMac->sme.pExtScanIndCb(pMac->hHdd,
2236 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2237 pMsg->bodyptr);
2238 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002239 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 pMsg->type);
2241
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302242 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 break;
2244 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2245 if (pMac->sme.pExtScanIndCb)
2246 pMac->sme.pExtScanIndCb(pMac->hHdd,
2247 eSIR_EPNO_NETWORK_FOUND_IND,
2248 pMsg->bodyptr);
2249 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002250 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 pMsg->type);
2252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 break;
2255#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 case eWNI_SME_SET_HW_MODE_RESP:
2257 if (pMsg->bodyptr) {
2258 status = sme_process_set_hw_mode_resp(pMac,
2259 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302260 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002262 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 }
2264 break;
2265 case eWNI_SME_HW_MODE_TRANS_IND:
2266 if (pMsg->bodyptr) {
2267 status = sme_process_hw_mode_trans_ind(pMac,
2268 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302269 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002271 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 }
2273 break;
2274 case eWNI_SME_NSS_UPDATE_RSP:
2275 if (pMsg->bodyptr) {
2276 status = sme_process_nss_update_resp(pMac,
2277 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302278 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002280 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 }
2282 break;
2283 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302284 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 pMac->sme.ocb_set_config_callback(
2286 pMac->sme.ocb_set_config_context,
2287 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302288 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002289 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 pMac->sme.ocb_set_config_callback = NULL;
2291 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302292 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 break;
2294 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302295 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 pMac->sme.ocb_get_tsf_timer_callback(
2297 pMac->sme.ocb_get_tsf_timer_context,
2298 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302299 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002300 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2302 pMac->sme.ocb_get_tsf_timer_context = NULL;
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_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302306 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 pMac->sme.dcc_get_stats_callback(
2308 pMac->sme.dcc_get_stats_context,
2309 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302310 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002311 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 pMac->sme.dcc_get_stats_callback = NULL;
2313 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302314 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 break;
2316 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302317 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 pMac->sme.dcc_update_ndl_callback(
2319 pMac->sme.dcc_update_ndl_context,
2320 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302321 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002322 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 pMac->sme.dcc_update_ndl_callback = NULL;
2324 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302325 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 break;
2327 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302328 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 pMac->sme.dcc_stats_event_callback(
2330 pMac->sme.dcc_stats_event_context,
2331 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302332 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002333 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 break;
2336 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2337 if (pMsg->bodyptr) {
2338 status = sme_process_dual_mac_config_resp(pMac,
2339 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002342 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 }
2344 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2345 if (pMac->sme.set_thermal_level_cb)
2346 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2347 pMsg->bodyval);
2348 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302349 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2350 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302351 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302352 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002353 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2354 if (pMsg->bodyptr) {
2355 status = sme_process_antenna_mode_resp(pMac,
2356 pMsg->bodyptr);
2357 qdf_mem_free(pMsg->bodyptr);
2358 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002359 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002360 }
2361 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302362 case eWNI_SME_LOST_LINK_INFO_IND:
2363 if (pMac->sme.lost_link_info_cb)
2364 pMac->sme.lost_link_info_cb(pMac->hHdd,
2365 (struct sir_lost_link_info *)pMsg->bodyptr);
2366 qdf_mem_free(pMsg->bodyptr);
2367 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302368 case eWNI_SME_RSO_CMD_STATUS_IND:
2369 if (pMac->sme.rso_cmd_status_cb)
2370 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002371 qdf_mem_free(pMsg->bodyptr);
2372 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002373 case eWMI_SME_LL_STATS_IND:
2374 if (pMac->sme.link_layer_stats_ext_cb)
2375 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2376 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302377 qdf_mem_free(pMsg->bodyptr);
2378 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302379 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2380 if (pMac->sme.bt_activity_info_cb)
2381 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2382 pMsg->bodyval);
2383 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 default:
2385
2386 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2387 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2388 /* CSR */
2389 if (pMsg->bodyptr) {
2390 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302391 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302392 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002393 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002395 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302397 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 }
2399 } /* switch */
2400release_lock:
2401 sme_release_global_lock(&pMac->sme);
2402 return status;
2403}
2404
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002405QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2406{
2407 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2408
2409 if (mac_ctx == NULL) {
2410 QDF_ASSERT(0);
2411 return QDF_STATUS_E_FAILURE;
2412 }
2413
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002414 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002415}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417/**
2418 * sme_process_nss_update_resp() - Process nss update response
2419 * @mac: Global MAC pointer
2420 * @msg: nss update response
2421 *
2422 * Processes the nss update response and invokes the HDD
2423 * callback to process further
2424 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302425static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426{
2427 tListElem *entry = NULL;
2428 tSmeCmd *command = NULL;
2429 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002430 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 struct sir_beacon_tx_complete_rsp *param;
2432
2433 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302434 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002435 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 /* Not returning. Need to check if active command list
2437 * needs to be freed
2438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439
Krunal Sonia8270f52017-02-23 19:51:25 -08002440 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002442 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302443 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 }
2445
2446 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2447 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002448 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 }
2451
2452 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002453 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 }
2456
2457 callback = command->u.nss_update_cmd.nss_update_cb;
2458 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302459 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002460 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302461 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 callback(command->u.nss_update_cmd.context,
2463 param->tx_status,
2464 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302465 command->u.nss_update_cmd.next_action,
2466 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002468 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 }
2470
Krunal Soni72dba662017-02-15 20:13:17 -08002471 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 if (found) {
2473 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002474 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002476
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302477 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478}
2479
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302480/* No need to hold the global lock here because this function can only be
2481 * called after sme_stop.
2482 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002483void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484{
2485 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302486 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302487 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 }
2489
2490}
2491
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302492/*
2493 * sme_stop() - Stop all SME modules and put them at idle state
2494 *
2495 * The function stops each module in SME, PMC, CSR, etc. . Upon
2496 * return, all modules are at idle state ready to start.
2497 * This is a synchronous call
2498 *
2499 * hHal - The handle returned by mac_open
2500 * tHalStopType - reason for stopping
2501 * Return QDF_STATUS_SUCCESS - SME is stopped.
2502 * Other status means SME is failed to stop but caller should still
2503 * consider SME is stopped.
2504 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302505QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302507 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2508 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2510
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002511 status = rrm_stop(pMac);
2512 if (!QDF_IS_STATUS_SUCCESS(status)) {
2513 sme_err("rrm_stop failed with status: %d", status);
2514 }
2515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302517 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002518 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 fail_status = status;
2520 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302522 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524
2525 pMac->sme.state = SME_STATE_STOP;
2526
2527 return status;
2528}
2529
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302530/*
2531 * sme_close() - Release all SME modules and their resources.
2532 * The function release each module in SME, PMC, CSR, etc. . Upon
2533 * return, all modules are at closed state.
2534 *
2535 * No SME APIs can be involved after smeClose except smeOpen.
2536 * smeClose must be called before mac_close.
2537 * This is a synchronous call
2538 *
2539 * hHal - The handle returned by mac_open
2540 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2541 *
2542 * Other status means SME is failed to be closed but caller still cannot
2543 * call any other SME functions except smeOpen.
2544 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302547 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2548 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2550
2551 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302552 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553
2554 /* Note: pSession will be invalid from here on, do not access */
2555 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302556 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002557 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 fail_status = status;
2559 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2561 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302562 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002563 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 fail_status = status;
2565 }
2566#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302568 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002569 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 fail_status = status;
2571 }
2572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302574 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002575 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 fail_status = status;
2577 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 free_sme_cmd_list(pMac);
2580
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302581 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302582 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302583 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302585 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587
2588 pMac->sme.state = SME_STATE_STOP;
2589
2590 return status;
2591}
2592
2593/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302594 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2595 * scan list
2596 * @hal: hal context.
2597 * @bssid: bssid to be removed
2598 *
2599 * This function remove the given bssid from scan list.
2600 *
2601 * Return: QDF status.
2602 */
2603QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2604 tSirMacAddr bssid)
2605{
2606 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2607 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2608
2609 status = sme_acquire_global_lock(&mac_ctx->sme);
2610 if (QDF_IS_STATUS_SUCCESS(status)) {
2611 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2612 sme_release_global_lock(&mac_ctx->sme);
2613 }
2614
2615 return status;
2616}
2617
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302619/*
2620 * sme_scan_get_result
2621 * A wrapper function to request scan results from CSR.
2622 * This is a synchronous call
2623 *
2624 * pFilter - If pFilter is NULL, all cached results are returned
2625 * phResult - an object for the result.
2626 * Return QDF_STATUS
2627 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302628QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 tCsrScanResultFilter *pFilter,
2630 tScanResultHandle *phResult)
2631{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302632 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2634
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302635 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2637 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302639 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 status = csr_scan_get_result(hHal, pFilter, phResult);
2641 sme_release_global_lock(&pMac->sme);
2642 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643
2644 return status;
2645}
2646
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302647QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2648 struct qdf_mac_addr *bssid,
2649 tCsrScanResultInfo *res)
2650{
2651 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2652 QDF_STATUS status;
2653
2654 status = sme_acquire_global_lock(&mac_ctx->sme);
2655 if (QDF_IS_STATUS_SUCCESS(status)) {
2656 status = csr_scan_get_result_for_bssid(hal_handle, bssid, res);
2657 sme_release_global_lock(&mac_ctx->sme);
2658 }
2659
2660 return status;
2661}
2662
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002664 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002665 * AP's channel id from
2666 * CSR by filtering the
2667 * result which matches
2668 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002669 * @profile: SAP profile
2670 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2671 * best ap from scan cache.
2672 *
2673 * This function is written to get AP's channel id from CSR by filtering
2674 * the result which matches our roam profile. This is a synchronous call.
2675 *
2676 * Return: QDF_STATUS.
2677 */
2678QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2679 tScanResultHandle *scan_cache,
2680 uint8_t *ap_chnl_id)
2681{
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002682 return sme_get_ap_channel_from_scan_cache((struct csr_roam_profile *)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002683 profile,
2684 scan_cache,
2685 ap_chnl_id);
2686}
2687
2688/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2690 * channel id from CSR by filtering the
2691 * result which matches our roam profile.
2692 * @profile: SAP adapter
2693 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2694 * best ap from scan cache.
2695 *
2696 * This function is written to get AP's channel id from CSR by filtering
2697 * the result which matches our roam profile. This is a synchronous call.
2698 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302699 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002701QDF_STATUS sme_get_ap_channel_from_scan_cache(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002702 struct csr_roam_profile *profile, tScanResultHandle *scan_cache,
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002703 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302705 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002706 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 tCsrScanResultFilter *scan_filter = NULL;
2708 tScanResultHandle filtered_scan_result = NULL;
2709 tSirBssDescription first_ap_profile;
2710
2711 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302712 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302714 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302716 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302718 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302720 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302721 }
2722 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2723 if (NULL == profile) {
2724 scan_filter->EncryptionType.numEntries = 1;
2725 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302727 } else {
2728 /* Here is the profile we need to connect to */
2729 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 profile,
2731 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302734 if (QDF_STATUS_SUCCESS == status) {
2735 /* Save the WPS info */
2736 if (NULL != profile) {
2737 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302739 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302742 scan_filter->bWPSAssociation = 0;
2743 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302745 } else {
2746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2747 FL("Preparing the profile filter failed"));
2748 qdf_mem_free(scan_filter);
2749 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 }
2751 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302752 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002753 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2757 &first_ap_profile);
2758 *scan_cache = filtered_scan_result;
2759 if (0 != first_ap_profile.channelId) {
2760 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302761 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302762 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 FL("Found best AP & its on chnl[%d]"),
2764 first_ap_profile.channelId);
2765 } else {
2766 /*
2767 * This means scan result is empty
2768 * so set the channel to zero, caller should
2769 * take of zero channel id case.
2770 */
2771 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302772 QDF_TRACE(QDF_MODULE_ID_SME,
2773 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302775 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 }
2777 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302778 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302780 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 }
2782 csr_free_scan_filter(mac_ctx, scan_filter);
2783 sme_release_global_lock(&mac_ctx->sme);
2784 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002787 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302788 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302790 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 return status;
2792}
2793
2794/**
2795 * sme_store_joinreq_param() - This function will pass station's join
2796 * request to store to csr.
2797 * @hal_handle: pointer to hal context.
2798 * @profile: pointer to station's roam profile.
2799 * @scan_cache: pointer to station's scan cache.
2800 * @roam_id: reference to roam_id variable being passed.
2801 * @session_id: station's session id.
2802 *
2803 * This function will pass station's join request further down to csr
2804 * to store it. this stored parameter will be used later.
2805 *
2806 * Return: true or false based on function's overall success.
2807 **/
2808bool sme_store_joinreq_param(tHalHandle hal_handle,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002809 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 tScanResultHandle scan_cache,
2811 uint32_t *roam_id,
2812 uint32_t session_id)
2813{
2814 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302815 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 bool ret_status = true;
2817
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302818 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2820 session_id, 0));
2821 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302822 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302824 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 sme_release_global_lock(&mac_ctx->sme);
2827 } else {
2828 ret_status = false;
2829 }
2830
2831 return ret_status;
2832}
2833
2834/**
2835 * sme_clear_joinreq_param() - This function will pass station's clear
2836 * the join request to csr.
2837 * @hal_handle: pointer to hal context.
2838 * @session_id: station's session id.
2839 *
2840 * This function will pass station's clear join request further down to csr
2841 * to cleanup.
2842 *
2843 * Return: true or false based on function's overall success.
2844 **/
2845bool sme_clear_joinreq_param(tHalHandle hal_handle,
2846 uint32_t session_id)
2847{
2848 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302849 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 bool ret_status = true;
2851
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302852 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2854 session_id, 0));
2855 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302856 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302858 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 sme_release_global_lock(&mac_ctx->sme);
2861 } else {
2862 ret_status = false;
2863 }
2864
2865 return ret_status;
2866}
2867
2868/**
2869 * sme_issue_stored_joinreq() - This function will issues station's stored
2870 * the join request to csr.
2871 * @hal_handle: pointer to hal context.
2872 * @roam_id: reference to roam_id variable being passed.
2873 * @session_id: station's session id.
2874 *
2875 * This function will issue station's stored join request further down to csr
2876 * to proceed forward.
2877 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302878 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302880QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 uint32_t *roam_id,
2882 uint32_t session_id)
2883{
2884 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302885 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2886 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302888 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2890 session_id, 0));
2891 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302892 if (QDF_STATUS_SUCCESS == status) {
2893 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 roam_id,
2895 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 }
2898 sme_release_global_lock(&mac_ctx->sme);
2899 } else {
2900 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302901 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 }
2903 return ret_status;
2904}
2905
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302906/*
2907 * sme_scan_flush_result() -
2908 * A wrapper function to request CSR to clear scan results.
2909 * This is a synchronous call
2910 *
2911 * Return QDF_STATUS
2912 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302913QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2917
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302918 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2920 0, 0));
2921 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 status = csr_scan_flush_result(hHal);
2924 sme_release_global_lock(&pMac->sme);
2925 }
2926
2927 return status;
2928}
2929
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302930/*
2931 * sme_filter_scan_results() -
2932 * A wrapper function to request CSR to clear scan results.
2933 * This is a synchronous call
2934 *
2935 * tHalHandle - HAL context handle
2936 * sessionId - session id
2937 * Return QDF_STATUS
2938 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302939QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302941 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2943
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302944 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2946 sessionId, 0));
2947 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302948 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 csr_scan_filter_results(pMac);
2950 sme_release_global_lock(&pMac->sme);
2951 }
2952
2953 return status;
2954}
2955
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302956QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302958 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2960
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302961 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2963 sessionId, 0));
2964 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302965 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 status = csr_scan_flush_selective_result(hHal, true);
2967 sme_release_global_lock(&pMac->sme);
2968 }
2969
2970 return status;
2971}
2972
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302973/*
2974 * sme_scan_result_get_first() -
2975 * A wrapper function to request CSR to returns the first element of
2976 * scan result.
2977 * This is a synchronous call
2978 *
2979 * hScanResult - returned from csr_scan_get_result
2980 * Return tCsrScanResultInfo * - NULL if no result
2981 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2983 tScanResultHandle hScanResult)
2984{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302985 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2987 tCsrScanResultInfo *pRet = NULL;
2988
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302989 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2991 NO_SESSION, 0));
2992 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302993 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 pRet = csr_scan_result_get_first(pMac, hScanResult);
2995 sme_release_global_lock(&pMac->sme);
2996 }
2997
2998 return pRet;
2999}
3000
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303001/*
3002 * sme_scan_result_get_next() -
3003 * A wrapper function to request CSR to returns the next element of
3004 * scan result. It can be called without calling csr_scan_result_get_first first
3005 * This is a synchronous call
3006 *
3007 * hScanResult - returned from csr_scan_get_result
3008 * Return Null if no result or reach the end
3009 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3011 tScanResultHandle hScanResult)
3012{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303013 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3015 tCsrScanResultInfo *pRet = NULL;
3016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303018 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 pRet = csr_scan_result_get_next(pMac, hScanResult);
3020 sme_release_global_lock(&pMac->sme);
3021 }
3022
3023 return pRet;
3024}
3025
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303026/*
3027 * sme_scan_result_purge() -
3028 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3029 * in the list and free memory for each item
3030 * This is a synchronous call
3031 *
3032 * hScanResult - returned from csr_scan_get_result. hScanResult is
3033 * considered gone by
3034 * calling this function and even before this function reutrns.
3035 * Return QDF_STATUS
3036 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003037QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303039 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003040 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303042 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3044 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003045 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303046 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003047 status = csr_scan_result_purge(mac_ctx, hScanResult);
3048 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 }
3050
3051 return status;
3052}
3053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3055{
3056 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 return pMac->roam.configParam.phyMode;
3059}
3060
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303061/*
jiadbdefb252018-01-03 14:27:06 +08003062 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303063 *
3064 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003065 * mode - channel bonding mode
3066 *
3067 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303068 */
jiadbdefb252018-01-03 14:27:06 +08003069QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070{
3071 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003072 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073
jiadbdefb252018-01-03 14:27:06 +08003074 if (!mode) {
3075 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3076 "%s: invalid mode", __func__);
3077 return QDF_STATUS_E_FAILURE;
3078 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079
jiadbdefb252018-01-03 14:27:06 +08003080 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3081 if (!smeConfig) {
3082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3083 "%s: failed to alloc smeConfig", __func__);
3084 return QDF_STATUS_E_NOMEM;
3085 }
3086
3087 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3088 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3089 "%s: sme_get_config_param failed", __func__);
3090 qdf_mem_free(smeConfig);
3091 return QDF_STATUS_E_FAILURE;
3092 }
3093
3094 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3095 qdf_mem_free(smeConfig);
3096
3097 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098}
3099
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303100/*
jiadbdefb252018-01-03 14:27:06 +08003101 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3102 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303103 *
3104 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003105 * mode - channel bonding mode
3106 *
3107 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303108 */
jiadbdefb252018-01-03 14:27:06 +08003109QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110{
3111 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003112 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113
jiadbdefb252018-01-03 14:27:06 +08003114 if (!mode) {
3115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3116 "%s: invalid mode", __func__);
3117 return QDF_STATUS_E_FAILURE;
3118 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119
jiadbdefb252018-01-03 14:27:06 +08003120 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3121 if (!smeConfig) {
3122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3123 "%s: failed to alloc smeConfig", __func__);
3124 return QDF_STATUS_E_NOMEM;
3125 }
3126
3127 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3128 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3129 "%s: sme_get_config_param failed", __func__);
3130 qdf_mem_free(smeConfig);
3131 return QDF_STATUS_E_FAILURE;
3132 }
3133
3134 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3135 qdf_mem_free(smeConfig);
3136
3137 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138}
3139
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303140/*
3141 * sme_roam_connect() -
3142 * A wrapper function to request CSR to inititiate an association
3143 * This is an asynchronous call.
3144 *
3145 * sessionId - the sessionId returned by sme_open_session.
3146 * pProfile - description of the network to which to connect
3147 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3148 * from csr_scan_get_result
3149 * pRoamId - to get back the request ID
3150 * Return QDF_STATUS
3151 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303152QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003153 struct csr_roam_profile *pProfile,
3154 uint32_t *pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303156 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3158
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303159 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303162 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303165 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3167 status =
3168 csr_roam_connect(pMac, sessionId, pProfile,
3169 pRoamId);
3170 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003171 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303172 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 }
3174 sme_release_global_lock(&pMac->sme);
3175 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003176 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 }
3178
3179 return status;
3180}
3181
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303182/*
3183 * sme_set_phy_mode() -
3184 * Changes the PhyMode.
3185 *
3186 * hHal - The handle returned by mac_open.
3187 * phyMode new phyMode which is to set
3188 * Return QDF_STATUS SUCCESS.
3189 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303190QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191{
3192 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3193
3194 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 }
3199
3200 pMac->roam.configParam.phyMode = phyMode;
3201 pMac->roam.configParam.uCfgDot11Mode =
3202 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303203 pMac->roam.configParam.phyMode,
3204 pMac->roam.configParam.
3205 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303207 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208}
3209
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303210/*
3211 * sme_roam_reassoc() -
3212 * A wrapper function to request CSR to inititiate a re-association
3213 *
3214 * pProfile - can be NULL to join the currently connected AP. In that
3215 * case modProfileFields should carry the modified field(s) which could trigger
3216 * reassoc
3217 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3218 * that might need modification dynamically once STA is up & running and this
3219 * could trigger a reassoc
3220 * pRoamId - to get back the request ID
3221 * Return QDF_STATUS
3222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303223QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003224 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 tCsrRoamModifyProfileFields modProfileFields,
3226 uint32_t *pRoamId, bool fForce)
3227{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303228 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3230
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303231 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303234 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303236 if ((NULL == pProfile) && (fForce == 1))
3237 status = csr_reassoc(pMac, sessionId,
3238 &modProfileFields, pRoamId,
3239 fForce);
3240 else
3241 status = csr_roam_reassoc(pMac, sessionId,
3242 pProfile,
3243 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303245 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 }
3247 sme_release_global_lock(&pMac->sme);
3248 }
3249
3250 return status;
3251}
3252
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303253/*
3254 * sme_roam_connect_to_last_profile() -
3255 * A wrapper function to request CSR to disconnect and reconnect with
3256 * the same profile
3257 * This is an asynchronous call.
3258 *
3259 * Return QDF_STATUS. It returns fail if currently connected
3260 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303261QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303263 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3265
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303266 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3268 sessionId, 0));
3269 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303270 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303271 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3272 status = csr_roam_connect_to_last_profile(pMac,
3273 sessionId);
3274 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 sme_release_global_lock(&pMac->sme);
3277 }
3278
3279 return status;
3280}
3281
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303282/*
3283 * sme_roam_disconnect() -
3284 * A wrapper function to request CSR to disconnect from a network
3285 * This is an asynchronous call.
3286 *
3287 * reason -- To indicate the reason for disconnecting. Currently, only
3288 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3289 * Return QDF_STATUS
3290 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 eCsrRoamDisconnectReason reason)
3293{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3296
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303297 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3299 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303301 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303302 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303304 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303305 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 sme_release_global_lock(&pMac->sme);
3307 }
3308
3309 return status;
3310}
3311
Abhishek Singhca408032016-09-13 15:26:12 +05303312/* sme_dhcp_done_ind() - send dhcp done ind
3313 * @hal: hal context
3314 * @session_id: session id
3315 *
3316 * Return: void.
3317 */
3318void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3319{
3320 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303321 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303322
3323 if (!mac_ctx)
3324 return;
3325
3326 session = CSR_GET_SESSION(mac_ctx, session_id);
3327 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003328 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303329 return;
3330 }
3331 session->dhcp_done = true;
3332}
3333
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303334/*
3335 * sme_roam_stop_bss() -
3336 * To stop BSS for Soft AP. This is an asynchronous API.
3337 *
3338 * hHal - Global structure
3339 * sessionId - sessionId of SoftAP
3340 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3341 * actual results
3342 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303345 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303350 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3351 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303352 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303353 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303354 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 sme_release_global_lock(&pMac->sme);
3356 }
3357
3358 return status;
3359}
3360
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303361/**
3362 * sme_roam_disconnect_sta() - disassociate a station
3363 * @hHal: Global structure
3364 * @sessionId: SessionId of SoftAP
3365 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3366 *
3367 * To disassociate a station. This is an asynchronous API.
3368 *
3369 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3370 * be called to indicate actual result.
3371 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303372QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003373 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303375 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3377
3378 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303379 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 return status;
3381 }
3382
3383 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303384 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303385 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303387 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303388 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303389 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 sme_release_global_lock(&pMac->sme);
3391 }
3392
3393 return status;
3394}
3395
3396/**
3397 * sme_roam_deauth_sta() - deauthenticate a station
3398 * @hHal: Global structure
3399 * @sessionId: SessionId of SoftAP
3400 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3401 *
3402 * To disassociate a station. This is an asynchronous API.
3403 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303404 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 * code on error. Roam callback will be called to indicate actual
3406 * result
3407 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003409 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303411 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3413
3414 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303415 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 return status;
3417 }
3418
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303419 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303420 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3421 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303424 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 status =
3426 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3427 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303428 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 sme_release_global_lock(&pMac->sme);
3431 }
3432
3433 return status;
3434}
3435
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303436/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303437 * sme_roam_get_associated_stas() -
3438 * To probe the list of associated stations from various modules
3439 * of CORE stack.
3440 * This is an asynchronous API.
3441 *
3442 * sessionId - sessionId of SoftAP
3443 * modId - Module from whom list of associtated stations is
3444 * to be probed. If an invalid module is passed then
3445 * by default QDF_MODULE_ID_PE will be probed.
3446 * pUsrContext - Opaque HDD context
3447 * pfnSapEventCallback - Sap event callback in HDD
3448 * pAssocBuf - Caller allocated memory to be filled with associatd
3449 * stations info
3450 * Return QDF_STATUS
3451 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303452QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303453 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454 void *pfnSapEventCallback,
3455 uint8_t *pAssocStasBuf)
3456{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303457 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3459
3460 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303461 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 return status;
3463 }
3464
3465 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303466 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303467 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303469 csr_roam_get_associated_stas(pMac, sessionId,
3470 modId,
3471 pUsrContext,
3472 pfnSapEventCallback,
3473 pAssocStasBuf);
3474 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476 sme_release_global_lock(&pMac->sme);
3477 }
3478
3479 return status;
3480}
3481
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303482/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303483 * sme_roam_get_connect_state() -
3484 * A wrapper function to request CSR to return the current connect state
3485 * of Roaming
3486 * This is a synchronous call.
3487 *
3488 * Return QDF_STATUS
3489 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303490QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 eCsrConnectState *pState)
3492{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303493 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3495
3496 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303497 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303498 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3499 status = csr_roam_get_connect_state(pMac, sessionId,
3500 pState);
3501 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 sme_release_global_lock(&pMac->sme);
3504 }
3505
3506 return status;
3507}
3508
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303509/*
3510 * sme_roam_get_connect_profile() -
3511 * A wrapper function to request CSR to return the current connect
3512 * profile. Caller must call csr_roam_free_connect_profile after it is done
3513 * and before reuse for another csr_roam_get_connect_profile call.
3514 * This is a synchronous call.
3515 *
3516 * pProfile - pointer to a caller allocated structure
3517 * tCsrRoamConnectedProfile
3518 * eturn QDF_STATUS. Failure if not connected
3519 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303520QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 tCsrRoamConnectedProfile *pProfile)
3522{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303523 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3525
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303526 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3528 sessionId, 0));
3529 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303530 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303531 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3532 status = csr_roam_get_connect_profile(pMac, sessionId,
3533 pProfile);
3534 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303535 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536 sme_release_global_lock(&pMac->sme);
3537 }
3538
3539 return status;
3540}
3541
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003542/**
3543 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3544 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3545 *
3546 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3547 *
3548 * Return: none
3549 */
3550void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303552 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3554 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003555 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556}
3557
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303558/*
3559 * sme_roam_set_pmkid_cache() -
3560 * A wrapper function to request CSR to return the PMKID candidate list
3561 * This is a synchronous call.
3562
3563 * pPMKIDCache - caller allocated buffer point to an array of
3564 * tPmkidCacheInfo
3565 * numItems - a variable that has the number of tPmkidCacheInfo
3566 * allocated when retruning, this is either the number needed
3567 * or number of items put into pPMKIDCache
3568 * update_entire_cache - this bool value specifies if the entire pmkid
3569 * cache should be overwritten or should it be
3570 * updated entry by entry.
3571 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3572 * big enough and pNumItems has the number of
3573 * tPmkidCacheInfo.
3574 * \Note: pNumItems is a number of tPmkidCacheInfo,
3575 * not sizeof(tPmkidCacheInfo) * something
3576 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303577QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 tPmkidCacheInfo *pPMKIDCache,
3579 uint32_t numItems, bool update_entire_cache)
3580{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303581 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3583
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303584 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3586 numItems));
3587 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303588 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303589 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3590 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3591 pPMKIDCache,
3592 numItems, update_entire_cache);
3593 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303594 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 sme_release_global_lock(&pMac->sme);
3596 }
3597
3598 return status;
3599}
3600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303601QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303602 tPmkidCacheInfo *pmksa,
3603 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303605 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303607
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303608 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303609 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3610 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303612 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303613 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303615 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303616 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303617 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 sme_release_global_lock(&pMac->sme);
3619 }
3620 return status;
3621}
3622
gaurank kathpalia99d06c12018-05-16 16:28:35 +05303623void sme_get_pmk_info(tHalHandle hal, uint8_t session_id,
3624 tPmkidCacheInfo *pmk_cache)
3625{
3626 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3627 QDF_STATUS status = sme_acquire_global_lock(&mac_ctx->sme);
3628
3629 if (QDF_IS_STATUS_SUCCESS(status)) {
3630 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3631 csr_get_pmk_info(mac_ctx, session_id, pmk_cache);
3632 sme_release_global_lock(&mac_ctx->sme);
3633 }
3634}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303636/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 * \fn sme_roam_set_psk_pmk
3638 * \brief a wrapper function to request CSR to save PSK/PMK
3639 * This is a synchronous call.
3640 * \param hHal - Global structure
3641 * \param sessionId - SME sessionId
3642 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3643 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3644 * connections. Need to pass this information to
3645 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303646 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 uint8_t *pPSK_PMK, size_t pmk_len)
3650{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303655 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303656 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3657 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303659 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 sme_release_global_lock(&pMac->sme);
3662 }
3663 return status;
3664}
3665#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666
Jeff Johnson0a078b52018-06-01 16:15:54 -07003667QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id,
3668 uint32_t *len, uint8_t *buf)
3669{
3670 QDF_STATUS status;
3671 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3672
3673 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303674 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003675 if (CSR_IS_SESSION_VALID(mac, session_id))
3676 status = csr_roam_get_wpa_rsn_req_ie(mac, session_id,
3677 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303678 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303679 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003680 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 }
3682
3683 return status;
3684}
3685
Jeff Johnson0a078b52018-06-01 16:15:54 -07003686QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id,
3687 uint32_t *len, uint8_t *buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688{
Jeff Johnson0a078b52018-06-01 16:15:54 -07003689 QDF_STATUS status;
3690 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691
Jeff Johnson0a078b52018-06-01 16:15:54 -07003692 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303693 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003694 if (CSR_IS_SESSION_VALID(mac, session_id))
3695 status = csr_roam_get_wpa_rsn_rsp_ie(mac, session_id,
3696 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303697 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303698 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003699 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 }
3701
3702 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703}
3704
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303705/*
3706 * sme_roam_get_num_pmkid_cache() -
3707 * A wrapper function to request CSR to return number of PMKID cache
3708 * entries
3709 * This is a synchronous call.
3710 *
3711 * Return uint32_t - the number of PMKID cache entries
3712 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3714{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3717 uint32_t numPmkidCache = 0;
3718
3719 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3722 numPmkidCache =
3723 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303724 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303725 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303726 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 sme_release_global_lock(&pMac->sme);
3728 }
3729
3730 return numPmkidCache;
3731}
3732
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303733/*
3734 * sme_roam_get_pmkid_cache() -
3735 * A wrapper function to request CSR to return PMKID cache from CSR
3736 * This is a synchronous call.
3737 *
3738 * pNum - caller allocated memory that has the space of the number of
3739 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3740 * needed or actually number in tPmkidCacheInfo.
3741 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3742 * any, upon return
3743 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3744 * big enough
3745 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303746QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303747 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303749 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003750 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3751
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303752 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3754 0));
3755 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303756 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303757 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3758 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303760 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303761 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 sme_release_global_lock(&pMac->sme);
3763 }
3764
3765 return status;
3766}
3767
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303768/*
3769 * sme_get_config_param() -
3770 * A wrapper function that HDD calls to get the global settings
3771 * currently maintained by CSR.
3772 * This is a synchronous call.
3773 *
3774 * pParam - caller allocated memory
3775 * Return QDF_STATUS
3776 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3781
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303782 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3784 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303785 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003788 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 sme_release_global_lock(&pMac->sme);
3790 return status;
3791 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303792 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003793 &pMac->rrm.rrmSmeContext.rrmConfig,
3794 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303795 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 sme_release_global_lock(&pMac->sme);
3797 }
3798
3799 return status;
3800}
3801
3802/**
3803 * sme_cfg_set_int() - Sets the cfg parameter value.
3804 * @hal: Handle to hal.
3805 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003806 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 *
3808 * This function sets the string value in cfg parameter.
3809 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303810 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303812QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813{
3814 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303815 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816
3817 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303818 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819
3820 return status;
3821}
3822
3823/**
3824 * sme_cfg_set_str() - Sets the cfg parameter string.
3825 * @hal: Handle to hal.
3826 * @cfg_id: Configuration parameter ID.
3827 * @str: Pointer to the string buffer.
3828 * @length: Length of the string.
3829 *
3830 * This function sets the string value in cfg parameter.
3831 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303832 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303834QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 uint32_t length)
3836{
3837 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303838 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003839
3840 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303841 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842
3843 return status;
3844}
3845
3846/**
3847 * sme_cfg_get_int() - Gets the cfg parameter value.
3848 * @hal: Handle to hal.
3849 * @cfg_id: Configuration parameter ID.
3850 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003851 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852 *
3853 * This function gets the value of the cfg parameter.
3854 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858{
3859 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861
3862 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303863 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864
3865 return status;
3866}
3867
3868/**
3869 * sme_cfg_get_str() - Gets the cfg parameter string.
3870 * @hal: Handle to hal.
3871 * @cfg_id: Configuration parameter ID.
3872 * @str: Pointer to the string buffer.
3873 * @length: Pointer to length of the string.
3874 *
3875 * This function gets the string value of the cfg parameter.
3876 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303877 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303879QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880 uint32_t *length)
3881{
3882 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303883 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884
3885 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303886 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887
3888 return status;
3889}
3890
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303891/*
3892 * sme_get_modify_profile_fields() -
3893 * HDD or SME - QOS calls this function to get the current values of
3894 * connected profile fields, changing which can cause reassoc.
3895 * This function must be called after CFG is downloaded and STA is in connected
3896 * state. Also, make sure to call this function to get the current profile
3897 * fields before calling the reassoc. So that pModifyProfileFields will have
3898 * all the latest values plus the one(s) has been updated as part of reassoc
3899 * request.
3900 *
3901 * pModifyProfileFields - pointer to the connected profile fields
3902 * changing which can cause reassoc
3903 * Return QDF_STATUS
3904 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303905QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 tCsrRoamModifyProfileFields *
3907 pModifyProfileFields)
3908{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303909 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3911
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303912 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3914 0));
3915 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303916 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303917 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3918 status = csr_get_modify_profile_fields(pMac, sessionId,
3919 pModifyProfileFields);
3920 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303921 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 sme_release_global_lock(&pMac->sme);
3923 }
3924
3925 return status;
3926}
3927
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303928/*
3929 * sme_set_dhcp_till_power_active_flag() -
3930 * Sets/Clears DHCP related flag to disable/enable auto PS
3931 *
3932 * hal - The handle returned by mac_open.
3933 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3935{
3936 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3937 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3938
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303939 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3941 flag));
3942 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3943 ps_global_info->remain_in_power_active_till_dhcp = flag;
3944}
3945
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303946/*
3947 * sme_register11d_scan_done_callback() -
3948 * Register a routine of type csr_scan_completeCallback which is
3949 * called whenever an 11d scan is done
3950 *
3951 * hHal - The handle returned by mac_open.
3952 * callback - 11d scan complete routine to be registered
3953 * Return QDF_STATUS
3954 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303955QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303956 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303958 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3960
3961 pMac->scan.callback11dScanDone = callback;
3962
3963 return status;
3964}
3965
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303966/**
3967 * sme_deregister11d_scan_done_callback() - De-register scandone callback
3968 * @h_hal: Handler return by mac_open
3969 *
3970 * This function De-registers the scandone callback to SME
3971 *
3972 * Return: None
3973 */
3974void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
3975{
3976 tpAniSirGlobal pmac;
3977
3978 if (!h_hal) {
3979 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3980 FL("hHal is not valid"));
3981 return;
3982 }
3983
3984 pmac = PMAC_STRUCT(h_hal);
3985 pmac->scan.callback11dScanDone = NULL;
3986}
3987
3988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989#ifdef FEATURE_OEM_DATA_SUPPORT
3990/**
3991 * sme_register_oem_data_rsp_callback() - Register a routine of
3992 * type send_oem_data_rsp_msg
3993 * @h_hal: Handle returned by mac_open.
3994 * @callback: Callback to send response
3995 * to oem application.
3996 *
3997 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
3998 * callback function.
3999 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304000 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 sme_send_oem_data_rsp_msg callback)
4004{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304005 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4007
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004008 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009
4010 return status;
4011
4012}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304013
4014/**
4015 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4016 * @h_hal: Handler return by mac_open
4017 * This function De-registers the OEM data response callback to SME
4018 *
4019 * Return: None
4020 */
4021void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4022{
4023 tpAniSirGlobal pmac;
4024
4025 if (!h_hal) {
4026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4027 FL("hHal is not valid"));
4028 return;
4029 }
4030 pmac = PMAC_STRUCT(h_hal);
4031
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004032 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304033}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034
4035/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004036 * sme_oem_update_capability() - update UMAC's oem related capability.
4037 * @hal: Handle returned by mac_open
4038 * @oem_cap: pointer to oem_capability
4039 *
4040 * This function updates OEM capability to UMAC. Currently RTT
4041 * related capabilities are updated. More capabilities can be
4042 * added in future.
4043 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304044 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004045 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304046QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004047 struct sme_oem_capability *cap)
4048{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304049 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004050 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4051 uint8_t *bytes;
4052
4053 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4054
4055 if (cap->ftm_rr)
4056 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4057 if (cap->lci_capability)
4058 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4059
4060 return status;
4061}
4062
4063/**
4064 * sme_oem_get_capability() - get oem capability
4065 * @hal: Handle returned by mac_open
4066 * @oem_cap: pointer to oem_capability
4067 *
4068 * This function is used to get the OEM capability from UMAC.
4069 * Currently RTT related capabilities are received. More
4070 * capabilities can be added in future.
4071 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304072 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004073 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304074QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004075 struct sme_oem_capability *cap)
4076{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304077 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004078 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4079 uint8_t *bytes;
4080
4081 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4082
4083 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4084 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4085
4086 return status;
4087}
Naveen Rawat910726a2017-03-06 11:42:51 -08004088#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004089
4090/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 * sme_roam_set_key() - To set encryption key.
4092 * @hal: hal global context
4093 * @session_id: session id
4094 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4095 * @ptr_roam_id: Upon success return, this is the id caller can use to
4096 * identify the request in roamcallback
4097 *
4098 * This function should be called only when connected. This is an asynchronous
4099 * API.
4100 *
4101 * Return: Status of operation
4102 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304103QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4105{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304106 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4108 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304109 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4111
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304112 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 session_id, 0));
4114 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004115 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304116 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 }
4118 /*Once Setkey is done, we can go in BMPS */
4119 if (set_key->keyLength)
4120 ps_global_info->remain_in_power_active_till_dhcp = false;
4121
4122 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304123 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 return status;
4125
4126 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4127 if (ptr_roam_id)
4128 *ptr_roam_id = roam_id;
4129
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004130 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004132 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 session = CSR_GET_SESSION(mac_ctx, session_id);
4134 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004135 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304137 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 }
4139 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4140 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4141 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4142 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4143 set_key->encType)) {
4144 session->pCurRoamProfile->negotiatedUCEncryptionType =
4145 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4146 }
4147 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4148 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4149 set_key->encType)) {
4150 session->pCurRoamProfile->negotiatedUCEncryptionType =
4151 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4152 }
4153 }
4154 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4155 sme_release_global_lock(&mac_ctx->sme);
4156 return status;
4157}
4158
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304159/**
4160 * sme_roam_set_default_key_index - To set default wep key idx
4161 * @hal: pointer to hal handler
4162 * @session_id: session id
4163 * @default_idx: default wep key index
4164 *
4165 * This function prepares a message and post to WMA to set wep default
4166 * key index
4167 *
4168 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4169 */
4170QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4171 uint8_t default_idx)
4172{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004173 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304174 struct wep_update_default_key_idx *update_key;
4175
4176 update_key = qdf_mem_malloc(sizeof(*update_key));
4177 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004178 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304179 return QDF_STATUS_E_NOMEM;
4180 }
4181
4182 update_key->session_id = session_id;
4183 update_key->default_idx = default_idx;
4184
4185 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4186 msg.reserved = 0;
4187 msg.bodyptr = (void *)update_key;
4188
4189 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004190 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004191 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304192 qdf_mem_free(update_key);
4193 return QDF_STATUS_E_FAILURE;
4194 }
4195
4196 return QDF_STATUS_SUCCESS;
4197}
4198
4199
Jeff Johnson8bd23352017-09-26 11:39:24 -07004200/**
4201 * sme_get_rssi() - API to retrieve current RSSI
4202 * @hHal: HAL handle for device
4203 * @callback: SME sends back the requested stats using the callback
4204 * @staId: The station ID for which the RSSI is requested for
4205 * @bssid: The bssid of the connected session
4206 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4207 * RSSI, do not hold up but return this value.
4208 * @pContext: user context to be passed back along with the callback
4209 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304210 * A wrapper function that client calls to register a callback to get RSSI
4211 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004212 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304213 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304214QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304215 tCsrRssiCallback callback, uint8_t staId,
4216 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004217 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304219 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4221
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304222 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4224 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304225 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 status = csr_get_rssi(pMac, callback,
4227 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004228 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 sme_release_global_lock(&pMac->sme);
4230 }
4231 return status;
4232}
4233
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304234/*
4235 * sme_get_snr() -
4236 * A wrapper function that client calls to register a callback to get SNR
4237 *
4238 * callback - SME sends back the requested stats using the callback
4239 * staId - The station ID for which the stats is requested for
4240 * pContext - user context to be passed back along with the callback
4241 * p_cds_context - cds context
4242 * \return QDF_STATUS
4243 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304246 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304248 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4250
4251 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304252 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4254 sme_release_global_lock(&pMac->sme);
4255 }
4256 return status;
4257}
4258
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004259#ifndef QCA_SUPPORT_CP_STATS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304260/*
4261 * sme_get_statistics() -
4262 * A wrapper function that client calls to register a callback to get
4263 * different PHY level statistics from CSR.
4264 *
4265 * requesterId - different client requesting for statistics,
4266 * HDD, UMA/GAN etc
4267 * statsMask - The different category/categories of stats requester
4268 * is looking for
4269 * callback - SME sends back the requested stats using the callback
4270 * periodicity - If requester needs periodic update in millisec, 0 means
4271 * it's an one time request
4272 * cache - If requester is happy with cached stats
4273 * staId - The station ID for which the stats is requested for
4274 * pContext - user context to be passed back along with the callback
4275 * sessionId - sme session interface
4276 * Return QDF_STATUS
4277 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304278QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 eCsrStatsRequesterType requesterId,
4280 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004281 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304283 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304287 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304288 status = csr_get_statistics(pMac, requesterId, statsMask,
4289 callback, staId, pContext,
4290 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 sme_release_global_lock(&pMac->sme);
4292 }
4293
4294 return status;
4295
4296}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004297#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304299QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 tCsrLinkStatusCallback callback,
4301 void *pContext, uint8_t sessionId)
4302{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304303 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4305 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004306 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307
4308 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304309 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304310 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304312 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 "%s: Not able to allocate memory for link status",
4314 __func__);
4315 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304316 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 }
4318
4319 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4320 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4321 pMsg->sessionId = sessionId;
4322 pMac->sme.linkStatusContext = pContext;
4323 pMac->sme.linkStatusCallback = callback;
4324
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004325 message.type = WMA_LINK_STATUS_GET_REQ;
4326 message.bodyptr = pMsg;
4327 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304329 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004330 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4331 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304332 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304334 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 pMac->sme.linkStatusContext = NULL;
4336 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304337 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 }
4339
4340 sme_release_global_lock(&pMac->sme);
4341 }
4342
4343 return status;
4344}
4345
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304346/*
4347 * sme_get_country_code() -
4348 * To return the current country code. If no country code is applied,
4349 * default country code is used to fill the buffer.
4350 * If 11d supported is turned off, an error is return and the last
4351 * applied/default country code is used.
4352 * This is a synchronous API.
4353 *
4354 * pBuf - pointer to a caller allocated buffer for returned country code.
4355 * pbLen For input, this parameter indicates how big is the buffer.
4356 * Upon return, this parameter has the number of bytes for
4357 * country. If pBuf doesn't have enough space, this function
4358 * returns fail status and this parameter contains the number
4359 * that is needed.
4360 *
4361 * Return QDF_STATUS SUCCESS.
4362 *
4363 * FAILURE or RESOURCES The API finished and failed.
4364 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304365QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366{
4367 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4368
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304369 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4371
4372 return csr_get_country_code(pMac, pBuf, pbLen);
4373}
4374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375/* some support functions */
4376bool sme_is11d_supported(tHalHandle hHal)
4377{
4378 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4379
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004380 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381}
4382
4383bool sme_is11h_supported(tHalHandle hHal)
4384{
4385 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4386
4387 return csr_is11h_supported(pMac);
4388}
4389
4390bool sme_is_wmm_supported(tHalHandle hHal)
4391{
4392 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4393
4394 return csr_is_wmm_supported(pMac);
4395}
4396
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304397/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304398 * sme_generic_change_country_code() -
4399 * Change Country code from upperlayer during WLAN driver operation.
4400 * This is a synchronous API.
4401 *
4402 * hHal - The handle returned by mac_open.
4403 * pCountry New Country Code String
4404 * reg_domain regulatory domain
4405 * Return QDF_STATUS SUCCESS.
4406 * FAILURE or RESOURCES The API finished and failed.
4407 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304408QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004409 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304411 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004413 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 tAniGenericChangeCountryCodeReq *pMsg;
4415
4416 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304417 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 "%s: pMac is null", __func__);
4419 return status;
4420 }
4421
4422 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304423 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304424 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425
4426 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004427 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304429 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 }
4431
4432 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4433 pMsg->msgLen =
4434 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304435 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004436 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437
4438 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4439 msg.bodyptr = pMsg;
4440 msg.reserved = 0;
4441
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304442 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004443 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004444 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304445 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 sme_release_global_lock(&pMac->sme);
4449 }
4450
4451 return status;
4452}
4453
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304454/*
4455 * sme_dhcp_start_ind() -
4456 * API to signal the FW about the DHCP Start event.
4457 *
4458 * hHal - HAL handle for device.
4459 * device_mode - mode(AP,SAP etc) of the device.
4460 * macAddr - MAC address of the adapter.
4461 * sessionId - session ID.
4462 * Return QDF_STATUS SUCCESS.
4463 * FAILURE or RESOURCES The API finished and failed.
4464 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304465QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 uint8_t device_mode,
4467 uint8_t *macAddr, uint8_t sessionId)
4468{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304469 QDF_STATUS status;
4470 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004472 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304474 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475
4476 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304477 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 pSession = CSR_GET_SESSION(pMac, sessionId);
4479
4480 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004481 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304483 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 }
Arif Hussain3316f402016-11-10 13:08:03 -08004485 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304487 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304489 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 "%s: Not able to allocate memory for dhcp start",
4491 __func__);
4492 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304493 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 }
4495 pMsg->msgType = WMA_DHCP_START_IND;
4496 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4497 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304498 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304499 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304500 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004501 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004503 message.type = WMA_DHCP_START_IND;
4504 message.bodyptr = pMsg;
4505 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304506 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004507 sessionId, message.type));
4508 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4509 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304510 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304511 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304514 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 }
4516 sme_release_global_lock(&pMac->sme);
4517 }
4518 return status;
4519}
4520
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304521/*
4522 * sme_dhcp_stop_ind() -
4523 * API to signal the FW about the DHCP complete event.
4524 *
4525 * hHal - HAL handle for device.
4526 * device_mode - mode(AP, SAP etc) of the device.
4527 * macAddr - MAC address of the adapter.
4528 * sessionId - session ID.
4529 * Return QDF_STATUS SUCCESS.
4530 * FAILURE or RESOURCES The API finished and failed.
4531 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304532QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 uint8_t device_mode,
4534 uint8_t *macAddr, uint8_t sessionId)
4535{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304536 QDF_STATUS status;
4537 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004539 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304541 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542
4543 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304544 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 pSession = CSR_GET_SESSION(pMac, sessionId);
4546
4547 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004548 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304550 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 }
Arif Hussain3316f402016-11-10 13:08:03 -08004552 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304556 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 "%s: Not able to allocate memory for dhcp stop",
4558 __func__);
4559 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304560 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 }
4562
4563 pMsg->msgType = WMA_DHCP_STOP_IND;
4564 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4565 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304566 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304567 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304568 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004569 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004571 message.type = WMA_DHCP_STOP_IND;
4572 message.bodyptr = pMsg;
4573 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304574 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004575 sessionId, message.type));
4576 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4577 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304578 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304581 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304582 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 }
4584
4585 sme_release_global_lock(&pMac->sme);
4586 }
4587 return status;
4588}
4589
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304590/*
4591 * sme_TXFailMonitorStopInd() -
4592 * API to signal the FW to start monitoring TX failures
4593 *
4594 * Return QDF_STATUS SUCCESS.
4595 * FAILURE or RESOURCES The API finished and failed.
4596 */
4597QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4598 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004599 void *txFailIndCallback)
4600{
4601 QDF_STATUS status;
4602 QDF_STATUS qdf_status;
4603 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004604 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004605 tAniTXFailMonitorInd *pMsg;
4606
4607 status = sme_acquire_global_lock(&pMac->sme);
4608 if (QDF_STATUS_SUCCESS == status) {
4609 pMsg = (tAniTXFailMonitorInd *)
4610 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4611 if (NULL == pMsg) {
4612 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4613 "%s: Failed to allocate memory", __func__);
4614 sme_release_global_lock(&pMac->sme);
4615 return QDF_STATUS_E_NOMEM;
4616 }
4617
4618 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4619 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4620
4621 /* tx_fail_count = 0 should disable the Monitoring in FW */
4622 pMsg->tx_fail_count = tx_fail_count;
4623 pMsg->txFailIndCallback = txFailIndCallback;
4624
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004625 message.type = WMA_TX_FAIL_MONITOR_IND;
4626 message.bodyptr = pMsg;
4627 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004628
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004629 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4630 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004631 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4632 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4633 "%s: Post TX Fail monitor Start MSG fail",
4634 __func__);
4635 qdf_mem_free(pMsg);
4636 status = QDF_STATUS_E_FAILURE;
4637 }
4638 sme_release_global_lock(&pMac->sme);
4639 }
4640 return status;
4641}
4642
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304643/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304644 * sme_neighbor_report_request() -
4645 * API to request neighbor report.
4646 *
4647 * hHal - The handle returned by mac_open.
4648 * pRrmNeighborReq - Pointer to a caller allocated object of type
4649 * tRrmNeighborReq. Caller owns the memory and is
4650 * responsible for freeing it.
4651 * Return QDF_STATUS
4652 * QDF_STATUS_E_FAILURE - failure
4653 * QDF_STATUS_SUCCESS success
4654 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304655QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304657 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304659 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304661
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304662 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4664 0));
4665
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304666 if (pRrmNeighborReq->neighbor_report_offload) {
4667 status = csr_invoke_neighbor_report_request(sessionId,
4668 pRrmNeighborReq,
4669 false);
4670 return status;
4671 }
4672
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 status =
4675 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304676 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 sme_release_global_lock(&pMac->sme);
4678 }
4679
4680 return status;
4681}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304683/*
4684 * sme_get_wcnss_wlan_compiled_version() -
4685 * This API returns the version of the WCNSS WLAN API with
4686 * which the HOST driver was built
4687 *
4688 * hHal - The handle returned by mac_open.
4689 * pVersion - Points to the Version structure to be filled
4690 * Return QDF_STATUS
4691 * QDF_STATUS_E_INVAL - failure
4692 * QDF_STATUS_SUCCESS success
4693 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304694QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 tSirVersionType *pVersion)
4696{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304697 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4699
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304700 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304702 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304704 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705
4706 sme_release_global_lock(&pMac->sme);
4707 }
4708
4709 return status;
4710}
4711
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304712/*
4713 * sme_get_wcnss_wlan_reported_version() -
4714 * This API returns the version of the WCNSS WLAN API with
4715 * which the WCNSS driver reports it was built
4716 * hHal - The handle returned by mac_open.
4717 * pVersion - Points to the Version structure to be filled
4718 * Return QDF_STATUS
4719 * QDF_STATUS_E_INVAL - failure
4720 * QDF_STATUS_SUCCESS success
4721 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304722QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 tSirVersionType *pVersion)
4724{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304725 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4727
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304728 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304730 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004731 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304732 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733
4734 sme_release_global_lock(&pMac->sme);
4735 }
4736
4737 return status;
4738}
4739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304740/*
4741 * sme_get_wcnss_software_version() -
4742 * This API returns the version string of the WCNSS driver
4743 *
4744 * hHal - The handle returned by mac_open.
4745 * pVersion - Points to the Version string buffer to be filled
4746 * versionBufferSize - THe size of the Version string buffer
4747 * Return QDF_STATUS
4748 * QDF_STATUS_E_INVAL - failure
4749 * QDF_STATUS_SUCCESS success
4750 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304751QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 uint8_t *pVersion,
4753 uint32_t versionBufferSize)
4754{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304755 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304758 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304759 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004761 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762 pVersion,
4763 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304764 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304765 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 sme_release_global_lock(&pMac->sme);
4767 }
4768
4769 return status;
4770}
4771
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304772/*
4773 * sme_get_wcnss_hardware_version() -
4774 * This API returns the version string of the WCNSS hardware
4775 *
4776 * hHal - The handle returned by mac_open.
4777 * pVersion - Points to the Version string buffer to be filled
4778 * versionBufferSize - THe size of the Version string buffer
4779 * Return QDF_STATUS
4780 * QDF_STATUS_E_INVAL - failure
4781 * QDF_STATUS_SUCCESS success
4782 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304783QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 uint8_t *pVersion,
4785 uint32_t versionBufferSize)
4786{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304787 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4789
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304790 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304792 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304794 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795
4796 sme_release_global_lock(&pMac->sme);
4797 }
4798
4799 return status;
4800}
4801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004803/**
4804 * sme_oem_data_req() - send oem data request to WMA
4805 * @hal: HAL handle
4806 * @hdd_oem_req: OEM data request from HDD
4807 *
4808 * Return: QDF_STATUS
4809 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004810QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304812 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004813 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004814 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004816 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004817 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4818 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004819 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004820 return QDF_STATUS_E_FAILURE;
4821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004823 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
4824 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004825 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004826 return QDF_STATUS_E_NOMEM;
4827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004829 oem_data_req->data_len = hdd_oem_req->data_len;
4830 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
4831 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004832 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004833 return QDF_STATUS_E_NOMEM;
4834 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004836 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
4837 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004839 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304841 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004842 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304843 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004844 sme_debug("OEM request(length: %d) sent to WMA",
4845 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004846
4847 if (oem_data_req->data_len)
4848 qdf_mem_free(oem_data_req->data);
4849 qdf_mem_free(oem_data_req);
4850
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004851 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852 return status;
4853}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004854#endif /*FEATURE_OEM_DATA_SUPPORT */
4855
Krunal Soni8d184fa2017-11-20 21:52:05 -08004856QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857{
Arif Hussainee677012017-01-26 17:50:13 -08004858 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004859 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08004860 struct cdp_pdev *pdev;
4861 ol_txrx_peer_handle peer;
4862 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07004863 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304865 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07004866 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08004867 __func__, params->type_of_persona,
4868 params->sme_session_id, params->subtype_of_persona,
4869 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870
Arif Hussainee677012017-01-26 17:50:13 -08004871 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4872
4873 if (NULL == pdev) {
4874 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4875 "%s: Failed to get pdev handler", __func__);
4876 return status;
4877 }
4878
Krunal Soni8d184fa2017-11-20 21:52:05 -08004879 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004880 if (QDF_IS_STATUS_ERROR(status))
4881 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882
Krunal Soni8d184fa2017-11-20 21:52:05 -08004883 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
4884 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08004885 if (peer) {
4886 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4887 "%s: Peer=%d exist with same MAC",
4888 __func__, peer_id);
4889 status = QDF_STATUS_E_INVAL;
4890 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004891 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08004892 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08004893 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004894
4895 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004896 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897
4898 return status;
4899}
4900
Krunal Soni8d184fa2017-11-20 21:52:05 -08004901QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304903 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004904 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304906 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004907 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304909 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004910 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 sme_release_global_lock(&pMac->sme);
4912 }
4913
4914 return status;
4915}
4916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304917/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304918 * sme_change_mcc_beacon_interval() -
4919 * To update P2P-GO beaconInterval. This function should be called after
4920 * disassociating all the station is done
4921 * This is an asynchronous API.
4922 *
4923 * @sessionId: Session Identifier
4924 * Return QDF_STATUS SUCCESS
4925 * FAILURE or RESOURCES
4926 * The API finished and failed.
4927 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004928QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304930 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004931 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932
Krunal Soni3fa80e22018-01-09 14:16:02 -08004933 if (!mac_ctx) {
4934 sme_err("mac_ctx is NULL");
4935 return status;
4936 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004937 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304938 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004939 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
4940 sessionId);
4941 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 }
4943 return status;
4944}
4945
4946/**
4947 * sme_set_host_offload(): API to set the host offload feature.
4948 * @hHal: The handle returned by mac_open.
4949 * @sessionId: Session Identifier
4950 * @request: Pointer to the offload request.
4951 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304952 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304954QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 tpSirHostOffloadReq request)
4956{
4957 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304960 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
4962 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304963 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004964#ifdef WLAN_NS_OFFLOAD
4965 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
4966 status = sme_set_ps_ns_offload(hHal, request,
4967 sessionId);
4968 } else
4969#endif /* WLAN_NS_OFFLOAD */
4970 {
4971 status = sme_set_ps_host_offload(hHal, request,
4972 sessionId);
4973 }
4974 sme_release_global_lock(&pMac->sme);
4975 }
4976
4977 return status;
4978}
4979
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304980/*
4981 * sme_set_keep_alive() -
4982 * API to set the Keep Alive feature.
4983 *
4984 * hHal - The handle returned by mac_open.
4985 * request - Pointer to the Keep Alive request.
4986 * Return QDF_STATUS
4987 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304988QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 tpSirKeepAliveReq request)
4990{
4991 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004992 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304994 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997 FL("WMA_SET_KEEP_ALIVE message"));
4998
4999 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305000 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305002 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305004 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305006 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305007 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305008 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009 }
5010
Anurag Chouhanc5548422016-02-24 18:33:27 +05305011 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305012 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305014 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 "buff TP %d input TP %d ", request_buf->timePeriod,
5016 request->timePeriod);
5017 request_buf->sessionId = session_id;
5018
5019 msg.type = WMA_SET_KEEP_ALIVE;
5020 msg.reserved = 0;
5021 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305022 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5023 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305024 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005025 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305027 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305028 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305029 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 }
5031
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305032 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033}
5034
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305035/*
5036 * sme_get_operation_channel() -
5037 * API to get current channel on which STA is parked his function gives
5038 * channel information only of infra station or IBSS station
5039 *
5040 * hHal, pointer to memory location and sessionId
5041 * Returns QDF_STATUS_SUCCESS
5042 * QDF_STATUS_E_FAILURE
5043 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305044QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 uint8_t sessionId)
5046{
5047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305048 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049
5050 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5051 pSession = CSR_GET_SESSION(pMac, sessionId);
5052
5053 if ((pSession->connectedProfile.BSSType ==
5054 eCSR_BSS_TYPE_INFRASTRUCTURE)
5055 || (pSession->connectedProfile.BSSType ==
5056 eCSR_BSS_TYPE_IBSS)
5057 || (pSession->connectedProfile.BSSType ==
5058 eCSR_BSS_TYPE_INFRA_AP)
5059 || (pSession->connectedProfile.BSSType ==
5060 eCSR_BSS_TYPE_START_IBSS)) {
5061 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305062 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 }
5064 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305065 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066} /* sme_get_operation_channel ends here */
5067
Abhishek Singh7996eb72015-12-30 17:24:02 +05305068/**
5069 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5070 * management frame indication to PE.
5071 *
5072 * @hal: hal pointer
5073 * @callback: callback pointer to be registered
5074 *
5075 * This function is used to register a callback for management
5076 * frame indication to PE.
5077 *
5078 * Return: Success if msg is posted to PE else Failure.
5079 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305080QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305081 sir_mgmt_frame_ind_callback callback)
5082{
5083 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5084 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305085 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305086
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305087 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305088 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305089 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305090 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005091 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305092 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305093 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305094 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305095 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5096 msg->length = sizeof(*msg);
5097
5098 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005099 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305100 sme_release_global_lock(&mac_ctx->sme);
5101 return status;
5102 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305103 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305104}
5105
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305106/*
5107 * sme_RegisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005108 * To register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305109 *
5110 * frameType - type of the frame that needs to be passed to HDD.
5111 * matchData - data which needs to be matched before passing frame
5112 * to HDD.
5113 * matchDataLen - Length of matched data.
5114 * Return QDF_STATUS
5115 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305116QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 uint16_t frameType, uint8_t *matchData,
5118 uint16_t matchLen)
5119{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305120 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305124 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 tSirRegisterMgmtFrame *pMsg;
5126 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305127 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5128 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129
5130 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005131 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305133 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 }
5135
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305136 if (!CSR_IS_SESSION_ANY(sessionId) &&
5137 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305138 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 "%s Invalid Sessionid", __func__);
5140 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305141 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142 }
5143
5144 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305146 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305148 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005149 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5151 pMsg->length = len;
5152 pMsg->sessionId = sessionId;
5153 pMsg->registerFrame = true;
5154 pMsg->frameType = frameType;
5155 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305156 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005157 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 }
5159 sme_release_global_lock(&pMac->sme);
5160 }
5161 return status;
5162}
5163
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305164/*
5165 * sme_DeregisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005166 * To De-register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305167 *
5168 * frameType - type of the frame that needs to be passed to HDD.
5169 * matchData - data which needs to be matched before passing frame
5170 * to HDD.
5171 * matchDataLen - Length of matched data.
5172 * Return QDF_STATUS
5173 */
5174QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 uint16_t frameType, uint8_t *matchData,
5176 uint16_t matchLen)
5177{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305178 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5180
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305181 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5183 0));
5184 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305185 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 tSirRegisterMgmtFrame *pMsg;
5187 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305188 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5189 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190
5191 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005192 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195 }
5196
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305197 if (!CSR_IS_SESSION_ANY(sessionId) &&
5198 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305199 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 "%s Invalid Sessionid", __func__);
5201 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305202 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 }
5204
5205 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5206
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305207 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005208 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305209 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5212 pMsg->length = len;
5213 pMsg->registerFrame = false;
5214 pMsg->frameType = frameType;
5215 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305216 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005217 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 }
5219 sme_release_global_lock(&pMac->sme);
5220 }
5221 return status;
5222}
5223
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305224/**
5225 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5226 * @hal: The handle returned by mac_open
5227 * @session_id: session id
5228 * @buf: pointer to frame
5229 * @len: frame length
5230 *
5231 * Return: QDF_STATUS
5232 */
5233static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5234 const uint8_t *buf, uint32_t len)
5235{
5236 QDF_STATUS status = QDF_STATUS_SUCCESS;
5237 struct sir_mgmt_msg *msg;
5238 uint16_t msg_len;
5239 struct scheduler_msg sch_msg = {0};
5240
5241 sme_debug("prepares auth frame");
5242
5243 msg_len = sizeof(*msg) + len;
5244 msg = qdf_mem_malloc(msg_len);
5245 if (msg == NULL) {
5246 status = QDF_STATUS_E_NOMEM;
5247 } else {
5248 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5249 msg->msg_len = msg_len;
5250 msg->session_id = session_id;
5251 msg->data = (uint8_t *)msg + sizeof(*msg);
5252 qdf_mem_copy(msg->data, buf, len);
5253
5254 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5255 sch_msg.bodyptr = msg;
5256 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5257 }
5258 return status;
5259}
5260
5261QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5262 const uint8_t *buf, uint32_t len)
5263{
5264 QDF_STATUS status = QDF_STATUS_SUCCESS;
5265 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5266
5267 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5268 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5269
5270 status = sme_acquire_global_lock(&mac->sme);
5271 if (QDF_IS_STATUS_SUCCESS(status)) {
5272 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5273 sme_release_global_lock(&mac->sme);
5274 }
5275
5276 return status;
5277}
5278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005280/**
5281 * sme_configure_ext_wow() - configure Extr WoW
5282 * @hHal - The handle returned by mac_open.
5283 * @wlanExtParams - Depicts the wlan Ext params.
5284 * @callback - ext_wow callback to be registered.
5285 * @callback_context - ext_wow callback context
5286 *
5287 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305288 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005289 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305290QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 tpSirExtWoWParams wlanExtParams,
5292 csr_readyToExtWoWCallback callback,
5293 void *callback_context)
5294{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305295 QDF_STATUS status = QDF_STATUS_SUCCESS;
5296 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005298 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305299 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300
5301 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305302 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305304 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5306
5307 pMac->readyToExtWoWCallback = callback;
5308 pMac->readyToExtWoWContext = callback_context;
5309
5310 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305311 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312
5313 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305314 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005315 message.bodyptr = MsgPtr;
5316 message.type = WMA_WLAN_EXT_WOW;
5317 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5318 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 pMac->readyToExtWoWCallback = NULL;
5321 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305322 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305323 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 }
5325 sme_release_global_lock(&pMac->sme);
5326 } else {
5327 pMac->readyToExtWoWCallback = NULL;
5328 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305329 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 }
5331
5332 return status;
5333}
5334
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305335/*
5336 * sme_configure_app_type1_params() -
5337 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5338 *
5339 * hHal - The handle returned by mac_open.
5340 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5341 * Return QDF_STATUS
5342 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305343QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344 tpSirAppType1Params wlanAppType1Params)
5345{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305346 QDF_STATUS status = QDF_STATUS_SUCCESS;
5347 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005349 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305350 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351
5352 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305353 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305355 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5357 0));
5358
5359 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305360 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305362 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005363 message.bodyptr = MsgPtr;
5364 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5365 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5366 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305367 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305368 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305369 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 }
5371 sme_release_global_lock(&pMac->sme);
5372 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305373 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 }
5375
5376 return status;
5377}
5378
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305379/*
5380 * sme_configure_app_type2_params() -
5381 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5382 *
5383 * hHal - The handle returned by mac_open.
5384 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5385 * Return QDF_STATUS
5386 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305387QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305388 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305390 QDF_STATUS status = QDF_STATUS_SUCCESS;
5391 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005393 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305394 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395
5396 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305397 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305399 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5401 0));
5402
5403 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305404 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005407 message.bodyptr = MsgPtr;
5408 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5409 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5410 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305411 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305412 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305413 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 }
5415 sme_release_global_lock(&pMac->sme);
5416 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305417 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 }
5419
5420 return status;
5421}
5422#endif
5423
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305424/*
5425 * sme_get_infra_session_id
5426 * To get the session ID for infra session, if connected
5427 * This is a synchronous API.
5428 *
5429 * hHal - The handle returned by mac_open.
5430 * sessionid, -1 if infra session is not connected
5431 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432int8_t sme_get_infra_session_id(tHalHandle hHal)
5433{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305434 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435 int8_t sessionid = -1;
5436 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5437
5438 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305439 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440
5441 sessionid = csr_get_infra_session_id(pMac);
5442
5443 sme_release_global_lock(&pMac->sme);
5444 }
5445
5446 return sessionid;
5447}
5448
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305449/*
5450 * sme_get_infra_operation_channel() -
5451 * To get the operating channel for infra session, if connected
5452 * This is a synchronous API.
5453 *
5454 * hHal - The handle returned by mac_open.
5455 * sessionId - the sessionId returned by sme_open_session.
5456 * Return operating channel, 0 if infra session is not connected
5457 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5459{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305460 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5462 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305465 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466
5467 channel = csr_get_infra_operation_channel(pMac, sessionId);
5468
5469 sme_release_global_lock(&pMac->sme);
5470 }
5471
5472 return channel;
5473}
5474
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305475/* This routine will return poerating channel on which other BSS is operating
5476 * to be used for concurrency mode. If other BSS is not up or not connected it
5477 * will return 0
5478 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5480{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305481 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5483 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305486 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487
5488 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305489 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5490 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 sme_release_global_lock(&pMac->sme);
5492 }
5493
5494 return channel;
5495}
5496
5497#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5498uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5499 eCsrPhyMode sapPhyMode,
5500 uint8_t cc_switch_mode)
5501{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305502 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5504 uint16_t channel = 0;
5505
5506 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305507 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305509 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5510 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511 cc_switch_mode);
5512 sme_release_global_lock(&pMac->sme);
5513 }
5514
5515 return channel;
5516}
5517#endif
5518
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305519/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005520 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005521 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005522 * @cb_fn: Callback function pointer
5523 * @db_ctx: Callback data
5524 *
5525 * Return: QDF_STATUS
5526 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005527QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005528 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5529{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005530 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005531 QDF_STATUS status;
5532
Manikandan Mohan976e7562016-03-15 16:33:31 -07005533 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005534 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005535 mac->sme.get_tsf_cb = cb_fn;
5536 mac->sme.get_tsf_cxt = cb_ctx;
5537 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005538 }
5539 return status;
5540}
5541
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305542/**
5543 * sme_reset_tsfcb() - Reset callback for TSF capture
5544 * @h_hal: Handler return by mac_open
5545 *
5546 * This function reset the tsf capture callback to SME
5547 *
5548 * Return: QDF_STATUS
5549 */
5550QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5551{
5552 tpAniSirGlobal mac;
5553 QDF_STATUS status;
5554
5555 if (!h_hal) {
5556 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5557 FL("h_hal is not valid"));
5558 return QDF_STATUS_E_INVAL;
5559 }
5560 mac = PMAC_STRUCT(h_hal);
5561
5562 status = sme_acquire_global_lock(&mac->sme);
5563 if (QDF_IS_STATUS_SUCCESS(status)) {
5564 mac->sme.get_tsf_cb = NULL;
5565 mac->sme.get_tsf_cxt = NULL;
5566 sme_release_global_lock(&mac->sme);
5567 }
5568 return status;
5569}
5570
Manikandan Mohan976e7562016-03-15 16:33:31 -07005571#ifdef WLAN_FEATURE_TSF
5572/*
5573 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5574 * @h_hal: Handler return by mac_open
5575 * @pinvalue: gpio pin id
5576 *
5577 * Return: QDF_STATUS
5578 */
5579QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5580{
5581 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005582 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005583 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5584
5585 status = sme_acquire_global_lock(&mac->sme);
5586 if (QDF_IS_STATUS_SUCCESS(status)) {
5587 tsf_msg.type = WMA_TSF_GPIO_PIN;
5588 tsf_msg.reserved = 0;
5589 tsf_msg.bodyval = pinvalue;
5590
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005591 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005592 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005593 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005594 status = QDF_STATUS_E_FAILURE;
5595 }
5596 sme_release_global_lock(&mac->sme);
5597 }
5598 return status;
5599}
5600#endif
5601
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005602QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603 uint32_t *len)
5604{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305605 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005606 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005608 if (NULL == mac_ctx) {
5609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5610 FL("Invalid MAC context"));
5611 return QDF_STATUS_E_FAILURE;
5612 }
5613
5614 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305615 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005616 status = csr_get_cfg_valid_channels(mac_ctx,
5617 aValidChannels, len);
5618 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 }
5620
5621 return status;
5622}
5623
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005624static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5625{
5626 switch (src) {
5627 case SOURCE_CORE:
5628 return "WORLD MODE";
5629
5630 case SOURCE_DRIVER:
5631 return "BDF file";
5632
5633 case SOURCE_USERSPACE:
5634 return "user-space";
5635
5636 case SOURCE_11D:
5637 return "802.11D IEs in beacons";
5638
5639 default:
5640 return "unknown";
5641 }
5642}
5643
Amar Singhal6edf9732016-11-20 21:43:40 -08005644void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5645{
5646 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5647
5648 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005649
5650 sme_debug("Country source is %s",
5651 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005652}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653
5654/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005655 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 * @mac_ctx: mac global context
5657 * @msg: request msg packet
5658 *
5659 * If Supplicant country code is priority than 11d is disabled.
5660 * If 11D is enabled, we update the country code after every scan.
5661 * Hence when Supplicant country code is priority, we don't need 11D info.
5662 * Country code from Supplicant is set as current country code.
5663 *
5664 * Return: status of operation
5665 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305666static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005667sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5668 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305670 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005671 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005672 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005674 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005675
Amar Singhal6edf9732016-11-20 21:43:40 -08005676 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5677 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5678 if (user_ctry_priority)
5679 mac_ctx->roam.configParam.Is11dSupportEnabled =
5680 false;
5681 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305682 if (mac_ctx->roam.configParam.
5683 Is11dSupportEnabled &&
5684 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005686 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005687
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305688 status =
5689 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005690 mac_ctx,
5691 mac_ctx->scan.countryCode11d,
5692 &reg_domain_id,
5693 SOURCE_11D);
5694 return QDF_STATUS_E_FAILURE;
5695 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005696 }
5697 }
5698 } else {
5699 /* if kernel gets invalid country code; it
5700 * resets the country code to world
5701 */
5702 if (('0' != msg->countryCode[0]) ||
5703 ('0' != msg->countryCode[1]))
5704 qdf_mem_copy(mac_ctx->scan.countryCode11d,
5705 msg->countryCode,
5706 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005708
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005709 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
5710 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 /* get the channels based on new cc */
5714 status = csr_get_channel_and_power_list(mac_ctx);
5715
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305716 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005717 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 return status;
5719 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 /* reset info based on new cc, and we are done */
5722 csr_apply_channel_power_info_wrapper(mac_ctx);
5723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005725
5726 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 * Country IE
5728 */
5729 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005730
Amar Singhal6edf9732016-11-20 21:43:40 -08005731 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
5732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005734
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305735 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736}
5737
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005738QDF_STATUS sme_update_channel_list(tHalHandle hal)
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305739{
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005740 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5741 QDF_STATUS status;
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305742
5743 status = sme_acquire_global_lock(&mac_ctx->sme);
5744 if (QDF_IS_STATUS_SUCCESS(status)) {
5745 /* Update umac channel (enable/disable) from cds channels */
5746 status = csr_get_channel_and_power_list(mac_ctx);
5747 if (status != QDF_STATUS_SUCCESS) {
5748 sme_err("fail to get Channels");
5749 sme_release_global_lock(&mac_ctx->sme);
5750 return status;
5751 }
5752
5753 csr_apply_channel_power_info_wrapper(mac_ctx);
5754 csr_scan_filter_results(mac_ctx);
5755 sme_disconnect_connected_sessions(mac_ctx);
5756 sme_release_global_lock(&mac_ctx->sme);
5757 }
5758
5759 return status;
5760}
5761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762static bool
5763sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
5764{
5765 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305766 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 ch_lst_info = &mac_ctx->scan.base_channels;
5769 for (i = 0; i < ch_lst_info->numChannels; i++) {
5770 if (ch_lst_info->channelList[i] == curr_ch)
5771 return true;
5772 }
5773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774 return false;
5775}
5776/**
5777 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
5778 * if channel is not supported
5779 * @mac_ctx: mac global context
5780 *
5781 * If new country code does not support the channel on which STA/P2P client
5782 * is connetced, it sends the disconnect to the AP/P2P GO
5783 *
5784 * Return: void
5785 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305786static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787{
5788 uint8_t session_id, found = false;
5789 uint8_t curr_ch;
5790
5791 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
5792 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
5793 continue;
5794 found = false;
5795 /* Session is connected.Check the channel */
5796 curr_ch = csr_get_infra_operation_channel(mac_ctx,
5797 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005798 sme_debug("Current Operating channel : %d, session :%d",
5799 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
5801 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005802 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 csr_roam_disconnect(mac_ctx, session_id,
5804 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5805 }
5806 }
5807}
5808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305810QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 tpSirRcvFltMcAddrList pMulticastAddrs)
5812{
5813 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005814 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305816 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
5819 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005821 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005823 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07005824 pSession = CSR_GET_SESSION(pMac, sessionId);
5825 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
5826 (!csr_is_conn_state_infra(pMac, sessionId) &&
5827 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05305828 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08005829 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305831 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 }
5833
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305834 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305836 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305837 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305839 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005840 }
5841
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005842 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
5843 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005845 "%s: Request ignored, session %d is not connected or started",
5846 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305847 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305848 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 }
5850
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305851 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 sizeof(tSirRcvFltMcAddrList));
5853
Anurag Chouhanc5548422016-02-24 18:33:27 +05305854 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
5855 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005856 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857
5858 msg.type = WMA_8023_MULTICAST_LIST_REQ;
5859 msg.reserved = 0;
5860 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305861 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5862 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005863 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005864 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305865 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305866 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005867 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305868 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305869 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870 }
5871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305872 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874#endif /* WLAN_FEATURE_PACKET_FILTERING */
5875
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305876/*
5877 * sme_is_channel_valid() -
5878 * To check if the channel is valid for currently established domain
5879 * This is a synchronous API.
5880 *
5881 * hHal - The handle returned by mac_open.
5882 * channel - channel to verify
5883 * Return true/false, true if channel is valid
5884 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
5886{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305887 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005888 bool valid = false;
5889 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5890
5891 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305892 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893
5894 valid = csr_roam_is_channel_valid(pMac, channel);
5895
5896 sme_release_global_lock(&pMac->sme);
5897 }
5898
5899 return valid;
5900}
5901
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305902/*
5903 * sme_set_freq_band() -
5904 * Used to set frequency band.
5905 *
5906 * hHal
5907 * sessionId - Session Identifier
5908 * band value to be configured
5909 * Return QDF_STATUS
5910 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005911QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
5912 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005913{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305914 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5916
5917 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305918 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 status = csr_set_band(hHal, sessionId, eBand);
5920 sme_release_global_lock(&pMac->sme);
5921 }
5922 return status;
5923}
5924
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305925/*
5926 * sme_get_freq_band() -
5927 * Used to get the current band settings.
5928 *
5929 * hHal
5930 * pBand pointer to hold band value
5931 * Return QDF_STATUS
5932 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005933QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005934{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305935 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5937
5938 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305939 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 *pBand = csr_get_current_band(hHal);
5941 sme_release_global_lock(&pMac->sme);
5942 }
5943 return status;
5944}
5945
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305946/*
5947 * sme_set_max_tx_power_per_band() -
5948 * Set the Maximum Transmit Power specific to band dynamically.
5949 * Note: this setting will not persist over reboots.
5950 *
5951 * band
5952 * power to set in dB
5953 * Return QDF_STATUS
5954 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005955QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005957 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
5959
5960 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305961 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305963 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
5965 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305966 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 }
5968
5969 pMaxTxPowerPerBandParams->power = dB;
5970 pMaxTxPowerPerBandParams->bandInfo = band;
5971
5972 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
5973 msg.reserved = 0;
5974 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305975 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5976 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005977 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005978 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305979 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
5981 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305982 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305983 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 }
5985
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305986 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987}
5988
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305989/*
5990 * sme_set_max_tx_power() -
5991 * Set the Maximum Transmit Power dynamically. Note: this setting will
5992 * not persist over reboots.
5993 *
5994 * hHal
5995 * pBssid BSSID to set the power cap for
5996 * pBssid pSelfMacAddress self MAC Address
5997 * pBssid power to set in dB
5998 * Return QDF_STATUS
5999 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306000QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6001 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006002{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006003 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004 tpMaxTxPowerParams pMaxTxParams = NULL;
6005
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306006 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306008 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 "%s: Not able to allocate memory for pMaxTxParams",
6012 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306013 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 }
6015
Anurag Chouhanc5548422016-02-24 18:33:27 +05306016 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6017 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018 pMaxTxParams->power = dB;
6019
6020 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6021 msg.reserved = 0;
6022 msg.bodyptr = pMaxTxParams;
6023
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006024 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006025 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6028 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306029 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306030 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 }
6032
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306033 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034}
6035
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306036/*
6037 * sme_set_custom_mac_addr() -
6038 * Set the customer Mac Address.
6039 *
6040 * customMacAddr customer MAC Address
6041 * Return QDF_STATUS
6042 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306043QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006045 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 tSirMacAddr *pBaseMacAddr;
6047
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306048 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306050 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306052 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006053 }
6054
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306055 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056
6057 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6058 msg.reserved = 0;
6059 msg.bodyptr = pBaseMacAddr;
6060
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006061 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006062 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306063 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306064 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306065 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306066 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 }
6068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306069 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070}
6071
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306072/*
6073 * sme_set_tx_power() -
6074 * Set Transmit Power dynamically.
6075 *
6076 * hHal
6077 * sessionId Target Session ID
6078 * BSSID
6079 * dev_mode dev_mode such as station, P2PGO, SAP
6080 * dBm power to set
6081 * Return QDF_STATUS
6082 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306083QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306084 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006085 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006087 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 tpMaxTxPowerParams pTxParams = NULL;
6089 int8_t power = (int8_t) dBm;
6090
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306091 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6093
6094 /* make sure there is no overflow */
6095 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306096 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306098 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 }
6100
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306101 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306103 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 "%s: Not able to allocate memory for pTxParams",
6105 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306106 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 }
6108
Anurag Chouhanc5548422016-02-24 18:33:27 +05306109 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 pTxParams->power = power; /* unit is dBm */
6111 pTxParams->dev_mode = dev_mode;
6112 msg.type = WMA_SET_TX_POWER_REQ;
6113 msg.reserved = 0;
6114 msg.bodyptr = pTxParams;
6115
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006116 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006117 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306118 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6120 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306121 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306122 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 }
6124
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306125 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126}
6127
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306128QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6129 uint8_t param_val)
6130{
6131 QDF_STATUS status;
6132 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6133
6134 pMac->roam.configParam.is_fils_enabled = !param_val;
6135
6136 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6137 status = wma_cli_set_command((int)session_id,
6138 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6139 !param_val, VDEV_CMD);
6140 if (status)
6141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6142 "%s: Failed to set enable bcast probe setting",
6143 __func__);
6144
6145 return status;
6146}
6147
6148QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306149 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306151 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306152 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153 uint16_t len;
6154
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306155 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306156 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306157 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306158 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6159 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306161 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006162 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306163 sme_release_global_lock(&mac_ctx->sme);
6164 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165 }
6166
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306167 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6168 mac_ctx->ignore_assoc_disallowed = param_val;
6169
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306170 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306171 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006172
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306173 len = sizeof(*msg);
6174 msg = qdf_mem_malloc(len);
6175 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306176 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306178 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6179 msg->length = len;
6180 msg->session_id = session_id;
6181 msg->param_type = param_type;
6182 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006183 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306185 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 }
6187 return status;
6188}
6189
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306190/*
6191 * sme_set_tm_level() -
6192 * Set Thermal Mitigation Level to RIVA
6193 *
6194 * hHal - The handle returned by mac_open.
6195 * newTMLevel - new Thermal Mitigation Level
6196 * tmMode - Thermal Mitigation handle mode, default 0
6197 * Return QDF_STATUS
6198 */
6199QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6200 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306202 QDF_STATUS status = QDF_STATUS_SUCCESS;
6203 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006205 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206 tAniSetTmLevelReq *setTmLevelReq = NULL;
6207
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306208 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6210 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306211 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006212 setTmLevelReq =
6213 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306214 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006215 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306216 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006217 "%s: Not able to allocate memory for sme_set_tm_level",
6218 __func__);
6219 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306220 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006221 }
6222
6223 setTmLevelReq->tmMode = tmMode;
6224 setTmLevelReq->newTmLevel = newTMLevel;
6225
6226 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006227 message.bodyptr = setTmLevelReq;
6228 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306229 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006230 NO_SESSION, message.type));
6231 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6232 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306233 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306234 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306236 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306237 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 }
6239 sme_release_global_lock(&pMac->sme);
6240 }
6241 return status;
6242}
6243
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306244/*
6245 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6246 * Host and FW.
6247 *
6248 * hHal - HAL handle for device
6249 * Return NONE
6250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251void sme_feature_caps_exchange(tHalHandle hHal)
6252{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306253 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306254 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6255 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256}
6257
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306258/*
6259 * sme_disable_feature_capablity() - SME interface to disable Active mode
6260 * offload capablity in Host.
6261 *
6262 * hHal - HAL handle for device
6263 * Return NONE
6264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265void sme_disable_feature_capablity(uint8_t feature_index)
6266{
6267}
6268
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306269/*
6270 * sme_reset_power_values_for5_g
6271 * Reset the power values for 5G band with default power values.
6272 *
6273 * hHal - HAL handle for device
6274 * Return NONE
6275 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276void sme_reset_power_values_for5_g(tHalHandle hHal)
6277{
6278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306279
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306280 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006281 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6282 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306283 /* Store the channel+power info in the global place: Cfg */
6284 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285}
6286
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306287/*
6288 * sme_update_roam_prefer5_g_hz() -
6289 * Enable/disable Roam prefer 5G runtime option
6290 * This function is called through dynamic setConfig callback function
6291 * to configure the Roam prefer 5G runtime option
6292 *
6293 * hHal - HAL handle for device
6294 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6295 * Return Success or failure
6296 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306298QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6299 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006300{
6301 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306302 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306304 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6306 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306307 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 "%s: gRoamPrefer5GHz is changed from %d to %d",
6310 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6311 nRoamPrefer5GHz);
6312 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6313 sme_release_global_lock(&pMac->sme);
6314 }
6315
6316 return status;
6317}
6318
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306319/*
6320 * sme_set_roam_intra_band() -
6321 * enable/disable Intra band roaming
6322 * This function is called through dynamic setConfig callback function
6323 * to configure the intra band roaming
6324 * hHal - HAL handle for device
6325 * nRoamIntraBand Enable/Disable Intra band roaming
6326 * Return Success or failure
6327 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306328QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329{
6330 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306331 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306333 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006334 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6335 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306336 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306337 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006338 "%s: gRoamIntraBand is changed from %d to %d",
6339 __func__, pMac->roam.configParam.nRoamIntraBand,
6340 nRoamIntraBand);
6341 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6342 sme_release_global_lock(&pMac->sme);
6343 }
6344
6345 return status;
6346}
6347
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306348/*
6349 * sme_update_roam_scan_n_probes() -
6350 * Function to update roam scan N probes
6351 * This function is called through dynamic setConfig callback function
6352 * to update roam scan N probes
6353 * hHal - HAL handle for device
6354 * sessionId - Session Identifier
6355 * nProbes number of probe requests to be sent out
6356 * Return Success or failure
6357 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306358QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 const uint8_t nProbes)
6360{
6361 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306362 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006363
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306364 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6366 NO_SESSION, 0));
6367 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306368 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306369 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 "%s: gRoamScanNProbes is changed from %d to %d",
6371 __func__, pMac->roam.configParam.nProbes, nProbes);
6372 pMac->roam.configParam.nProbes = nProbes;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306373
6374 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6375 csr_roam_offload_scan(pMac, sessionId,
6376 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6377 REASON_NPROBES_CHANGED);
6378 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006379 sme_release_global_lock(&pMac->sme);
6380 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 return status;
6382}
6383
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306384/*
6385 * sme_update_roam_scan_home_away_time() -
6386 * Function to update roam scan Home away time
6387 * This function is called through dynamic setConfig callback function
6388 * to update roam scan home away time
6389 *
6390 * hHal - HAL handle for device
6391 * sessionId - Session Identifier
6392 * nRoamScanAwayTime Scan home away time
6393 * bSendOffloadCmd If true then send offload command to firmware
6394 * If false then command is not sent to firmware
6395 * Return Success or failure
6396 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306397QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306399 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 const bool bSendOffloadCmd)
6401{
6402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306403 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306405 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006406 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6407 NO_SESSION, 0));
6408 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306409 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306410 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006411 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6412 __func__,
6413 pMac->roam.configParam.nRoamScanHomeAwayTime,
6414 nRoamScanHomeAwayTime);
6415 pMac->roam.configParam.nRoamScanHomeAwayTime =
6416 nRoamScanHomeAwayTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306417
6418 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6419 bSendOffloadCmd) {
6420 csr_roam_offload_scan(pMac, sessionId,
6421 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6422 REASON_HOME_AWAY_TIME_CHANGED);
6423 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 sme_release_global_lock(&pMac->sme);
6425 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 return status;
6427}
6428
Abhishek Singh518323d2015-10-19 17:42:01 +05306429/**
6430 * sme_ext_change_channel()- function to post send ECSA
6431 * action frame to csr.
6432 * @hHal: Hal context
6433 * @channel: new channel to switch
6434 * @session_id: senssion it should be sent on.
6435 *
6436 * This function is called to post ECSA frame to csr.
6437 *
6438 * Return: success if msg is sent else return failure
6439 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306440QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306441 uint8_t session_id)
6442{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306443 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306444 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6445 uint8_t channel_state;
6446
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006447 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306448 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006449 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306450
6451 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006452 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306453 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306454 }
6455
6456 status = sme_acquire_global_lock(&mac_ctx->sme);
6457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306458 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306459 /* update the channel list to the firmware */
6460 status = csr_send_ext_change_channel(mac_ctx,
6461 channel, session_id);
6462 sme_release_global_lock(&mac_ctx->sme);
6463 }
6464
6465 return status;
6466}
6467
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306468/*
6469 * sme_get_roam_intra_band() -
6470 * get Intra band roaming
6471 *
6472 * hHal - HAL handle for device
6473 * Return Success or failure
6474 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475bool sme_get_roam_intra_band(tHalHandle hHal)
6476{
6477 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306478
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306479 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6481 return pMac->roam.configParam.nRoamIntraBand;
6482}
6483
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306484/*
6485 * sme_get_roam_scan_n_probes() -
6486 * get N Probes
6487 *
6488 * hHal - HAL handle for device
6489 * Return Success or failure
6490 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6492{
6493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006495 return pMac->roam.configParam.nProbes;
6496}
6497
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306498/*
6499 * sme_get_roam_scan_home_away_time() -
6500 * get Roam scan home away time
6501 *
6502 * hHal - HAL handle for device
6503 * Return Success or failure
6504 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6506{
6507 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6510}
6511
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306512/*
6513 * sme_update_roam_rssi_diff() -
6514 * Update RoamRssiDiff
6515 * This function is called through dynamic setConfig callback function
6516 * to configure RoamRssiDiff
6517 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6518 *
6519 * hHal - HAL handle for device
6520 * sessionId - Session Identifier
6521 * RoamRssiDiff - minimum rssi difference between potential
6522 * candidate and current AP.
6523 * Return Success or failure
6524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006525
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306526QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 uint8_t RoamRssiDiff)
6528{
6529 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306530 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006532 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6533 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6534 FL("Invalid sme session id: %d"), sessionId);
6535 return QDF_STATUS_E_INVAL;
6536 }
6537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306539 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6542 RoamRssiDiff,
6543 pMac->roam.configParam.RoamRssiDiff,
6544 mac_trace_get_neighbour_roam_state(pMac->roam.
6545 neighborRoamInfo
6546 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306547 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006548 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306549
6550 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
6551 csr_roam_offload_scan(pMac, sessionId,
6552 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6553 REASON_RSSI_DIFF_CHANGED);
6554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 sme_release_global_lock(&pMac->sme);
6556 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006557 return status;
6558}
6559
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306560#ifdef WLAN_FEATURE_FILS_SK
6561QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006562 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306563{
6564 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6565 QDF_STATUS status = QDF_STATUS_SUCCESS;
6566 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6567 &mac->roam.neighborRoamInfo[session_id];
6568
6569 if (session_id >= CSR_ROAM_SESSION_MAX) {
6570 sme_err("Invalid sme session id: %d", session_id);
6571 return QDF_STATUS_E_INVAL;
6572 }
6573
6574 if (!src_profile) {
6575 sme_err("src roam profile NULL");
6576 return QDF_STATUS_E_INVAL;
6577 }
6578
6579 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6580 (neighbor_roam_info->neighborRoamState !=
6581 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6582 sme_info("Fast roam is disabled or not connected(%d)",
6583 neighbor_roam_info->neighborRoamState);
6584 return QDF_STATUS_E_PERM;
6585 }
6586
6587 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306588 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306589 status = sme_acquire_global_lock(&mac->sme);
6590 if (QDF_IS_STATUS_SUCCESS(status)) {
6591 sme_debug("Updating fils config to fw");
6592 csr_roam_offload_scan(mac, session_id,
6593 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6594 REASON_FILS_PARAMS_CHANGED);
6595 sme_release_global_lock(&mac->sme);
6596 } else {
6597 sme_err("Failed to acquire SME lock");
6598 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306599 } else {
6600 sme_info("LFR3 not enabled");
6601 return QDF_STATUS_E_INVAL;
6602 }
6603
6604 return status;
6605}
6606
6607void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006608 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306609{
6610 int i;
6611 struct scheduler_msg msg;
6612 QDF_STATUS status;
6613 struct hlp_params *params;
6614 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6615 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6616 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6617 &mac->roam.neighborRoamInfo[session_id];
6618
6619 if (!session) {
6620 sme_err("session NULL");
6621 return;
6622 }
6623
6624 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6625 (neighbor_roam_info->neighborRoamState !=
6626 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6627 sme_debug("Fast roam is disabled or not connected(%d)",
6628 neighbor_roam_info->neighborRoamState);
6629 return;
6630 }
6631
6632 params = qdf_mem_malloc(sizeof(*params));
6633 if (!params) {
6634 sme_err("Mem alloc for HLP IE fails");
6635 return;
6636 }
6637 if ((profile->hlp_ie_len +
6638 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6639 sme_err("HLP IE len exceeds %d",
6640 profile->hlp_ie_len);
6641 qdf_mem_free(params);
6642 return;
6643 }
6644
6645 params->vdev_id = session_id;
6646 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6647
6648 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6649 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6650
6651 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6652 profile->hlp_ie, profile->hlp_ie_len);
6653
6654 msg.type = SIR_HAL_HLP_IE_INFO;
6655 msg.reserved = 0;
6656 msg.bodyptr = params;
6657 status = sme_acquire_global_lock(&mac->sme);
6658 if (status != QDF_STATUS_SUCCESS) {
6659 sme_err("sme lock acquire fails");
6660 qdf_mem_free(params);
6661 return;
6662 }
6663
6664 if (!QDF_IS_STATUS_SUCCESS
6665 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6666 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6667 sme_release_global_lock(&mac->sme);
6668 qdf_mem_free(params);
6669 return;
6670 }
6671
6672 sme_release_global_lock(&mac->sme);
6673}
6674
Jeff Johnson172237b2017-11-07 15:32:59 -08006675void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306676{
6677 struct fils_join_rsp_params *roam_fils_params;
6678
6679 if (!roam_info) {
6680 sme_err("FILS Roam Info NULL");
6681 return;
6682 }
6683
6684 roam_fils_params = roam_info->fils_join_rsp;
6685 if (!roam_fils_params) {
6686 sme_err("FILS Roam Param NULL");
6687 return;
6688 }
6689
6690 if (roam_fils_params->fils_pmk)
6691 qdf_mem_free(roam_fils_params->fils_pmk);
6692
6693 qdf_mem_free(roam_fils_params);
6694
6695 roam_info->fils_join_rsp = NULL;
6696}
6697
6698#else
6699inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006700 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306701{}
6702#endif
6703
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306704/*
6705 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6706 * support at runtime
6707 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6708 * isFastTransitionEnabled.
6709 * This is a synchronous call
6710 *
6711 * hHal - The handle returned by mac_open.
6712 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
6713 * successfully.
6714 * Other status means SME is failed to update isFastTransitionEnabled.
6715 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306716QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717 bool isFastTransitionEnabled)
6718{
6719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306720 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306722 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
6724 0));
6725 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306726 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 "%s: FastTransitionEnabled is changed from %d to %d",
6729 __func__,
6730 pMac->roam.configParam.isFastTransitionEnabled,
6731 isFastTransitionEnabled);
6732 pMac->roam.configParam.isFastTransitionEnabled =
6733 isFastTransitionEnabled;
6734 sme_release_global_lock(&pMac->sme);
6735 }
6736
6737 return status;
6738}
6739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306740/*
6741 * sme_update_wes_mode() -
6742 * Update WES Mode
6743 * This function is called through dynamic setConfig callback function
6744 * to configure isWESModeEnabled
6745 *
6746 * hHal - HAL handle for device
6747 * isWESModeEnabled - WES mode
6748 * sessionId - Session Identifier
6749 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
6750 * Other status means SME is failed to update isWESModeEnabled.
6751 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306753QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006754 uint8_t sessionId)
6755{
6756 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306757 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006759 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6761 FL("Invalid sme session id: %d"), sessionId);
6762 return QDF_STATUS_E_INVAL;
6763 }
6764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006765 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306766 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306767 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
6769 isWESModeEnabled,
6770 pMac->roam.configParam.isWESModeEnabled,
6771 mac_trace_get_neighbour_roam_state(pMac->roam.
6772 neighborRoamInfo
6773 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306774 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006775 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
6776 sme_release_global_lock(&pMac->sme);
6777 }
6778
6779 return status;
6780}
6781
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306782/*
6783 * sme_set_roam_scan_control() -
6784 * Set roam scan control
6785 * This function is called to set roam scan control
6786 * if roam scan control is set to 0, roaming scan cache is cleared
6787 * any value other than 0 is treated as invalid value
6788 * hHal - HAL handle for device
6789 * sessionId - Session Identifier
6790 * Return QDF_STATUS_SUCCESS - SME update config successfully.
6791 * Other status means SME failure to update
6792 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306793QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 bool roamScanControl)
6795{
6796 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306797 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006798
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306799 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006801
6802 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6804 FL("Invalid sme session id: %d"), sessionId);
6805 return QDF_STATUS_E_INVAL;
6806 }
6807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006808 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306809 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006811 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
6812 roamScanControl,
6813 pMac->roam.configParam.nRoamScanControl,
6814 mac_trace_get_neighbour_roam_state(pMac->roam.
6815 neighborRoamInfo
6816 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306817 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818 pMac->roam.configParam.nRoamScanControl = roamScanControl;
6819 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306820 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006821 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306822 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
6823 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006824 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6825 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306826 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6827 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006828 }
6829 }
6830 sme_release_global_lock(&pMac->sme);
6831 }
6832 return status;
6833}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006834
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306835/*
6836 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
6837 * support at runtime
6838 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6839 * isFastRoamIniFeatureEnabled.
6840 * This is a synchronous call
6841 *
6842 * hHal - The handle returned by mac_open.
6843 * sessionId - Session Identifier
6844 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
6845 * successfully.
6846 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6847 */
6848QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
6849 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
6850{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6852
6853 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
6854 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306855 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
6857 __func__,
6858 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6859 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306860 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006861 }
6862
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006864 "%s: FastRoamEnabled is changed from %d to %d", __func__,
6865 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6866 isFastRoamIniFeatureEnabled);
6867 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
6868 isFastRoamIniFeatureEnabled;
6869 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306870 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306872 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006873}
6874
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306875/**
6876 * sme_config_fast_roaming() - enable/disable LFR support at runtime
6877 * @hal - The handle returned by macOpen.
6878 * @session_id - Session Identifier
6879 * @is_fast_roam_enabled - flag to enable/disable roaming
6880 *
6881 * When Supplicant issues enabled/disable fast roaming on the basis
6882 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
6883 *
6884 * Return: QDF_STATUS
6885 */
6886
6887QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
6888 const bool is_fast_roam_enabled)
6889{
6890 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306891 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306892 QDF_STATUS status;
6893
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006894 /*
6895 * supplicant_disabled_roaming flag is set to true in
6896 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
6897 * request with BSSID. This flag is reset when supplicant sends
6898 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006899 *
6900 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006901 * if roaming is disabled using driver command or INI and
6902 * supplicant_disabled_roaming flag remains set. So make sure to set
6903 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
6904 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006905 */
6906 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006907 session->pCurRoamProfile->supplicant_disabled_roaming =
6908 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08006909
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306910 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006911 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306912 if (!is_fast_roam_enabled)
6913 return QDF_STATUS_SUCCESS;
6914 return QDF_STATUS_E_FAILURE;
6915 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05306916
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306917 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
6918 session_id, is_fast_roam_enabled);
6919 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006920 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306921 return QDF_STATUS_E_FAILURE;
6922 }
6923
6924 return QDF_STATUS_SUCCESS;
6925}
6926
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306927/*
6928 * sme_update_is_mawc_ini_feature_enabled() -
6929 * Enable/disable LFR MAWC support at runtime
6930 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6931 * isMAWCIniFeatureEnabled.
6932 * This is a synchronous call
6933 *
6934 * hHal - The handle returned by mac_open.
6935 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
6936 * Other status means SME is failed to update MAWCEnabled.
6937 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306938QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006939 const bool MAWCEnabled)
6940{
6941 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306942 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943
6944 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306945 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006947 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07006948 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
6949 MAWCEnabled);
6950 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
6951 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006952 sme_release_global_lock(&pMac->sme);
6953 }
6954
6955 return status;
6956
6957}
6958
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006959/**
6960 * sme_stop_roaming() - Stop roaming for a given sessionId
6961 * This is a synchronous call
6962 *
6963 * @hHal - The handle returned by mac_open
6964 * @sessionId - Session Identifier
6965 *
6966 * Return QDF_STATUS_SUCCESS on success
6967 * Other status on failure
6968 */
6969QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006971 struct scheduler_msg wma_msg = {0};
6972 tSirRetStatus status;
6973 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006974 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6975 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006976 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006977
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006978 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006979 sme_err("incorrect session/vdev ID");
6980 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006982
6983 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306984
6985 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
6986 if (!roam_info->b_roam_scan_offload_started) {
6987 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006988 return QDF_STATUS_SUCCESS;
6989 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006990 req = qdf_mem_malloc(sizeof(*req));
6991 if (!req) {
6992 sme_err("failed to allocated memory");
6993 return QDF_STATUS_E_NOMEM;
6994 }
6995
6996 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05306997 if (reason == eCsrForcedDisassoc)
6998 req->reason = REASON_ROAM_STOP_ALL;
6999 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08007000 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007001 req->sessionId = session_id;
7002 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007003 req->middle_of_roaming = 1;
7004 else
7005 csr_roam_reset_roam_params(mac_ctx);
7006
7007 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7008 wma_msg.bodyptr = req;
7009
7010 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7011 if (eSIR_SUCCESS != status) {
7012 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007013 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007014 qdf_mem_free(req);
7015 return QDF_STATUS_E_FAULT;
7016 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007017 roam_info->b_roam_scan_offload_started = false;
7018 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007019
7020 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007021}
7022
Abhishek Singhd5686472017-09-20 15:18:50 +05307023void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7024{
7025 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7026 QDF_STATUS status = QDF_STATUS_SUCCESS;
7027 struct csr_roam_session *session;
7028
7029 status = sme_acquire_global_lock(&mac_ctx->sme);
7030 if (QDF_IS_STATUS_SUCCESS(status)) {
7031 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7032 session = CSR_GET_SESSION(mac_ctx, session_id);
7033 if (session)
7034 session->discon_in_progress = true;
7035 }
7036 sme_release_global_lock(&mac_ctx->sme);
7037 }
7038}
7039
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307040/*
7041 * sme_start_roaming() - Start roaming for a given sessionId
7042 * This is a synchronous call
7043 *
7044 * hHal - The handle returned by mac_open
7045 * sessionId - Session Identifier
7046 * Return QDF_STATUS_SUCCESS on success
7047 * Other status on failure
7048 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307049QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007050{
7051 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307052 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053
7054 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307055 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7057 reason);
7058 sme_release_global_lock(&pMac->sme);
7059 }
7060
7061 return status;
7062}
7063
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307064/*
7065 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7066 * Concurrent session exists
7067 * This is a synchronuous call
7068 *
7069 * hHal - The handle returned by mac_open.
7070 * Return QDF_STATUS_SUCCESS
7071 * Other status means SME is failed
7072 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307073QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307075 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007076{
7077
7078 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307079 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080
7081 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307082 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7084 bFastRoamInConIniFeatureEnabled;
7085 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7086 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7087 0;
7088 }
7089 sme_release_global_lock(&pMac->sme);
7090 }
7091
7092 return status;
7093}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307095/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307096 * sme_set_roam_opportunistic_scan_threshold_diff() -
7097 * Update Opportunistic Scan threshold diff
7098 * This function is called through dynamic setConfig callback function
7099 * to configure nOpportunisticThresholdDiff
7100 *
7101 * hHal - HAL handle for device
7102 * sessionId - Session Identifier
7103 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7104 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7105 * successfully.
7106 * else SME is failed to update nOpportunisticThresholdDiff.
7107 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307108QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 uint8_t sessionId,
7110 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307111 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007112{
7113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307114 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115
7116 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307117 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007118 status = csr_neighbor_roam_update_config(pMac, sessionId,
7119 nOpportunisticThresholdDiff,
7120 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307121 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122 pMac->roam.configParam.neighborRoamConfig.
7123 nOpportunisticThresholdDiff =
7124 nOpportunisticThresholdDiff;
7125 }
7126 sme_release_global_lock(&pMac->sme);
7127 }
7128 return status;
7129}
7130
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307131/*
7132 * sme_get_roam_opportunistic_scan_threshold_diff()
7133 * gets Opportunistic Scan threshold diff
7134 * This is a synchronous call
7135 *
7136 * hHal - The handle returned by mac_open
7137 * Return uint8_t - nOpportunisticThresholdDiff
7138 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7140{
7141 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007143 return pMac->roam.configParam.neighborRoamConfig.
7144 nOpportunisticThresholdDiff;
7145}
7146
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307147/*
7148 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7149 * This function is called through dynamic setConfig callback function
7150 * to configure nRoamRescanRssiDiff
7151 *
7152 * hHal - HAL handle for device
7153 * sessionId - Session Identifier
7154 * nRoamRescanRssiDiff - roam rescan rssi diff
7155 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7156 * successfully.
7157 * else SME is failed to update nRoamRescanRssiDiff.
7158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307159QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 uint8_t sessionId,
7161 const uint8_t nRoamRescanRssiDiff)
7162{
7163 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307164 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007165
7166 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307167 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007168 status = csr_neighbor_roam_update_config(pMac, sessionId,
7169 nRoamRescanRssiDiff,
7170 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307171 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 pMac->roam.configParam.neighborRoamConfig.
7173 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7174 }
7175 sme_release_global_lock(&pMac->sme);
7176 }
7177 return status;
7178}
7179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307180/*
7181 * sme_get_roam_rescan_rssi_diff()
7182 * gets roam rescan rssi diff
7183 * This is a synchronous call
7184 *
7185 * hHal - The handle returned by mac_open
7186 * Return int8_t - nRoamRescanRssiDiff
7187 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7189{
7190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007192 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7193}
7194
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307195/*
7196 * sme_set_roam_bmiss_first_bcnt() -
7197 * Update Roam count for first beacon miss
7198 * This function is called through dynamic setConfig callback function
7199 * to configure nRoamBmissFirstBcnt
7200 * hHal - HAL handle for device
7201 * sessionId - Session Identifier
7202 * nRoamBmissFirstBcnt - Roam first bmiss count
7203 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7204 * successfully.
7205 * else SME is failed to update nRoamBmissFirstBcnt
7206 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307207QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 uint8_t sessionId,
7209 const uint8_t nRoamBmissFirstBcnt)
7210{
7211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307212 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007213
7214 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307215 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007216 status = csr_neighbor_roam_update_config(pMac, sessionId,
7217 nRoamBmissFirstBcnt,
7218 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307219 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 pMac->roam.configParam.neighborRoamConfig.
7221 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7222 }
7223 sme_release_global_lock(&pMac->sme);
7224 }
7225 return status;
7226}
7227
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307228/*
7229 * sme_get_roam_bmiss_first_bcnt() -
7230 * get neighbor roam beacon miss first count
7231 *
7232 * hHal - The handle returned by mac_open.
7233 * Return uint8_t - neighbor roam beacon miss first count
7234 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007235uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7236{
7237 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007239 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7240}
7241
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307242/*
7243 * sme_set_roam_bmiss_final_bcnt() -
7244 * Update Roam count for final beacon miss
7245 * This function is called through dynamic setConfig callback function
7246 * to configure nRoamBmissFinalBcnt
7247 * hHal - HAL handle for device
7248 * sessionId - Session Identifier
7249 * nRoamBmissFinalBcnt - Roam final bmiss count
7250 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7251 * successfully.
7252 * else SME is failed to update nRoamBmissFinalBcnt
7253 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307254QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007255 uint8_t sessionId,
7256 const uint8_t nRoamBmissFinalBcnt)
7257{
7258 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307259 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260
7261 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307262 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007263 status = csr_neighbor_roam_update_config(pMac, sessionId,
7264 nRoamBmissFinalBcnt,
7265 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307266 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007267 pMac->roam.configParam.neighborRoamConfig.
7268 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7269 }
7270 sme_release_global_lock(&pMac->sme);
7271 }
7272 return status;
7273}
7274
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307275/*
7276 * sme_get_roam_bmiss_final_bcnt() -
7277 * gets Roam count for final beacon miss
7278 * This is a synchronous call
7279 *
7280 * hHal - The handle returned by mac_open
7281 * Return uint8_t - nRoamBmissFinalBcnt
7282 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007283uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7284{
7285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7288}
7289
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307290/*
7291 * sme_set_roam_beacon_rssi_weight() -
7292 * Update Roam beacon rssi weight
7293 * This function is called through dynamic setConfig callback function
7294 * to configure nRoamBeaconRssiWeight
7295 *
7296 * hHal - HAL handle for device
7297 * sessionId - Session Identifier
7298 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7299 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7300 * successfully.
7301 * else SME is failed to update nRoamBeaconRssiWeight
7302 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307303QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007304 uint8_t sessionId,
7305 const uint8_t nRoamBeaconRssiWeight)
7306{
7307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307308 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007309
7310 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307311 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007312 status = csr_neighbor_roam_update_config(pMac, sessionId,
7313 nRoamBeaconRssiWeight,
7314 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307315 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 pMac->roam.configParam.neighborRoamConfig.
7317 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7318 }
7319 sme_release_global_lock(&pMac->sme);
7320 }
7321 return status;
7322}
7323
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307324/*
7325 * sme_get_roam_beacon_rssi_weight() -
7326 * gets Roam beacon rssi weight
7327 * This is a synchronous call
7328 *
7329 * hHal - The handle returned by mac_open
7330 * Return uint8_t - nRoamBeaconRssiWeight
7331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7333{
7334 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007336 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7337}
7338
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307339/*
7340 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7341 * rssi threshold
7342 * This is a synchronous call
7343 *
7344 * hHal - The handle returned by mac_open.
7345 * sessionId - Session Identifier
7346 * Return QDF_STATUS_SUCCESS - SME update config successful.
7347 * Other status means SME is failed to update
7348 */
7349QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7350 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7351{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007352 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307353 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007354
7355 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307356 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007357 status = csr_neighbor_roam_update_config(pMac,
7358 sessionId, neighborLookupRssiThreshold,
7359 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307360 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 pMac->roam.configParam.neighborRoamConfig.
7362 nNeighborLookupRssiThreshold =
7363 neighborLookupRssiThreshold;
7364 }
7365 sme_release_global_lock(&pMac->sme);
7366 }
7367 return status;
7368}
7369
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307370/*
7371 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7372 * This is a synchronous call
7373 *
7374 * hal - The handle returned by macOpen.
7375 * session_id - Session Identifier
7376 * delay_before_vdev_stop - value to be set
7377 * Return QDF_STATUS_SUCCESS - SME update config successful.
7378 * Other status means SME is failed to update
7379 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307380QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 uint8_t session_id,
7382 uint8_t delay_before_vdev_stop)
7383{
7384 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307385 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007386
7387 if (session_id >= CSR_ROAM_SESSION_MAX) {
7388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7389 FL("Invalid sme session id: %d"), session_id);
7390 return QDF_STATUS_E_INVAL;
7391 }
7392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007393 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307394 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307395 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7396 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007397 pMac->roam.configParam.neighborRoamConfig.
7398 delay_before_vdev_stop,
7399 delay_before_vdev_stop);
7400 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7401 delay_before_vdev_stop = delay_before_vdev_stop;
7402 pMac->roam.configParam.neighborRoamConfig.
7403 delay_before_vdev_stop = delay_before_vdev_stop;
7404 sme_release_global_lock(&pMac->sme);
7405 }
7406 return status;
7407}
7408
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307409/*
7410 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7411 * rssi threshold
7412 * This is a synchronous call
7413 *
7414 * hHal - The handle returned by mac_open.
7415 * Return QDF_STATUS_SUCCESS - SME update config successful.
7416 * Other status means SME is failed to update
7417 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7419{
7420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 return pMac->roam.configParam.neighborRoamConfig.
7423 nNeighborLookupRssiThreshold;
7424}
7425
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307426/*
7427 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7428 * refresh period
7429 * This is a synchronous call
7430 *
7431 * hHal - The handle returned by mac_open.
7432 * sessionId - Session Identifier
7433 * Return QDF_STATUS_SUCCESS - SME update config successful.
7434 * Other status means SME is failed to update
7435 */
7436QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7437 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7438{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307440 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307441 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7443
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007444 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7446 FL("Invalid sme session id: %d"), sessionId);
7447 return QDF_STATUS_E_INVAL;
7448 }
7449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307451 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007452 pNeighborRoamConfig =
7453 &pMac->roam.configParam.neighborRoamConfig;
7454 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307455 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7457 neighborScanResultsRefreshPeriod,
7458 pMac->roam.configParam.neighborRoamConfig.
7459 nNeighborResultsRefreshPeriod,
7460 mac_trace_get_neighbour_roam_state(pMac->roam.
7461 neighborRoamInfo
7462 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307463 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7465 neighborScanResultsRefreshPeriod;
7466 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7467 neighborScanResultsRefreshPeriod;
7468
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307469 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7470 csr_roam_offload_scan(pMac, sessionId,
7471 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7472 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
7473 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 sme_release_global_lock(&pMac->sme);
7475 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007477 return status;
7478}
7479
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307480/*
7481 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7482 * offload feaure
7483 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7484 * gRoamScanOffloadEnabled.
7485 * This is a synchronous call
7486 *
7487 * hHal - The handle returned by mac_open.
7488 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7489 * Other status means SME is failed to update.
7490 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307491QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007492 bool nRoamScanOffloadEnabled)
7493{
7494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307495 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496
7497 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307498 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307500 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501 pMac->roam.configParam.isRoamOffloadScanEnabled,
7502 nRoamScanOffloadEnabled);
7503 pMac->roam.configParam.isRoamOffloadScanEnabled =
7504 nRoamScanOffloadEnabled;
7505 sme_release_global_lock(&pMac->sme);
7506 }
7507
7508 return status;
7509}
7510
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307511/*
7512 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7513 * refresh period
7514 * This is a synchronous call
7515 *
7516 * \param hHal - The handle returned by mac_open.
7517 * \return uint16_t - Neighbor scan results refresh period value
7518 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007519uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7520{
7521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523 return pMac->roam.configParam.neighborRoamConfig.
7524 nNeighborResultsRefreshPeriod;
7525}
7526
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307527/*
7528 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7529 * This is a synchronuous call
7530 *
7531 * hHal - The handle returned by mac_open.
7532 * Return QDF_STATUS_SUCCESS - SME update config successful.
7533 * Other status means SME is failed to update
7534 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7536{
7537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539 return pMac->roam.configParam.neighborRoamConfig.
7540 nEmptyScanRefreshPeriod;
7541}
7542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307543/*
7544 * sme_update_empty_scan_refresh_period
7545 * Update nEmptyScanRefreshPeriod
7546 * This function is called through dynamic setConfig callback function
7547 * to configure nEmptyScanRefreshPeriod
7548 * Usage: adb shell iwpriv wlan0 setConfig
7549 * nEmptyScanRefreshPeriod=[0 .. 60]
7550 *
7551 * hHal - HAL handle for device
7552 * sessionId - Session Identifier
7553 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7554 * Return Success or failure
7555 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007556
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307557QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7558 sessionId, uint16_t
7559 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007560{
7561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307562 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307563 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7565
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007566 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7568 FL("Invalid sme session id: %d"), sessionId);
7569 return QDF_STATUS_E_INVAL;
7570 }
7571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007572 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307573 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 pNeighborRoamConfig =
7575 &pMac->roam.configParam.neighborRoamConfig;
7576 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307577 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7579 nEmptyScanRefreshPeriod,
7580 pMac->roam.configParam.neighborRoamConfig.
7581 nEmptyScanRefreshPeriod,
7582 mac_trace_get_neighbour_roam_state(pMac->roam.
7583 neighborRoamInfo
7584 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307585 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007586 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7587 nEmptyScanRefreshPeriod;
7588 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7589 nEmptyScanRefreshPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307590
7591 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7592 csr_roam_offload_scan(pMac, sessionId,
7593 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7594 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007596 sme_release_global_lock(&pMac->sme);
7597 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599 return status;
7600}
7601
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307602/*
7603 * sme_set_neighbor_scan_min_chan_time() -
7604 * Update nNeighborScanMinChanTime
7605 * This function is called through dynamic setConfig callback function
7606 * to configure gNeighborScanChannelMinTime
7607 * Usage: adb shell iwpriv wlan0 setConfig
7608 * gNeighborScanChannelMinTime=[0 .. 60]
7609 *
7610 * hHal - HAL handle for device
7611 * nNeighborScanMinChanTime - Channel minimum dwell time
7612 * sessionId - Session Identifier
7613 * Return Success or failure
7614 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307615QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616 const uint16_t
7617 nNeighborScanMinChanTime,
7618 uint8_t sessionId)
7619{
7620 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307621 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007623 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7624 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7625 FL("Invalid sme session id: %d"), sessionId);
7626 return QDF_STATUS_E_INVAL;
7627 }
7628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007629 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307630 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307631 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007632 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7633 nNeighborScanMinChanTime,
7634 pMac->roam.configParam.neighborRoamConfig.
7635 nNeighborScanMinChanTime,
7636 mac_trace_get_neighbour_roam_state(pMac->roam.
7637 neighborRoamInfo
7638 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307639 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007640
7641 pMac->roam.configParam.neighborRoamConfig.
7642 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7643 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7644 minChannelScanTime = nNeighborScanMinChanTime;
7645 sme_release_global_lock(&pMac->sme);
7646 }
7647
7648 return status;
7649}
7650
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307651/*
7652 * sme_set_neighbor_scan_max_chan_time() -
7653 * Update nNeighborScanMaxChanTime
7654 * This function is called through dynamic setConfig callback function
7655 * to configure gNeighborScanChannelMaxTime
7656 * Usage: adb shell iwpriv wlan0 setConfig
7657 * gNeighborScanChannelMaxTime=[0 .. 60]
7658 *
7659 * hHal - HAL handle for device
7660 * sessionId - Session Identifier
7661 * nNeighborScanMinChanTime - Channel maximum dwell time
7662 * Return Success or failure
7663 */
7664QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7665 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007666 const uint16_t
7667 nNeighborScanMaxChanTime)
7668{
7669 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307670 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307671 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007672 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7673
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007674 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7676 FL("Invalid sme session id: %d"), sessionId);
7677 return QDF_STATUS_E_INVAL;
7678 }
7679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307681 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682 pNeighborRoamConfig =
7683 &pMac->roam.configParam.neighborRoamConfig;
7684 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307685 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
7687 nNeighborScanMaxChanTime,
7688 pMac->roam.configParam.neighborRoamConfig.
7689 nNeighborScanMaxChanTime,
7690 mac_trace_get_neighbour_roam_state(pMac->roam.
7691 neighborRoamInfo
7692 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307693 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 pNeighborRoamConfig->nNeighborScanMaxChanTime =
7695 nNeighborScanMaxChanTime;
7696 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
7697 nNeighborScanMaxChanTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307698 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7699 csr_roam_offload_scan(pMac, sessionId,
7700 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7701 REASON_SCAN_CH_TIME_CHANGED);
7702 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703 sme_release_global_lock(&pMac->sme);
7704 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007706
7707 return status;
7708}
7709
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307710/*
7711 * sme_get_neighbor_scan_min_chan_time() -
7712 * get neighbor scan min channel time
7713 *
7714 * hHal - The handle returned by mac_open.
7715 * sessionId - Session Identifier
7716 * Return uint16_t - channel min time value
7717 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
7719{
7720 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007721
7722 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7723 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7724 FL("Invalid sme session id: %d"), sessionId);
7725 return 0;
7726 }
7727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7729 minChannelScanTime;
7730}
7731
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307732/*
7733 * sme_get_neighbor_roam_state() -
7734 * get neighbor roam state
7735 *
7736 * hHal - The handle returned by mac_open.
7737 * sessionId - Session Identifier
7738 * Return uint32_t - neighbor roam state
7739 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007740uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
7741{
7742 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007743
7744 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7746 FL("Invalid sme session id: %d"), sessionId);
7747 return 0;
7748 }
7749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
7751}
7752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307753/*
7754 * sme_get_current_roam_state() -
7755 * get current roam state
7756 *
7757 * hHal - The handle returned by mac_open.
7758 * sessionId - Session Identifier
7759 * Return uint32_t - current roam state
7760 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
7762{
7763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765 return pMac->roam.curState[sessionId];
7766}
7767
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307768/*
7769 * sme_get_current_roam_sub_state() -
7770 * \brief get neighbor roam sub state
7771 *
7772 * hHal - The handle returned by mac_open.
7773 * sessionId - Session Identifier
7774 * Return uint32_t - current roam sub state
7775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
7777{
7778 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780 return pMac->roam.curSubState[sessionId];
7781}
7782
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307783/*
7784 * sme_get_lim_sme_state() -
7785 * get Lim Sme state
7786 *
7787 * hHal - The handle returned by mac_open.
7788 * Return uint32_t - Lim Sme state
7789 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790uint32_t sme_get_lim_sme_state(tHalHandle hHal)
7791{
7792 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794 return pMac->lim.gLimSmeState;
7795}
7796
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307797/*
7798 * sme_get_lim_mlm_state() -
7799 * get Lim Mlm state
7800 *
7801 * hHal - The handle returned by mac_open.
7802 * Return uint32_t - Lim Mlm state
7803 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
7805{
7806 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808 return pMac->lim.gLimMlmState;
7809}
7810
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307811/*
7812 * sme_is_lim_session_valid() -
7813 * is Lim session valid
7814 *
7815 * hHal - The handle returned by mac_open.
7816 * sessionId - Session Identifier
7817 * Return bool - true or false
7818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
7820{
7821 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05307822
7823 if (sessionId > pMac->lim.maxBssId)
7824 return false;
7825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826 return pMac->lim.gpSession[sessionId].valid;
7827}
7828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307829/*
7830 * sme_get_lim_sme_session_state() -
7831 * get Lim Sme session state
7832 *
7833 * hHal - The handle returned by mac_open.
7834 * sessionId - Session Identifier
7835 * Return uint32_t - Lim Sme session state
7836 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
7838{
7839 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 return pMac->lim.gpSession[sessionId].limSmeState;
7842}
7843
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307844/*
7845 * sme_get_lim_mlm_session_state() -
7846 * \brief get Lim Mlm session state
7847 *
7848 * hHal - The handle returned by mac_open.
7849 * sessionId - Session Identifier
7850 * Return uint32_t - Lim Mlm session state
7851 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
7853{
7854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007856 return pMac->lim.gpSession[sessionId].limMlmState;
7857}
7858
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307859/*
7860 * sme_get_neighbor_scan_max_chan_time() -
7861 * get neighbor scan max channel time
7862 *
7863 * hHal - The handle returned by mac_open.
7864 * sessionId - Session Identifier
7865 * Return uint16_t - channel max time value
7866 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
7868{
7869 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007870
7871 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7873 FL("Invalid sme session id: %d"), sessionId);
7874 return 0;
7875 }
7876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007877 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7878 maxChannelScanTime;
7879}
7880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307881/*
7882 * sme_set_neighbor_scan_period() -
7883 * Update nNeighborScanPeriod
7884 * This function is called through dynamic setConfig callback function
7885 * to configure nNeighborScanPeriod
7886 * Usage: adb shell iwpriv wlan0 setConfig
7887 * nNeighborScanPeriod=[0 .. 1000]
7888 *
7889 * hHal - HAL handle for device
7890 * sessionId - Session Identifier
7891 * nNeighborScanPeriod - neighbor scan period
7892 * Return Success or failure
7893 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307894QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007895 const uint16_t nNeighborScanPeriod)
7896{
7897 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307898 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307899 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007900 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7901
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007902 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7903 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7904 FL("Invalid sme session id: %d"), sessionId);
7905 return QDF_STATUS_E_INVAL;
7906 }
7907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007908 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307909 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 pNeighborRoamConfig =
7911 &pMac->roam.configParam.neighborRoamConfig;
7912 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307913 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307914 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007915 nNeighborScanPeriod,
7916 pMac->roam.configParam.neighborRoamConfig.
7917 nNeighborScanTimerPeriod,
7918 mac_trace_get_neighbour_roam_state(pMac->roam.
7919 neighborRoamInfo
7920 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307921 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007922 pNeighborRoamConfig->nNeighborScanTimerPeriod =
7923 nNeighborScanPeriod;
7924 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
7925 nNeighborScanPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307926
7927 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7928 csr_roam_offload_scan(pMac, sessionId,
7929 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7930 REASON_SCAN_HOME_TIME_CHANGED);
7931 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007932 sme_release_global_lock(&pMac->sme);
7933 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007934
7935 return status;
7936}
7937
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307938/*
7939 * sme_get_neighbor_scan_period() -
7940 * get neighbor scan period
7941 *
7942 * hHal - The handle returned by mac_open.
7943 * sessionId - Session Identifier
7944 * Return uint16_t - neighbor scan period
7945 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
7947{
7948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007949
7950 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7952 FL("Invalid sme session id: %d"), sessionId);
7953 return 0;
7954 }
7955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7957 neighborScanPeriod;
7958}
7959
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307960/**
7961 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
7962 * This function is called through dynamic setConfig callback function
7963 * to configure neighbor_scan_min_period
7964 *
7965 * @hal - HAL handle for device
7966 * @session_id - Session Identifier
7967 * @neighbor_scan_min_period - neighbor scan min period
7968 *
7969 * Return - QDF_STATUS
7970 */
7971QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
7972 uint8_t session_id,
7973 const uint16_t
7974 neighbor_scan_min_period)
7975{
7976 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
7977 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307978 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307979 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307981 if (session_id >= CSR_ROAM_SESSION_MAX) {
7982 sme_err("Invalid sme session id: %d", session_id);
7983 return QDF_STATUS_E_INVAL;
7984 }
7985
7986 status = sme_acquire_global_lock(&pmac->sme);
7987 if (QDF_IS_STATUS_SUCCESS(status)) {
7988 p_neighbor_roam_config =
7989 &pmac->roam.configParam.neighborRoamConfig;
7990 p_neighbor_roam_info = &pmac->
7991 roam.neighborRoamInfo[session_id];
7992 sme_debug("LFR:set neighbor scan min period, old:%d, "
7993 "new: %d, state: %s",
7994 pmac->roam.configParam.neighborRoamConfig.
7995 neighbor_scan_min_timer_period,
7996 neighbor_scan_min_period,
7997 mac_trace_get_neighbour_roam_state(pmac->roam.
7998 neighborRoamInfo[session_id].
7999 neighborRoamState));
8000 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8001 neighbor_scan_min_period;
8002 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8003 neighbor_scan_min_period;
8004 sme_release_global_lock(&pmac->sme);
8005 }
8006
8007 return status;
8008}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008009
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308010/*
8011 * sme_get_roam_rssi_diff() - get Roam rssi diff
8012 * This is a synchronous call
8013 *
8014 * hHal - The handle returned by mac_open.
8015 * Return uint16_t - Rssi diff value
8016 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8018{
8019 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008021 return pMac->roam.configParam.RoamRssiDiff;
8022}
8023
8024/**
8025 * sme_change_roam_scan_channel_list() - to change scan channel list
8026 * @hHal: pointer HAL handle returned by mac_open
8027 * @sessionId: sme session id
8028 * @pChannelList: Output channel list
8029 * @numChannels: Output number of channels
8030 *
8031 * This routine is called to Change roam scan channel list.
8032 * This is a synchronous call
8033 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308034 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308036QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 uint8_t *pChannelList,
8038 uint8_t numChannels)
8039{
8040 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308041 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008043 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8044 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8045 uint8_t i = 0, j = 0;
8046 tCsrChannelInfo *chan_info;
8047
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008048 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8050 FL("Invalid sme session id: %d"), sessionId);
8051 return QDF_STATUS_E_INVAL;
8052 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008053
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008054 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308056 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308057 sme_err("Failed to acquire SME lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008058 return status;
8059 }
8060 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8061
8062 if (NULL != chan_info->ChannelList) {
8063 for (i = 0; i < chan_info->numOfChannels; i++) {
8064 if (j < sizeof(oldChannelList))
8065 j += snprintf(oldChannelList + j,
8066 sizeof(oldChannelList) -
8067 j, "%d",
8068 chan_info->ChannelList[i]);
8069 else
8070 break;
8071 }
8072 }
8073 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8074 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8075 numChannels);
8076 sme_set_roam_scan_control(hHal, sessionId, 1);
8077 if (NULL != chan_info->ChannelList) {
8078 j = 0;
8079 for (i = 0; i < chan_info->numOfChannels; i++) {
8080 if (j < sizeof(newChannelList))
8081 j += snprintf(newChannelList + j,
8082 sizeof(newChannelList) -
8083 j, " %d",
8084 chan_info->ChannelList[i]);
8085 else
8086 break;
8087 }
8088 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308090 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308092 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008093
8094 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8095 csr_roam_offload_scan(pMac, sessionId,
8096 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8097 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308098
8099 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008100 return status;
8101}
8102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103/**
8104 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8105 * @hHal: HAL pointer
8106 * @pChannelList: Output channel list
8107 * @pNumChannels: Output number of channels
8108 * @sessionId: Session Identifier
8109 *
8110 * To get roam scan channel list This is a synchronous call
8111 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308112 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008113 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308114QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 uint8_t *pChannelList, uint8_t *pNumChannels,
8116 uint8_t sessionId)
8117{
8118 int i = 0;
8119 uint8_t *pOutPtr = pChannelList;
8120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008121 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308122 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008124 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8126 FL("Invalid sme session id: %d"), sessionId);
8127 return QDF_STATUS_E_INVAL;
8128 }
8129
8130 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308132 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008133 return status;
8134 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136 FL("Roam Scan channel list is NOT yet initialized"));
8137 *pNumChannels = 0;
8138 sme_release_global_lock(&pMac->sme);
8139 return status;
8140 }
8141
8142 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308143 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144 pOutPtr[i] =
8145 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 pOutPtr[i] = '\0';
8148 sme_release_global_lock(&pMac->sme);
8149 return status;
8150}
8151
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308152/*
8153 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8154 * This is a synchronuous call
8155 *
8156 * hHal - The handle returned by mac_open.
8157 * Return true (1) - if the ESE feature is enabled
8158 * false (0) - if feature is disabled (compile or runtime)
8159 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008160bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8161{
8162#ifdef FEATURE_WLAN_ESE
8163 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165 return csr_roam_is_ese_ini_feature_enabled(pMac);
8166#else
8167 return false;
8168#endif
8169}
8170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308171/*
8172 * sme_get_wes_mode() - get WES Mode
8173 * This is a synchronous call
8174 *
8175 * hHal - The handle returned by mac_open
8176 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8177 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178bool sme_get_wes_mode(tHalHandle hHal)
8179{
8180 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 return pMac->roam.configParam.isWESModeEnabled;
8183}
8184
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308185/*
8186 * sme_get_roam_scan_control() - get scan control
8187 * This is a synchronous call
8188 *
8189 * hHal - The handle returned by mac_open.
8190 * Return bool - Enabled(1)/Disabled(0)
8191 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192bool sme_get_roam_scan_control(tHalHandle hHal)
8193{
8194 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008196 return pMac->roam.configParam.nRoamScanControl;
8197}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308199/*
8200 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8201 * This is a synchronuous call
8202 * hHal - The handle returned by mac_open.
8203 * Return true (1) - if the feature is enabled
8204 * false (0) - if feature is disabled (compile or runtime)
8205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008206bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8207{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008210 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211}
8212
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308213/*
8214 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8215 * This is a synchronuous call
8216 *
8217 * hHal - The handle returned by mac_open.
8218 * Return true (1) - if the feature is enabled
8219 * false (0) - if feature is disabled (compile or runtime)
8220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8222{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308224
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008225 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008226}
8227
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008228/**
8229 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8230 * @feature: enum value of requested feature.
8231 *
8232 * Retrun: 1 if supported; 0 otherwise
8233 */
8234bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008236 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237}
8238
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308239QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008240 void *plsContext,
8241 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8242 void *pContext))
8243{
8244
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308245 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008246 tpAniSirGlobal pMac;
8247 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308248 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008249
Jeff Johnsona5317a62017-01-26 08:51:25 -08008250 if (!hHal || !pCallbackfn || !lsReq) {
8251 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8252 FL("Invalid parameter"));
8253 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008255
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308256 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8257 if (!wma_handle) {
8258 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8259 "wma handle is NULL");
8260 return QDF_STATUS_E_FAILURE;
8261 }
8262
Jeff Johnsona5317a62017-01-26 08:51:25 -08008263 pMac = PMAC_STRUCT(hHal);
8264 req = qdf_mem_malloc(sizeof(*req));
8265 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008266 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008267 return QDF_STATUS_E_NOMEM;
8268 }
8269 *req = *lsReq;
8270
8271 status = sme_acquire_global_lock(&pMac->sme);
8272 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008273 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008274 qdf_mem_free(req);
8275 return QDF_STATUS_E_FAILURE;
8276 }
8277
8278 pMac->sme.pLinkSpeedCbContext = plsContext;
8279 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308280 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008281 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008283 return status;
8284}
8285
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308286QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8287 struct sir_peer_info_req req)
8288{
8289 QDF_STATUS qdf_status;
8290 struct scheduler_msg message = {0};
8291
8292 qdf_status = sme_acquire_global_lock(&mac->sme);
8293 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8294 sme_debug("Failed to get Lock");
8295 return qdf_status;
8296 }
8297 /* serialize the req through MC thread */
8298 message.bodyptr = qdf_mem_malloc(sizeof(req));
8299 if (NULL == message.bodyptr) {
8300 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8301 "%s: Memory allocation failed.", __func__);
8302 sme_release_global_lock(&mac->sme);
8303 return QDF_STATUS_E_NOMEM;
8304 }
8305 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8306 message.type = WMA_GET_PEER_INFO;
8307 message.reserved = 0;
8308 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8309 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8310 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8311 "%s: Post get peer info msg fail", __func__);
8312 qdf_mem_free(message.bodyptr);
8313 qdf_status = QDF_STATUS_E_FAILURE;
8314 }
8315 sme_release_global_lock(&mac->sme);
8316 return qdf_status;
8317}
8318
Will Huang558f8082017-05-31 16:22:24 +08008319QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8320 void *context,
8321 void (*callbackfn)(struct sir_peer_info_resp *param,
8322 void *pcontext))
8323{
8324
8325 QDF_STATUS status;
8326 QDF_STATUS qdf_status;
8327 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008328 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008329
8330 status = sme_acquire_global_lock(&mac->sme);
8331 if (QDF_STATUS_SUCCESS == status) {
8332 if (NULL == callbackfn) {
8333 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8334 "%s: Indication Call back is NULL",
8335 __func__);
8336 sme_release_global_lock(&mac->sme);
8337 return QDF_STATUS_E_FAILURE;
8338 }
8339
8340 mac->sme.pget_peer_info_ind_cb = callbackfn;
8341 mac->sme.pget_peer_info_cb_context = context;
8342
8343 /* serialize the req through MC thread */
8344 message.bodyptr = qdf_mem_malloc(sizeof(req));
8345 if (NULL == message.bodyptr) {
8346 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8347 "%s: Memory allocation failed.", __func__);
8348 sme_release_global_lock(&mac->sme);
8349 return QDF_STATUS_E_NOMEM;
8350 }
8351 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8352 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308353 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008354 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8355 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8356 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8357 "%s: Post get peer info msg fail", __func__);
8358 qdf_mem_free(message.bodyptr);
8359 status = QDF_STATUS_E_FAILURE;
8360 }
8361 sme_release_global_lock(&mac->sme);
8362 }
8363 return status;
8364}
8365
8366QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8367 struct sir_peer_info_ext_req *req,
8368 void *context,
8369 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8370 void *pcontext))
8371{
8372 QDF_STATUS status;
8373 QDF_STATUS qdf_status;
8374 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008375 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008376
8377 status = sme_acquire_global_lock(&mac->sme);
8378 if (QDF_STATUS_SUCCESS == status) {
8379 if (NULL == callbackfn) {
8380 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8381 "%s: Indication Call back is NULL",
8382 __func__);
8383 sme_release_global_lock(&mac->sme);
8384 return QDF_STATUS_E_FAILURE;
8385 }
8386
8387 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8388 mac->sme.pget_peer_info_ext_cb_context = context;
8389
8390 /* serialize the req through MC thread */
8391 message.bodyptr =
8392 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8393 if (NULL == message.bodyptr) {
8394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8395 "%s: Memory allocation failed.", __func__);
8396 sme_release_global_lock(&mac->sme);
8397 return QDF_STATUS_E_NOMEM;
8398 }
8399 qdf_mem_copy(message.bodyptr,
8400 req,
8401 sizeof(struct sir_peer_info_ext_req));
8402 message.type = WMA_GET_PEER_INFO_EXT;
8403 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8404 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8405 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8406 "%s: Post get rssi msg fail", __func__);
8407 qdf_mem_free(message.bodyptr);
8408 status = QDF_STATUS_E_FAILURE;
8409 }
8410 sme_release_global_lock(&mac->sme);
8411 }
8412 return status;
8413}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008414
8415/*
8416 * SME API to enable/disable WLAN driver initiated SSR
8417 */
8418void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8419{
8420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308421 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422
8423 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308424 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008425 sme_debug("SSR level is changed %d", enableSSR);
Jeff Johnson698eacd2018-05-12 17:00:03 -07008426 /* not serializing this message, as this is only going
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008427 * to set a variable in WMA/WDI
8428 */
8429 WMA_SetEnableSSR(enableSSR);
8430 sme_release_global_lock(&pMac->sme);
8431 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008432}
8433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008434/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8435ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8436{
8437 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8438}
8439
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308440/*
8441 * sme_set_curr_device_mode() - Sets the current operating device mode.
8442 *
8443 * hHal - The handle returned by mac_open.
8444 * currDeviceMode - Current operating device mode.
8445 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008446void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008447 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448{
8449 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008451 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008452}
8453
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308454/*
8455 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8456 * This is a synchronous call
8457 *
8458 * hHal - The handle returned by mac_open
8459 * sessionId - Session Identifier
8460 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8461 * BSSID, channel etc.)
8462 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8463 * Other status means SME is failed to send the request.
8464 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308466QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008467 uint8_t sessionId,
8468 tCsrHandoffRequest *pHandoffInfo)
8469{
8470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308471 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008472
8473 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308474 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308475 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008476 "%s: invoked", __func__);
8477 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8478 sme_release_global_lock(&pMac->sme);
8479 }
8480
8481 return status;
8482}
8483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008484/*
8485 * SME API to check if there is any infra station or
8486 * P2P client is connected
8487 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308488QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008489{
8490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308491
8492 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308493 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308494
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308495 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008496}
8497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008498/**
8499 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8500 * @hal: global hal handle
8501 * @addPeriodicTxPtrnParams: request message
8502 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308503 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008504 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308505QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008506sme_add_periodic_tx_ptrn(tHalHandle hal,
8507 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8508{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308509 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8511 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008512 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008513
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008514 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308516 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008517 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008518 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308519 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 }
8521
8522 *req_msg = *addPeriodicTxPtrnParams;
8523
8524 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308525 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008526 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008527 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308528 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008529 return status;
8530 }
8531
8532 /* Serialize the req through MC thread */
8533 msg.bodyptr = req_msg;
8534 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308535 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8536 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008537 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308538 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008539 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008540 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308541 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008542 }
8543 sme_release_global_lock(&mac->sme);
8544 return status;
8545}
8546
8547/**
8548 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8549 * @hal: global hal handle
8550 * @delPeriodicTxPtrnParams: request message
8551 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308552 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008553 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308554QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008555sme_del_periodic_tx_ptrn(tHalHandle hal,
8556 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8557{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308558 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008559 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8560 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008561 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008563 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008564
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308565 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008567 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308568 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008569 }
8570
8571 *req_msg = *delPeriodicTxPtrnParams;
8572
8573 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308574 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008575 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008576 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308577 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008578 return status;
8579 }
8580
8581 /* Serialize the req through MC thread */
8582 msg.bodyptr = req_msg;
8583 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308584 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8585 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008586 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308587 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008588 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008589 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308590 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008591 }
8592 sme_release_global_lock(&mac->sme);
8593 return status;
8594}
8595
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308596/*
8597 * sme_enable_rmc() - enables RMC
8598 * @hHal : Pointer to global HAL handle
8599 * @sessionId : Session ID
8600 *
8601 * Return: QDF_STATUS
8602 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008603QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8604{
8605 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8606 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008607 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008608 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8609
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008610 SME_ENTER();
8611
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008612 status = sme_acquire_global_lock(&pMac->sme);
8613 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008614 message.bodyptr = NULL;
8615 message.type = WMA_RMC_ENABLE_IND;
8616 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8617 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008618 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8620 "%s: failed to post message to WMA",
8621 __func__);
8622 status = QDF_STATUS_E_FAILURE;
8623 }
8624 sme_release_global_lock(&pMac->sme);
8625 }
8626 return status;
8627}
8628
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308629/*
8630 * sme_disable_rmc() - disables RMC
8631 * @hHal : Pointer to global HAL handle
8632 * @sessionId : Session ID
8633 *
8634 * Return: QDF_STATUS
8635 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008636QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
8637{
8638 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8639 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008640 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008641 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8642
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008643 SME_ENTER();
8644
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008645 status = sme_acquire_global_lock(&pMac->sme);
8646 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008647 message.bodyptr = NULL;
8648 message.type = WMA_RMC_DISABLE_IND;
8649 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8650 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008651 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8652 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8653 "%s: failed to post message to WMA",
8654 __func__);
8655 status = QDF_STATUS_E_FAILURE;
8656 }
8657 sme_release_global_lock(&pMac->sme);
8658 }
8659 return status;
8660}
8661
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308662/*
8663 * sme_send_rmc_action_period() - sends RMC action period param to target
8664 * @hHal : Pointer to global HAL handle
8665 * @sessionId : Session ID
8666 *
8667 * Return: QDF_STATUS
8668 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008669QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
8670{
8671 QDF_STATUS status = QDF_STATUS_SUCCESS;
8672 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8673 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008674 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008675
8676 status = sme_acquire_global_lock(&pMac->sme);
8677 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008678 message.bodyptr = NULL;
8679 message.type = WMA_RMC_ACTION_PERIOD_IND;
8680 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8681 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008682 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8683 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8684 "%s: failed to post message to WMA",
8685 __func__);
8686 status = QDF_STATUS_E_FAILURE;
8687 }
8688 sme_release_global_lock(&pMac->sme);
8689 }
8690
8691 return status;
8692}
8693
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308694/*
8695 * sme_request_ibss_peer_info() - request ibss peer info
8696 * @hHal : Pointer to global HAL handle
8697 * @pUserData : Pointer to user data
8698 * @peerInfoCbk : Peer info callback
8699 * @allPeerInfoReqd : All peer info required or not
8700 * @staIdx : sta index
8701 *
8702 * Return: QDF_STATUS
8703 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008704QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
8705 pIbssPeerInfoCb peerInfoCbk,
8706 bool allPeerInfoReqd, uint8_t staIdx)
8707{
8708 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8709 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
8710 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008711 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008712 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
8713
8714 status = sme_acquire_global_lock(&pMac->sme);
8715 if (QDF_STATUS_SUCCESS == status) {
8716 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
8717 pMac->sme.peerInfoParams.pUserData = pUserData;
8718
8719 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308720 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008721 if (NULL == pIbssInfoReqParams) {
8722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8723 "%s: Not able to allocate memory for dhcp start",
8724 __func__);
8725 sme_release_global_lock(&pMac->sme);
8726 return QDF_STATUS_E_NOMEM;
8727 }
8728 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
8729 pIbssInfoReqParams->staIdx = staIdx;
8730
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008731 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
8732 message.bodyptr = pIbssInfoReqParams;
8733 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008734
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008735 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8736 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008737 if (QDF_STATUS_SUCCESS != qdf_status) {
8738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8739 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
8740 __func__);
8741 qdf_mem_free(pIbssInfoReqParams);
8742 qdf_status = QDF_STATUS_E_FAILURE;
8743 }
8744 sme_release_global_lock(&pMac->sme);
8745 }
8746
8747 return qdf_status;
8748}
8749
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308750/*
8751 * sme_send_cesium_enable_ind() -
8752 * Used to send proprietary cesium enable indication to fw
8753 *
8754 * hHal
8755 * sessionId
8756 * Return QDF_STATUS
8757 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008758QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
8759{
8760 QDF_STATUS status = QDF_STATUS_SUCCESS;
8761 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008763 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008764
8765 status = sme_acquire_global_lock(&pMac->sme);
8766 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008767 message.bodyptr = NULL;
8768 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
8769 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8770 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008771 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8772 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8773 "%s: failed to post message to WMA",
8774 __func__);
8775 status = QDF_STATUS_E_FAILURE;
8776 }
8777 sme_release_global_lock(&pMac->sme);
8778 }
8779
8780 return status;
8781}
8782
Paul Zhang99fe8842017-12-08 14:43:46 +08008783QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
8784 uint16_t latency_level)
8785{
8786 QDF_STATUS status;
8787 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
8788 struct wlm_latency_level_param params;
8789 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
8790
Bala Venkatesh7cf5b662018-05-10 15:18:53 +05308791 if (!wma)
8792 return QDF_STATUS_E_FAILURE;
8793
Paul Zhang99fe8842017-12-08 14:43:46 +08008794 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
8795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8796 "%s: WLM latency level setting is disabled",
8797 __func__);
8798 return QDF_STATUS_E_FAILURE;
8799 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08008800 if (!wma) {
8801 sme_err("wma is NULL");
8802 return QDF_STATUS_E_FAILURE;
8803 }
Paul Zhang99fe8842017-12-08 14:43:46 +08008804
8805 params.wlm_latency_level = latency_level;
8806 params.wlm_latency_flags =
8807 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
8808 params.vdev_id = session_id;
8809
8810 status = wma_set_wlm_latency_level(wma, &params);
8811 if (!QDF_IS_STATUS_SUCCESS(status))
8812 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8813 "%s: failed to set latency level",
8814 __func__);
8815
8816 return status;
8817}
8818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008819void sme_get_command_q_status(tHalHandle hHal)
8820{
8821 tSmeCmd *pTempCmd = NULL;
8822 tListElem *pEntry;
8823 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8824
8825 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308826 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827 "%s: pMac is NULL", __func__);
8828 return;
8829 }
8830
Krunal Sonia8270f52017-02-23 19:51:25 -08008831 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308832 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308834
Kabilan Kannan33fcd682018-03-08 14:29:46 -08008835 sme_err("WLAN_BUG_RCA: Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008836 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
8837 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308838 if (eSmeCsrCommandMask & pTempCmd->command)
8839 /* CSR command is stuck. See what the reason code is
8840 * for that command
8841 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008843 } /* if(pTempCmd) */
8844
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008845 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08008846 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008849/**
8850 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
8851 * @hal: The handle returned by macOpen
8852 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
8853 */
8854void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
8855 bool sta_prefer_80MHz_over_160MHz)
8856{
8857 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308858
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008859 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
8860}
8861
Agrawal Ashishb141b092016-09-02 19:59:26 +05308862#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863/**
8864 * sme_set_dot11p_config() - API to set the 802.11p config
8865 * @hHal: The handle returned by macOpen
8866 * @enable_dot11p: 802.11p config param
8867 */
8868void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
8869{
8870 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008872 pMac->enable_dot11p = enable_dot11p;
8873}
8874
8875/**
8876 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
8877 * @src: the source configuration
8878 *
8879 * Return: pointer to the copied OCB configuration
8880 */
8881static struct sir_ocb_config *sme_copy_sir_ocb_config(
8882 struct sir_ocb_config *src)
8883{
8884 struct sir_ocb_config *dst;
8885 uint32_t length;
8886 void *cursor;
8887
8888 length = sizeof(*src) +
8889 src->channel_count * sizeof(*src->channels) +
8890 src->schedule_size * sizeof(*src->schedule) +
8891 src->dcc_ndl_chan_list_len +
8892 src->dcc_ndl_active_state_list_len;
8893
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308894 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895 if (!dst)
8896 return NULL;
8897
8898 *dst = *src;
8899
8900 cursor = dst;
8901 cursor += sizeof(*dst);
8902 dst->channels = cursor;
8903 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308904 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008905 src->channel_count * sizeof(*src->channels));
8906 dst->schedule = cursor;
8907 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308908 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008909 src->schedule_size * sizeof(*src->schedule));
8910 dst->dcc_ndl_chan_list = cursor;
8911 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308912 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008913 src->dcc_ndl_chan_list_len);
8914 dst->dcc_ndl_active_state_list = cursor;
8915 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308916 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008917 src->dcc_ndl_active_state_list,
8918 src->dcc_ndl_active_state_list_len);
8919 return dst;
8920}
8921
8922/**
8923 * sme_ocb_set_config() - Set the OCB configuration
8924 * @hHal: reference to the HAL
8925 * @context: the context of the call
8926 * @callback: the callback to hdd
8927 * @config: the OCB configuration
8928 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308929 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008930 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308931QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008932 ocb_callback callback,
8933 struct sir_ocb_config *config)
8934{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308935 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008937 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008938 struct sir_ocb_config *msg_body;
8939
8940 /* Lock the SME structure */
8941 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308942 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943 return status;
8944
8945 /*
8946 * Check if there is a pending request and return an error if one
8947 * exists
8948 */
8949 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308950 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008951 goto end;
8952 }
8953
8954 msg_body = sme_copy_sir_ocb_config(config);
8955
8956 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308957 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008958 goto end;
8959 }
8960
8961 msg.type = WMA_OCB_SET_CONFIG_CMD;
8962 msg.bodyptr = msg_body;
8963
8964 /* Set the request callback and context */
8965 pMac->sme.ocb_set_config_callback = callback;
8966 pMac->sme.ocb_set_config_context = context;
8967
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008968 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308969 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008971 FL("Error posting message to WDA: %d"), status);
8972 pMac->sme.ocb_set_config_callback = callback;
8973 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308974 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008975 goto end;
8976 }
8977
8978end:
8979 sme_release_global_lock(&pMac->sme);
8980
8981 return status;
8982}
8983
8984/**
8985 * sme_ocb_set_utc_time() - Set the OCB UTC time
8986 * @hHal: reference to the HAL
8987 * @utc: the UTC time struct
8988 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308989 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008990 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308991QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008992{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308993 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008994 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008995 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 struct sir_ocb_utc *sme_utc;
8997
8998 /* Lock the SME structure */
8999 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309000 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009001 return status;
9002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309003 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009004 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309005 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009006 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309007 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 goto end;
9009 }
9010 *sme_utc = *utc;
9011
9012 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9013 msg.reserved = 0;
9014 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009015 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309016 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009018 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309019 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 goto end;
9021 }
9022
9023end:
9024 sme_release_global_lock(&pMac->sme);
9025
9026 return status;
9027}
9028
9029/**
9030 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9031 * @hHal: reference to the HAL
9032 * @timing_advert: the timing advertisement struct
9033 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309034 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009035 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309036QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009037 struct sir_ocb_timing_advert *timing_advert)
9038{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309039 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009040 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009041 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009042 void *buf;
9043 struct sir_ocb_timing_advert *sme_timing_advert;
9044
9045 /* Lock the SME structure */
9046 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309047 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009048 return status;
9049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309050 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009051 timing_advert->template_length);
9052 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309055 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009056 goto end;
9057 }
9058
9059 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9060 *sme_timing_advert = *timing_advert;
9061 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309062 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009063 timing_advert->template_value, timing_advert->template_length);
9064
9065 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9066 msg.reserved = 0;
9067 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009068 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309069 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309070 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009071 FL("Not able to post msg to WDA"));
9072 goto end;
9073 }
9074
9075end:
9076 sme_release_global_lock(&pMac->sme);
9077
9078 return status;
9079}
9080
9081/**
9082 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9083 * @hHal: reference to the HAL
9084 * @timing_advert: the timing advertisement struct
9085 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309086 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009087 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309088QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009089 struct sir_ocb_timing_advert *timing_advert)
9090{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309091 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009092 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009093 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009094 struct sir_ocb_timing_advert *sme_timing_advert;
9095
9096 /* Lock the SME structure */
9097 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309098 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009099 return status;
9100
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309101 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309103 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009104 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309105 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 goto end;
9107 }
9108 *sme_timing_advert = *timing_advert;
9109
9110 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9111 msg.reserved = 0;
9112 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009113 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309114 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009116 FL("Not able to post msg to WDA"));
9117 goto end;
9118 }
9119
9120end:
9121 sme_release_global_lock(&pMac->sme);
9122
9123 return status;
9124}
9125
9126/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009127 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9128 * @hal_handle: reference to the HAL
9129 * @self_addr: the self MAC address
9130 * @buf: the buffer that will contain the frame
9131 * @timestamp_offset: return for the offset of the timestamp field
9132 * @time_value_offset: return for the time_value field in the TA IE
9133 *
9134 * Return: the length of the buffer.
9135 */
9136int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9137 tSirMacAddr self_addr, uint8_t **buf,
9138 uint32_t *timestamp_offset,
9139 uint32_t *time_value_offset)
9140{
9141 int template_length;
9142 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9143
9144 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9145 timestamp_offset,
9146 time_value_offset);
9147 return template_length;
9148}
9149/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009150 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9151 * @hHal: reference to the HAL
9152 * @context: the context of the call
9153 * @callback: the callback to hdd
9154 * @request: the TSF timer request
9155 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309156 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009157 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309158QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009159 ocb_callback callback,
9160 struct sir_ocb_get_tsf_timer *request)
9161{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309162 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009163 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009164 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009165 struct sir_ocb_get_tsf_timer *msg_body;
9166
9167 /* Lock the SME structure */
9168 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309169 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009170 return status;
9171
9172 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309173 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009174 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309175 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009176 goto end;
9177 }
9178 *msg_body = *request;
9179
9180 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9181 msg.bodyptr = msg_body;
9182
9183 /* Set the request callback and the context */
9184 pMac->sme.ocb_get_tsf_timer_callback = callback;
9185 pMac->sme.ocb_get_tsf_timer_context = context;
9186
9187 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009188 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309189 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309190 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009191 FL("Error posting message to WDA: %d"), status);
9192 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9193 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309194 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009195 goto end;
9196 }
9197
9198end:
9199 sme_release_global_lock(&pMac->sme);
9200
9201 return status;
9202}
9203
9204/**
9205 * sme_dcc_get_stats() - Get the DCC stats
9206 * @hHal: reference to the HAL
9207 * @context: the context of the call
9208 * @callback: the callback to hdd
9209 * @request: the get DCC stats request
9210 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309211 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309213QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009214 ocb_callback callback,
9215 struct sir_dcc_get_stats *request)
9216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009219 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 struct sir_dcc_get_stats *msg_body;
9221
9222 /* Lock the SME structure */
9223 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309224 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009225 return status;
9226
9227 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309228 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009229 request->request_array_len);
9230 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309231 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009232 goto end;
9233 }
9234 *msg_body = *request;
9235 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309236 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009237 request->request_array_len);
9238
9239 msg.type = WMA_DCC_GET_STATS_CMD;
9240 msg.bodyptr = msg_body;
9241
9242 /* Set the request callback and context */
9243 pMac->sme.dcc_get_stats_callback = callback;
9244 pMac->sme.dcc_get_stats_context = context;
9245
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009246 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009249 FL("Error posting message to WDA: %d"), status);
9250 pMac->sme.dcc_get_stats_callback = callback;
9251 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309252 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009253 goto end;
9254 }
9255
9256end:
9257 sme_release_global_lock(&pMac->sme);
9258
9259 return status;
9260}
9261
9262/**
9263 * sme_dcc_clear_stats() - Clear the DCC stats
9264 * @hHal: reference to the HAL
9265 * @vdev_id: vdev id for OCB interface
9266 * @dcc_stats_bitmap: the entries in the stats to clear
9267 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309268 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309270QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009271 uint32_t dcc_stats_bitmap)
9272{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309273 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009275 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009276 struct sir_dcc_clear_stats *request;
9277
9278 /* Lock the SME structure */
9279 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309280 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 return status;
9282
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309283 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309285 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009286 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309287 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009288 goto end;
9289 }
9290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009291 request->vdev_id = vdev_id;
9292 request->dcc_stats_bitmap = dcc_stats_bitmap;
9293
9294 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9295 msg.bodyptr = request;
9296
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009297 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309298 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309299 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009300 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309301 qdf_mem_free(request);
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_dcc_update_ndl() - Update the DCC settings
9313 * @hHal: reference to the HAL
9314 * @context: the context of the call
9315 * @callback: the callback to hdd
9316 * @request: the update DCC request
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_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009321 ocb_callback callback,
9322 struct sir_dcc_update_ndl *request)
9323{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309324 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009326 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009327 struct sir_dcc_update_ndl *msg_body;
9328
9329 /* Lock the SME structure */
9330 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309331 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 return status;
9333
9334 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309335 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 request->dcc_ndl_chan_list_len +
9337 request->dcc_ndl_active_state_list_len);
9338 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309339 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309341 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342 goto end;
9343 }
9344
9345 *msg_body = *request;
9346
9347 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9348 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9349 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309350 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009351 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309352 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009353 request->dcc_ndl_active_state_list,
9354 request->dcc_ndl_active_state_list_len);
9355
9356 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9357 msg.bodyptr = msg_body;
9358
9359 /* Set the request callback and the context */
9360 pMac->sme.dcc_update_ndl_callback = callback;
9361 pMac->sme.dcc_update_ndl_context = context;
9362
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009363 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309364 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309365 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009366 FL("Error posting message to WDA: %d"), status);
9367 pMac->sme.dcc_update_ndl_callback = NULL;
9368 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309369 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 goto end;
9371 }
9372
9373end:
9374 sme_release_global_lock(&pMac->sme);
9375
9376 return status;
9377}
9378
9379/**
9380 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9381 * event
9382 * @hHal: reference to the HAL
9383 * @context: the context of the call
9384 * @callback: the callback to hdd
9385 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309386 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309388QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009389 ocb_callback callback)
9390{
9391 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309392 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009393
9394 status = sme_acquire_global_lock(&pMac->sme);
9395 pMac->sme.dcc_stats_event_callback = callback;
9396 pMac->sme.dcc_stats_event_context = context;
9397 sme_release_global_lock(&pMac->sme);
9398
9399 return 0;
9400}
9401
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309402/**
9403 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9404 * event
9405 * @h_hal: Hal Handle
9406 *
9407 * This function de-registers the DCC perioc stats callback
9408 *
9409 * Return: QDF_STATUS Enumeration
9410 */
9411QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9412{
9413 tpAniSirGlobal mac;
9414 QDF_STATUS status;
9415
9416 if (!h_hal) {
9417 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9418 FL("h_hal is not valid"));
9419 return QDF_STATUS_E_INVAL;
9420 }
9421 mac = PMAC_STRUCT(h_hal);
9422
9423 status = sme_acquire_global_lock(&mac->sme);
9424 if (!QDF_IS_STATUS_SUCCESS(status)) {
9425 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9426 FL("Failed to acquire global lock"));
9427 return status;
9428 }
9429 mac->sme.dcc_stats_event_callback = NULL;
9430 mac->sme.dcc_stats_event_context = NULL;
9431 sme_release_global_lock(&mac->sme);
9432
9433 return status;
9434}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309435#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009437void sme_get_recovery_stats(tHalHandle hHal)
9438{
9439 uint8_t i;
9440
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309441 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442 "Self Recovery Stats");
9443 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9444 if (eSmeNoCommand !=
9445 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309446 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 "timestamp %llu: command 0x%0X: reason %d: session %d",
9448 g_self_recovery_stats.activeCmdStats[i].
9449 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309450 g_self_recovery_stats.activeCmdStats[i].command,
9451 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009452 g_self_recovery_stats.activeCmdStats[i].
9453 sessionId);
9454 }
9455 }
9456}
9457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309458QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009459{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009460 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009461 tpSirModemPowerStateInd request_buf;
9462 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9463
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309464 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309465 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009466
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309467 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309469 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9471 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309472 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009473 }
9474
9475 request_buf->param = value;
9476
9477 msg.type = WMA_MODEM_POWER_STATE_IND;
9478 msg.reserved = 0;
9479 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309480 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009481 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309482 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309483 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9484 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309485 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309486 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487 }
9488
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309489 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009490}
9491
9492#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309493QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309494 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009495 uint8_t sessionId,
9496 uint8_t channel_type)
9497{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009498 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499 tUpdateVHTOpMode *pHtOpMode = NULL;
9500 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9501
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309502 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309503 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309505 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009506 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309507 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508 "%s: Not able to allocate memory for setting OP mode",
9509 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309510 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511 }
9512
9513 switch (channel_type) {
9514 case eHT_CHAN_HT20:
9515 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9516 break;
9517
9518 case eHT_CHAN_HT40MINUS:
9519 case eHT_CHAN_HT40PLUS:
9520 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9521 break;
9522
9523 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309524 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009525 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309526 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009527 }
9528
9529 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309530 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 sizeof(tSirMacAddr));
9532 pHtOpMode->smesessionId = sessionId;
9533
9534 msg.type = WMA_UPDATE_OP_MODE;
9535 msg.reserved = 0;
9536 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309537 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009538 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309539 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309540 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9541 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309542 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309543 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009544 }
9545
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309546 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson698eacd2018-05-12 17:00:03 -07009547 "%s: Notified FW about OP mode: %d for staId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009548 __func__, pHtOpMode->opMode, staId);
9549
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309550 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009551}
9552
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309553/*
9554 * sme_set_ht2040_mode() -
9555 * To update HT Operation beacon IE.
9556 *
9557 * Return QDF_STATUS SUCCESS
9558 * FAILURE or RESOURCES
9559 * The API finished and failed.
9560 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309561QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 uint8_t channel_type, bool obssEnabled)
9563{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309564 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009565 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9566 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309567 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009568
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309569 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9570 sme_err("Session not valid for session id %d", sessionId);
9571 return QDF_STATUS_E_INVAL;
9572 }
9573 session = CSR_GET_SESSION(pMac, sessionId);
9574 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9575 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576
9577 switch (channel_type) {
9578 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309579 if (!session->bssParams.cbMode)
9580 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9582 break;
9583 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309584 if (session->bssParams.cbMode)
9585 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009586 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9587 break;
9588 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309589 if (session->bssParams.cbMode)
9590 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009591 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9592 break;
9593 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309594 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309597 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009598 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309599 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009600 status = csr_set_ht2040_mode(pMac, sessionId,
9601 cbMode, obssEnabled);
9602 sme_release_global_lock(&pMac->sme);
9603 }
9604 return status;
9605}
9606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009607#endif
9608
9609/*
9610 * SME API to enable/disable idle mode powersave
9611 * This should be called only if powersave offload
9612 * is enabled
9613 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309614QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009615{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309616 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009617
9618 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309621 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009622 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309623 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009624 " Idle Ps Set Value %d", value);
9625
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309626 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309627 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009628 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309629 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309631
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309632 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009633}
9634
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309635int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9636 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009637{
9638 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309639 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009640
9641 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009643 "%s: pSession is NULL", __func__);
9644 return -EIO;
9645 }
9646 switch (ht_capab) {
9647 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9648 return pSession->htConfig.ht_rx_ldpc;
9649 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9650 return pSession->htConfig.ht_tx_stbc;
9651 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9652 return pSession->htConfig.ht_rx_stbc;
9653 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009654 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009655 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009656 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309658 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659 "invalid ht capability");
9660 return -EIO;
9661 }
9662}
9663
9664int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9665 int value)
9666{
9667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309668 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009669
9670 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009672 "%s: pSession is NULL", __func__);
9673 return -EIO;
9674 }
9675
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309676 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309677 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009678 "Failed to set ht capability in target");
9679 return -EIO;
9680 }
9681
9682 switch (htCapab) {
9683 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9684 pSession->htConfig.ht_rx_ldpc = value;
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -07009685 pMac->roam.configParam.rx_ldpc_enable = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009686 break;
9687 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9688 pSession->htConfig.ht_tx_stbc = value;
9689 break;
9690 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9691 pSession->htConfig.ht_rx_stbc = value;
9692 break;
9693 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009694 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009695 pSession->htConfig.ht_sgi20 = value;
9696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009697 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009698 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009699 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009700 break;
9701 }
9702
Naveen Rawat8029a402017-06-01 10:54:19 -07009703 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009704 return 0;
9705}
9706
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08009707int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
9708{
9709 struct sme_addba_accept *addba_accept;
9710 struct scheduler_msg msg = {0};
9711 QDF_STATUS status;
9712
9713 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
9714 if (!addba_accept) {
9715 sme_err("mem alloc failed for addba_accept");
9716 return -EIO;
9717 }
9718 addba_accept->session_id = session_id;
9719 addba_accept->addba_accept = value;
9720 qdf_mem_zero(&msg, sizeof(msg));
9721 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
9722 msg.reserved = 0;
9723 msg.bodyptr = addba_accept;
9724 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9725 if (status != QDF_STATUS_SUCCESS) {
9726 sme_err("Not able to post addba reject");
9727 qdf_mem_free(addba_accept);
9728 return -EIO;
9729 }
9730 return 0;
9731}
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08009732
9733int sme_set_ba_buff_size(tHalHandle hal, uint8_t session_id,
9734 uint16_t buff_size)
9735{
9736 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9737 if (!buff_size) {
9738 sme_err("invalid buff size %d", buff_size);
9739 return -EINVAL;
9740 }
9741 mac_ctx->usr_cfg_ba_buff_size = buff_size;
9742 sme_debug("addba buff size is set to %d",
9743 mac_ctx->usr_cfg_ba_buff_size);
9744
9745 return 0;
9746}
9747
9748#define DEFAULT_BA_BUFF_SIZE 64
9749int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid,
9750 uint16_t buff_size)
9751{
9752 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9753 uint16_t ba_buff = 0;
9754 QDF_STATUS status;
9755 struct scheduler_msg msg = {0};
9756 struct send_add_ba_req *send_ba_req;
9757 struct csr_roam_session *csr_session = NULL;
9758
9759 if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9760 sme_err("STA not infra/connected state session_id: %d",
9761 session_id);
9762 return -EINVAL;
9763 }
9764 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
9765 if (!csr_session) {
9766 sme_err("CSR session is NULL");
9767 return -EINVAL;
9768 }
9769 send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req));
9770 if (!send_ba_req) {
9771 sme_err("mem alloc failed");
9772 return -EIO;
9773 }
9774 qdf_mem_copy(send_ba_req->mac_addr,
9775 csr_session->connectedProfile.bssid.bytes,
9776 QDF_MAC_ADDR_SIZE);
9777 ba_buff = buff_size;
9778 if (!buff_size) {
9779 if (mac_ctx->usr_cfg_ba_buff_size)
9780 ba_buff = mac_ctx->usr_cfg_ba_buff_size;
9781 else
9782 ba_buff = DEFAULT_BA_BUFF_SIZE;
9783 }
9784 send_ba_req->param.vdev_id = session_id;
9785 send_ba_req->param.tidno = tid;
9786 send_ba_req->param.buffersize = ba_buff;
9787 msg.type = WMA_SEND_ADDBA_REQ;
9788 msg.bodyptr = send_ba_req;
9789 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
9790 if (QDF_STATUS_SUCCESS != status) {
9791 sme_err("Failed to post WMA_SEND_ADDBA_REQ");
9792 qdf_mem_free(send_ba_req);
9793 return -EIO;
9794 }
9795 sme_debug("ADDBA_REQ sent to FW: tid %d buff_size %d", tid, ba_buff);
9796
9797 return 0;
9798}
9799
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009800int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id,
9801 uint8_t val, uint8_t ac)
9802{
9803 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9804 uint8_t i, set_val;
Arif Hussaineb8ba362018-03-07 19:15:13 -08009805 struct scheduler_msg msg = {0};
9806 QDF_STATUS status;
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009807
9808 if (ac > MAX_NUM_AC) {
9809 sme_err("invalid ac val %d", ac);
9810 return -EINVAL;
9811 }
9812 if (val)
9813 set_val = 1;
9814 else
9815 set_val = 0;
9816 if (ac == MAX_NUM_AC) {
9817 for (i = 0; i < ac; i++)
9818 mac_ctx->no_ack_policy_cfg[i] = set_val;
9819 } else {
9820 mac_ctx->no_ack_policy_cfg[ac] = set_val;
9821 }
9822 sme_debug("no ack is set to %d for ac %d", set_val, ac);
Arif Hussaineb8ba362018-03-07 19:15:13 -08009823 qdf_mem_zero(&msg, sizeof(msg));
9824 msg.type = eWNI_SME_UPDATE_EDCA_PROFILE;
9825 msg.reserved = 0;
9826 msg.bodyval = session_id;
9827 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9828 if (status != QDF_STATUS_SUCCESS) {
9829 sme_err("Not able to post update edca profile");
9830 return -EIO;
9831 }
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009832
9833 return 0;
9834}
9835
Kiran Kumar Lokerea006a302018-03-07 20:58:13 -08009836int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id,
9837 uint8_t cfg_val)
9838{
9839 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9840 uint32_t set_val;
9841 uint32_t bit_mask = 0;
9842 int status;
9843
9844 if (cfg_val > QCA_WLAN_HE_LTF_4X) {
9845 sme_err("invalid HE LTF cfg %d", cfg_val);
9846 return -EINVAL;
9847 }
9848
9849 /*set the corresponding HE LTF cfg BIT*/
9850 if (cfg_val == QCA_WLAN_HE_LTF_AUTO)
9851 bit_mask = HE_LTF_ALL;
9852 else
9853 bit_mask = (1 << (cfg_val - 1));
9854
9855 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9856
9857 SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask);
9858
9859 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9860 status = wma_cli_set_command(session_id,
9861 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9862 set_val, VDEV_CMD);
9863 if (status) {
9864 sme_err("failed to set he_ltf_sgi");
9865 return status;
9866 }
9867
9868 sme_debug("HE SGI_LTF is set to 0x%08X",
9869 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9870
9871 return 0;
9872}
9873
9874int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id,
9875 uint8_t cfg_val)
9876{
9877 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9878 uint32_t set_val;
9879 uint32_t sgi_bit_mask = 0;
9880 int status;
9881
9882 if ((cfg_val > AUTO_RATE_GI_3200NS) ||
9883 (cfg_val < AUTO_RATE_GI_400NS)) {
9884 sme_err("invalid auto rate GI cfg %d", cfg_val);
9885 return -EINVAL;
9886 }
9887
9888 sgi_bit_mask = (1 << cfg_val);
9889
9890 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9891 SET_AUTO_RATE_SGI_VAL(set_val, sgi_bit_mask);
9892
9893 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9894 status = wma_cli_set_command(session_id,
9895 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9896 set_val, VDEV_CMD);
9897 if (status) {
9898 sme_err("failed to set he_ltf_sgi");
9899 return status;
9900 }
9901
9902 sme_debug("auto rate HE SGI_LTF is set to 0x%08X",
9903 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9904
9905 return 0;
9906}
9907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309909/*
9910 * sme_send_rate_update_ind() -
9911 * API to Update rate
9912 *
9913 * hHal - The handle returned by mac_open
9914 * rateUpdateParams - Pointer to rate update params
9915 * Return QDF_STATUS
9916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309917QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009918 tSirRateUpdateInd *rateUpdateParams)
9919{
9920 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309921 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009922 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309923 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009924
9925 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009929 }
9930 *rate_upd = *rateUpdateParams;
9931
9932 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
9933 rate_upd->mcastDataRate24GHzTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009934 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009935 else if (rate_upd->reliableMcastDataRate ==
9936 HT20_SHORT_GI_MCS7_RATE)
9937 rate_upd->reliableMcastDataRateTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009938 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009939
9940 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309941 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009942 msg.type = WMA_RATE_UPDATE_IND;
9943 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309944 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9945 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309946 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009947 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309948 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309949 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009950 __func__);
9951
9952 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309953 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309954 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009955 }
9956
9957 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309958 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009959 }
9960
9961 return status;
9962}
9963
9964/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309965 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
9966 * @hal: Pointer to the mac context
9967 * @session_id: sme session id
9968 * @vendor_ie: vendor ie
9969 * @access_policy: vendor ie access policy
9970 *
9971 * This function updates the vendor ie and access policy to lim.
9972 *
9973 * Return: success or failure.
9974 */
9975QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
9976 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
9977{
9978 struct sme_update_access_policy_vendor_ie *msg;
9979 uint16_t msg_len;
9980 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309981
9982 msg_len = sizeof(*msg);
9983
9984 msg = qdf_mem_malloc(msg_len);
9985 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009986 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309987 return QDF_STATUS_E_FAILURE;
9988 }
9989
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309990 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
9991 msg->length = (uint16_t)msg_len;
9992
9993 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
9994
9995 msg->sme_session_id = session_id;
9996 msg->access_policy = access_policy;
9997
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009998 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
9999 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010000
Rajeev Kumard138ac52017-01-30 18:38:37 -080010001 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010002
10003 return status;
10004}
10005
10006/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010007 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10008 * @hal: Handle returned by mac_open
10009 * @session_id: Session ID on which short frame retry limit needs to be
10010 * updated to FW
10011 * @short_limit_count_th: Retry count TH to retry short frame.
10012 *
10013 * This function is used to configure count to retry short frame.
10014 *
10015 * Return: QDF_STATUS
10016 */
10017QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10018 struct sme_short_retry_limit *short_retry_limit_th)
10019{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010020 QDF_STATUS status = QDF_STATUS_SUCCESS;
10021 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010022 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010023
10024 srl = qdf_mem_malloc(sizeof(*srl));
10025 if (NULL == srl) {
10026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10027 "%s: fail to alloc short retry limit", __func__);
10028 return QDF_STATUS_E_FAILURE;
10029 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010030 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010031 short_retry_limit_th->session_id,
10032 short_retry_limit_th->short_retry_limit);
10033
10034 srl->session_id = short_retry_limit_th->session_id;
10035 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10036
10037 qdf_mem_zero(&msg, sizeof(msg));
10038 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10039 msg.reserved = 0;
10040 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010041 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010042 if (status != QDF_STATUS_SUCCESS) {
10043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10044 FL("Not able to post short retry limit count to WDA"));
10045 qdf_mem_free(srl);
10046 return QDF_STATUS_E_FAILURE;
10047 }
10048
10049 return status;
10050}
10051
10052/**
10053 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10054 * @hal: Handle returned by mac_open
10055 * @session_id: Session ID on which long frames retry TH needs to be updated
10056 * to FW
10057 * @long_limit_count_th: Retry count to retry long frame.
10058 *
10059 * This function is used to configure TH to retry long frame.
10060 *
10061 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010062 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010063QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10064 struct sme_long_retry_limit *long_retry_limit_th)
10065{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010066 QDF_STATUS status = QDF_STATUS_SUCCESS;
10067 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010068 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010069
10070 lrl = qdf_mem_malloc(sizeof(*lrl));
10071 if (NULL == lrl) {
10072 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10073 "%s: fail to alloc long retry limit", __func__);
10074 return QDF_STATUS_E_FAILURE;
10075 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010076 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010077 long_retry_limit_th->session_id,
10078 long_retry_limit_th->long_retry_limit);
10079
10080 lrl->session_id = long_retry_limit_th->session_id;
10081 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10082
10083 qdf_mem_zero(&msg, sizeof(msg));
10084 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10085 msg.reserved = 0;
10086 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010087 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010088
10089 if (status != QDF_STATUS_SUCCESS) {
10090 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10091 FL("Not able to post long retry limit count to WDA"));
10092 qdf_mem_free(lrl);
10093 return QDF_STATUS_E_FAILURE;
10094 }
10095
10096 return status;
10097}
10098
10099/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010100 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10101 * @hal: Handle returned by mac_open
10102 * @session_id: Session ID on which sta_inactivity_timeout needs
10103 * to be updated to FW
10104 * @sta_inactivity_timeout: sta inactivity timeout.
10105 *
10106 * If a station does not send anything in sta_inactivity_timeout seconds, an
10107 * empty data frame is sent to it in order to verify whether it is
10108 * still in range. If this frame is not ACKed, the station will be
10109 * disassociated and then deauthenticated.
10110 *
10111 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010112 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010113QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10114 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10115{
10116 struct sme_sta_inactivity_timeout *inactivity_time;
10117 void *wma_handle;
10118
10119 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10120 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10121 if (NULL == inactivity_time) {
10122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10123 "%s: fail to alloc inactivity_time", __func__);
10124 return QDF_STATUS_E_FAILURE;
10125 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010126 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010127 FL("sta_inactivity_timeout: %d"),
10128 sta_inactivity_timer->sta_inactivity_timeout);
10129 inactivity_time->session_id = sta_inactivity_timer->session_id;
10130 inactivity_time->sta_inactivity_timeout =
10131 sta_inactivity_timer->sta_inactivity_timeout;
10132
10133 wma_update_sta_inactivity_timeout(wma_handle,
10134 inactivity_time);
10135 return QDF_STATUS_SUCCESS;
10136}
10137
10138/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010139 * sme_get_reg_info() - To get registration info
10140 * @hHal: HAL context
10141 * @chanId: channel id
10142 * @regInfo1: first reg info to fill
10143 * @regInfo2: second reg info to fill
10144 *
10145 * This routine will give you reg info
10146 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010147 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010148 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010149QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010150 uint32_t *regInfo1, uint32_t *regInfo2)
10151{
10152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010153 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010154 uint8_t i;
10155 bool found = false;
10156
10157 status = sme_acquire_global_lock(&pMac->sme);
10158 *regInfo1 = 0;
10159 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010160 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010161 return status;
10162
10163 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010164 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010165 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010166 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010167
10168 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010169 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010170 found = true;
10171 break;
10172 }
10173 }
10174 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010175 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176
10177 sme_release_global_lock(&pMac->sme);
10178 return status;
10179}
10180
10181#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010182/*
10183 * sme_auto_shutdown_cb() -
10184 * Used to plug in callback function for receiving auto shutdown evt
10185 *
10186 * hHal
10187 * pCallbackfn : callback function pointer should be plugged in
10188 * Return QDF_STATUS
10189 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010190QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010191 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010192 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10194
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010196 "%s: Plug in Auto shutdown event callback", __func__);
10197
10198 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010199 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010200 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010202 sme_release_global_lock(&pMac->sme);
10203 }
10204
10205 return status;
10206}
10207
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010208/*
10209 * sme_set_auto_shutdown_timer() -
10210 * API to set auto shutdown timer value in FW.
10211 *
10212 * hHal - The handle returned by mac_open
10213 * timer_val - The auto shutdown timer value to be set
10214 * Return Configuration message posting status, SUCCESS or Fail
10215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010216QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010217{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010218 QDF_STATUS status = QDF_STATUS_SUCCESS;
10219 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10221 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010222 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010223
10224 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010225 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010226 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010227 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010228 if (auto_sh_cmd == NULL) {
Dustin Browna2868622018-03-20 11:38:14 -070010229 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010231 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 }
10233
10234 auto_sh_cmd->timer_val = timer_val;
10235
10236 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010237 message.bodyptr = auto_sh_cmd;
10238 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10239 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10240 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010241 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010242 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010243 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010244 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010246 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010247 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 "%s: Posted Auto shutdown MSG", __func__);
10250 sme_release_global_lock(&pMac->sme);
10251 }
10252
10253 return status;
10254}
10255#endif
10256
Nirav Shaheb017be2018-02-15 11:20:58 +053010257#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010258/*
10259 * sme_ch_avoid_update_req() -
10260 * API to request channel avoidance update from FW.
10261 *
10262 * hHal - The handle returned by mac_open
Jeff Johnsonc5927de2018-05-11 09:12:53 -070010263 * update_type - The update_type parameter of this request call
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010264 * Return Configuration message posting status, SUCCESS or Fail
10265 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010266QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010267{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010268 QDF_STATUS status = QDF_STATUS_SUCCESS;
10269 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010270 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10271 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010272 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010273
10274 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010275 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010277 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010278 if (NULL == cauReq) {
Dustin Browna2868622018-03-20 11:38:14 -070010279 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010280 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010281 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 }
10283
10284 cauReq->reserved_param = 0;
10285
10286 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010287 message.bodyptr = cauReq;
10288 message.type = WMA_CH_AVOID_UPDATE_REQ;
10289 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10290 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010291 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010292 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010293 "%s: Post Ch Avoid Update MSG fail",
10294 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010295 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010297 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010298 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010299 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300 "%s: Posted Ch Avoid Update MSG", __func__);
10301 sme_release_global_lock(&pMac->sme);
10302 }
10303
10304 return status;
10305}
Nirav Shaheb017be2018-02-15 11:20:58 +053010306#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010307
10308/**
10309 * sme_set_miracast() - Function to set miracast value to UMAC
10310 * @hal: Handle returned by macOpen
10311 * @filter_type: 0-Disabled, 1-Source, 2-sink
10312 *
10313 * This function passes down the value of miracast set by
10314 * framework to UMAC
10315 *
10316 * Return: Configuration message posting status, SUCCESS or Fail
10317 *
10318 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010319QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010320{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010321 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010322 uint32_t *val;
10323 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10324
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010325 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010326 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010327 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010328 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010329 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010330 }
10331
10332 *val = filter_type;
10333
10334 msg.type = SIR_HAL_SET_MIRACAST;
10335 msg.reserved = 0;
10336 msg.bodyptr = val;
10337
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010338 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010339 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010340 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010341 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10342 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010343 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010344 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 }
10346
10347 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010348 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010349}
10350
10351/**
10352 * sme_set_mas() - Function to set MAS value to UMAC
10353 * @val: 1-Enable, 0-Disable
10354 *
10355 * This function passes down the value of MAS to the UMAC. A
10356 * value of 1 will enable MAS and a value of 0 will disable MAS
10357 *
10358 * Return: Configuration message posting status, SUCCESS or Fail
10359 *
10360 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010361QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010363 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010364 uint32_t *ptr_val;
10365
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010366 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010367 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010368 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010370 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010371 }
10372
10373 *ptr_val = val;
10374
10375 msg.type = SIR_HAL_SET_MAS;
10376 msg.reserved = 0;
10377 msg.bodyptr = ptr_val;
10378
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010379 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010380 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010381 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010382 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10383 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010384 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010385 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010386 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010387 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388}
10389
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010390/**
10391 * sme_roam_channel_change_req() - Channel change to new target channel
10392 * @hHal: handle returned by mac_open
10393 * @bssid: mac address of BSS
10394 * @ch_params: target channel information
10395 * @profile: CSR profile
10396 *
10397 * API to Indicate Channel change to new target channel
10398 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010399 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010400 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010401QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010402 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010403 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010404 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010405{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010406 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010407 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408
10409 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010410 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010411
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010412 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010413 profile);
10414 sme_release_global_lock(&pMac->sme);
10415 }
10416 return status;
10417}
10418
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010419/*
10420 * sme_process_channel_change_resp() -
10421 * API to Indicate Channel change response message to SAP.
10422 *
10423 * Return QDF_STATUS
10424 */
10425static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010426 uint16_t msg_type, void *pMsgBuf)
10427{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010428 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010429 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010430 eCsrRoamResult roamResult;
10431 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10432 uint32_t SessionId = pChnlParams->peSessionId;
10433
10434 proam_info.channelChangeRespEvent =
10435 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010436 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010437 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010438 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010439 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010440 return status;
10441 }
10442 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10443 proam_info.channelChangeRespEvent->sessionId = SessionId;
10444 proam_info.channelChangeRespEvent->newChannelNumber =
10445 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010447 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10450 SessionId);
10451 proam_info.channelChangeRespEvent->channelChangeStatus =
10452 1;
10453 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10454 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010455 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010456 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10457 SessionId);
10458 proam_info.channelChangeRespEvent->channelChangeStatus =
10459 0;
10460 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10461 }
10462
10463 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10464 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10465
10466 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010467 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010468 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010469 status);
10470 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010471 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472
10473 return status;
10474}
10475
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010476/*
10477 * sme_roam_start_beacon_req() -
10478 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10479 *
10480 * hHal - The handle returned by mac_open
10481 * sessionId - session ID
10482 * dfsCacWaitStatus - CAC WAIT status flag
10483 * Return QDF_STATUS
10484 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010485QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010486 uint8_t dfsCacWaitStatus)
10487{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010488 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010489 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010491 status = sme_acquire_global_lock(&pMac->sme);
10492
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010493 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010494 status = csr_roam_start_beacon_req(pMac, bssid,
10495 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010496 sme_release_global_lock(&pMac->sme);
10497 }
10498 return status;
10499}
10500
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010501/**
10502 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10503 * @hHal: handle returned by mac_open
10504 * @bssid: SAP bssid
10505 * @targetChannel: target channel information
10506 * @csaIeReqd: CSA IE Request
10507 * @ch_params: channel information
10508 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010509 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010510 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010511QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010513 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010515 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010516 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010519 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010520 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10521 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010522 sme_release_global_lock(&pMac->sme);
10523 }
10524 return status;
10525}
10526
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010527/*
10528 * sme_init_thermal_info() -
10529 * SME API to initialize the thermal mitigation parameters
10530 *
10531 * hHal
10532 * thermalParam : thermal mitigation parameters
10533 * Return QDF_STATUS
10534 */
10535QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10536 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537{
10538 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010539 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010540 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10541
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010542 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010543 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010544 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010545 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010546 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010547 }
10548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010549 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10550 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010551
10552 pWmaParam->throttle_duty_cycle_tbl[0] =
10553 thermalParam.sme_throttle_duty_cycle_tbl[0];
10554 pWmaParam->throttle_duty_cycle_tbl[1] =
10555 thermalParam.sme_throttle_duty_cycle_tbl[1];
10556 pWmaParam->throttle_duty_cycle_tbl[2] =
10557 thermalParam.sme_throttle_duty_cycle_tbl[2];
10558 pWmaParam->throttle_duty_cycle_tbl[3] =
10559 thermalParam.sme_throttle_duty_cycle_tbl[3];
10560
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010561 pWmaParam->thermalLevels[0].minTempThreshold =
10562 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10563 pWmaParam->thermalLevels[0].maxTempThreshold =
10564 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10565 pWmaParam->thermalLevels[1].minTempThreshold =
10566 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10567 pWmaParam->thermalLevels[1].maxTempThreshold =
10568 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10569 pWmaParam->thermalLevels[2].minTempThreshold =
10570 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10571 pWmaParam->thermalLevels[2].maxTempThreshold =
10572 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10573 pWmaParam->thermalLevels[3].minTempThreshold =
10574 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10575 pWmaParam->thermalLevels[3].maxTempThreshold =
10576 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10577
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010578 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010579 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10580 msg.bodyptr = pWmaParam;
10581
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010582 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010583 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010584 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010585 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10586 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010587 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010588 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010589 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010590 }
10591 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010592 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010593 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010594 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010596}
10597
10598/**
10599 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10600 * @hal: Handle returned by macOpen
10601 * @callback: sme_set_thermal_level_callback
10602 *
10603 * Plug in set thermal level callback
10604 *
10605 * Return: none
10606 */
10607void sme_add_set_thermal_level_callback(tHalHandle hal,
10608 sme_set_thermal_level_callback callback)
10609{
10610 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10611
10612 pMac->sme.set_thermal_level_cb = callback;
10613}
10614
10615/**
10616 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10617 * @hal: Handler to HAL
10618 * @level: Thermal mitigation level
10619 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010620 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010621 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010622QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010623{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010624 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010625 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010626 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010627
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010628 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010629 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010630 msg.type = WMA_SET_THERMAL_LEVEL;
10631 msg.bodyval = level;
10632
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010633 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010634 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010635 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010636 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10637 __func__);
10638 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010639 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010640 }
10641 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010642 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010643 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010644 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010645}
10646
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010647/*
10648 * sme_txpower_limit() -
10649 * SME API to set txpower limits
10650 *
10651 * hHal
10652 * psmetx : power limits for 2g/5g
10653 * Return QDF_STATUS
10654 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010655QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010656{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010657 QDF_STATUS status = QDF_STATUS_SUCCESS;
10658 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010659 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010661 tSirTxPowerLimit *tx_power_limit;
10662
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010663 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010664 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010665 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010666 "%s: Memory allocation for TxPowerLimit failed!",
10667 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010668 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010669 }
10670
10671 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010672
10673 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010674 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010675 message.type = WMA_TX_POWER_LIMIT;
10676 message.reserved = 0;
10677 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010678
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010679 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10680 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010681 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010682 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683 "%s: not able to post WMA_TX_POWER_LIMIT",
10684 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010685 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010686 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 }
10688 sme_release_global_lock(&pMac->sme);
10689 }
10690 return status;
10691}
10692
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010693QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010694{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010695 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010698 pMac->fEnableDebugLog = set_value;
10699 return status;
10700}
10701
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010702/*
10703 * sme_ap_disable_intra_bss_fwd() -
10704 * SME will send message to WMA to set Intra BSS in txrx
10705 *
10706 * hHal - The handle returned by mac_open
10707 * sessionId - session id ( vdev id)
10708 * disablefwd - bool value that indicate disable intrabss fwd disable
10709 * Return QDF_STATUS
10710 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010711QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010712 bool disablefwd)
10713{
10714 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010715 int status = QDF_STATUS_SUCCESS;
10716 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010717 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010718 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10719
10720 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010721 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010722 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010723 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010724 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010725 }
10726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010727 pSapDisableIntraFwd->sessionId = sessionId;
10728 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10729
10730 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010731 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010732 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010733 message.bodyptr = pSapDisableIntraFwd;
10734 message.type = WMA_SET_SAP_INTRABSS_DIS;
10735 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10736 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010737 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10738 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010739 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010740 }
10741 sme_release_global_lock(&pMac->sme);
10742 }
10743 return status;
10744}
10745
10746#ifdef WLAN_FEATURE_STATS_EXT
10747
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010748/*
10749 * sme_stats_ext_register_callback() -
10750 * This function called to register the callback that send vendor event for
10751 * stats ext
10752 *
10753 * callback - callback to be registered
10754 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010755void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10756{
10757 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10758
10759 pMac->sme.StatsExtCallback = callback;
10760}
10761
lifeng66831662017-05-19 16:01:35 +080010762void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10763 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10764{
10765 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10766
10767 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10768}
10769
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010770/**
10771 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10772 * @h_hal: Hal Handle
10773 *
10774 * This function is called to de initialize the HDD NAN feature. Currently
10775 * the only operation required is to de-register a callback with SME.
10776 *
10777 * Return: None
10778 */
10779void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10780{
10781 tpAniSirGlobal pmac;
10782
10783 if (!h_hal) {
10784 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10785 FL("hHal is not valid"));
10786 return;
10787 }
10788
10789 pmac = PMAC_STRUCT(h_hal);
10790 pmac->sme.StatsExtCallback = NULL;
10791}
10792
10793
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010794/*
10795 * sme_stats_ext_request() -
10796 * Function called when HDD receives STATS EXT vendor command from userspace
10797 *
10798 * sessionID - vdevID for the stats ext request
10799 * input - Stats Ext Request structure ptr
10800 * Return QDF_STATUS
10801 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010802QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010803{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010804 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010805 tpStatsExtRequest data;
10806 size_t data_len;
10807
10808 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010809 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010810
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010811 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010812 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010814 data->vdev_id = session_id;
10815 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010816 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010817 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010818 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010819
10820 msg.type = WMA_STATS_EXT_REQUEST;
10821 msg.reserved = 0;
10822 msg.bodyptr = data;
10823
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010824 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010825 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010826 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010827 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10828 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010829 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010830 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010831 }
10832
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010833 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010834}
10835
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010836/*
10837 * sme_stats_ext_event() -
10838 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10839 * response from WMA
10840 *
10841 * hHal - HAL handle for device
10842 * pMsg - Message body passed from WMA; includes NAN header
10843 * Return QDF_STATUS
10844 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010845QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010846{
10847 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010848 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010849
10850 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010851 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010852 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010854 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010855 pMac->sme.StatsExtCallback(pMac->hHdd,
10856 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010857 }
10858
10859 return status;
10860}
10861
10862#endif
10863
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010864/*
10865 * sme_update_dfs_scan_mode() -
10866 * Update DFS roam scan mode
10867 * This function is called through dynamic setConfig callback function
10868 * to configure allowDFSChannelRoam.
10869 * hHal - HAL handle for device
10870 * sessionId - Session Identifier
10871 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10872 * 1 (passive), 2 (active)
10873 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
10874 * successfully.
10875 * Other status means SME failed to update DFS roaming scan config.
10876 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010877QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878 uint8_t allowDFSChannelRoam)
10879{
10880 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010881 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080010883 if (sessionId >= CSR_ROAM_SESSION_MAX) {
10884 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10885 FL("Invalid sme session id: %d"), sessionId);
10886 return QDF_STATUS_E_INVAL;
10887 }
10888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010889 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010890 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010891 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010892 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010893 allowDFSChannelRoam,
10894 pMac->roam.configParam.allowDFSChannelRoam,
10895 mac_trace_get_neighbour_roam_state(pMac->roam.
10896 neighborRoamInfo
10897 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010898 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010899 pMac->roam.configParam.allowDFSChannelRoam =
10900 allowDFSChannelRoam;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010901 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
10902 csr_roam_offload_scan(pMac, sessionId,
10903 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10904 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
10905 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906 sme_release_global_lock(&pMac->sme);
10907 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010909
10910 return status;
10911}
10912
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010913/*
10914 * sme_get_dfs_scan_mode() - get DFS roam scan mode
10915 * This is a synchronous call
10916 *
10917 * hHal - The handle returned by mac_open.
10918 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
10919 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010920uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
10921{
10922 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924 return pMac->roam.configParam.allowDFSChannelRoam;
10925}
10926
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010927/*
10928 * sme_modify_add_ie() -
10929 * This function sends msg to updates the additional IE buffers in PE
10930 *
10931 * hHal - global structure
10932 * pModifyIE - pointer to tModifyIE structure
10933 * updateType - type of buffer
10934 * Return Success or failure
10935 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010936QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010937 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
10938{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010939 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010942 status = sme_acquire_global_lock(&pMac->sme);
10943
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010944 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
10946 sme_release_global_lock(&pMac->sme);
10947 }
10948 return status;
10949}
10950
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010951/*
10952 * sme_update_add_ie() -
10953 * This function sends msg to updates the additional IE buffers in PE
10954 *
10955 * hHal - global structure
10956 * pUpdateIE - pointer to structure tUpdateIE
10957 * updateType - type of buffer
10958 * Return Success or failure
10959 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010960QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010961 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
10962{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010963 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010964 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010966 status = sme_acquire_global_lock(&pMac->sme);
10967
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010968 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010969 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
10970 sme_release_global_lock(&pMac->sme);
10971 }
10972 return status;
10973}
10974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975/**
10976 * sme_update_dsc_pto_up_mapping()
10977 * @hHal: HAL context
10978 * @dscpmapping: pointer to DSCP mapping structure
10979 * @sessionId: SME session id
10980 *
10981 * This routine is called to update dscp mapping
10982 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010983 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010984 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010985QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053010986 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010987 uint8_t sessionId)
10988{
10989 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010990 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010991 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010992 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010993 tpPESession pSession = NULL;
10994
10995 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010996 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010997 return status;
10998 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
10999 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011000 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011001 FL("Session lookup fails for CSR session"));
11002 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011003 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011004 }
11005 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011006 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011007 FL("Invalid session Id %u"), sessionId);
11008 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011009 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011010 }
11011
11012 pSession = pe_find_session_by_bssid(pMac,
11013 pCsrSession->connectedProfile.bssid.bytes,
11014 &peSessionId);
11015
11016 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011018 FL(" Session lookup fails for BSSID"));
11019 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011020 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011021 }
11022
11023 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011024 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011025 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011026 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027 }
11028 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11029 for (j = pSession->QosMapSet.dscp_range[i][0];
11030 j <= pSession->QosMapSet.dscp_range[i][1];
11031 j++) {
11032 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11033 && (pSession->QosMapSet.dscp_range[i][1] ==
11034 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011035 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011036 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011037 FL("User Priority %d isn't used"), i);
11038 break;
11039 } else {
11040 dscpmapping[j] = i;
11041 }
11042 }
11043 }
11044 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11045 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11046 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11047 pSession->QosMapSet.dscp_exceptions[i][1];
11048
11049 sme_release_global_lock(&pMac->sme);
11050 return status;
11051}
11052
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011053/*
11054 * sme_abort_roam_scan() -
11055 * API to abort current roam scan cycle by roam scan offload module.
11056 *
11057 * hHal - The handle returned by mac_open.
11058 * sessionId - Session Identifier
11059 * Return QDF_STATUS
11060 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011061
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011062QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011063{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011064 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011067 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11068 /* acquire the lock for the sme object */
11069 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011070 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011071 csr_roam_offload_scan(pMac, sessionId,
11072 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11073 REASON_ROAM_ABORT_ROAM_SCAN);
11074 /* release the lock for the sme object */
11075 sme_release_global_lock(&pMac->sme);
11076 }
11077 }
11078
11079 return status;
11080}
11081
11082#ifdef FEATURE_WLAN_EXTSCAN
11083/**
11084 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11085 * @hHal: HAL context
11086 * @wifiBand: RF band information
11087 * @aValidChannels: output array to store channel info
11088 * @pNumChannels: output number of channels
11089 *
11090 * SME API to fetch all valid channels filtered by band
11091 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011092 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011093 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011094QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011095 uint8_t wifiBand,
11096 uint32_t *aValidChannels,
11097 uint8_t *pNumChannels)
11098{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011099 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011100 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011101 uint8_t numChannels = 0;
11102 uint8_t i = 0;
11103 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011104 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011105
11106 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011107 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011108 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011109 }
11110
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011111 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011112 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011113 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011114 }
11115
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011116 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011117 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011118 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011119 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011120 return status;
11121 }
11122
11123 switch (wifiBand) {
11124 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011125 sme_debug("Unspec Band, return all %d valid channels",
11126 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011127 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011128 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011130 break;
11131
11132 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011133 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011135 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011136 aValidChannels[numChannels++] =
11137 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011138 }
11139 break;
11140
11141 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011142 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011143 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011144 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011145 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011146 aValidChannels[numChannels++] =
11147 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011148 }
11149 break;
11150
11151 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011152 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011153 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011154 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11155 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011156 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 aValidChannels[numChannels++] =
11158 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 }
11160 break;
11161
11162 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011163 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011164 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011165 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011166 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011167 aValidChannels[numChannels++] =
11168 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011169 }
11170 break;
11171
11172 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011173 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011174 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011175 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011176 aValidChannels[numChannels++] =
11177 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011178 }
11179 break;
11180
11181 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011182 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011183 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011184 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011185 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011186 aValidChannels[numChannels++] =
11187 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011188 }
11189 break;
11190
11191 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011192 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011193 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011194 }
11195 *pNumChannels = numChannels;
11196
11197 return status;
11198}
11199
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011200/*
11201 * sme_ext_scan_get_capabilities() -
11202 * SME API to fetch extscan capabilities
11203 *
11204 * hHal
11205 * pReq: extscan capabilities structure
11206 * Return QDF_STATUS
11207 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011208QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011209 tSirGetExtScanCapabilitiesReqParams *
11210 pReq)
11211{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011212 QDF_STATUS status = QDF_STATUS_SUCCESS;
11213 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011214 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011215 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011216
11217 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011218 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011219 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011220 message.bodyptr = pReq;
11221 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011222 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011223 NO_SESSION, message.type));
11224 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11225 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011226 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11227 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011228
11229 sme_release_global_lock(&pMac->sme);
11230 }
11231 return status;
11232}
11233
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011234/*
11235 * sme_ext_scan_start() -
11236 * SME API to issue extscan start
11237 *
11238 * hHal
11239 * pStartCmd: extscan start structure
11240 * Return QDF_STATUS
11241 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011242QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011243 tSirWifiScanCmdReqParams *pStartCmd)
11244{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011245 QDF_STATUS status = QDF_STATUS_SUCCESS;
11246 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011247 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011248 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011249
11250 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011251 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011252 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011253 message.bodyptr = pStartCmd;
11254 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011255 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011256 NO_SESSION, message.type));
11257 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11258 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011259 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11260 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261
11262 sme_release_global_lock(&pMac->sme);
11263 }
11264 return status;
11265}
11266
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011267/*
11268 * sme_ext_scan_stop() -
11269 * SME API to issue extscan stop
11270 *
11271 * hHal
11272 * pStopReq: extscan stop structure
11273 * Return QDF_STATUS
11274 */
11275QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11276 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011277{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011278 QDF_STATUS status = QDF_STATUS_SUCCESS;
11279 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011280 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011281 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282
11283 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011284 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011286 message.bodyptr = pStopReq;
11287 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011288 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011289 NO_SESSION, message.type));
11290 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11291 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011292 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11293 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011294 sme_release_global_lock(&pMac->sme);
11295 }
11296 return status;
11297}
11298
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011299/*
11300 * sme_set_bss_hotlist() -
11301 * SME API to set BSSID hotlist
11302 *
11303 * hHal
11304 * pSetHotListReq: extscan set hotlist structure
11305 * Return QDF_STATUS
11306 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011307QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011308 tSirExtScanSetBssidHotListReqParams *
11309 pSetHotListReq)
11310{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011311 QDF_STATUS status = QDF_STATUS_SUCCESS;
11312 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011313 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011314 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011315
11316 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011317 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011318 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011319 message.bodyptr = pSetHotListReq;
11320 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011321 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011322 NO_SESSION, message.type));
11323 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11324 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011325 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11326 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327
11328 sme_release_global_lock(&pMac->sme);
11329 }
11330 return status;
11331}
11332
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011333/*
11334 * sme_reset_bss_hotlist() -
11335 * SME API to reset BSSID hotlist
11336 *
11337 * hHal
11338 * pSetHotListReq: extscan set hotlist structure
11339 * Return QDF_STATUS
11340 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011341QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 tSirExtScanResetBssidHotlistReqParams *
11343 pResetReq)
11344{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011345 QDF_STATUS status = QDF_STATUS_SUCCESS;
11346 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011347 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011348 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011349
11350 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011351 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011352 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011353 message.bodyptr = pResetReq;
11354 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011355 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011356 NO_SESSION, message.type));
11357 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11358 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011359 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11360 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011361
11362 sme_release_global_lock(&pMac->sme);
11363 }
11364 return status;
11365}
11366
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011367/*
11368 * sme_set_significant_change() -
11369 * SME API to set significant change
11370 *
11371 * hHal
11372 * pSetSignificantChangeReq: extscan set significant change structure
11373 * Return QDF_STATUS
11374 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011375QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011376 tSirExtScanSetSigChangeReqParams *
11377 pSetSignificantChangeReq)
11378{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011379 QDF_STATUS status = QDF_STATUS_SUCCESS;
11380 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011382 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011383
11384 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011385 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011386 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011387 message.bodyptr = pSetSignificantChangeReq;
11388 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011389 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011390 NO_SESSION, message.type));
11391 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11392 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011393 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11394 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011395
11396 sme_release_global_lock(&pMac->sme);
11397 }
11398 return status;
11399}
11400
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011401/*
11402 * sme_reset_significant_change
11403 * SME API to reset significant change
11404 *
11405 * hHal
11406 * pResetReq: extscan reset significant change structure
11407 * Return QDF_STATUS
11408 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011409QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011410 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011411 *pResetReq)
11412{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011413 QDF_STATUS status = QDF_STATUS_SUCCESS;
11414 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011416 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011417
11418 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011419 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011420 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011421 message.bodyptr = pResetReq;
11422 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011423 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011424 NO_SESSION, message.type));
11425 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11426 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011427 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11428 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011429
11430 sme_release_global_lock(&pMac->sme);
11431 }
11432 return status;
11433}
11434
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011435/*
11436 * sme_get_cached_results() -
11437 * SME API to get cached results
11438 *
11439 * hHal
11440 * pCachedResultsReq: extscan get cached results structure
11441 * Return QDF_STATUS
11442 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011443QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011444 tSirExtScanGetCachedResultsReqParams *
11445 pCachedResultsReq)
11446{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011447 QDF_STATUS status = QDF_STATUS_SUCCESS;
11448 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011449 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011450 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011451
11452 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011453 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011454 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011455 message.bodyptr = pCachedResultsReq;
11456 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011457 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011458 NO_SESSION, message.type));
11459 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11460 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011461 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11462 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463
11464 sme_release_global_lock(&pMac->sme);
11465 }
11466 return status;
11467}
11468
11469/**
11470 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011471 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011472 * @input: request message
11473 *
11474 * This function constructs the cds message and fill in message type,
11475 * bodyptr with %input and posts it to WDA queue.
11476 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011477 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011478 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011479QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011480 struct wifi_epno_params *input)
11481{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011482 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011484 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011485 struct wifi_epno_params *req_msg;
11486 int len, i;
11487
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011488 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011489 len = sizeof(*req_msg) +
11490 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011491
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011492 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011493 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011494 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011495 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011496 }
11497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011498 req_msg->num_networks = input->num_networks;
11499 req_msg->request_id = input->request_id;
11500 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011501
11502 /* Fill only when num_networks are non zero */
11503 if (req_msg->num_networks) {
11504 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11505 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11506 req_msg->initial_score_max = input->initial_score_max;
11507 req_msg->same_network_bonus = input->same_network_bonus;
11508 req_msg->secure_bonus = input->secure_bonus;
11509 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11510 req_msg->current_connection_bonus =
11511 input->current_connection_bonus;
11512
11513 for (i = 0; i < req_msg->num_networks; i++) {
11514 req_msg->networks[i].flags = input->networks[i].flags;
11515 req_msg->networks[i].auth_bit_field =
11516 input->networks[i].auth_bit_field;
11517 req_msg->networks[i].ssid.length =
11518 input->networks[i].ssid.length;
11519 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11520 input->networks[i].ssid.ssId,
11521 req_msg->networks[i].ssid.length);
11522 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011523 }
11524
11525 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011526 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011527 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011528 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011529 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011530 return status;
11531 }
11532
11533 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011534 message.bodyptr = req_msg;
11535 message.type = WMA_SET_EPNO_LIST_REQ;
11536 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011537 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011538 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011539 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011540 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011541 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 }
11543 sme_release_global_lock(&mac->sme);
11544 return status;
11545}
11546
11547/**
11548 * sme_set_passpoint_list() - set passpoint network list
11549 * @hal: global hal handle
11550 * @input: request message
11551 *
11552 * This function constructs the cds message and fill in message type,
11553 * bodyptr with @input and posts it to WDA queue.
11554 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011555 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011556 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011557QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558 struct wifi_passpoint_req *input)
11559{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011560 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011561 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011562 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 struct wifi_passpoint_req *req_msg;
11564 int len, i;
11565
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011566 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011567 len = sizeof(*req_msg) +
11568 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011569 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011570 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011571 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011572 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 }
11574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575 req_msg->num_networks = input->num_networks;
11576 req_msg->request_id = input->request_id;
11577 req_msg->session_id = input->session_id;
11578 for (i = 0; i < req_msg->num_networks; i++) {
11579 req_msg->networks[i].id =
11580 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011581 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 input->networks[i].realm,
11583 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011584 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011585 input->networks[i].plmn,
11586 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011587 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011588 input->networks[i].roaming_consortium_ids,
11589 sizeof(req_msg->networks[i].roaming_consortium_ids));
11590 }
11591
11592 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011593 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011594 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011595 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011596 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011597 return status;
11598 }
11599
11600 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011601 message.bodyptr = req_msg;
11602 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11603 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011604 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011605 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011606 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011607 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011608 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011609 }
11610 sme_release_global_lock(&mac->sme);
11611 return status;
11612}
11613
11614/**
11615 * sme_reset_passpoint_list() - reset passpoint network list
11616 * @hHal: global hal handle
11617 * @input: request message
11618 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011619 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011620 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011621QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011622 struct wifi_passpoint_req *input)
11623{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011624 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011625 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011626 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011627 struct wifi_passpoint_req *req_msg;
11628
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011629 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011630 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011631 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011632 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011633 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011634 }
11635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011636 req_msg->request_id = input->request_id;
11637 req_msg->session_id = input->session_id;
11638
11639 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011640 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011641 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011642 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011643 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011644 return status;
11645 }
11646
11647 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011648 message.bodyptr = req_msg;
11649 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11650 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011651 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011652 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011653 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011654 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011655 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011656 }
11657 sme_release_global_lock(&mac->sme);
11658 return status;
11659}
11660
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011661QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011662 void (*pExtScanIndCb)(void *,
11663 const uint16_t,
11664 void *))
11665{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011666 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11668
11669 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011670 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011671 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11672 sme_release_global_lock(&pMac->sme);
11673 }
11674 return status;
11675}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011676#endif /* FEATURE_WLAN_EXTSCAN */
11677
Wen Gong7952fbd2018-04-18 11:27:23 +080011678/**
11679 * sme_send_wisa_params(): Pass WISA mode to WMA
11680 * @hal: HAL context
11681 * @wisa_params: pointer to WISA params struct
11682 * @sessionId: SME session id
11683 *
11684 * Pass WISA params to WMA
11685 *
11686 * Return: QDF_STATUS
11687 */
11688QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11689 struct sir_wisa_params *wisa_params)
11690{
11691 QDF_STATUS status = QDF_STATUS_SUCCESS;
11692 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11693 struct scheduler_msg message = {0};
11694 struct sir_wisa_params *cds_msg_wisa_params;
11695
11696 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11697 if (!cds_msg_wisa_params)
11698 return QDF_STATUS_E_NOMEM;
11699
11700 *cds_msg_wisa_params = *wisa_params;
11701 status = sme_acquire_global_lock(&mac->sme);
11702 if (QDF_IS_STATUS_SUCCESS(status)) {
11703 message.bodyptr = cds_msg_wisa_params;
11704 message.type = WMA_SET_WISA_PARAMS;
11705 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
11706 sme_release_global_lock(&mac->sme);
11707 }
11708 return status;
11709}
11710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011711#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11712
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011713/*
11714 * sme_ll_stats_clear_req() -
11715 * SME API to clear Link Layer Statistics
11716 *
11717 * hHal
11718 * pclearStatsReq: Link Layer clear stats request params structure
11719 * Return QDF_STATUS
11720 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011721QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011722 tSirLLStatsClearReq *pclearStatsReq)
11723{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011724 QDF_STATUS status = QDF_STATUS_SUCCESS;
11725 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011727 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728 tSirLLStatsClearReq *clear_stats_req;
11729
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011730 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011732 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 "statsClearReqMask = 0x%X",
11734 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011735 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011736 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011737 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11739 "%s: invalid staId %d",
11740 __func__, pclearStatsReq->staId);
11741 return QDF_STATUS_E_INVAL;
11742 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011744 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011745
11746 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011747 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011748 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11749 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011750 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011751 }
11752
11753 *clear_stats_req = *pclearStatsReq;
11754
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011755 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011756 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011757 message.bodyptr = clear_stats_req;
11758 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011759 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011760 NO_SESSION, message.type));
11761 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11762 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011763 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011764 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011765 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11766 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011767 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011768 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011769 }
11770 sme_release_global_lock(&pMac->sme);
11771 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011772 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11773 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011774 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011775 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011776 }
11777
11778 return status;
11779}
11780
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011781/*
11782 * sme_ll_stats_set_req() -
11783 * SME API to set the Link Layer Statistics
11784 *
11785 * hHal
11786 * psetStatsReq: Link Layer set stats request params structure
11787 * Return QDF_STATUS
11788 */
11789QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11790 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011791{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011792 QDF_STATUS status = QDF_STATUS_SUCCESS;
11793 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011795 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796 tSirLLStatsSetReq *set_stats_req;
11797
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011799 "%s: MPDU Size = %u", __func__,
11800 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011801 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 " Aggressive Stats Collections = %u",
11803 psetStatsReq->aggressiveStatisticsGathering);
11804
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011805 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011806
11807 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011808 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11810 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011811 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812 }
11813
11814 *set_stats_req = *psetStatsReq;
11815
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011816 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011817 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011818 message.bodyptr = set_stats_req;
11819 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011820 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011821 NO_SESSION, message.type));
11822 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11823 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011824 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011825 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011826 "%s: not able to post WMA_LL_STATS_SET_REQ",
11827 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011828 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011829 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011830 }
11831 sme_release_global_lock(&pMac->sme);
11832 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011833 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11834 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011835 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011836 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011837 }
11838
11839 return status;
11840}
11841
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011842/*
11843 * sme_ll_stats_get_req() -
11844 * SME API to get the Link Layer Statistics
11845 *
11846 * hHal
11847 * pgetStatsReq: Link Layer get stats request params structure
11848 * Return QDF_STATUS
11849 */
11850QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
11851 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011852{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011853 QDF_STATUS status = QDF_STATUS_SUCCESS;
11854 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011855 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011856 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 tSirLLStatsGetReq *get_stats_req;
11858
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011859 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011860
11861 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011862 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011863 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
11864 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011865 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011866 }
11867
11868 *get_stats_req = *pgetStatsReq;
11869
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011870 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011871 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011872 message.bodyptr = get_stats_req;
11873 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011874 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011875 NO_SESSION, message.type));
11876 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11877 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011878 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011879 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011880 "%s: not able to post WMA_LL_STATS_GET_REQ",
11881 __func__);
11882
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011883 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011884 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011885
11886 }
11887 sme_release_global_lock(&pMac->sme);
11888 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011889 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11890 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011891 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011892 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011893 }
11894
11895 return status;
11896}
11897
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011898/*
11899 * sme_set_link_layer_stats_ind_cb() -
11900 * SME API to trigger the stats are available after get request
11901 *
11902 * hHal
11903 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011904 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011905 * Return QDF_STATUS
11906 */
11907QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
11908 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
11909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011910 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11912
11913 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011914 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011915 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
11916 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011917 } else
11918 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11919 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011920
11921 return status;
11922}
11923
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011924/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080011925 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
11926 * @hal: Mac global handle
11927 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
11928 * status notification from FW
11929 *
11930 * Return: eHalStatus
11931 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011932QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
Jeff Johnson2d292122018-06-02 21:02:02 -070011933 (hdd_handle_t callback_ctx, tSirLLStatsResults
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011934 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080011935{
11936 QDF_STATUS status;
11937 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11938
11939 status = sme_acquire_global_lock(&mac->sme);
11940 if (status == QDF_STATUS_SUCCESS) {
11941 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
11942 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011943 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080011944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11945 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080011946 return status;
11947}
11948
11949/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011950 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
11951 * indication
11952 * @h_hal: Hal Handle
11953 *
11954 * This function reset's the link layer stats indication
11955 *
11956 * Return: QDF_STATUS Enumeration
11957 */
11958
11959QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
11960{
11961 QDF_STATUS status;
11962 tpAniSirGlobal pmac;
11963
11964 if (!h_hal) {
11965 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11966 FL("hHal is not valid"));
11967 return QDF_STATUS_E_INVAL;
11968 }
11969 pmac = PMAC_STRUCT(h_hal);
11970
11971 status = sme_acquire_global_lock(&pmac->sme);
11972 if (QDF_IS_STATUS_SUCCESS(status)) {
11973 pmac->sme.pLinkLayerStatsIndCallback = NULL;
11974 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011975 } else
11976 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11977 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011978
11979 return status;
11980}
11981
Zhang Qian73c348a2017-03-13 16:15:55 +080011982/**
11983 * sme_ll_stats_set_thresh - set threshold for mac counters
11984 * @hal, hal layer handle
11985 * @threshold, threshold for mac counters
11986 *
11987 * Return: QDF_STATUS Enumeration
11988 */
11989QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
11990 struct sir_ll_ext_stats_threshold *threshold)
11991{
11992 QDF_STATUS status;
11993 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080011994 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080011995 struct sir_ll_ext_stats_threshold *thresh;
11996
11997 if (!threshold) {
11998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11999 FL("threshold is not valid"));
12000 return QDF_STATUS_E_INVAL;
12001 }
12002
12003 if (!hal) {
12004 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12005 FL("hal is not valid"));
12006 return QDF_STATUS_E_INVAL;
12007 }
12008 mac = PMAC_STRUCT(hal);
12009
12010 thresh = qdf_mem_malloc(sizeof(*thresh));
12011 if (!thresh) {
12012 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12013 "%s: Fail to alloc mem", __func__);
12014 return QDF_STATUS_E_NOMEM;
12015 }
12016 *thresh = *threshold;
12017
12018 status = sme_acquire_global_lock(&mac->sme);
12019 if (QDF_IS_STATUS_SUCCESS(status)) {
12020 /* Serialize the req through MC thread */
12021 message.bodyptr = thresh;
12022 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12023 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12024 NO_SESSION, message.type));
12025 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12026 if (!QDF_IS_STATUS_SUCCESS(status)) {
12027 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12028 "%s: not able to post WDA_LL_STATS_GET_REQ",
12029 __func__);
12030 qdf_mem_free(thresh);
12031 }
12032 sme_release_global_lock(&mac->sme);
12033 } else {
12034 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12035 FL("sme_acquire_global_lock error"));
12036 qdf_mem_free(thresh);
12037 }
12038 return status;
12039}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012041#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12042
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012043#ifdef WLAN_POWER_DEBUGFS
12044/**
12045 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12046 * @callback_fn: Pointer to the callback function for Power stats event
12047 * @power_stats_context: Pointer to context
12048 *
12049 * Return: QDF_STATUS
12050 */
12051QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12052 (struct power_stats_response *response,
12053 void *context), void *power_stats_context)
12054{
12055 QDF_STATUS status = QDF_STATUS_SUCCESS;
12056 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012057 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012058
12059 status = sme_acquire_global_lock(&mac_ctx->sme);
12060 if (QDF_IS_STATUS_SUCCESS(status)) {
12061 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012062 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012063 sme_release_global_lock(&mac_ctx->sme);
12064 return QDF_STATUS_E_FAILURE;
12065 }
12066
12067 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12068 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12069 msg.bodyptr = NULL;
12070 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012071 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012072 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012073 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012074 sme_release_global_lock(&mac_ctx->sme);
12075 }
12076 return status;
12077}
12078#endif
12079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012081/*
12082 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12083 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12084 *
12085 * hHal - The handle returned by mac_open.
12086 * nRoamOffloadEnabled - The bool to update with
12087 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12088 * Other status means SME is failed to update.
12089 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012090
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012091QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012092 bool nRoamOffloadEnabled)
12093{
12094 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012095 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012096
12097 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012098 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012100 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12101 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12102 nRoamOffloadEnabled);
12103 pMac->roam.configParam.isRoamOffloadEnabled =
12104 nRoamOffloadEnabled;
12105 sme_release_global_lock(&pMac->sme);
12106 }
12107
12108 return status;
12109}
12110
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012111/**
12112 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12113 * This is a synchronous call
12114 * @hal_ctx: The handle returned by mac_open.
12115 * @session_id: Session Identifier
12116 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012117 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012118 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12119 * Other status means SME is failed to update.
12120 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012121
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012122QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012123 uint8_t session_id,
12124 bool key_mgmt_offload_enabled,
12125 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012126{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012127 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012129
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012130 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012131 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012132 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012133 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012134 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12135 __func__, key_mgmt_offload_enabled);
12136 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12137 session_id,
12138 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012139 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012140 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012141 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012142 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143 }
12144
12145 return status;
12146}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012147#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012148
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012149/*
12150 * sme_get_temperature() -
12151 * SME API to get the pdev temperature
12152 *
12153 * hHal
12154 * temperature context
12155 * pCallbackfn: callback fn with response (temperature)
12156 * Return QDF_STATUS
12157 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012158QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012159 void *tempContext,
12160 void (*pCallbackfn)(int temperature,
12161 void *pContext))
12162{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012163 QDF_STATUS status = QDF_STATUS_SUCCESS;
12164 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012166 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012167
12168 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012169 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012170 if ((NULL == pCallbackfn) &&
12171 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012172 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012173 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012174 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012175 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012176 } else if (NULL != pCallbackfn) {
12177 pMac->sme.pTemperatureCbContext = tempContext;
12178 pMac->sme.pGetTemperatureCb = pCallbackfn;
12179 }
12180 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012181 message.bodyptr = NULL;
12182 message.type = WMA_GET_TEMPERATURE_REQ;
12183 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12184 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012185 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
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 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012188 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012189 }
12190 sme_release_global_lock(&pMac->sme);
12191 }
12192 return status;
12193}
12194
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012195/*
12196 * sme_set_scanning_mac_oui() -
12197 * SME API to set scanning mac oui
12198 *
12199 * hHal
12200 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12201 * Return QDF_STATUS
12202 */
12203QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12204 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012205{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012206 QDF_STATUS status = QDF_STATUS_SUCCESS;
12207 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012209 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012210
12211 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012212 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012213 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012214 message.bodyptr = pScanMacOui;
12215 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12216 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12217 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012218 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012219 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012220 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012221 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012222 }
12223 sme_release_global_lock(&pMac->sme);
12224 }
12225 return status;
12226}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012227
12228#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012229/*
12230 * sme_set_dhcp_srv_offload() -
12231 * SME API to set DHCP server offload info
12232 *
12233 * hHal
12234 * pDhcpSrvInfo : DHCP server offload info struct
12235 * Return QDF_STATUS
12236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012237QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012238 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12239{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012240 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012241 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012242 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012243 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12244
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012245 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012246
12247 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012249 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12250 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012251 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012252 }
12253
12254 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12255
12256 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012257 if (QDF_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.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12260 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012261
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012262 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012263 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12264 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012266 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012267 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012268 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012269 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012270 }
12271 sme_release_global_lock(&pMac->sme);
12272 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012273 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012274 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012275 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012276 }
12277
12278 return status;
12279}
12280#endif /* DHCP_SERVER_OFFLOAD */
12281
Krunal Soniaadaa272017-10-04 16:42:55 -070012282QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12283 uint32_t arg_count, uint32_t *arg)
12284{
12285 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12286 arg_count, arg);
12287}
12288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012289#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012290/*
12291 * sme_set_led_flashing() -
12292 * API to set the Led flashing parameters.
12293 *
12294 * hHal - The handle returned by mac_open.
12295 * x0, x1 - led flashing parameters
12296 * Return QDF_STATUS
12297 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012298QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012299 uint32_t x0, uint32_t x1)
12300{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012301 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012303 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012304 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012305
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012306 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012307 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012309 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012310 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012311 }
12312
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012313 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012314 ledflashing->pattern_id = type;
12315 ledflashing->led_x0 = x0;
12316 ledflashing->led_x1 = x1;
12317
12318 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012319 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012320 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012321 message.bodyptr = ledflashing;
12322 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012323 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012324 sme_release_global_lock(&pMac->sme);
12325 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012326 if (!QDF_IS_STATUS_SUCCESS(status))
12327 qdf_mem_free(ledflashing);
12328
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012329 return status;
12330}
12331#endif
12332
12333/**
12334 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12335 * @h_hal: corestack handler
12336 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012337 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012339QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012341 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012342 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12343
12344 status = sme_acquire_global_lock(&mac->sme);
12345
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012346 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012347
12348 mac->scan.fEnableDFSChnlScan = dfs_flag;
12349
12350 /* update the channel list to the firmware */
12351 status = csr_update_channel_list(mac);
12352
12353 sme_release_global_lock(&mac->sme);
12354 }
12355
12356 return status;
12357}
12358
Min Liu5eaf7242018-03-13 17:32:15 +080012359/**
12360 * sme_enable_dfS_chan_scan() - set DFS channel scan enable/disable
12361 * @h_hal: corestack handler
12362 * @dfs_flag: flag indicating dfs channel enable/disable
12363 * Return: QDF_STATUS
12364 */
12365QDF_STATUS sme_enable_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
12366{
12367 QDF_STATUS status = QDF_STATUS_SUCCESS;
12368 tpAniSirGlobal mac;
12369
12370 if (!h_hal) {
12371 sme_err("hal is NULL");
12372 return QDF_STATUS_E_INVAL;
12373 }
12374
12375 mac = PMAC_STRUCT(h_hal);
12376 if (!mac) {
12377 sme_err("mac is NULL");
12378 return QDF_STATUS_E_INVAL;
12379 }
12380
12381 mac->scan.fEnableDFSChnlScan = dfs_flag;
12382
12383 return status;
12384}
12385
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012386#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12387/**
12388 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12389 * concurreny rules set to avoid channel interference.
12390 * @hal - Hal context
12391 * @sap_ch - channel to switch
12392 * @sap_phy_mode - phy mode of SAP
12393 * @cc_switch_mode - concurreny switch mode
12394 * @session_id - sme session id.
12395 *
12396 * Return: true if there is no channel interference else return false
12397 */
12398bool sme_validate_sap_channel_switch(tHalHandle hal,
12399 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12400 uint8_t session_id)
12401{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012402 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012403 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012404 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012405 uint16_t intf_channel = 0;
12406
12407 if (!session)
12408 return false;
12409
12410 session->ch_switch_in_progress = true;
12411 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012412 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012413 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12414 sap_phy_mode,
12415 cc_switch_mode);
12416 sme_release_global_lock(&mac->sme);
12417 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012418 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012419 FL("sme_acquire_global_lock error!"));
12420 session->ch_switch_in_progress = false;
12421 return false;
12422 }
12423
12424 session->ch_switch_in_progress = false;
12425 return (intf_channel == 0) ? true : false;
12426}
12427#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012428
12429/**
12430 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12431 * @hal: hal
12432 * @session_id: session ID
12433 * @stats_avg_factor: average stats factor
12434 *
12435 * This function configures the stats avg factor in firmware
12436 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012437 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012439QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440 uint16_t stats_avg_factor)
12441{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012442 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012443 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012444 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12445 struct sir_stats_avg_factor *stats_factor;
12446
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012447 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012448
12449 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012450 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012451 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12452 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012453 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012454 }
12455
12456 status = sme_acquire_global_lock(&mac->sme);
12457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012458 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459
12460 stats_factor->vdev_id = session_id;
12461 stats_factor->stats_avg_factor = stats_avg_factor;
12462
12463 /* serialize the req through MC thread */
12464 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12465 msg.bodyptr = stats_factor;
12466
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012467 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012468 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012469 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012470 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12471 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012472 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012473 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012474 }
12475 sme_release_global_lock(&mac->sme);
12476 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012477 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012478 "%s: sme_acquire_global_lock error!",
12479 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012480 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012481 }
12482
12483 return status;
12484}
12485
12486/**
12487 * sme_configure_guard_time() - function to configure guard time
12488 * @hal: hal
12489 * @session_id: session id
12490 * @guard_time: guard time
12491 *
12492 * This function configures the guard time in firmware
12493 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012494 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012495 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012496QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012497 uint32_t guard_time)
12498{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012499 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012500 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12502 struct sir_guard_time_request *g_time;
12503
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012504 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012505
12506 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012507 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012508 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12509 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012510 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012511 }
12512
12513 status = sme_acquire_global_lock(&mac->sme);
12514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012515 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012516
12517 g_time->vdev_id = session_id;
12518 g_time->guard_time = guard_time;
12519
12520 /* serialize the req through MC thread */
12521 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12522 msg.bodyptr = g_time;
12523
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012524 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012525 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012527 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12528 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012529 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012530 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012531 }
12532 sme_release_global_lock(&mac->sme);
12533 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012534 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012535 "%s: sme_acquire_global_lock error!",
12536 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012537 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012538 }
12539
12540 return status;
12541}
12542
12543/**
12544 * sme_configure_modulated_dtim() - function to configure modulated dtim
12545 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12546 * @session_id: session ID
12547 * @modulated_dtim: modulated dtim value
12548 *
12549 * This function configures the modulated dtim in firmware
12550 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012551 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012553QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012554 uint32_t modulated_dtim)
12555{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012556 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012557 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012558 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12559 wma_cli_set_cmd_t *iwcmd;
12560
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012561 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012563 QDF_TRACE(QDF_MODULE_ID_SME,
12564 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012565 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012566 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012567 }
12568
12569 status = sme_acquire_global_lock(&mac->sme);
12570
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012571 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012573 iwcmd->param_value = modulated_dtim;
12574 iwcmd->param_vdev_id = session_id;
12575 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12576 iwcmd->param_vp_dev = GEN_CMD;
12577 msg.type = WMA_CLI_SET_CMD;
12578 msg.reserved = 0;
12579 msg.bodyptr = (void *)iwcmd;
12580
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012581 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012582 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012583 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012584 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12585 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012586 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012587 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012588 }
12589 sme_release_global_lock(&mac->sme);
12590 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592 "%s: sme_acquire_global_lock error!",
12593 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012594 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012595 }
12596
12597 return status;
12598}
12599
Mukul Sharma6398b252017-05-01 17:58:12 +053012600/**
12601 * sme_override_listen_interval() - function to override static LI
12602 * @h_hal: SME API to override listen interval
12603 * @session_id: session ID
12604 * @override_li: new LI value passed by user
12605 *
12606 * This function override (enable/disable) static a.k.a ini based LI
12607 *
12608 * Return: QDF_STATUS
12609 */
12610QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12611 uint32_t override_li)
12612{
12613 struct scheduler_msg msg = {0};
12614 QDF_STATUS status = QDF_STATUS_SUCCESS;
12615 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12616 wma_cli_set_cmd_t *iwcmd;
12617
12618 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12619 if (!iwcmd) {
12620 QDF_TRACE(QDF_MODULE_ID_SME,
12621 QDF_TRACE_LEVEL_FATAL,
12622 "%s: qdf_mem_malloc failed", __func__);
12623 return QDF_STATUS_E_NOMEM;
12624 }
12625
12626 status = sme_acquire_global_lock(&mac->sme);
12627
12628 if (status == QDF_STATUS_SUCCESS) {
12629
12630 iwcmd->param_value = override_li;
12631 iwcmd->param_vdev_id = session_id;
12632 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12633 iwcmd->param_vp_dev = GEN_CMD;
12634 msg.type = WMA_CLI_SET_CMD;
12635 msg.reserved = 0;
12636 msg.bodyptr = (void *)iwcmd;
12637
12638 if (!QDF_IS_STATUS_SUCCESS(
12639 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12640 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12641 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12642 __func__);
12643 qdf_mem_free(iwcmd);
12644 status = QDF_STATUS_E_FAILURE;
12645 }
12646 sme_release_global_lock(&mac->sme);
12647 } else {
12648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12649 "%s: sme_acquire_global_lock error!",
12650 __func__);
12651 qdf_mem_free(iwcmd);
12652 }
12653
12654 return status;
12655}
12656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012657/*
12658 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12659 * to either start/stop logging
12660 * @hal: HAL context
12661 * @start_log: Structure containing the wifi start logger params
12662 *
12663 * This function sends the start/stop logging command to WMA
12664 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012665 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012666 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012667QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012668 struct sir_wifi_start_log start_log)
12669{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012670 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012671 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012672 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 struct sir_wifi_start_log *req_msg;
12674 uint32_t len;
12675
12676 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012677 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012678 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012679 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012680 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012681 }
12682
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012683 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012684 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012685 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012686 req_msg->ini_triggered = start_log.ini_triggered;
12687 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012688 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012689 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012690
12691 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012692 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012693 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012694 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012695 return status;
12696 }
12697
12698 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012699 message.bodyptr = req_msg;
12700 message.type = SIR_HAL_START_STOP_LOGGING;
12701 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012702 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012703 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012704 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012705 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012706 }
12707 sme_release_global_lock(&mac->sme);
12708
12709 return status;
12710}
12711
12712/**
12713 * sme_neighbor_middle_of_roaming() - Function to know if
12714 * STA is in the middle of roaming states
12715 * @hal: Handle returned by macOpen
12716 * @sessionId: sessionId of the STA session
12717 *
12718 * This function is a wrapper to call
12719 * csr_neighbor_middle_of_roaming to know STA is in the
12720 * middle of roaming states
12721 *
12722 * Return: True or False
12723 *
12724 */
12725bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12726{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012727 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12728 bool val = false;
12729
12730 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12731 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12732 else
Rajeev Kumar9176ca42018-05-03 09:20:40 -070012733 sme_debug("Invalid Session: %d", sessionId);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012734
Sandeep Puligillaca631612016-11-08 11:53:52 -080012735 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012736}
12737
12738/*
12739 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12740 * @mac: MAC handle
12741 *
12742 * This function is used to send the command that will
12743 * be used to flush the logs in the firmware
12744 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012745 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012746 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012747QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012748{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012749 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012750 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012752 /* Serialize the req through MC thread */
12753 message.bodyptr = NULL;
12754 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012755 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012756 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012757 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012758 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012759 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012760 return status;
12761}
12762
Jeff Johnsona1e92612017-09-24 15:33:44 -070012763QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012764 sme_ac_enum_type ac, uint8_t tid,
12765 uint8_t pri, uint32_t srvc_int,
12766 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012767 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012768 uint8_t psb, uint32_t sessionId,
12769 uint32_t delay_interval)
12770{
12771 void *wma_handle;
12772 t_wma_trigger_uapsd_params uapsd_params;
12773 enum uapsd_ac access_category;
12774
12775 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012777 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012778 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012779 }
12780
Anurag Chouhan6d760662016-02-20 16:05:43 +053012781 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012782 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012783 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012784 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012785 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786 }
12787
12788 switch (ac) {
12789 case SME_AC_BK:
12790 access_category = UAPSD_BK;
12791 break;
12792 case SME_AC_BE:
12793 access_category = UAPSD_BE;
12794 break;
12795 case SME_AC_VI:
12796 access_category = UAPSD_VI;
12797 break;
12798 case SME_AC_VO:
12799 access_category = UAPSD_VO;
12800 break;
12801 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012802 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012803 }
12804
12805 uapsd_params.wmm_ac = access_category;
12806 uapsd_params.user_priority = pri;
12807 uapsd_params.service_interval = srvc_int;
12808 uapsd_params.delay_interval = delay_interval;
12809 uapsd_params.suspend_interval = sus_int;
12810
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012811 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012812 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012814 "Failed to Trigger Uapsd params for sessionId %d",
12815 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012816 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012817 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012818 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012819}
12820
Jeff Johnsona1e92612017-09-24 15:33:44 -070012821QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012822 sme_ac_enum_type ac,
12823 uint32_t sessionId)
12824{
12825 void *wma_handle;
12826 enum uapsd_ac access_category;
12827
12828 switch (ac) {
12829 case SME_AC_BK:
12830 access_category = UAPSD_BK;
12831 break;
12832 case SME_AC_BE:
12833 access_category = UAPSD_BE;
12834 break;
12835 case SME_AC_VI:
12836 access_category = UAPSD_VI;
12837 break;
12838 case SME_AC_VO:
12839 access_category = UAPSD_VO;
12840 break;
12841 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012842 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012843 }
12844
Anurag Chouhan6d760662016-02-20 16:05:43 +053012845 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012846 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012847 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012848 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012849 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012851 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012852 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012853 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012854 "Failed to disable uapsd for ac %d for sessionId %d",
12855 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012856 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012857 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012858 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012859}
12860
12861/**
12862 * sme_update_nss() - SME API to change the number for spatial streams
12863 * (1 or 2)
12864 * @hal: Handle returned by mac open
12865 * @nss: Number of spatial streams
12866 *
12867 * This function is used to update the number of spatial streams supported.
12868 *
12869 * Return: Success upon successfully changing nss else failure
12870 *
12871 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012872QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012873{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012874 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012875 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
12876 uint32_t i, value = 0;
12877 union {
12878 uint16_t cfg_value16;
12879 tSirMacHTCapabilityInfo ht_cap_info;
12880 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012881 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012882
12883 status = sme_acquire_global_lock(&mac_ctx->sme);
12884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012885 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012886 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
12887
12888 /* get the HT capability info*/
12889 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
12890 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
12891
12892 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
12893 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
12894 csr_session = &mac_ctx->roam.roamSession[i];
12895 csr_session->htConfig.ht_tx_stbc =
12896 uHTCapabilityInfo.ht_cap_info.txSTBC;
12897 }
12898 }
12899
12900 sme_release_global_lock(&mac_ctx->sme);
12901 }
12902 return status;
12903}
12904
12905/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070012906 * sme_update_user_configured_nss() - sets the nss based on user request
12907 * @hal: Pointer to HAL
12908 * @nss: number of streams
12909 *
12910 * Return: None
12911 */
12912void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
12913{
12914 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12915
12916 mac_ctx->user_configured_nss = nss;
12917}
12918
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012919int sme_update_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12920 uint8_t cfg_val)
12921{
12922 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12923 QDF_STATUS status = QDF_STATUS_SUCCESS;
12924 status = sme_cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
12925 cfg_val);
12926 if (status != QDF_STATUS_SUCCESS) {
12927 sme_err("Failed to set SU BFEE CFG");
12928 return -EFAULT;
12929 }
12930
12931 return sme_update_he_tx_bfee_supp(hal, session_id, cfg_val);
12932}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012933#ifdef WLAN_FEATURE_11AX
12934void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
12935 uint8_t nss)
12936{
12937 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12938 struct csr_roam_session *csr_session;
12939 uint32_t tx_mcs_map = 0;
12940 uint32_t rx_mcs_map = 0;
12941
12942 if (!nss || (nss > 2)) {
12943 sme_err("invalid Nss value %d", nss);
12944 }
12945 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12946 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
12947 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
12948 if (nss == 1) {
12949 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
12950 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
12951 } else {
12952 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_0_11, 2);
12953 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_0_11, 2);
12954 }
12955 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
12956 rx_mcs_map, tx_mcs_map);
12957 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
12958 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
12959 csr_update_session_he_cap(mac_ctx, csr_session);
12960
12961}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012962
12963int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
12964{
12965 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12966 struct csr_roam_session *csr_session;
12967 uint16_t mcs_val = 0;
12968 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
12969 uint32_t wni_cfg_tx_param = 0;
12970 uint32_t wni_cfg_rx_param = 0;
12971
12972 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12973 if (!csr_session) {
12974 sme_err("No session for id %d", session_id);
12975 return -EINVAL;
12976 }
12977 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
12978 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
12979 he_mcs);
12980 return -EINVAL;
12981 }
12982 mcs_val = he_mcs & 0x3;
12983 switch (he_mcs) {
12984 case HE_80_MCS0_7:
12985 case HE_80_MCS0_9:
12986 case HE_80_MCS0_11:
12987 if (mac_ctx->roam.configParam.enable2x2) {
12988 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12989 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
12990 } else {
12991 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12992 }
12993 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
12994 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
12995 break;
12996
12997 case HE_160_MCS0_7:
12998 case HE_160_MCS0_9:
12999 case HE_160_MCS0_11:
13000 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13001 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
13002 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
13003 break;
13004
13005 case HE_80p80_MCS0_7:
13006 case HE_80p80_MCS0_9:
13007 case HE_80p80_MCS0_11:
13008 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13009 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
13010 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
13011 break;
13012
13013 default:
13014 sme_err("Invalid HE MCS 0x%0x", he_mcs);
13015 return -EINVAL;
13016 }
13017 sme_info("new HE MCS 0x%0x", mcs_map);
13018 sme_cfg_set_int(mac_ctx, wni_cfg_tx_param, mcs_map);
13019 sme_cfg_set_int(mac_ctx, wni_cfg_rx_param, mcs_map);
13020 csr_update_session_he_cap(mac_ctx, csr_session);
13021
13022 return 0;
13023}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013024
13025static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
13026 uint16_t he_cap, int value)
13027{
13028 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13029 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013030
13031 session = CSR_GET_SESSION(mac_ctx, session_id);
13032 if (!session) {
13033 sme_err("No session for id %d", session_id);
13034 return -EINVAL;
13035 }
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013036 sme_cfg_set_int(mac_ctx, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013037 csr_update_session_he_cap(mac_ctx, session);
13038
13039 return 0;
13040}
13041
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070013042int sme_update_he_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
13043 uint8_t cfg_val)
13044{
13045 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_SU_BEAMFORMEE,
13046 cfg_val);
13047}
13048
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013049int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13050{
13051 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013052 uint32_t he_cap_val = 0;
13053
13054 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013055
13056 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013057 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013058 if (ret)
13059 return ret;
13060
13061 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013062 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013063}
13064
13065int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13066{
13067 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013068 uint32_t he_cap_val = 0;
13069
13070 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013071
13072 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013073 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013074 if (ret)
13075 return ret;
13076
13077 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013078 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
13079}
13080
13081int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
13082 uint16_t he_frag)
13083{
13084 return sme_update_he_cap(hal, session_id,
13085 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013086}
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -070013087
13088int sme_update_he_ldpc_supp(tHalHandle hal, uint8_t session_id,
13089 uint16_t he_ldpc)
13090{
13091 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_LDPC, he_ldpc);
13092}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013093#endif
13094
Archana Ramachandran5041b252016-04-25 14:29:25 -070013095/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013096 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13097 * @hal: global hal handle
13098 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013099 * @context: callback context
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013100 *
13101 * This function stores nud debug stats callback function.
13102 *
13103 * Return: QDF_STATUS enumeration.
13104 */
13105QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013106 void (*cb)(void *, struct rsp_stats *, void *),
13107 void *context)
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013108{
13109 QDF_STATUS status = QDF_STATUS_SUCCESS;
13110 tpAniSirGlobal mac;
13111
13112 if (!hal) {
13113 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13114 FL("hal is not valid"));
13115 return QDF_STATUS_E_INVAL;
13116 }
13117 mac = PMAC_STRUCT(hal);
13118
13119 status = sme_acquire_global_lock(&mac->sme);
13120 if (!QDF_IS_STATUS_SUCCESS(status)) {
13121 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13122 FL("sme_acquire_global_lock failed!(status=%d)"),
13123 status);
13124 return status;
13125 }
13126
13127 mac->sme.get_arp_stats_cb = cb;
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013128 mac->sme.get_arp_stats_context = context;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013129 sme_release_global_lock(&mac->sme);
13130 return status;
13131}
13132
13133/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013134 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013135 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013136 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013137 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013138 *
13139 * This function stores the rssi threshold breached callback function.
13140 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013141 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013143QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013144 void (*cb)(void *, struct rssi_breach_event *))
13145{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013146 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013147 tpAniSirGlobal mac;
13148
13149 if (!h_hal) {
13150 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13151 FL("hHal is not valid"));
13152 return QDF_STATUS_E_INVAL;
13153 }
13154 mac = PMAC_STRUCT(h_hal);
13155
13156 status = sme_acquire_global_lock(&mac->sme);
13157 if (!QDF_IS_STATUS_SUCCESS(status)) {
13158 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13159 FL("sme_acquire_global_lock failed!(status=%d)"),
13160 status);
13161 return status;
13162 }
13163
13164 mac->sme.rssi_threshold_breached_cb = cb;
13165 sme_release_global_lock(&mac->sme);
13166 return status;
13167}
13168
13169/**
13170 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13171 * @hal: global hal handle
13172 *
13173 * This function de-registers the rssi threshold breached callback function.
13174 *
13175 * Return: QDF_STATUS enumeration.
13176 */
13177QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13178{
13179 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013180 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13181
13182 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013183 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013184 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013185 return status;
13186 }
13187
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013188 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013189 sme_release_global_lock(&mac->sme);
13190 return status;
13191}
13192
13193/**
13194 * sme_is_any_session_in_connected_state() - SME wrapper API to
13195 * check if any session is in connected state or not.
13196 *
13197 * @hal: Handle returned by mac open
13198 *
13199 * This function is used to check if any valid sme session is in
13200 * connected state or not.
13201 *
13202 * Return: true if any session is connected, else false.
13203 *
13204 */
13205bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13206{
13207 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013208 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013209 bool ret = false;
13210
13211 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013212 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013213 ret = csr_is_any_session_in_connect_state(mac_ctx);
13214 sme_release_global_lock(&mac_ctx->sme);
13215 }
13216 return ret;
13217}
13218
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013219QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13220 void (*cb)(void *,
13221 struct chip_pwr_save_fail_detected_params *)) {
13222
13223 QDF_STATUS status = QDF_STATUS_SUCCESS;
13224 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13225
13226 status = sme_acquire_global_lock(&mac->sme);
13227 if (status != QDF_STATUS_SUCCESS) {
13228 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13229 return status;
13230 }
13231 mac->sme.chip_power_save_fail_cb = cb;
13232 sme_release_global_lock(&mac->sme);
13233 return status;
13234}
13235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013236/**
13237 * sme_set_rssi_monitoring() - set rssi monitoring
13238 * @hal: global hal handle
13239 * @input: request message
13240 *
13241 * This function constructs the vos message and fill in message type,
13242 * bodyptr with @input and posts it to WDA queue.
13243 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013244 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013245 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013246QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013247 struct rssi_monitor_req *input)
13248{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013249 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013250 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013251 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013252 struct rssi_monitor_req *req_msg;
13253
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013254 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013255 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013256 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013257 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013258 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013259 }
13260
13261 *req_msg = *input;
13262
13263 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013264 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013265 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013266 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013267 return status;
13268 }
13269
13270 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013271 message.bodyptr = req_msg;
13272 message.type = WMA_SET_RSSI_MONITOR_REQ;
13273 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013274 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013275 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013276 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277 }
13278 sme_release_global_lock(&mac->sme);
13279
13280 return status;
13281}
13282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013283/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013284 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013285 * @hal: Handle returned by macOpen
13286 * @msg: PCL channel list and length structure
13287 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013288 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013289 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290 */
Krunal Soni8a090df2018-05-03 15:02:54 -070013291QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013292{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013293 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013294 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013295 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013296 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013297 uint32_t len, i;
13298
Krunal Soni3fa80e22018-01-09 14:16:02 -080013299 if (!mac) {
13300 sme_err("mac is NULL");
13301 return QDF_STATUS_E_FAILURE;
13302 }
Krunal Soni8a090df2018-05-03 15:02:54 -070013303
13304 if (!msg) {
13305 sme_err("msg is NULL");
13306 return QDF_STATUS_E_FAILURE;
13307 }
13308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013309 len = sizeof(*req_msg);
13310
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013311 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013312 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013313 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013314 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013315 }
13316
Krunal Soni8a090df2018-05-03 15:02:54 -070013317 for (i = 0; i < msg->pcl_len; i++) {
13318 req_msg->pcl_list[i] = msg->pcl_list[i];
13319 req_msg->weight_list[i] = msg->weight_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013320 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013321
Krunal Soni8a090df2018-05-03 15:02:54 -070013322 req_msg->pcl_len = msg->pcl_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013323
13324 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013325 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013326 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013327 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013328 return status;
13329 }
13330
13331 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013332 message.bodyptr = req_msg;
13333 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13334 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013335 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013336 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013337 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013338 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013339 }
13340 sme_release_global_lock(&mac->sme);
13341
13342 return status;
13343}
13344
13345/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013346 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013347 * @hal: Handle returned by macOpen
13348 * @msg: HW mode structure containing hw mode and callback details
13349 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013350 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013351 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013352 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013353QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013354{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013355 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013356 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013357 tSmeCmd *cmd = NULL;
13358
Krunal Soni3fa80e22018-01-09 14:16:02 -080013359 if (!mac) {
13360 sme_err("mac is NULL");
13361 return QDF_STATUS_E_FAILURE;
13362 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013363 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013364 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013365 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013366 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013367 }
13368
Krunal Soni78618d92017-02-14 21:46:31 -080013369 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013370 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013371 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013372 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013373 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013374 }
13375
13376 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013377 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13379 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013380 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13381 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013382 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013383 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013384
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013385 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013386 cmd->u.set_hw_mode_cmd.session_id,
13387 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013388 csr_queue_sme_command(mac, cmd, false);
13389
13390 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013391 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013392}
13393
13394/**
13395 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13396 * @hal: Handle returned by macOpen
13397 * @callback: HDD callback to be registered
13398 *
13399 * Registers the HDD callback with SME. This callback will be invoked when
13400 * HW mode transition event is received from the FW
13401 *
13402 * Return: None
13403 */
13404void sme_register_hw_mode_trans_cb(tHalHandle hal,
13405 hw_mode_transition_cb callback)
13406{
13407 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13408
13409 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013410}
13411
13412/**
13413 * sme_nss_update_request() - Send beacon templete update to FW with new
13414 * nss value
13415 * @hal: Handle returned by macOpen
13416 * @vdev_id: the session id
13417 * @new_nss: the new nss value
13418 * @cback: hdd callback
13419 * @next_action: next action to happen at policy mgr after beacon update
13420 *
13421 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013422 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013423 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013424QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13425 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13426 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13427 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013428{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013429 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013430 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013431 tSmeCmd *cmd = NULL;
13432
Krunal Soni3fa80e22018-01-09 14:16:02 -080013433 if (!mac) {
13434 sme_err("mac is null");
13435 return status;
13436 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013437 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013438 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013439 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013440 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013441 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013442 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013443 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013444 }
13445 cmd->command = e_sme_command_nss_update;
13446 /* Sessionized modules may require this info */
13447 cmd->sessionId = vdev_id;
13448 cmd->u.nss_update_cmd.new_nss = new_nss;
13449 cmd->u.nss_update_cmd.session_id = vdev_id;
13450 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013451 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013452 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013453 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013454
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013455 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013456 csr_queue_sme_command(mac, cmd, false);
13457 sme_release_global_lock(&mac->sme);
13458 }
13459 return status;
13460}
13461
13462/**
13463 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13464 * @hal: Handle returned by macOpen
13465 * @msg: Structure containing the dual mac config parameters
13466 *
13467 * Queues configuration information to CSR to configure
13468 * WLAN firmware for the dual MAC features
13469 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013470 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013471 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013472QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013473{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013474 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013475 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013476 tSmeCmd *cmd;
13477
Krunal Soni3fa80e22018-01-09 14:16:02 -080013478 if (!mac) {
13479 sme_err("mac is null");
13480 return QDF_STATUS_E_FAILURE;
13481 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013482 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013483 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013484 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013485 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013486 }
13487
Krunal Soni78618d92017-02-14 21:46:31 -080013488 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013489 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013490 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013492 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013493 }
13494
13495 cmd->command = e_sme_command_set_dual_mac_config;
13496 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13497 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13498 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13499
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013500 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013501 cmd->u.set_dual_mac_cmd.scan_config,
13502 cmd->u.set_dual_mac_cmd.fw_mode_config);
13503 csr_queue_sme_command(mac, cmd, false);
13504
13505 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013506 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013507}
13508
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013509#ifdef FEATURE_LFR_SUBNET_DETECTION
13510/**
13511 * sme_gateway_param_update() - to update gateway parameters with WMA
13512 * @Hal: hal handle
13513 * @gw_params: request parameters from HDD
13514 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013515 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013516 *
13517 * This routine will update gateway parameters to WMA
13518 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013519QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013520 struct gateway_param_update_req *gw_params)
13521{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013522 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013523 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013524 struct gateway_param_update_req *request_buf;
13525
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013526 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013527 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013528 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013529 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013530 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013531 }
13532
13533 *request_buf = *gw_params;
13534
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013535 message.type = WMA_GW_PARAM_UPDATE_REQ;
13536 message.reserved = 0;
13537 message.bodyptr = request_buf;
13538 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013539 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013541 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013542 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013543 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013544 }
13545
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013546 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013547}
13548#endif /* FEATURE_LFR_SUBNET_DETECTION */
13549
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013550/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013551 * sme_soc_set_antenna_mode() - set antenna mode
13552 * @hal: Handle returned by macOpen
13553 * @msg: Structure containing the antenna mode parameters
13554 *
13555 * Send the command to CSR to send
13556 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13557 *
13558 * Return: QDF_STATUS
13559 */
13560QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13561 struct sir_antenna_mode_param *msg)
13562{
13563 QDF_STATUS status = QDF_STATUS_SUCCESS;
13564 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13565 tSmeCmd *cmd;
13566
13567 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013568 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013569 return QDF_STATUS_E_FAILURE;
13570 }
13571
13572 status = sme_acquire_global_lock(&mac->sme);
13573 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013574 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013575 return QDF_STATUS_E_RESOURCES;
13576 }
13577
Krunal Soni78618d92017-02-14 21:46:31 -080013578 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013579 if (!cmd) {
13580 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013581 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013582 return QDF_STATUS_E_NULL_VALUE;
13583 }
13584
13585 cmd->command = e_sme_command_set_antenna_mode;
13586 cmd->u.set_antenna_mode_cmd = *msg;
13587
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013588 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013589 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13590 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13591
13592 csr_queue_sme_command(mac, cmd, false);
13593 sme_release_global_lock(&mac->sme);
13594
13595 return QDF_STATUS_SUCCESS;
13596}
13597
13598/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013599 * sme_set_peer_authorized() - call peer authorized callback
13600 * @peer_addr: peer mac address
13601 * @auth_cb: auth callback
13602 * @vdev_id: vdev id
13603 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013604 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013605 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013606QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013607 sme_peer_authorized_fp auth_cb,
13608 uint32_t vdev_id)
13609{
13610 void *wma_handle;
13611
Anurag Chouhan6d760662016-02-20 16:05:43 +053013612 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013613 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013614 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013615 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013616 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013617 }
13618
13619 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13620 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13621 1, vdev_id);
13622}
13623
13624/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013625 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013626 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013627 * @fcc_constraint: flag to enable/disable the constraint
13628 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013629 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013630 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013631 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013632QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13633 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013634{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013635 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013636 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13637
13638 status = sme_acquire_global_lock(&mac_ptr->sme);
13639
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013640 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013641
13642 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13643 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013644 if (scan_pending)
13645 mac_ptr->scan.defer_update_channel_list = true;
13646 else
13647 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013648 }
13649
13650 sme_release_global_lock(&mac_ptr->sme);
13651 }
13652
13653 return status;
13654}
13655/**
13656 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13657 * @hal: Global MAC pointer
13658 *
13659 * Return: NULL.
13660 */
13661void sme_setdef_dot11mode(tHalHandle hal)
13662{
13663 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013664
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013665 csr_set_default_dot11_mode(mac_ctx);
13666}
13667
13668/**
13669 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13670 * params
13671 * @hal_handle - The handle returned by macOpen.
13672 * @session_id - Session Identifier
13673 * @notify_id - Identifies 1 of the 4 parameters to be modified
13674 * @val New value of the parameter
13675 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013676 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013677 * Other status means SME failed to update
13678 */
13679
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013680QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013681 uint8_t session_id,
13682 uint32_t notify_id,
13683 int32_t val)
13684{
13685 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013686 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013687 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013688 tpCsrNeighborRoamControlInfo nr_info = NULL;
13689 uint32_t reason = 0;
13690
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013691 if (session_id >= CSR_ROAM_SESSION_MAX) {
13692 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13693 FL("Invalid sme session id: %d"), session_id);
13694 return QDF_STATUS_E_INVAL;
13695 }
13696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013697 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013698 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013699 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13700 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13701 switch (notify_id) {
13702 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013703 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013704 "%s: gRoamScanHirssiMaxCount %d => %d",
13705 __func__, nr_config->nhi_rssi_scan_max_count,
13706 val);
13707 nr_config->nhi_rssi_scan_max_count = val;
13708 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13709 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13710 break;
13711
13712 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013713 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013714 FL("gRoamScanHiRssiDelta %d => %d"),
13715 nr_config->nhi_rssi_scan_rssi_delta,
13716 val);
13717 nr_config->nhi_rssi_scan_rssi_delta = val;
13718 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13719 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13720 break;
13721
13722 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013723 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013724 FL("gRoamScanHiRssiDelay %d => %d"),
13725 nr_config->nhi_rssi_scan_delay,
13726 val);
13727 nr_config->nhi_rssi_scan_delay = val;
13728 nr_info->cfgParams.hi_rssi_scan_delay = val;
13729 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13730 break;
13731
13732 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013733 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013734 FL("gRoamScanHiRssiUpperBound %d => %d"),
13735 nr_config->nhi_rssi_scan_rssi_ub,
13736 val);
13737 nr_config->nhi_rssi_scan_rssi_ub = val;
13738 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13739 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13740 break;
13741
13742 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013743 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013744 FL("invalid parameter notify_id %d"),
13745 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013746 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013747 break;
13748 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053013749
13750 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
13751 status == QDF_STATUS_SUCCESS) {
13752 csr_roam_offload_scan(mac_ctx, session_id,
13753 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13754 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013755 sme_release_global_lock(&mac_ctx->sme);
13756 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013757
13758 return status;
13759}
13760
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013761/**
13762 * sme_update_tgt_services() - update the target services config.
13763 * @hal: HAL pointer.
13764 * @cfg: wma_tgt_services parameters.
13765 *
13766 * update the target services config.
13767 *
13768 * Return: None.
13769 */
13770void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13771{
13772 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13773
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013774 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013775 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013776 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013777 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013778 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013779 mac_ctx->is_fils_roaming_supported =
13780 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013781 mac_ctx->is_11k_offload_supported =
13782 cfg->is_11k_offload_supported;
13783 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13784 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13785 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013786}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013787
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013788/**
13789 * sme_is_session_id_valid() - Check if the session id is valid
13790 * @hal: Pointer to HAL
13791 * @session_id: Session id
13792 *
13793 * Checks if the session id is valid or not
13794 *
13795 * Return: True is the session id is valid, false otherwise
13796 */
13797bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13798{
13799 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013800
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013801 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13803 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013804 return false;
13805 }
13806
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013807 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013808 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013809
13810 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013811}
13812
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013813#ifdef FEATURE_WLAN_TDLS
13814
13815/**
13816 * sme_get_opclass() - determine operating class
13817 * @hal: Pointer to HAL
13818 * @channel: channel id
13819 * @bw_offset: bandwidth offset
13820 * @opclass: pointer to operating class
13821 *
13822 * Function will determine operating class from regdm_get_opclass_from_channel
13823 *
13824 * Return: none
13825 */
13826void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13827 uint8_t *opclass)
13828{
13829 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13830
13831 /* redgm opclass table contains opclass for 40MHz low primary,
13832 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13833 * first we will check if bit for 40MHz is set and if so find
13834 * matching opclass either with low primary or high primary
13835 * (a channel would never be in both) and then search for opclass
13836 * matching 20MHz, else for any BW.
13837 */
13838 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013839 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013840 mac_ctx->scan.countryCodeCurrent,
13841 channel, BW40_LOW_PRIMARY);
13842 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013843 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013844 mac_ctx->scan.countryCodeCurrent,
13845 channel, BW40_HIGH_PRIMARY);
13846 }
13847 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013848 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013849 mac_ctx->scan.countryCodeCurrent,
13850 channel, BW20);
13851 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013852 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013853 mac_ctx->scan.countryCodeCurrent,
13854 channel, BWALL);
13855 }
13856}
13857#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013858
Sandeep Puligillae0875662016-02-12 16:09:21 -080013859/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013860 * sme_set_fw_test() - set fw test
13861 * @fw_test: fw test param
13862 *
13863 * Return: Return QDF_STATUS, otherwise appropriate failure code
13864 */
13865QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13866{
13867 void *wma_handle;
13868
13869 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13870 if (!wma_handle) {
13871 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13872 "wma handle is NULL");
13873 return QDF_STATUS_E_FAILURE;
13874 }
13875 wma_process_fw_test_cmd(wma_handle, fw_test);
13876 return QDF_STATUS_SUCCESS;
13877}
13878
13879/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013880 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13881 * @hal: mac handel
13882 * @vdev_id: vdev identifier
13883 *
13884 * Return: Return QDF_STATUS, otherwise appropriate failure code
13885 */
13886QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13887{
13888 void *wma_handle;
13889
13890 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13891 if (!wma_handle) {
13892 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13893 "wma handle is NULL");
13894 return QDF_STATUS_E_FAILURE;
13895 }
13896 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13897 return QDF_STATUS_SUCCESS;
13898}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013899
13900/**
13901 * sme_update_mimo_power_save() - Update MIMO power save
13902 * configuration
13903 * @hal: The handle returned by macOpen
13904 * @is_ht_smps_enabled: enable/disable ht smps
13905 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013906 * @send_smps_action: flag to send smps force mode command
13907 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013908 *
13909 * Return: QDF_STATUS if SME update mimo power save
Jeff Johnson698eacd2018-05-12 17:00:03 -070013910 * configuration success else failure status
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013911 */
13912QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13913 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013914 uint8_t ht_smps_mode,
13915 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013916{
13917 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013918
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013919 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013920 is_ht_smps_enabled, ht_smps_mode,
13921 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013922 mac_ctx->roam.configParam.enableHtSmps =
13923 is_ht_smps_enabled;
13924 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013925 mac_ctx->roam.configParam.send_smps_action =
13926 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013927
13928 return QDF_STATUS_SUCCESS;
13929}
13930
13931/**
13932 * sme_is_sta_smps_allowed() - check if the supported nss for
13933 * the session is greater than 1x1 to enable sta SMPS
13934 * @hal: The handle returned by macOpen
13935 * @session_id: session id
13936 *
13937 * Return: bool returns true if supported nss is greater than
13938 * 1x1 else false
13939 */
13940bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13941{
13942 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013943 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013944
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013945 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13946 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013947 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013948 return false;
13949 }
13950
13951 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013952 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013953 return false;
13954 }
13955
13956 return (csr_session->supported_nss_1x1 == true) ? false : true;
13957}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013958
13959/**
13960 * sme_add_beacon_filter() - set the beacon filter configuration
13961 * @hal: The handle returned by macOpen
13962 * @session_id: session id
13963 * @ie_map: bitwise array of IEs
13964 *
13965 * Return: Return QDF_STATUS, otherwise appropriate failure code
13966 */
13967QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13968 uint32_t session_id,
13969 uint32_t *ie_map)
13970{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013971 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013972 QDF_STATUS qdf_status;
13973 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13974 struct beacon_filter_param *filter_param;
13975
13976 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013977 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013978 return QDF_STATUS_E_FAILURE;
13979 }
13980
13981 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13982 if (NULL == filter_param) {
13983 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13984 "%s: fail to alloc filter_param", __func__);
13985 return QDF_STATUS_E_FAILURE;
13986 }
13987
13988 filter_param->vdev_id = session_id;
13989
13990 qdf_mem_copy(filter_param->ie_map, ie_map,
13991 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
13992
13993 message.type = WMA_ADD_BCN_FILTER_CMDID;
13994 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013995 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013996 &message);
13997 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13999 "%s: Not able to post msg to WDA!",
14000 __func__);
14001
14002 qdf_mem_free(filter_param);
14003 }
14004 return qdf_status;
14005}
14006
14007/**
14008 * sme_remove_beacon_filter() - set the beacon filter configuration
14009 * @hal: The handle returned by macOpen
14010 * @session_id: session id
14011 *
14012 * Return: Return QDF_STATUS, otherwise appropriate failure code
14013 */
14014QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14015{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014016 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014017 QDF_STATUS qdf_status;
14018 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14019 struct beacon_filter_param *filter_param;
14020
14021 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014022 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014023 return QDF_STATUS_E_FAILURE;
14024 }
14025
14026 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14027 if (NULL == filter_param) {
14028 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14029 "%s: fail to alloc filter_param", __func__);
14030 return QDF_STATUS_E_FAILURE;
14031 }
14032
14033 filter_param->vdev_id = session_id;
14034
14035 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14036 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014037 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014038 &message);
14039 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14040 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14041 "%s: Not able to post msg to WDA!",
14042 __func__);
14043
14044 qdf_mem_free(filter_param);
14045 }
14046 return qdf_status;
14047}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014048
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014049/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014050 * sme_send_disassoc_req_frame - send disassoc req
14051 * @hal: handler to hal
14052 * @session_id: session id
14053 * @peer_mac: peer mac address
14054 * @reason: reason for disassociation
14055 * wait_for_ack: wait for acknowledgment
14056 *
14057 * function to send disassoc request to lim
14058 *
14059 * return: none
14060 */
14061void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14062 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14063{
14064 struct sme_send_disassoc_frm_req *msg;
14065 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14066 A_UINT8 *buf;
14067 A_UINT16 tmp;
14068
14069 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14070
14071 if (NULL == msg)
14072 qdf_status = QDF_STATUS_E_FAILURE;
14073 else
14074 qdf_status = QDF_STATUS_SUCCESS;
14075
14076 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14077 return;
14078
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014079 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14080
14081 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14082
14083 buf = &msg->session_id;
14084
14085 /* session id */
14086 *buf = (A_UINT8) session_id;
14087 buf += sizeof(A_UINT8);
14088
14089 /* transaction id */
14090 *buf = 0;
14091 *(buf + 1) = 0;
14092 buf += sizeof(A_UINT16);
14093
14094 /* Set the peer MAC address before sending the message to LIM */
14095 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14096
14097 buf += QDF_MAC_ADDR_SIZE;
14098
14099 /* reasoncode */
14100 tmp = (uint16_t) reason;
14101 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14102 buf += sizeof(uint16_t);
14103
14104 *buf = wait_for_ack;
14105 buf += sizeof(uint8_t);
14106
Rajeev Kumard138ac52017-01-30 18:38:37 -080014107 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014108
14109 if (qdf_status != QDF_STATUS_SUCCESS)
14110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14111 FL("cds_send_mb_message Failed"));
14112}
14113
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014114QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14115 bpf_get_offload_cb callback,
14116 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014117{
14118 QDF_STATUS status = QDF_STATUS_SUCCESS;
14119 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014120 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014121
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014122 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014123
14124 status = sme_acquire_global_lock(&mac_ctx->sme);
14125 if (QDF_STATUS_SUCCESS == status) {
14126 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014127 mac_ctx->sme.bpf_get_offload_cb = callback;
14128 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014129 cds_msg.bodyptr = NULL;
14130 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014131 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014132 if (!QDF_IS_STATUS_SUCCESS(status)) {
14133 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14134 FL("Post bpf get offload msg fail"));
14135 status = QDF_STATUS_E_FAILURE;
14136 }
14137 sme_release_global_lock(&mac_ctx->sme);
14138 } else {
14139 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14140 FL("sme_acquire_global_lock error"));
14141 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014142 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014143 return status;
14144}
14145
14146
14147/**
14148 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14149 * @hal: HAL handle
14150 * @bpf_set_offload: struct to set bpf filter instructions.
14151 *
14152 * Return: QDF_STATUS enumeration.
14153 */
14154QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14155 struct sir_bpf_set_offload *req)
14156{
14157 QDF_STATUS status = QDF_STATUS_SUCCESS;
14158 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014159 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014160 struct sir_bpf_set_offload *set_offload;
14161
Arun Khandavallica198b52016-04-26 20:53:35 +053014162 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14163 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014164
14165 if (NULL == set_offload) {
14166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14167 FL("Failed to alloc set_offload"));
14168 return QDF_STATUS_E_NOMEM;
14169 }
14170
14171 set_offload->session_id = req->session_id;
14172 set_offload->filter_id = req->filter_id;
14173 set_offload->current_offset = req->current_offset;
14174 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014175 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014176 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014177 set_offload->program = ((uint8_t *)set_offload) +
14178 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014179 qdf_mem_copy(set_offload->program, req->program,
14180 set_offload->current_length);
14181 }
14182 status = sme_acquire_global_lock(&mac_ctx->sme);
14183 if (QDF_STATUS_SUCCESS == status) {
14184 /* Serialize the req through MC thread */
14185 cds_msg.bodyptr = set_offload;
14186 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014187 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014188
14189 if (!QDF_IS_STATUS_SUCCESS(status)) {
14190 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14191 FL("Post BPF set offload msg fail"));
14192 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014193 qdf_mem_free(set_offload);
14194 }
14195 sme_release_global_lock(&mac_ctx->sme);
14196 } else {
14197 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14198 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014199 qdf_mem_free(set_offload);
14200 }
14201 return status;
14202}
14203
14204/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014205 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14206 * @hal: hal pointer
14207 *
14208 * Return: wni dot11 mode.
14209 */
14210uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14211{
14212 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14213
14214 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14215 mac_ctx->roam.configParam.uCfgDot11Mode);
14216}
14217
14218/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014219 * sme_create_mon_session() - post message to create PE session for monitormode
14220 * operation
14221 * @hal_handle: Handle to the HAL
14222 * @bssid: pointer to bssid
14223 *
14224 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14225 */
14226QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14227{
14228 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14229 struct sir_create_session *msg;
14230
14231 msg = qdf_mem_malloc(sizeof(*msg));
14232 if (NULL != msg) {
14233 msg->type = eWNI_SME_MON_INIT_SESSION;
14234 msg->msg_len = sizeof(*msg);
14235 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014236 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014237 }
14238 return status;
14239}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014240
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014241void sme_set_chan_info_callback(tHalHandle hal_handle,
14242 void (*callback)(struct scan_chan_info *chan_info))
14243{
14244 tpAniSirGlobal mac;
14245
14246 if (hal_handle == NULL) {
14247 QDF_ASSERT(0);
14248 return;
14249 }
14250 mac = PMAC_STRUCT(hal_handle);
14251 mac->chan_info_cb = callback;
14252}
14253
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014254/**
14255 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14256 * @hal: The handle returned by macOpen
14257 * @params: adaptive_dwelltime_params config
14258 *
14259 * Return: QDF_STATUS if adaptive dwell time update
Jeff Johnson698eacd2018-05-12 17:00:03 -070014260 * configuration success else failure status
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014261 */
14262QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14263 struct adaptive_dwelltime_params *params)
14264{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014265 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014266 QDF_STATUS status;
14267 struct adaptive_dwelltime_params *dwelltime_params;
14268
14269 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14270 if (NULL == dwelltime_params) {
14271 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14272 "%s: fail to alloc dwelltime_params", __func__);
14273 return QDF_STATUS_E_NOMEM;
14274 }
14275
14276 dwelltime_params->is_enabled = params->is_enabled;
14277 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14278 dwelltime_params->lpf_weight = params->lpf_weight;
14279 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14280 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14281
14282 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14283 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014284 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014285 if (!QDF_IS_STATUS_SUCCESS(status)) {
14286 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14287 "%s: Not able to post msg to WMA!", __func__);
14288
14289 qdf_mem_free(dwelltime_params);
14290 }
14291 return status;
14292}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014293
14294/**
14295 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14296 * @hal: Pointer to HAL
14297 * @vdev_id: vdev_id for which IE is targeted
14298 *
14299 * Return: None
14300 */
14301void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14302{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014303 struct sir_set_vdev_ies_per_band *p_msg;
14304 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14305
14306 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14307 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014308 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014309 return;
14310 }
14311
14312 p_msg->vdev_id = vdev_id;
14313 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14314 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014315 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014316 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014317 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014318 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014319 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014320}
14321
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014322/**
14323 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14324 * @hal: Pointer to HAL
14325 * @enable2x2: 1x1 or 2x2 mode.
14326 *
14327 * Sends the set pdev IE req with Nss value.
14328 *
14329 * Return: None
14330 */
14331void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14332{
14333 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14334 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14335 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14336
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014337 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14338 eCSR_CFG_DOT11_MODE_AUTO) ||
14339 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14340 eCSR_CFG_DOT11_MODE_11N) ||
14341 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14342 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14343 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14344 eCSR_CFG_DOT11_MODE_11AC) ||
14345 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14346 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14347 return;
14348
14349 status = sme_acquire_global_lock(&mac_ctx->sme);
14350 if (QDF_STATUS_SUCCESS == status) {
14351 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14352 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014353 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014354 sme_release_global_lock(&mac_ctx->sme);
14355 return;
14356 }
14357
14358 ht_vht_cfg->pdev_id = 0;
14359 if (enable2x2)
14360 ht_vht_cfg->nss = 2;
14361 else
14362 ht_vht_cfg->nss = 1;
14363 ht_vht_cfg->dot11mode =
14364 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14365 mac_ctx->roam.configParam.uCfgDot11Mode);
14366
14367 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14368 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014369 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14370 ht_vht_cfg->nss,
14371 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014372 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014373 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014374 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014375
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014376 sme_release_global_lock(&mac_ctx->sme);
14377 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014378}
14379
14380/**
14381 * sme_update_vdev_type_nss() - sets the nss per vdev type
14382 * @hal: Pointer to HAL
14383 * @max_supp_nss: max_supported Nss
14384 * @band: 5G or 2.4G band
14385 *
14386 * Sets the per band Nss for each vdev type based on INI and configured
14387 * chain mask value.
14388 *
14389 * Return: None
14390 */
14391void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014392 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014393{
14394 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14395 struct vdev_type_nss *vdev_nss;
14396
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014397 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014398 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14399 else
14400 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14401
14402 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14403 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14404 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14405 CFG_P2P_GO_NSS(vdev_type_nss));
14406 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14407 CFG_P2P_CLI_NSS(vdev_type_nss));
14408 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14409 CFG_P2P_DEV_NSS(vdev_type_nss));
14410 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14411 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14412 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14413
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014414 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 -070014415 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14416 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14417 vdev_nss->tdls, vdev_nss->ocb);
14418}
Peng Xu8fdaa492016-06-22 10:20:47 -070014419
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014420#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14421#define MAX_BSS_COLOR_VAL 63
14422#define MIN_BSS_COLOR_VAL 1
14423
14424QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14425 uint8_t bss_color)
14426
14427{
14428 struct sir_set_he_bss_color *bss_color_msg;
14429 uint8_t len;
14430
14431 if (!hal) {
14432 sme_err("Invalid hal pointer");
14433 return QDF_STATUS_E_FAULT;
14434 }
14435
14436 sme_debug("Set HE bss_color %d", bss_color);
14437
14438 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14439 sme_debug("Invalid HE bss_color %d", bss_color);
14440 return QDF_STATUS_E_INVAL;
14441 }
14442 len = sizeof(*bss_color_msg);
14443 bss_color_msg = qdf_mem_malloc(len);
14444 if (!bss_color_msg) {
14445 sme_err("mem alloc failed");
14446 return QDF_STATUS_E_NOMEM;
14447 }
14448 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14449 bss_color_msg->length = len;
14450 bss_color_msg->session_id = session_id;
14451 bss_color_msg->bss_color = bss_color;
14452 return umac_send_mb_message_to_mac(bss_color_msg);
14453}
14454#endif
14455
Peng Xu8fdaa492016-06-22 10:20:47 -070014456/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014457 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14458 * @hal: Pointer to HAL
14459 * @hw_dbs_capable: HW DBS capability
14460 *
14461 * Sets HW DBS capability based on INI and fw capability.
14462 *
14463 * Return: None
14464 */
14465void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14466{
14467 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014468
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014469 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14470}
14471
14472/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014473 * sme_register_p2p_lo_event() - Register for the p2p lo event
14474 * @hHal: reference to the HAL
14475 * @context: the context of the call
14476 * @callback: the callback to hdd
14477 *
14478 * This function registers the callback function for P2P listen
14479 * offload stop event.
14480 *
14481 * Return: none
14482 */
14483void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14484 p2p_lo_callback callback)
14485{
14486 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14487 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14488
14489 status = sme_acquire_global_lock(&pMac->sme);
14490 pMac->sme.p2p_lo_event_callback = callback;
14491 pMac->sme.p2p_lo_event_context = context;
14492 sme_release_global_lock(&pMac->sme);
14493}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014494
14495/**
14496 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14497 * @hal: The handle returned by macOpen
14498 * @session_id: session id
14499 * @dbg_args: args for mac pwr debug command
14500 * Return: Return QDF_STATUS, otherwise appropriate failure code
14501 */
14502QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14503 struct sir_mac_pwr_dbg_cmd*
14504 dbg_args)
14505{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014506 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014507 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14508 struct sir_mac_pwr_dbg_cmd *req;
14509 int i;
14510
14511 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014512 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014513 return QDF_STATUS_E_FAILURE;
14514 }
14515
14516 req = qdf_mem_malloc(sizeof(*req));
14517 if (NULL == req) {
14518 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14519 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14520 return QDF_STATUS_E_FAILURE;
14521 }
14522 req->module_id = dbg_args->module_id;
14523 req->pdev_id = dbg_args->pdev_id;
14524 req->num_args = dbg_args->num_args;
14525 for (i = 0; i < req->num_args; i++)
14526 req->args[i] = dbg_args->args[i];
14527
14528 message.type = SIR_HAL_POWER_DBG_CMD;
14529 message.bodyptr = req;
14530
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014531 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014532 (QDF_MODULE_ID_WMA, &message))) {
14533 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14534 "%s: Not able to post msg to WDA!",
14535 __func__);
14536 qdf_mem_free(req);
14537 }
14538 return QDF_STATUS_SUCCESS;
14539}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014540/**
14541 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014542 * @dev_mode: connection type.
14543 * @nss2g: Pointer to the 2G Nss parameter.
14544 * @nss5g: Pointer to the 5G Nss parameter.
14545 *
14546 * Fills the 2G and 5G Nss values based on connection type.
14547 *
14548 * Return: None
14549 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014550void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14551 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014552{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014553 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14554
14555 if (NULL == mac_ctx) {
14556 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14557 FL("Invalid MAC context"));
14558 return;
14559 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014560 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14561}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014562
14563/**
14564 * sme_update_sta_roam_policy() - update sta roam policy for
14565 * unsafe and DFS channels.
14566 * @hal_handle: hal handle for getting global mac struct
14567 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14568 * skipped or not
14569 * @skip_unsafe_channels: Param to tell if driver needs to
14570 * skip unsafe channels or not.
14571 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014572 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014573 *
14574 * sme_update_sta_roam_policy update sta rome policies to csr
14575 * this function will call csrUpdateChannelList as well
14576 * to include/exclude DFS channels and unsafe channels.
14577 *
14578 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14579 */
14580QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14581 enum sta_roam_policy_dfs_mode dfs_mode,
14582 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014583 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014584{
14585 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14586 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014587 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014588
14589 if (!mac_ctx) {
14590 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14591 "%s: mac_ctx is null", __func__);
14592 return QDF_STATUS_E_FAILURE;
14593 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014594
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014595 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14596 if (!sme_config) {
14597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14598 FL("failed to allocate memory for sme_config"));
14599 return QDF_STATUS_E_FAILURE;
14600 }
14601 qdf_mem_zero(sme_config, sizeof(*sme_config));
14602 sme_get_config_param(hal_handle, sme_config);
14603
14604 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014605 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014606 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014607 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014608 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014609 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014610
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014611 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014612
14613 status = csr_update_channel_list(mac_ctx);
14614 if (QDF_STATUS_SUCCESS != status) {
14615 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14616 FL("failed to update the supported channel list"));
14617 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014618
14619 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled) {
14620 status = sme_acquire_global_lock(&mac_ctx->sme);
14621 if (QDF_IS_STATUS_SUCCESS(status)) {
14622 csr_roam_offload_scan(mac_ctx, session_id,
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014623 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14624 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014625 sme_release_global_lock(&mac_ctx->sme);
14626 } else {
14627 sme_err("Failed to acquire SME lock");
14628 }
14629 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014630 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014631 return status;
14632}
14633
14634/**
14635 * sme_enable_disable_chanavoidind_event - configure ca event ind
14636 * @hal: handler to hal
14637 * @set_value: enable/disable
14638 *
14639 * function to enable/disable chan avoidance indication
14640 *
14641 * Return: QDF_STATUS
14642 */
14643QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14644 uint8_t set_value)
14645{
14646 QDF_STATUS status;
14647 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014648 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014649
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014650 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014651 status = sme_acquire_global_lock(&mac_ctx->sme);
14652 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014653 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014654 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14655 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014656 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014657 sme_release_global_lock(&mac_ctx->sme);
14658 return status;
14659 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014660 return status;
14661}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014662
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014663/*
14664 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14665 * @hal: reference to the HAL
14666 * @session_id: current session ID
14667 * @ie_data: Pointer to Scan IE data
14668 * @ie_len: Length of @ie_data
14669 *
14670 * Return: QDF_STATUS
14671 */
14672QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14673 uint8_t *ie_data, uint16_t ie_len)
14674{
14675 QDF_STATUS status;
14676 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14677 struct hdd_default_scan_ie *set_ie_params;
14678
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014679 if (!ie_data)
14680 return QDF_STATUS_E_INVAL;
14681
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014682 status = sme_acquire_global_lock(&mac_ctx->sme);
14683 if (QDF_IS_STATUS_SUCCESS(status)) {
14684 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14685 if (!set_ie_params)
14686 status = QDF_STATUS_E_NOMEM;
14687 else {
14688 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14689 set_ie_params->length = sizeof(*set_ie_params);
14690 set_ie_params->session_id = session_id;
14691 set_ie_params->ie_len = ie_len;
14692 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014693 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014694 }
14695 sme_release_global_lock(&mac_ctx->sme);
14696 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014697 return status;
14698}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014699
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014700QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14701 wma_sar_cb callback, void *context)
14702{
14703 void *wma_handle;
14704
14705 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14706 if (!wma_handle) {
14707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14708 "wma handle is NULL");
14709 return QDF_STATUS_E_FAILURE;
14710 }
14711
14712 return wma_get_sar_limit(wma_handle, callback, context);
14713}
14714
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014715QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14716 struct sar_limit_cmd_params *sar_limit_cmd)
14717{
14718 void *wma_handle;
14719
14720 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14721 if (!wma_handle) {
14722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14723 "wma handle is NULL");
14724 return QDF_STATUS_E_FAILURE;
14725 }
14726
14727 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14728}
14729
Jeff Johnson6136fb92017-03-30 15:21:49 -070014730#ifdef WLAN_FEATURE_FIPS
14731QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14732 wma_fips_cb callback, void *context)
14733{
14734 void *wma_handle;
14735
14736 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14737 if (!wma_handle) {
14738 sme_err("wma handle is NULL");
14739 return QDF_STATUS_E_FAILURE;
14740 }
14741
14742 return wma_fips_request(wma_handle, param, callback, context);
14743}
14744#endif
14745
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014746QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14747{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014748 void *wma_handle;
14749
14750 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14751 if (!wma_handle) {
14752 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14753 "wma_handle is NULL");
14754 return QDF_STATUS_E_FAILURE;
14755 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014756 if (QDF_STATUS_SUCCESS !=
14757 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14759 "%s: Failed to set cts2self for p2p GO to firmware",
14760 __func__);
14761 return QDF_STATUS_E_FAILURE;
14762 }
14763 return QDF_STATUS_SUCCESS;
14764}
Yingying Tang95409972016-10-20 15:16:15 +080014765
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014766/**
14767 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14768 * @hal: Handle returned by mac_open
14769 * @session_id: Session ID on which tx fail count needs to be updated to FW
14770 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14771 *
14772 * This function is used to set tx fail count threshold to firmware.
14773 * firmware will issue disocnnect with peer device once this threshold is
14774 * reached.
14775 *
14776 * Return: Return QDF_STATUS, otherwise appropriate failure code
14777 */
14778QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14779 uint8_t session_id, uint32_t tx_fail_count)
14780{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014781 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14782 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014783 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014784
14785 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14786 if (NULL == tx_fail_cnt) {
14787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14788 "%s: fail to alloc filter_param", __func__);
14789 return QDF_STATUS_E_FAILURE;
14790 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014791 sme_debug("session_id: %d tx_fail_count: %d",
14792 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014793 tx_fail_cnt->session_id = session_id;
14794 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14795
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014796 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014797 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14798 msg.reserved = 0;
14799 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014800 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014801
14802 if (!QDF_IS_STATUS_SUCCESS(status)) {
14803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014804 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014805 qdf_mem_free(tx_fail_cnt);
14806 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014807 return status;
14808}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014809
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014810QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14811 void (*cb)(void *, struct sir_lost_link_info *))
14812{
14813 QDF_STATUS status = QDF_STATUS_SUCCESS;
14814 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14815
14816 status = sme_acquire_global_lock(&mac->sme);
14817 if (QDF_IS_STATUS_SUCCESS(status)) {
14818 mac->sme.lost_link_info_cb = cb;
14819 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014820 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014821 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014822 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014823
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014824 return status;
14825}
Yingying Tang95409972016-10-20 15:16:15 +080014826
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014827#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014828bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014829{
14830 return roam_info->isESEAssoc;
14831}
Manjeet Singh2f785062017-03-08 18:14:18 +053014832#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014833/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014834 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014835 * params from ini.
14836 * @hal_handle: Handle returned by mac_open
14837 * @5g_pref_params: pref params from ini.
14838 *
14839 * Returns: None
14840 */
14841void sme_set_5g_band_pref(tHalHandle hal_handle,
14842 struct sme_5g_band_pref_params *pref_params)
14843{
14844
14845 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14846 struct roam_ext_params *roam_params;
14847 QDF_STATUS status = QDF_STATUS_SUCCESS;
14848
14849 if (!pref_params) {
14850 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14851 "Invalid 5G pref params!");
14852 return;
14853 }
14854 status = sme_acquire_global_lock(&mac_ctx->sme);
14855 if (QDF_STATUS_SUCCESS == status) {
14856 roam_params = &mac_ctx->roam.configParam.roam_params;
14857 roam_params->raise_rssi_thresh_5g =
14858 pref_params->rssi_boost_threshold_5g;
14859 roam_params->raise_factor_5g =
14860 pref_params->rssi_boost_factor_5g;
14861 roam_params->max_raise_rssi_5g =
14862 pref_params->max_rssi_boost_5g;
14863 roam_params->drop_rssi_thresh_5g =
14864 pref_params->rssi_penalize_threshold_5g;
14865 roam_params->drop_factor_5g =
14866 pref_params->rssi_penalize_factor_5g;
14867 roam_params->max_drop_rssi_5g =
14868 pref_params->max_rssi_penalize_5g;
14869
14870 sme_release_global_lock(&mac_ctx->sme);
14871 } else
14872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14873 "Unable to acquire global sme lock");
14874}
14875
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014876
14877bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14878{
14879 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014880
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014881 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14882}
Yingying Tang95409972016-10-20 15:16:15 +080014883
14884#ifdef WLAN_FEATURE_WOW_PULSE
14885/**
14886 * sme_set_wow_pulse() - set wow pulse info
14887 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14888 *
14889 * Return: QDF_STATUS
14890 */
14891QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14892{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014893 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014894 QDF_STATUS status;
14895 struct wow_pulse_mode *wow_pulse_set_cmd;
14896
14897 if (!wow_pulse_set_info) {
14898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14899 "%s: invalid wow_pulse_set_info pointer", __func__);
14900 return QDF_STATUS_E_FAILURE;
14901 }
14902
14903 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14904 if (NULL == wow_pulse_set_cmd) {
14905 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14906 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14907 return QDF_STATUS_E_NOMEM;
14908 }
14909
14910 *wow_pulse_set_cmd = *wow_pulse_set_info;
14911
14912 message.type = WMA_SET_WOW_PULSE_CMD;
14913 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014914 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014915 &message);
14916 if (!QDF_IS_STATUS_SUCCESS(status)) {
14917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14918 "%s: Not able to post msg to WDA!",
14919 __func__);
14920 qdf_mem_free(wow_pulse_set_cmd);
14921 status = QDF_STATUS_E_FAILURE;
14922 }
14923
14924 return status;
14925}
14926#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014927
14928/**
14929 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14930 * different fields and IEs from bss descriptor.
14931 * @frame_buf: frame buffer to populate
14932 * @bss_descp: bss descriptor
14933 * @bssid: bssid of the beacon frame to populate
14934 * @ie_len: length of IE fields
14935 *
14936 * Return: None
14937 */
14938static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14939 tSirBssDescription *bss_descp,
14940 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014941 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014942{
14943 tDot11fBeacon1 *bcn_fixed;
14944 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14945
14946 /* populate mac header first to indicate beacon */
14947 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14948 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14949 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14950 qdf_mem_copy((uint8_t *) mac_hdr->da,
14951 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14952 sizeof(struct qdf_mac_addr));
14953 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
14954 sizeof(struct qdf_mac_addr));
14955 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
14956 sizeof(struct qdf_mac_addr));
14957
14958 /* now populate fixed params */
14959 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
14960 /* populate timestamp */
14961 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
14962 sizeof(bss_descp->timeStamp));
14963 /* populate beacon interval */
14964 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
14965 /* populate capability */
14966 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
14967 sizeof(bss_descp->capabilityInfo));
14968
14969 /* copy IEs now */
14970 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
14971 + SIR_MAC_B_PR_SSID_OFFSET,
14972 &bss_descp->ieFields, ie_len);
14973}
14974
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014975QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014976 struct csr_roam_profile *profile,
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014977 const uint8_t *bssid,
14978 int8_t *rssi, int8_t *snr)
14979{
14980 tSirBssDescription *bss_descp;
14981 tCsrScanResultFilter *scan_filter;
14982 struct scan_result_list *bss_list;
14983 tScanResultHandle result_handle = NULL;
14984 QDF_STATUS status = QDF_STATUS_SUCCESS;
14985 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14986
14987 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14988 if (NULL == scan_filter) {
14989 sme_err("memory allocation failed");
14990 status = QDF_STATUS_E_NOMEM;
14991 goto free_scan_flter;
14992 }
14993
14994 status = csr_roam_prepare_filter_from_profile(mac_ctx,
14995 profile, scan_filter);
14996 if (QDF_STATUS_SUCCESS != status) {
14997 sme_err("prepare_filter failed");
14998 goto free_scan_flter;
14999 }
15000
15001 /* update filter to get scan result with just target BSSID */
15002 if (NULL == scan_filter->BSSIDs.bssid) {
15003 scan_filter->BSSIDs.bssid =
15004 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15005 if (scan_filter->BSSIDs.bssid == NULL) {
15006 sme_err("malloc failed");
15007 status = QDF_STATUS_E_NOMEM;
15008 goto free_scan_flter;
15009 }
15010 }
15011
15012 scan_filter->BSSIDs.numOfBSSIDs = 1;
15013 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15014 bssid, sizeof(struct qdf_mac_addr));
15015
15016 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15017 if (QDF_STATUS_SUCCESS != status) {
15018 sme_err("parse_scan_result failed");
15019 goto free_scan_flter;
15020 }
15021
15022 bss_list = (struct scan_result_list *)result_handle;
15023 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15024 if (!bss_descp) {
15025 sme_err("unable to fetch bss descriptor");
15026 status = QDF_STATUS_E_FAULT;
15027 goto free_scan_flter;
15028 }
15029
15030 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15031 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15032
15033 if (rssi)
15034 *rssi = bss_descp->rssi;
15035 if (snr)
15036 *snr = bss_descp->sinr;
15037
15038free_scan_flter:
15039 /* free scan filter and exit */
15040 if (scan_filter) {
15041 csr_free_scan_filter(mac_ctx, scan_filter);
15042 qdf_mem_free(scan_filter);
15043 }
15044
15045 if (result_handle)
15046 csr_scan_result_purge(mac_ctx, result_handle);
15047
15048 return status;
15049}
15050
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015051QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile,
15052 const tSirMacAddr bssid,
15053 uint8_t **frame_buf, uint32_t *frame_len,
15054 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015055{
15056 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015057 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015058 tCsrScanResultFilter *scan_filter;
15059 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15060 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015061 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015062 uint32_t ie_len;
15063
15064 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15065 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015066 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015067 status = QDF_STATUS_E_NOMEM;
15068 goto free_scan_flter;
15069 }
15070 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15071 profile, scan_filter);
15072 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015073 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015074 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015075 goto free_scan_flter;
15076 }
15077
15078 /* update filter to get scan result with just target BSSID */
15079 if (NULL == scan_filter->BSSIDs.bssid) {
15080 scan_filter->BSSIDs.bssid =
15081 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15082 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015083 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015084 status = QDF_STATUS_E_NOMEM;
15085 goto free_scan_flter;
15086 }
15087 }
15088 scan_filter->BSSIDs.numOfBSSIDs = 1;
15089 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15090 bssid, sizeof(struct qdf_mac_addr));
15091
15092 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15093 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015094 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015095 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015096 goto free_scan_flter;
15097 }
15098
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015099 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015100 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015101 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015102 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015103 status = QDF_STATUS_E_FAULT;
15104 goto free_scan_flter;
15105 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015106
Naveen Rawat81f058c2017-06-02 16:02:39 -070015107 /**
15108 * Length of BSS descriptor is without length of
15109 * length itself and length of pointer that holds ieFields.
15110 *
15111 * tSirBssDescription
15112 * +--------+---------------------------------+---------------+
15113 * | length | other fields | pointer to IEs|
15114 * +--------+---------------------------------+---------------+
15115 * ^
15116 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015117 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015118 ie_len = bss_descp->length + sizeof(bss_descp->length)
15119 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015120 sme_debug("found bss_descriptor ie_len: %d channel %d",
15121 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015122
15123 /* include mac header and fixed params along with IEs in frame */
15124 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15125 *frame_buf = qdf_mem_malloc(*frame_len);
15126 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015127 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015128 status = QDF_STATUS_E_NOMEM;
15129 goto free_scan_flter;
15130 }
15131
15132 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15133
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015134 if (!*channel)
15135 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015136free_scan_flter:
15137 /* free scan filter and exit */
15138 if (scan_filter) {
15139 csr_free_scan_filter(mac_ctx, scan_filter);
15140 qdf_mem_free(scan_filter);
15141 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015142 if (result_handle)
15143 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015144
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015145 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015146}
15147
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015148#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015149QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile,
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015150 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015151 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015152{
15153 QDF_STATUS status;
15154 struct wma_roam_invoke_cmd *fastreassoc;
15155 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015156 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015157
15158 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15159 if (NULL == fastreassoc) {
15160 sme_err("qdf_mem_malloc failed for fastreassoc");
15161 return QDF_STATUS_E_NOMEM;
15162 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015163 /* if both are same then set the flag */
15164 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15165 fastreassoc->is_same_bssid = true;
15166 sme_debug("bssid same, bssid[%pM]", bssid);
15167 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015168 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015169 fastreassoc->bssid[0] = bssid[0];
15170 fastreassoc->bssid[1] = bssid[1];
15171 fastreassoc->bssid[2] = bssid[2];
15172 fastreassoc->bssid[3] = bssid[3];
15173 fastreassoc->bssid[4] = bssid[4];
15174 fastreassoc->bssid[5] = bssid[5];
15175
15176 status = sme_get_beacon_frm(hal, profile, bssid,
15177 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015178 &fastreassoc->frame_len,
15179 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015180
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015181 if (!channel) {
15182 sme_err("channel retrieval from BSS desc fails!");
15183 qdf_mem_free(fastreassoc);
15184 return QDF_STATUS_E_FAULT;
15185 }
15186
15187 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015188 if (QDF_STATUS_SUCCESS != status) {
15189 sme_warn("sme_get_beacon_frm failed");
15190 fastreassoc->frame_buf = NULL;
15191 fastreassoc->frame_len = 0;
15192 }
15193
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015194 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15195 connectedProfile.AuthType)) {
15196 sme_debug("Beacon is not required for ESE");
15197 if (fastreassoc->frame_len) {
15198 qdf_mem_free(fastreassoc->frame_buf);
15199 fastreassoc->frame_buf = NULL;
15200 fastreassoc->frame_len = 0;
15201 }
15202 }
15203
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015204 msg.type = SIR_HAL_ROAM_INVOKE;
15205 msg.reserved = 0;
15206 msg.bodyptr = fastreassoc;
15207 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15208 if (QDF_STATUS_SUCCESS != status) {
15209 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15210 qdf_mem_free(fastreassoc);
15211 }
15212
15213 return status;
15214}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015215#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015216
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015217QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15218 tPmkidCacheInfo *pmk_cache_info,
15219 bool is_add)
15220{
15221 struct wmi_unified_pmk_cache *pmk_cache;
15222 struct scheduler_msg msg;
15223
15224 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15225 if (!pmk_cache) {
15226 sme_err("Memory allocation failure");
15227 return QDF_STATUS_E_NOMEM;
15228 }
15229
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015230 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15231
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015232 pmk_cache->session_id = session_id;
15233
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015234 if (!pmk_cache_info)
15235 goto send_flush_cmd;
15236
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015237 if (!pmk_cache_info->ssid_len) {
15238 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15239 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15240 &pmk_cache->bssid);
15241 } else {
15242 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15243 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15244 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15245 pmk_cache_info->ssid,
15246 pmk_cache->ssid.length);
15247 }
15248 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15249 pmk_cache_info->cache_id[1]);
15250
15251 if (is_add)
15252 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15253 else
15254 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15255
15256 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15257 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15258 CSR_RSN_PMKID_SIZE);
15259
15260 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15261 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15262 pmk_cache->pmk_len);
15263
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015264send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015265 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15266 msg.reserved = 0;
15267 msg.bodyptr = pmk_cache;
15268 if (QDF_STATUS_SUCCESS !=
15269 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15270 sme_err("Not able to post message to WDA");
15271 qdf_mem_free(pmk_cache);
15272 return QDF_STATUS_E_FAILURE;
15273 }
15274
15275 return QDF_STATUS_SUCCESS;
15276}
15277
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015278/* ARP DEBUG STATS */
15279
15280/**
15281 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15282 * @hal: handle to hal
15283 * @set_stats_param: pointer to set stats param
15284 *
15285 * Return: Return QDF_STATUS.
15286 */
15287QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15288 struct set_arp_stats_params
15289 *set_stats_param)
15290{
15291 struct set_arp_stats_params *arp_set_param;
15292 struct scheduler_msg msg;
15293
15294 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15295 if (arp_set_param == NULL) {
15296 sme_err("Memory allocation failure");
15297 return QDF_STATUS_E_NOMEM;
15298 }
15299
15300 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15301
15302 msg.type = WMA_SET_ARP_STATS_REQ;
15303 msg.reserved = 0;
15304 msg.bodyptr = arp_set_param;
15305
15306 if (QDF_STATUS_SUCCESS !=
15307 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15308 sme_err("Not able to post message to WDA");
15309 qdf_mem_free(arp_set_param);
15310 return QDF_STATUS_E_FAILURE;
15311 }
15312
15313 return QDF_STATUS_SUCCESS;
15314}
15315
15316/**
15317 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15318 * @hal: handle to hal
15319 * @get_stats_param: pointer to set stats param
15320 *
15321 * Return: Return QDF_STATUS.
15322 */
15323QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15324 struct get_arp_stats_params
15325 *get_stats_param)
15326{
15327 struct get_arp_stats_params *arp_get_param;
15328 struct scheduler_msg msg;
15329
15330 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15331 if (arp_get_param == NULL) {
15332 sme_err("Memory allocation failure");
15333 return QDF_STATUS_E_NOMEM;
15334 }
15335
15336 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15337
15338 msg.type = WMA_GET_ARP_STATS_REQ;
15339 msg.reserved = 0;
15340 msg.bodyptr = arp_get_param;
15341
15342 if (QDF_STATUS_SUCCESS !=
15343 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15344 sme_err("Not able to post message to WDA");
15345 qdf_mem_free(arp_get_param);
15346 return QDF_STATUS_E_FAILURE;
15347 }
15348
15349 return QDF_STATUS_SUCCESS;
15350}
15351
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015352QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15353 uint32_t param_value, uint32_t vdev_id)
15354{
15355 void *wma_handle;
15356
15357 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15358 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015359 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015360 return QDF_STATUS_E_FAILURE;
15361 }
15362
15363 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15364 param_value, vdev_id);
15365}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015366
15367QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015368 bool (*set_connection_info_cb)(bool),
15369 bool (*get_connection_info_cb)(uint8_t *session_id,
15370 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015371{
15372 QDF_STATUS status = QDF_STATUS_SUCCESS;
15373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15374
15375 status = sme_acquire_global_lock(&pMac->sme);
15376 if (QDF_IS_STATUS_SUCCESS(status)) {
15377 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015378 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015379 sme_release_global_lock(&pMac->sme);
15380 }
15381 return status;
15382}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015383
15384QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15385 void (*cb)(void *, struct rso_cmd_status *))
15386{
15387 QDF_STATUS status = QDF_STATUS_SUCCESS;
15388 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15389
15390 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015391 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015392 return status;
15393}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015394
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015395QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15396 struct wmi_dbs_scan_sel_params *params)
15397{
15398 struct scheduler_msg message = {0};
15399 QDF_STATUS status;
15400 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15401 uint32_t i;
15402
15403 if (0 == params->num_clients) {
15404 sme_err("Num of clients is 0");
15405 return QDF_STATUS_E_FAILURE;
15406 }
15407
15408 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15409 if (!dbs_scan_params) {
15410 sme_err("fail to alloc dbs_scan_params");
15411 return QDF_STATUS_E_NOMEM;
15412 }
15413
15414 dbs_scan_params->num_clients = params->num_clients;
15415 dbs_scan_params->pdev_id = params->pdev_id;
15416 for (i = 0; i < params->num_clients; i++) {
15417 dbs_scan_params->module_id[i] = params->module_id[i];
15418 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15419 dbs_scan_params->num_non_dbs_scans[i] =
15420 params->num_non_dbs_scans[i];
15421 }
15422 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15423 message.bodyptr = dbs_scan_params;
15424 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15425 if (!QDF_IS_STATUS_SUCCESS(status)) {
15426 sme_err("Not able to post msg to WMA!");
15427 qdf_mem_free(dbs_scan_params);
15428 }
15429
15430 return status;
15431}
15432
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015433QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15434{
15435 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15436 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015437 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015438 struct sme_rcpi_req *rcpi_req;
15439
15440 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15441 if (rcpi_req == NULL) {
15442 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15443 "%s: Not able to allocate memory for rcpi req",
15444 __func__);
15445 return QDF_STATUS_E_NOMEM;
15446 }
15447 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15448
15449 status = sme_acquire_global_lock(&pMac->sme);
15450 if (QDF_IS_STATUS_SUCCESS(status)) {
15451 msg.bodyptr = rcpi_req;
15452 msg.type = WMA_GET_RCPI_REQ;
15453 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15454 sme_release_global_lock(&pMac->sme);
15455 if (!QDF_IS_STATUS_SUCCESS(status)) {
15456 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15457 FL("post get rcpi req failed"));
15458 status = QDF_STATUS_E_FAILURE;
15459 qdf_mem_free(rcpi_req);
15460 }
15461 } else {
15462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15463 FL("sme_acquire_global_lock failed"));
15464 qdf_mem_free(rcpi_req);
15465 }
15466
15467 return status;
15468}
15469
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015470void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15471{
15472 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15473 void *wma_handle;
15474 QDF_STATUS status;
15475
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015476 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015477 if (QDF_STATUS_SUCCESS != status) {
15478 mac_ctx->pdev = NULL;
15479 return;
15480 }
15481 mac_ctx->pdev = pdev;
15482 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15483 if (!wma_handle) {
15484 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015485 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015486 return;
15487 }
15488 wma_store_pdev(wma_handle, pdev);
15489}
15490
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015491QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15492 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15493{
15494 QDF_STATUS status;
15495 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15496
15497 status = sme_acquire_global_lock(&mac->sme);
15498 if (QDF_IS_STATUS_SUCCESS(status)) {
15499 mac->sme.congestion_cb = congestion_cb;
15500 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015501 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015502 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015503 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015504 }
15505
15506 return status;
15507}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015508
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015509QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
15510 void (*tx_queue_cb)(void *,
15511 uint32_t vdev_id,
15512 enum netif_action_type action,
15513 enum netif_reason_type reason))
15514{
15515 QDF_STATUS status;
15516 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15517
15518 status = sme_acquire_global_lock(&mac->sme);
15519 if (QDF_IS_STATUS_SUCCESS(status)) {
15520 mac->sme.tx_queue_cb = tx_queue_cb;
15521 sme_release_global_lock(&mac->sme);
15522 sme_debug("Tx queue callback set");
15523 } else {
15524 sme_err("Aquiring lock failed %d", status);
15525 }
15526
15527 return status;
15528}
15529
15530QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
15531{
15532 return sme_register_tx_queue_cb(hal, NULL);
15533}
15534
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015535QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15536 uint32_t param_val)
15537{
15538 return wma_configure_smps_params(vdev_id, param_id, param_val);
15539}
15540
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015541QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15542 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15543{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015544 wma_cli_set_cmd_t *iwcmd;
15545 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015546
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015547 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15548 if (!iwcmd) {
15549 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015550 return QDF_STATUS_E_NOMEM;
15551 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015552
15553 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15554 iwcmd->param_sec_value = 0;
15555 iwcmd->param_vdev_id = vdev_id;
15556 iwcmd->param_id = param_id;
15557 iwcmd->param_vp_dev = req_cat;
15558 iwcmd->param_value = param_val;
15559 wma_ipa_uc_stat_request(iwcmd);
15560 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015561
15562 return status;
15563}
lifeng66831662017-05-19 16:01:35 +080015564
15565QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15566 struct sir_set_rx_reorder_timeout_val *req)
15567{
15568 QDF_STATUS status;
15569
15570 status = wma_set_rx_reorder_timeout_val(hal, req);
15571
15572 return status;
15573}
15574
15575QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15576 struct sir_peer_set_rx_blocksize *req)
15577{
15578 QDF_STATUS status;
15579
15580 status = wma_set_rx_blocksize(hal, req);
15581
15582 return status;
15583}
Naveen Rawat247a8682017-06-05 15:00:31 -070015584
15585int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15586{
15587 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15588}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015589
15590QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15591 void (*cb)(void *, uint32_t bt_activity))
15592{
15593 QDF_STATUS status;
15594 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15595
15596 status = sme_acquire_global_lock(&mac->sme);
15597 if (QDF_IS_STATUS_SUCCESS(status)) {
15598 mac->sme.bt_activity_info_cb = cb;
15599 sme_release_global_lock(&mac->sme);
15600 sme_debug("bt activity info callback set");
15601 } else {
15602 sme_debug("sme_acquire_global_lock failed %d", status);
15603 }
15604
15605 return status;
15606}
lifengd217d192017-05-09 19:44:16 +080015607
15608QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15609 struct get_chain_rssi_req_params *input,
15610 get_chain_rssi_callback callback,
15611 void *context)
15612{
15613 QDF_STATUS status = QDF_STATUS_SUCCESS;
15614 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15615
15616 SME_ENTER();
15617
15618 if (NULL == input) {
15619 sme_err("Invalid req params");
15620 return QDF_STATUS_E_INVAL;
15621 }
15622
15623 mac_ctx->sme.get_chain_rssi_cb = callback;
15624 mac_ctx->sme.get_chain_rssi_context = context;
15625 wma_get_chain_rssi(hal, input);
15626
15627 SME_EXIT();
15628 return status;
15629}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015630
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015631QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15632 struct scheduler_msg *msg)
15633{
15634 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15635
15636 if (msg == NULL) {
15637 sme_err("Empty message for SME Msg callback");
15638 return status;
15639 }
15640 status = sme_process_msg(hal, msg);
15641 return status;
15642}
15643
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015644void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15645{
15646 struct csr_roam_session *session;
15647 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15648
15649 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15650 sme_err("%s Invalid session id: %d", __func__, session_id);
15651 return;
15652 }
15653
15654 session = CSR_GET_SESSION(mac_ctx, session_id);
15655 if (!session) {
15656 sme_err("%s Failed to get session for id: %d",
15657 __func__, session_id);
15658 return;
15659 }
15660
15661 sme_debug("Total No. of Disconnections: %d",
15662 session->disconnect_stats.disconnection_cnt);
15663
15664 sme_debug("No. of Diconnects Triggered by Application: %d",
15665 session->disconnect_stats.disconnection_by_app);
15666
15667 sme_debug("No. of Disassoc Sent by Peer: %d",
15668 session->disconnect_stats.disassoc_by_peer);
15669
15670 sme_debug("No. of Deauth Sent by Peer: %d",
15671 session->disconnect_stats.deauth_by_peer);
15672
15673 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15674 session->disconnect_stats.bmiss);
15675
15676 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15677 session->disconnect_stats.peer_kickout);
15678}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015679
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015680 /**
15681 * sme_set_vc_mode_config() - Set voltage corner config to FW
15682 * @bitmap: Bitmap that referes to voltage corner config with
15683 * different phymode and bw configuration
15684 *
15685 * Return: QDF_STATUS
15686 */
15687QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15688{
15689 void *wma_handle;
15690
15691 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15692 if (!wma_handle) {
15693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15694 "wma_handle is NULL");
15695 return QDF_STATUS_E_FAILURE;
15696 }
15697 if (QDF_STATUS_SUCCESS !=
15698 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15699 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15700 "%s: Failed to set Voltage Control config to FW",
15701 __func__);
15702 return QDF_STATUS_E_FAILURE;
15703 }
15704 return QDF_STATUS_SUCCESS;
15705}
15706
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015707/**
15708 * sme_set_bmiss_bcnt() - set bmiss config parameters
15709 * @vdev_id: virtual device for the command
15710 * @first_cnt: bmiss first value
15711 * @final_cnt: bmiss final value
15712 *
15713 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15714 */
15715QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15716 uint32_t final_cnt)
15717{
15718 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15719}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015720
15721QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15722 bool is_tos_active, uint32_t max_off_chan_time,
15723 uint32_t rest_time, bool skip_dfs_chan)
15724{
15725 struct sir_limit_off_chan *cmd;
15726 struct scheduler_msg msg = {0};
15727
15728 cmd = qdf_mem_malloc(sizeof(*cmd));
15729 if (!cmd) {
15730 sme_err("qdf_mem_malloc failed for limit off channel");
15731 return QDF_STATUS_E_NOMEM;
15732 }
15733
15734 cmd->vdev_id = vdev_id;
15735 cmd->is_tos_active = is_tos_active;
15736 cmd->max_off_chan_time = max_off_chan_time;
15737 cmd->rest_time = rest_time;
15738 cmd->skip_dfs_chans = skip_dfs_chan;
15739
15740 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15741 msg.reserved = 0;
15742 msg.bodyptr = cmd;
15743
15744 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15745 &msg))) {
15746 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15747 qdf_mem_free(cmd);
15748 return QDF_STATUS_E_FAILURE;
15749 }
15750
15751 return QDF_STATUS_SUCCESS;
15752}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015753
15754/**
15755 * sme_get_status_for_candidate() - Get bss transition status for candidate
15756 * @hal: Handle for HAL
15757 * @conn_bss_desc: connected bss descriptor
15758 * @bss_desc: candidate bss descriptor
15759 * @info: candiadate bss information
15760 * @trans_reason: transition reason code
15761 * @is_bt_in_progress: bt activity indicator
15762 *
15763 * Return : true if candidate is rejected and reject reason is filled
15764 * @info->status. Otherwise returns false.
15765 */
15766static bool sme_get_status_for_candidate(tHalHandle *hal,
15767 tSirBssDescription *conn_bss_desc,
15768 tSirBssDescription *bss_desc,
15769 struct bss_candidate_info *info,
15770 uint8_t trans_reason,
15771 bool is_bt_in_progress)
15772{
15773 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15774
15775 /*
15776 * Low RSSI based rejection
15777 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15778 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15779 * candidate with MBO reason code 4.
15780 */
15781 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15782 mbo_candidate_rssi_thres) &&
15783 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15784 mbo_current_rssi_thres)) {
15785 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15786 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15787 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15788 return true;
15789 }
15790
15791 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15792 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15793 /*
15794 * MCC rejection
15795 * If moving to candidate's channel will result in MCC scenario
15796 * and the rssi of connected bss is greater than
15797 * mbo_current_rssi_mss_thres, then reject the candidate with
15798 * MBO reason code 3.
15799 */
15800 if ((conn_bss_desc->rssi >
15801 mac_ctx->roam.configParam.mbo_thresholds.
15802 mbo_current_rssi_mcc_thres) &&
15803 csr_is_mcc_channel(hal, bss_desc->channelId)) {
15804 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15805 MAC_ADDR_ARRAY(bss_desc->bssId));
15806 info->status =
15807 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15808 return true;
15809 }
15810
15811 /*
15812 * BT coex rejection
15813 * If AP is trying to move the client from 5G to 2.4G and moving
15814 * to 2.4G will result in BT coex and candidate channel rssi is
15815 * less than mbo_candidate_rssi_btc_thres, then reject the
15816 * candidate with MBO reason code 2.
15817 */
15818 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15819 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15820 is_bt_in_progress &&
15821 (bss_desc->rssi <
15822 mac_ctx->roam.configParam.mbo_thresholds.
15823 mbo_candidate_rssi_btc_thres)) {
15824 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15825 MAC_ADDR_ARRAY(bss_desc->bssId));
15826 info->status =
15827 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15828 return true;
15829 }
15830
15831 /*
15832 * LTE coex rejection
15833 * If moving to candidate's channel can cause LTE coex, then
15834 * reject the candidate with MBO reason code 5.
15835 */
15836 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15837 conn_bss_desc->channelId) &&
15838 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
15839 bss_desc->channelId))) {
15840 sme_err("High interference expected if transitioned to BSS "
15841 MAC_ADDRESS_STR" hence reject",
15842 MAC_ADDR_ARRAY(bss_desc->bssId));
15843 info->status =
15844 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
15845 return true;
15846 }
15847 }
15848
15849 return false;
15850}
15851
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015852uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15853 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15854 bool append_ie)
15855{
15856 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15857
Abhishek Singh3f13a812018-01-16 14:24:44 +053015858 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015859}
15860
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015861/**
15862 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
15863 * @adapter : Pointer to adapter
15864 * @transition_reason : Transition reason
15865 * @info : bss candidate information
15866 * @n_candidates : number of candidates
15867 *
15868 * Return : 0 on success otherwise errno
15869 */
15870int sme_get_bss_transition_status(tHalHandle hal,
15871 uint8_t transition_reason,
15872 struct qdf_mac_addr *bssid,
15873 struct bss_candidate_info *info,
15874 uint16_t n_candidates,
15875 bool is_bt_in_progress)
15876{
15877 QDF_STATUS status = QDF_STATUS_SUCCESS;
15878 tSirBssDescription *bss_desc, *conn_bss_desc;
15879 tCsrScanResultInfo *res, *conn_res;
15880 uint16_t i;
15881
15882 if (!n_candidates || !info) {
15883 sme_err("No candidate info available");
15884 return QDF_STATUS_E_INVAL;
15885 }
15886
15887 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15888 if (!conn_res) {
15889 sme_err("Failed to allocate memory for conn_res");
15890 return QDF_STATUS_E_NOMEM;
15891 }
15892
15893 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15894 if (!res) {
15895 sme_err("Failed to allocate memory for conn_res");
15896 status = QDF_STATUS_E_NOMEM;
15897 goto free;
15898 }
15899
15900 /* Get the connected BSS descriptor */
15901 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
15902 if (!QDF_IS_STATUS_SUCCESS(status)) {
15903 sme_err("Failed to find connected BSS in scan list");
15904 goto free;
15905 }
15906 conn_bss_desc = &conn_res->BssDescriptor;
15907
15908 for (i = 0; i < n_candidates; i++) {
15909 /* Get candidate BSS descriptors */
15910 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
15911 res);
15912 if (!QDF_IS_STATUS_SUCCESS(status)) {
15913 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
15914 MAC_ADDR_ARRAY(info[i].bssid.bytes));
15915 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
15916 continue;
15917 }
15918
15919 bss_desc = &res->BssDescriptor;
15920 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
15921 &info[i], transition_reason, is_bt_in_progress)) {
15922 /*
15923 * If status is not over written, it means it is a
15924 * candidate for accept.
15925 */
15926 info[i].status = QCA_STATUS_ACCEPT;
15927 }
15928 }
15929
15930 /* success */
15931 status = QDF_STATUS_SUCCESS;
15932
15933free:
15934 /* free allocated memory */
15935 if (conn_res)
15936 qdf_mem_free(conn_res);
15937 if (res)
15938 qdf_mem_free(res);
15939
15940 return status;
15941}
15942
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015943void sme_enable_roaming_on_connected_sta(tHalHandle hal)
15944{
15945 uint8_t session_id;
15946 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15947 QDF_STATUS status;
15948
15949 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
15950 if (session_id != CSR_SESSION_ID_INVALID)
15951 return;
15952
15953 session_id = csr_get_connected_infra(mac_ctx);
15954 if (session_id == CSR_SESSION_ID_INVALID) {
15955 sme_debug("No STA in conencted state");
15956 return;
15957 }
15958
15959 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
15960 session_id);
15961 status = sme_acquire_global_lock(&mac_ctx->sme);
15962 if (QDF_IS_STATUS_SUCCESS(status)) {
15963 csr_roam_offload_scan(mac_ctx, session_id,
15964 ROAM_SCAN_OFFLOAD_START,
15965 REASON_CTX_INIT);
15966 sme_release_global_lock(&mac_ctx->sme);
15967 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015968}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015969
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015970int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
15971{
15972 uint8_t vdev_id, chan;
15973 struct csr_roam_session *session;
15974 tpAniSirGlobal mac_ctx;
15975 tHalHandle h_hal;
15976 int16_t freq = 0;
15977
15978 if (vdev == NULL) {
15979 sme_err("Invalid vdev id is passed");
15980 return 0;
15981 }
15982
15983 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080015984 if (!h_hal) {
15985 sme_err("h_hal is null");
15986 return 0;
15987 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015988 mac_ctx = PMAC_STRUCT(h_hal);
15989 vdev_id = wlan_vdev_get_id(vdev);
15990 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
15991 sme_err("Invalid vdev id is passed");
15992 return 0;
15993 }
15994
15995 session = CSR_GET_SESSION(mac_ctx, vdev_id);
15996 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
15997 if (chan)
15998 freq = cds_chan_to_freq(chan);
15999
16000 return freq;
16001}
16002
16003enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
16004{
16005 uint8_t vdev_id;
16006 struct csr_roam_session *session;
16007 tpAniSirGlobal mac_ctx;
16008 tHalHandle h_hal;
16009 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
16010
16011 if (vdev == NULL) {
16012 sme_err("Invalid vdev id is passed");
16013 return CH_WIDTH_INVALID;
16014 }
16015
16016 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016017 if (!h_hal) {
16018 sme_err("h_hal is null");
16019 return CH_WIDTH_INVALID;
16020 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016021 mac_ctx = PMAC_STRUCT(h_hal);
16022 vdev_id = wlan_vdev_get_id(vdev);
16023 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16024 sme_err("Invalid vdev id is passed");
16025 return CH_WIDTH_INVALID;
16026 }
16027
16028 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16029
16030 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16031 ch_width = session->connectedProfile.vht_channel_width;
16032
16033 return ch_width;
16034}
16035
16036int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16037 uint16_t *sec20chan_freq)
16038{
16039 uint8_t vdev_id;
16040
16041 vdev_id = wlan_vdev_get_id(vdev);
16042 /* Need to extend */
16043 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016044}
16045
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016046#ifdef WLAN_FEATURE_SAE
16047QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16048 uint8_t sae_status)
16049{
16050 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16051 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16052 struct sir_sae_msg *sae_msg;
16053 struct scheduler_msg sch_msg = {0};
16054
16055 qdf_status = sme_acquire_global_lock(&mac->sme);
16056 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16057 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16058 if (!sae_msg) {
16059 qdf_status = QDF_STATUS_E_NOMEM;
16060 sme_err("SAE: memory allocation failed");
16061 } else {
16062 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16063 sae_msg->length = sizeof(*sae_msg);
16064 sae_msg->session_id = session_id;
16065 sae_msg->sae_status = sae_status;
16066 sme_debug("SAE: sae_status %d session_id %d",
16067 sae_msg->sae_status,
16068 sae_msg->session_id);
16069
16070 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16071 sch_msg.bodyptr = sae_msg;
16072
16073 qdf_status =
16074 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16075 }
16076 sme_release_global_lock(&mac->sme);
16077 }
16078
16079 return qdf_status;
16080}
16081#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016082
16083bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16084{
16085 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16086
16087 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16088 sme_err("Invalid session id: %d", session_id);
16089 return false;
16090 }
16091
16092 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16093}
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016094
16095bool sme_validate_channel_list(tHalHandle hal,
16096 uint8_t *chan_list,
16097 uint8_t num_channels)
16098{
16099 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16100 uint8_t i = 0;
16101 uint8_t j;
16102 bool found;
16103 struct csr_channel *ch_lst_info = &mac_ctx->scan.base_channels;
16104
16105 if (!chan_list || !num_channels) {
16106 sme_err("Chan list empty %pK or num_channels is 0", chan_list);
16107 return false;
16108 }
16109
16110 while (i < num_channels) {
16111 found = false;
16112 for (j = 0; j < ch_lst_info->numChannels; j++) {
16113 if (ch_lst_info->channelList[j] == chan_list[i]) {
16114 found = true;
16115 break;
16116 }
16117 }
16118
16119 if (!found) {
16120 sme_debug("Invalid channel %d", chan_list[i]);
16121 return false;
16122 }
16123
16124 i++;
16125 }
Arif Hussain0e246802018-05-01 18:13:44 -070016126
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016127 return true;
16128}
Arif Hussain0e246802018-05-01 18:13:44 -070016129
16130void sme_set_amsdu(tHalHandle hal, bool enable)
16131{
16132 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16133 mac_ctx->is_usr_cfg_amsdu_enabled = enable;
16134}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016135
16136uint8_t sme_get_mcs_idx(uint16_t max_rate, uint8_t rate_flags,
16137 uint8_t nss, uint8_t *mcs_rate_flags)
16138{
16139 return wma_get_mcs_idx(max_rate, rate_flags, nss, mcs_rate_flags);
16140}