blob: 6487ed4f10086f09d3da3594ace3caaffecb9e5a [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053028/*
29 * DOC: smeApi.c
30 *
31 * Definitions for SME APIs
32 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053034/* Include Files */
Srinivas Girigowda2c263352017-03-17 17:49:53 -070035#include <sir_common.h>
36#include <ani_global.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include "sme_api.h"
38#include "csr_inside_api.h"
39#include "sme_inside.h"
40#include "csr_internal.h"
41#include "wma_types.h"
42#include "wma_if.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070043#include "wma_fips_api.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053044#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "sme_trace.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053046#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053047#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sap_api.h"
50#include "mac_trace.h"
51#ifdef WLAN_FEATURE_NAN
52#include "nan_api.h"
53#endif
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055#include "cfg_api.h"
56#include "sme_power_save_api.h"
57#include "wma.h"
Naveen Rawatb4d37622015-11-13 16:15:25 -080058#include "sch_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070059#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053060#include "csr_api.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070061#include "wlan_reg_services_api.h"
Abhishek Singh158fe252017-03-23 11:09:34 +053062#include <wlan_scan_ucfg_api.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070063#include "wlan_reg_ucfg_api.h"
Arif Hussainee677012017-01-26 17:50:13 -080064#include "ol_txrx.h"
Naveen Rawatd2657be2017-10-10 14:31:23 -070065#include "wifi_pos_api.h"
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053066#include "net/cfg80211.h"
67#include <qca_vendor.h>
Sandeep Puligilla063a4342018-01-10 02:50:14 -080068#include <wlan_spectral_utils_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053072static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053074static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
75 void *pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053077static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053079static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 void *pMsgBuf);
81
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053082static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053085QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
87#endif
88
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053090static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 uint16_t msg_type, void *pMsgBuf);
92
93/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053094QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053096 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097
98 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053099 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530100 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530101 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 }
103
104 return status;
105}
106
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530107QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530109 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110
111 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530112 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530113 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530114 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 }
116
117 return status;
118}
119
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700120tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700121{
122 tpAniSirGlobal mac_ctx;
123 tHalHandle h_hal;
124
125 h_hal = cds_get_context(QDF_MODULE_ID_SME);
126 if (NULL == h_hal) {
127 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
128 FL("invalid h_hal"));
129 return NULL;
130 }
131
132 mac_ctx = PMAC_STRUCT(h_hal);
133 if (NULL == mac_ctx) {
134 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
135 FL("Invalid MAC context"));
136 return NULL;
137 }
138
139 return mac_ctx;
140}
141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142/**
143 * sme_process_set_hw_mode_resp() - Process set HW mode response
144 * @mac: Global MAC pointer
145 * @msg: HW mode response
146 *
147 * Processes the HW mode response and invokes the HDD callback
148 * to process further
149 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530150static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151{
Krunal Sonia8270f52017-02-23 19:51:25 -0800152 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 tSmeCmd *command = NULL;
154 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800155 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530157 enum sir_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530158 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800159 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700160
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 param = (struct sir_set_hw_mode_resp *)msg;
162 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700163 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 /* Not returning. Need to check if active command list
165 * needs to be freed
166 */
167 }
168
Krunal Sonia8270f52017-02-23 19:51:25 -0800169 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700171 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800172 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 }
174
175 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
176 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700177 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800178 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 }
180
181 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700182 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 }
185
186 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530187 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800188 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530189
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700190 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530191 command->u.set_hw_mode_cmd.reason,
192 command->u.set_hw_mode_cmd.session_id);
193
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700194 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700195 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700196 goto end;
197 }
198
199 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700200 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700201 goto end;
202 }
203
204 /* Irrespective of the reason for which the hw mode change request
205 * was issued, the policy manager connection table needs to be updated
206 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
207 * set hw mode was successful.
208 */
209 callback(param->status,
210 param->cfgd_hw_mode_index,
211 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800212 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800213 command->u.set_hw_mode_cmd.next_action,
214 command->u.set_hw_mode_cmd.reason,
215 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800216 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800217 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
218 sme_err("session %d is invalid", session_id);
219 goto end;
220 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800221 session = CSR_GET_SESSION(mac, session_id);
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700222 if (reason == SIR_UPDATE_REASON_HIDDEN_STA) {
223 /* In the case of hidden SSID, connection update
224 * (set hw mode) is done after the scan with reason
225 * code eCsrScanForSsid completes. The connect/failure
226 * needs to be handled after the response of set hw
227 * mode
228 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800229 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700230 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800231 csr_scan_handle_search_for_ssid(mac,
232 session_id);
233 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700234 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800235 csr_scan_handle_search_for_ssid_failure(mac,
236 session_id);
237 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800238 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239 }
240
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530241end:
Krunal Soni72dba662017-02-15 20:13:17 -0800242 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530244 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800246 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800247
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249}
250
251/**
252 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
253 * @mac: Global MAC pointer
254 * @msg: HW mode transition response
255 *
256 * Processes the HW mode transition indication and invoke the HDD callback
257 * to process further
258 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530259static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 uint8_t *msg)
261{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 struct sir_hw_mode_trans_ind *param;
263
264 param = (struct sir_hw_mode_trans_ind *)msg;
265 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700266 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530267 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 }
269
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800270 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800271 param->new_hw_mode_index,
272 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800273 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530275 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276}
277
Naveen Rawate7d86052015-11-13 12:01:43 -0800278/**
279 * free_sme_cmds() - This function frees memory allocated for SME commands
280 * @mac_ctx: Pointer to Global MAC structure
281 *
282 * This function frees memory allocated for SME commands
283 *
284 * @Return: void
285 */
286static void free_sme_cmds(tpAniSirGlobal mac_ctx)
287{
288 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530289
Naveen Rawate7d86052015-11-13 12:01:43 -0800290 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
291 return;
292
293 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530294 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800295
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800297 mac_ctx->sme.pSmeCmdBufAddr = NULL;
298}
299
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530300static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530302 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 tSmeCmd *pCmd;
304 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800305 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306
307 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530311 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 goto end;
313
Naveen Rawate7d86052015-11-13 12:01:43 -0800314 /* following pointer contains array of pointers for tSmeCmd* */
315 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530316 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800317 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530318 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800319 goto end;
320 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530322 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800323 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
324 /*
325 * Since total size of all commands together can be huge chunk
326 * of memory, allocate SME cmd individually. These SME CMDs are
327 * moved between pending and active queues. And these freeing of
328 * these queues just manipulates the list but does not actually
329 * frees SME CMD pointers. Hence store each SME CMD address in
330 * the array, sme.pSmeCmdBufAddr. This will later facilitate
331 * freeing up of all SME CMDs with just a for loop.
332 */
333 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530334 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800335 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530336 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800337 free_sme_cmds(pMac);
338 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800340 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
341 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
342 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 }
344
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530346 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700347 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348
349 return status;
350}
351
Krunal Sonia8270f52017-02-23 19:51:25 -0800352void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353{
Krunal Sonia8270f52017-02-23 19:51:25 -0800354 sme_cmd->command = eSmeNoCommand;
355 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530356 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357}
358
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530359static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530361 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 csr_ll_close(&pMac->sme.smeCmdFreeList);
364
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530365 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530366 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700367 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 goto done;
369 }
370
Naveen Rawate7d86052015-11-13 12:01:43 -0800371 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530373 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530374 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700375 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376done:
377 return status;
378}
379
Jeff Johnson49c02f92016-10-07 10:29:09 -0700380static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381{
382 switch (pCmd->command) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700384 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 pCmd->u.roamCmd.roamReason);
386 break;
387
388 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700389 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 pCmd->u.wmStatusChangeCmd.Type);
391 break;
392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700394 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 pCmd->command);
396 break;
397 }
398}
399
400tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
401{
402 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
403 tListElem *pEntry;
404 static int sme_command_queue_full;
405
406 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
407
408 /* If we can get another MS Msg buffer, then we are ok. Just link */
409 /* the entry onto the linked list. (We are using the linked list */
410 /* to keep track of tfhe message buffers). */
411 if (pEntry) {
412 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
413 /* reset when free list is available */
414 sme_command_queue_full = 0;
415 } else {
416 int idx = 1;
417
418 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800419 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530420 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530422
423 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
425 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530426 if (eSmeCsrCommandMask & pTempCmd->command)
427 /* CSR command is stuck. See what the reason
428 * code is for that command
429 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 } /* if(pTempCmd) */
432
433 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800434 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800436 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 LL_ACCESS_NOLOCK);
438 while (pEntry && !sme_command_queue_full) {
439 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
440 /* Print only 1st five commands from pending queue. */
441 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530442 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 idx, pTempCmd->command);
444 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530445 if (eSmeCsrCommandMask & pTempCmd->command)
446 /* CSR command is stuck. See what the reason
447 * code is for that command
448 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800450 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 LL_ACCESS_NOLOCK);
452 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800453 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454
Abhishek Singh5ea86532016-04-27 14:10:53 +0530455 if (pMac->roam.configParam.enable_fatal_event)
456 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
457 WLAN_LOG_INDICATOR_HOST_DRIVER,
458 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
459 false,
460 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530461 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530462 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 }
464
465 /* memset to zero */
466 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530467 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530469 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530471 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 }
473
474 return pRetCmd;
475}
476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800478 * sme_ser_handle_active_cmd() - handle command activation callback from
479 * new serialization module
480 * @cmd: pointer to new serialization command
481 *
482 * This API is to handle command activation callback from new serialization
483 * callback
484 *
485 * Return: QDF_STATUS_SUCCESS
486 */
487static
488QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
489{
490 tSmeCmd *sme_cmd;
491 tHalHandle hal;
492 tpAniSirGlobal mac_ctx;
493 QDF_STATUS status = QDF_STATUS_SUCCESS;
494 bool do_continue;
495
496 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700497 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800498 return QDF_STATUS_E_FAILURE;
499 }
500
501 hal = cds_get_context(QDF_MODULE_ID_SME);
502 mac_ctx = PMAC_STRUCT(hal);
503 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700504 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800505 return QDF_STATUS_E_FAILURE;
506 }
507 sme_cmd = cmd->umac_cmd;
508 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700509 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800510 return QDF_STATUS_E_FAILURE;
511 }
512
513 switch (sme_cmd->command) {
514 case eSmeCommandRoam:
515 status = csr_roam_process_command(mac_ctx, sme_cmd);
516 break;
517 case eSmeCommandWmStatusChange:
518 csr_roam_process_wm_status_change_command(mac_ctx,
519 sme_cmd);
520 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800521 /*
522 * Treat standby differently here because caller may not be able
523 * to handle the failure so we do our best here
524 */
525 case eSmeCommandEnterStandby:
526 break;
527 case eSmeCommandAddTs:
528 case eSmeCommandDelTs:
529#ifndef WLAN_MDM_CODE_REDUCTION_OPT
530 do_continue = qos_process_command(mac_ctx, sme_cmd);
531 if (do_continue)
532 status = QDF_STATUS_E_FAILURE;
533#endif
534 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800535 case e_sme_command_set_hw_mode:
536 csr_process_set_hw_mode(mac_ctx, sme_cmd);
537 break;
538 case e_sme_command_nss_update:
539 csr_process_nss_update_req(mac_ctx, sme_cmd);
540 break;
541 case e_sme_command_set_dual_mac_config:
542 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
543 break;
544 case e_sme_command_set_antenna_mode:
545 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
546 break;
547 default:
548 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700549 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800550 status = QDF_STATUS_E_FAILURE;
551 break;
552 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800553 return status;
554}
555
556QDF_STATUS sme_ser_cmd_callback(void *buf,
557 enum wlan_serialization_cb_reason reason)
558{
559 struct wlan_serialization_command *cmd = buf;
560 tHalHandle hal;
561 tpAniSirGlobal mac_ctx;
562 QDF_STATUS status = QDF_STATUS_SUCCESS;
563 tSmeCmd *sme_cmd;
564
565 hal = cds_get_context(QDF_MODULE_ID_SME);
566 mac_ctx = PMAC_STRUCT(hal);
567 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700568 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800569 return QDF_STATUS_E_FAILURE;
570 }
571 /*
572 * Do not acquire lock here as sme global lock is already acquired in
573 * caller or MC thread context
574 */
575 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700576 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800577 return QDF_STATUS_E_FAILURE;
578 }
579
580 switch (reason) {
581 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700582 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800583 status = sme_ser_handle_active_cmd(cmd);
584 break;
585 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700586 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800587 break;
588 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700589 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800590 sme_cmd = cmd->umac_cmd;
591 csr_release_command_buffer(mac_ctx, sme_cmd);
592 break;
593 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700594 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800595 break;
596 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700597 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800598 return QDF_STATUS_E_FAILURE;
599 }
600 return status;
601}
602
603/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530604 * sme_get_sessionid_from_activelist() - gets session id
605 * @mac: mac context
606 *
607 * This function is used to get session id from sme command
608 * active list
609 *
610 * Return: returns session id
611 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700612static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530613{
614 tListElem *entry;
615 tSmeCmd *command;
616 uint32_t session_id = CSR_SESSION_ID_INVALID;
617
Krunal Sonia8270f52017-02-23 19:51:25 -0800618 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530619 if (entry) {
620 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
621 session_id = command->sessionId;
622 }
623
624 return session_id;
625}
626
627/**
628 * sme_state_info_dump() - prints state information of sme layer
629 * @buf: buffer pointer
630 * @size: size of buffer to be filled
631 *
632 * This function is used to dump state information of sme layer
633 *
634 * Return: None
635 */
636static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
637{
638 uint32_t session_id, active_session_id;
639 tHalHandle hal;
640 tpAniSirGlobal mac;
641 uint16_t len = 0;
642 char *buf = *buf_ptr;
643 eCsrConnectState connect_state;
644
645 hal = cds_get_context(QDF_MODULE_ID_SME);
646 if (hal == NULL) {
647 QDF_ASSERT(0);
648 return;
649 }
650
651 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530652
653 active_session_id = sme_get_sessionid_from_activelist(mac);
654 if (active_session_id != CSR_SESSION_ID_INVALID) {
655 len += qdf_scnprintf(buf + len, *size - len,
656 "\n active command sessionid %d", active_session_id);
657 }
658
659 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
660 if (CSR_IS_SESSION_VALID(mac, session_id)) {
661 connect_state =
662 mac->roam.roamSession[session_id].connectState;
663 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
664 connect_state)
665 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
666 connect_state)) {
667 len += qdf_scnprintf(buf + len, *size - len,
668 "\n NeighborRoamState: %d",
669 mac->roam.neighborRoamInfo[session_id].
670 neighborRoamState);
671 len += qdf_scnprintf(buf + len, *size - len,
672 "\n RoamState: %d", mac->roam.
673 curState[session_id]);
674 len += qdf_scnprintf(buf + len, *size - len,
675 "\n RoamSubState: %d", mac->roam.
676 curSubState[session_id]);
677 len += qdf_scnprintf(buf + len, *size - len,
678 "\n ConnectState: %d",
679 connect_state);
680 }
681 }
682 }
683
684 *size -= len;
685 *buf_ptr += len;
686}
687
688/**
689 * sme_register_debug_callback() - registration function sme layer
690 * to print sme state information
691 *
692 * Return: None
693 */
694static void sme_register_debug_callback(void)
695{
696 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
697}
698
699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700/* Global APIs */
701
702/**
703 * sme_open() - Initialze all SME modules and put them at idle state
704 * @hHal: The handle returned by mac_open
705 *
706 * The function initializes each module inside SME, PMC, CSR, etc. Upon
707 * successfully return, all modules are at idle state ready to start.
708 * smeOpen must be called before any other SME APIs can be involved.
709 * smeOpen must be called after mac_open.
710 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530711 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 * Other status means SME is failed to be initialized
713 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530714QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800715{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530716 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718
719 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530720 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530721 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700723 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530724 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 }
726 status = csr_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("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 return status;
730 }
731
732 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530733 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700734 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 return status;
736 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
738#ifndef WLAN_MDM_CODE_REDUCTION_OPT
739 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530740 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700741 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 return status;
743 }
744#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530746 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530750 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700751 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 return status;
753 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530755 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700756 wlan_serialization_legacy_init_callback();
757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 return status;
759}
760
761/*
762 * sme_init_chan_list, triggers channel setup based on country code.
763 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530764QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700765 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766{
767 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
768
Amar Singhala297bfa2015-10-15 15:07:29 -0700769 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
771 pmac->roam.configParam.Is11dSupportEnabled = false;
772 }
773
774 return csr_init_chan_list(pmac, alpha2);
775}
776
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530777/*
778 * sme_set11dinfo() - Set the 11d information about valid channels
779 * and there power using information from nvRAM
780 * This function is called only for AP.
781 *
782 * This is a synchronous call
783 *
784 * hHal - The handle returned by mac_open.
785 * pSmeConfigParams - a pointer to a caller allocated object of
786 * typedef struct _smeConfigParams.
787 *
788 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
789 *
790 * Other status means SME is failed to update the config parameters.
791 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530793QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530797 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
799 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700800 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return status;
802 }
803
804 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700805 if (!QDF_IS_STATUS_SUCCESS(status))
806 sme_err("csr_set_channels failed with status: %d", status);
807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 return status;
809}
810
811/**
812 * sme_set_scan_disable() - Dynamically enable/disable scan
813 * @h_hal: Handle to HAL
814 *
815 * This command gives the user an option to dynamically
816 * enable or disable scans.
817 *
818 * Return: None
819 */
820void sme_set_scan_disable(tHalHandle h_hal, int value)
821{
822 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530823
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700824 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530825 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530827/*
828 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
829 * This is a synchronous call
830 *
831 * hHal - The handle returned by HostapdAdapter.
832 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
833 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
834 * Other status means, failed to get the current regulatory domain.
835 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530837QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
838 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530840 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
842
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530843 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
845 NO_SESSION, 0));
846 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700847 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 return status;
849 }
850
851 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530852 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
854 return status;
855}
856
Krunal Sonie3531942016-04-12 17:43:53 -0700857/**
858 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
859 * incoming val
860 * @hal: Handle for Hal layer
861 * @val: New FTM capability value
862 *
863 * Return: None
864 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530865void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
866 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700867{
868 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530869
Naveen Rawatd2657be2017-10-10 14:31:23 -0700870 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700871
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530872 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700873 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
874 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
875 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
876 } else {
877 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
878 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
879 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
880 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530881
882 /* Inform this RRM IE change to FW */
883 csr_roam_offload_scan(mac_ctx, session_id,
884 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
885 REASON_CONNECT_IES_CHANGED);
Krunal Sonie3531942016-04-12 17:43:53 -0700886}
887
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530888/*
889 * sme_update_config() - Change configurations for all SME moduels
890 * The function updates some configuration for modules in SME, CSR, etc
891 * during SMEs close open sequence.
892 * Modules inside SME apply the new configuration at the next transaction.
893 * This is a synchronous call
894 *
895 * hHal - The handle returned by mac_open.
896 * pSmeConfigParams - a pointer to a caller allocated object of
897 * typedef struct _smeConfigParams.
898 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
899 * Other status means SME is failed to update the config parameters.
900 */
901QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
902 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530904 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
906
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530907 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
909 0));
910 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700911 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 return status;
913 }
914
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530915 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
916 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530918 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700919 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530922 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
923 rrmConfig);
924
925 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700926 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530928
929 /* For SOC, CFG is set before start We don't want to apply global CFG
930 * in connect state because that may cause some side affect
931 */
932 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934
935 /*
936 * If scan offload is enabled then lim has allow the sending of
937 * scan request to firmware even in powersave mode. The firmware has
938 * to take care of exiting from power save mode
939 */
940 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
941
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530942 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530943 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530945
946 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
947
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 return status;
949}
950
951/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530952 * sme_update_scan_roam_params() - Update the scan roaming params
953 * @mac_ctx: mac ctx
954 *
955 * Return: void.
956 */
957static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
958{
959 struct roam_filter_params scan_params = {0};
960 struct roam_ext_params *roam_params_src;
961 uint8_t i;
962 QDF_STATUS status;
963
964 roam_params_src = &mac_ctx->roam.configParam.roam_params;
965
966 scan_params.num_bssid_avoid_list =
967 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530968
969 if (scan_params.num_bssid_avoid_list >
970 MAX_AVOID_LIST_BSSID)
971 scan_params.num_bssid_avoid_list =
972 MAX_AVOID_LIST_BSSID;
973
974 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
975 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
976 &roam_params_src->bssid_avoid_list[i]);
977 }
978
979 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
980 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700981 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530982 status);
983}
984
985/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 * sme_update_roam_params() - Store/Update the roaming params
987 * @hal: Handle for Hal layer
988 * @session_id: SME Session ID
989 * @roam_params_src: The source buffer to copy
990 * @update_param: Type of parameter to be updated
991 *
992 * Return: Return the status of the updation.
993 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530994QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -0700995 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 int update_param)
997{
998 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
999 struct roam_ext_params *roam_params_dst;
1000 uint8_t i;
1001
1002 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1003 switch (update_param) {
1004 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1005 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001006 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001008 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001010 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001012 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001014 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001016 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001018 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 roam_params_dst->is_5g_pref_enabled = true;
1020 break;
1021 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301022 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1024 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001025 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1027 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001028 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301029 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001030 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 roam_params_dst->ssid_allowed_list[i].length);
1032 }
1033 break;
1034 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301035 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1037 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001038 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301040 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001041 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 sizeof(tSirMacAddr));
1043 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001044 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 }
1046 break;
1047 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301048 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301049 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001051 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301053 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001054 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 }
1056 break;
1057 case REASON_ROAM_GOOD_RSSI_CHANGED:
1058 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001059 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 break;
1061 default:
1062 break;
1063 }
1064 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1065 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301066
1067 sme_update_scan_roam_params(mac_ctx);
1068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 return 0;
1070}
1071
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301072/*
1073 * sme_process_ready_to_suspend() -
1074 * On getting ready to suspend indication, this function calls
1075 * callback registered (HDD callbacks) with SME to inform ready
1076 * to suspend indication.
1077 *
1078 * hHal - Handle returned by mac_open.
1079 * pReadyToSuspend - Parameter received along with ready to suspend
1080 * indication from WMA.
1081 * Return: None
1082 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001083static void sme_process_ready_to_suspend(tHalHandle hHal,
1084 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085{
1086 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1087
1088 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 "%s: pMac is null", __func__);
1091 return;
1092 }
1093
1094 if (NULL != pMac->readyToSuspendCallback) {
1095 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1096 pReadyToSuspend->suspended);
1097 pMac->readyToSuspendCallback = NULL;
1098 }
1099}
1100
1101#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001103/**
1104 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1105 * @hHal - Handle returned by mac_open.
1106 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1107 * indication from WMA.
1108 *
1109 * On getting ready to Ext WoW indication, this function calls callback
1110 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1111 *
1112 * Return: None
1113 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001114static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1115 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001116{
1117 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1118
1119 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301120 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 "%s: pMac is null", __func__);
1122 return;
1123 }
1124
1125 if (NULL != pMac->readyToExtWoWCallback) {
1126 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1127 pReadyToExtWoW->status);
1128 pMac->readyToExtWoWCallback = NULL;
1129 pMac->readyToExtWoWContext = NULL;
1130 }
1131
1132}
1133#endif
1134
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301135/*
1136 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1137 * that the NIC is ready tio run.
1138 * The function is called by HDD at the end of initialization stage so PE/HAL
1139 * can enable the NIC to running state.
1140 * This is a synchronous call
1141 *
1142 * @hHal - The handle returned by mac_open.
1143 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1144 * successfully.
1145 * Other status means SME failed to send the message to PE.
1146 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301147QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148{
Abhishek Singhde410b72017-05-22 15:25:39 +05301149 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301150 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1152
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301153 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1155 do {
1156
Abhishek Singhde410b72017-05-22 15:25:39 +05301157 msg = qdf_mem_malloc(sizeof(*msg));
1158 if (!msg) {
1159 sme_err("Memory allocation failed! for msg");
1160 return QDF_STATUS_E_NOMEM;
1161 }
1162 msg->messageType = eWNI_SME_SYS_READY_IND;
1163 msg->length = sizeof(*msg);
Abhishek Singhde410b72017-05-22 15:25:39 +05301164 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001165 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301167 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1168 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301169 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001171 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172 break;
1173 }
1174
1175 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301176 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001177 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 break;
1179 }
1180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 pMac->sme.state = SME_STATE_READY;
1182 } while (0);
1183
1184 return status;
1185}
1186
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001187QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1188{
1189 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1190 QDF_STATUS status = QDF_STATUS_SUCCESS;
1191
1192 if (NULL == mac_ctx) {
1193 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1194 FL("Invalid MAC context"));
1195 return QDF_STATUS_E_FAILURE;
1196 }
1197
1198 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1199 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1200 status = QDF_STATUS_E_INVAL;
1201
1202 return status;
1203}
1204
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301205/*
1206 * sme_start() - Put all SME modules at ready state.
1207 * The function starts each module in SME, PMC, CSR, etc. . Upon
1208 * successfully return, all modules are ready to run.
1209 * This is a synchronous call
1210 *
1211 * hHal - The handle returned by mac_open.
1212 * Return QDF_STATUS_SUCCESS - SME is ready.
1213 * Other status means SME is failed to start
1214 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301215QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001219 struct policy_mgr_sme_cbacks sme_cbacks;
Sandeep Puligilla063a4342018-01-10 02:50:14 -08001220 struct spectral_legacy_cbacks spectral_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221
1222 do {
1223 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301224 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001225 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 break;
1227 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001228 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001229 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001230 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1231 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1232 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1233 sme_cbacks.sme_soc_set_dual_mac_config =
1234 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001235 sme_cbacks.sme_change_mcc_beacon_interval =
1236 sme_change_mcc_beacon_interval;
1237 sme_cbacks.sme_get_ap_channel_from_scan =
1238 sme_get_ap_channel_from_scan;
1239 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001240 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1241 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001242 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001243 status);
1244 break;
1245 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -08001246 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1247 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1248 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1249 spectral_register_legacy_cb(pMac->psoc, &spectral_cb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001252 /* START RRM */
1253 status = rrm_start(pMac);
1254 if (!QDF_IS_STATUS_SUCCESS(status)) {
1255 sme_err("Failed to start RRM");
1256 break;
1257 }
1258 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 return status;
1260}
1261
Arif Hussaincd151632017-02-11 16:57:19 -08001262static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1263 struct scheduler_msg *msg)
1264{
1265 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001266 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001267 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1268 uint32_t session_id = 0;
1269 eRoamCmdStatus roam_status;
1270 eCsrRoamResult roam_result;
1271
1272 switch (msg->type) {
1273 case eWNI_SME_DFS_RADAR_FOUND:
1274 {
1275 session_id = msg->bodyval;
1276 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1277 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001279 "sapdfs: Radar indication event occurred");
1280 break;
1281 }
1282 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1283 {
1284 csa_ie_tx_complete_rsp =
1285 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1286 if (!csa_ie_tx_complete_rsp) {
1287 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1288 return QDF_STATUS_E_FAILURE;
1289 }
1290 session_id = csa_ie_tx_complete_rsp->sessionId;
1291 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1292 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001294 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1295 session_id);
1296 break;
1297 }
1298 case eWNI_SME_DFS_CAC_COMPLETE:
1299 {
1300 session_id = msg->bodyval;
1301 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1302 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301303 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001304 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1305 session_id);
1306 break;
1307 }
1308 default:
1309 {
1310 sme_err("Invalid DFS message: 0x%x", msg->type);
1311 status = QDF_STATUS_E_FAILURE;
1312 return status;
1313 }
1314 }
1315
1316 /* Indicate Radar Event to SAP */
1317 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1318 roam_status, roam_result);
1319 return status;
1320}
1321
1322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301324/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 * Handle the unprotected management frame indication from LIM and
1326 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301327 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301328QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1330{
1331 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301332 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001333 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1335
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001336 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1337 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1338 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001341 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1343
1344 return status;
1345}
1346#endif
1347
Kapil Gupta8878ad92017-02-13 11:56:04 +05301348QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1349{
1350 QDF_STATUS status = QDF_STATUS_SUCCESS;
1351 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001352 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301353 eRoamCmdStatus roamStatus;
1354 eCsrRoamResult roamResult;
1355
1356 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001357 if (!roamInfo) {
1358 sme_err("mem alloc failed for roam info");
1359 return QDF_STATUS_E_FAILURE;
1360 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301361 roamInfo->dfs_event.sessionId = session_id;
1362
1363 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1364 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301365 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301366 "sapdfs: Updated new channel event");
1367
1368 /* Indicate channel Event to SAP */
1369 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1370 roamStatus, roamResult);
1371
1372 qdf_mem_free(roamInfo);
1373 return status;
1374}
1375
1376
Abhishek Singh518323d2015-10-19 17:42:01 +05301377/**
1378 * sme_extended_change_channel_ind()- function to indicate ECSA
1379 * action frame is received in lim to SAP
1380 * @mac_ctx: pointer to global mac structure
1381 * @msg_buf: contain new channel and session id.
1382 *
1383 * This function is called to post ECSA action frame
1384 * receive event to SAP.
1385 *
1386 * Return: success if msg indicated to SAP else return failure
1387 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301388static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301389 void *msg_buf)
1390{
1391 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301392 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301393 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001394 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301395 eRoamCmdStatus roam_status;
1396 eCsrRoamResult roam_result;
1397
Abhishek Singh518323d2015-10-19 17:42:01 +05301398 ext_chan_ind = msg_buf;
1399 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001400 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301401 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301402 }
1403 session_id = ext_chan_ind->session_id;
1404 roamInfo.target_channel = ext_chan_ind->new_channel;
1405 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1406 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001407 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1408 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301409
1410 /* Indicate Ext Channel Change event to SAP */
1411 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1412 roam_status, roam_result);
1413 return status;
1414}
1415
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001416#ifdef FEATURE_WLAN_ESE
1417/**
1418 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1419 * @hHal: HAL handle
1420 * @sessionId: session id
1421 * @isEseIniFeatureEnabled: ese ini enabled
1422 *
1423 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1424 * isEseIniFeatureEnabled. This is a synchronous call
1425 *
1426 * Return: QDF_STATUS enumeration
1427 */
1428QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1429 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1430{
1431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1432
1433 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1434 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301435 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001436 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1437 __func__,
1438 pMac->roam.configParam.isEseIniFeatureEnabled,
1439 isEseIniFeatureEnabled);
1440 return QDF_STATUS_SUCCESS;
1441 }
1442
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001444 "%s: EseEnabled is changed from %d to %d", __func__,
1445 pMac->roam.configParam.isEseIniFeatureEnabled,
1446 isEseIniFeatureEnabled);
1447 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001448 csr_neighbor_roam_update_fast_roaming_enabled(
1449 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001450
1451 if (true == isEseIniFeatureEnabled)
1452 sme_update_fast_transition_enabled(hHal, true);
1453
1454 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1455 csr_roam_offload_scan(pMac, sessionId,
1456 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1457 REASON_ESE_INI_CFG_CHANGED);
1458
1459 return QDF_STATUS_SUCCESS;
1460}
1461
1462/**
1463 * sme_set_plm_request() - set plm request
1464 * @hHal: HAL handle
1465 * @pPlmReq: Pointer to input plm request
1466 *
1467 * Return: QDF_STATUS enumeration
1468 */
1469QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1470{
1471 QDF_STATUS status;
1472 bool ret = false;
1473 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001474 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001475 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001476 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301477 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1478 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001479
1480 status = sme_acquire_global_lock(&pMac->sme);
1481 if (!QDF_IS_STATUS_SUCCESS(status))
1482 return status;
1483
1484 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001485 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001486 sme_release_global_lock(&pMac->sme);
1487 return QDF_STATUS_E_FAILURE;
1488 }
1489
1490 if (!pSession->sessionActive) {
1491 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1492 FL("Invalid Sessionid"));
1493 sme_release_global_lock(&pMac->sme);
1494 return QDF_STATUS_E_FAILURE;
1495 }
1496
1497 if (!pPlmReq->enable)
1498 goto send_plm_start;
1499 /* validating channel numbers */
1500 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1501 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1502 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001503 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1504 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001505 pPlmReq->plmChList[count])) {
1506 /* DFS channel is provided, no PLM bursts can be
1507 * transmitted. Ignoring these channels.
1508 */
1509 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301510 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001511 FL("DFS channel %d ignored for PLM"),
1512 pPlmReq->plmChList[count]);
1513 continue;
1514 }
1515 } else if (!ret) {
1516 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301517 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001518 FL("Unsupported channel %d ignored for PLM"),
1519 pPlmReq->plmChList[count]);
1520 continue;
1521 }
1522 ch_list[valid_count] = pPlmReq->plmChList[count];
1523 valid_count++;
1524 } /* End of for () */
1525
1526 /* Copying back the valid channel list to plm struct */
1527 qdf_mem_set((void *)pPlmReq->plmChList,
1528 pPlmReq->plmNumCh, 0);
1529 if (valid_count)
1530 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1531 valid_count);
1532 /* All are invalid channels, FW need to send the PLM
1533 * report with "incapable" bit set.
1534 */
1535 pPlmReq->plmNumCh = valid_count;
1536
1537send_plm_start:
1538 /* PLM START */
1539 msg.type = WMA_SET_PLM_REQ;
1540 msg.reserved = 0;
1541 msg.bodyptr = pPlmReq;
1542
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001543 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001544 &msg))) {
1545 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1546 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1547 sme_release_global_lock(&pMac->sme);
1548 return QDF_STATUS_E_FAILURE;
1549 }
1550
1551 sme_release_global_lock(&pMac->sme);
1552 return status;
1553}
1554
1555/**
1556 * sme_tsm_ie_ind() - sme tsm ie indication
1557 * @hHal: HAL handle
1558 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 *
1560 * Handle the tsm ie indication from LIM and forward it to HDD.
1561 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001562 * Return: QDF_STATUS enumeration
1563 */
1564static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565{
1566 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301567 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001568 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301570
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001571 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1572 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1573 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001575 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301576 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 return status;
1578}
1579
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001580/**
1581 * sme_set_cckm_ie() - set cckm ie
1582 * @hHal: HAL handle
1583 * @sessionId: session id
1584 * @pCckmIe: Pointer to CCKM Ie
1585 * @cckmIeLen: Length of @pCckmIe
1586 *
1587 * Function to store the CCKM IE passed from supplicant and use
1588 * it while packing reassociation request.
1589 *
1590 * Return: QDF_STATUS enumeration
1591 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301592QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 uint8_t *pCckmIe, uint8_t cckmIeLen)
1594{
1595 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301596 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301597
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301599 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1601 sme_release_global_lock(&pMac->sme);
1602 }
1603 return status;
1604}
1605
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001606/**
1607 * sme_set_ese_beacon_request() - set ese beacon request
1608 * @hHal: HAL handle
1609 * @sessionId: session id
1610 * @pEseBcnReq: Ese beacon report
1611 *
1612 * function to set ESE beacon request parameters
1613 *
1614 * Return: QDF_STATUS enumeration
1615 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301616QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 const tCsrEseBeaconReq *pEseBcnReq)
1618{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001619 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1621 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1622 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1623 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301624 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1626
1627 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001628 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301629 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 }
1631
1632 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301633 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 sizeof(tCsrEseBeaconReq));
1635
1636 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301637 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001639 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301640 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 }
1642
1643 pSmeRrmContext->eseBcnReqInProgress = true;
1644
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001645 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646
1647 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1648 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301649 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 pSession->connectedProfile.bssid.bytes,
1651 sizeof(tSirMacAddr));
1652 pSmeBcnReportReq->channelInfo.channelNum = 255;
1653 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1654 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1655
1656 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1657 pBeaconReq =
1658 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1659 pSmeBcnReportReq->fMeasurementtype[counter] =
1660 pBeaconReq->scanMode;
1661 pSmeBcnReportReq->measurementDuration[counter] =
1662 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1663 pSmeBcnReportReq->channelList.channelNumber[counter] =
1664 pBeaconReq->channel;
1665 }
1666
1667 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1668
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301669 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 pSmeRrmContext->eseBcnReqInProgress = false;
1671
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301672 qdf_mem_free(pSmeBcnReportReq);
1673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 return status;
1675}
1676
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001677/**
1678 * sme_get_tsm_stats() - SME get tsm stats
1679 * @hHal: HAL handle
1680 * @callback: SME sends back the requested stats using the callback
1681 * @staId: The station ID for which the stats is requested for
1682 * @bssId: bssid
1683 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001684 * @tid: Traffic id
1685 *
1686 * API register a callback to get TSM Stats.
1687 *
1688 * Return: QDF_STATUS enumeration
1689 */
1690QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1691 tCsrTsmStatsCallback callback,
1692 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001693 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001694{
1695 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1696 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1697
1698 status = sme_acquire_global_lock(&pMac->sme);
1699 if (QDF_IS_STATUS_SUCCESS(status)) {
1700 status = csr_get_tsm_stats(pMac, callback,
1701 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001702 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001703 sme_release_global_lock(&pMac->sme);
1704 }
1705 return status;
1706}
1707
1708/**
1709 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1710 * @hHal: pointer HAL handle returned by mac_open
1711 * @sessionId: sme session id
1712 * @pChannelList: Output channel list
1713 * @numChannels: Output number of channels
1714 *
1715 * This routine is called to set ese roam scan channel list.
1716 * This is a synchronous call
1717 *
1718 * Return: QDF_STATUS
1719 */
1720QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1721 uint8_t sessionId,
1722 uint8_t *pChannelList,
1723 uint8_t numChannels)
1724{
1725 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1726 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001727 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1728 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001729 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1730 uint8_t newChannelList[128] = { 0 };
1731 uint8_t i = 0, j = 0;
1732
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001733 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1735 FL("Invalid sme session id: %d"), sessionId);
1736 return QDF_STATUS_E_INVAL;
1737 }
1738
1739 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1740 curchnl_list_info =
1741 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1742
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001743 status = sme_acquire_global_lock(&pMac->sme);
1744 if (!QDF_IS_STATUS_SUCCESS(status)) {
1745 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1746 csr_roam_offload_scan(pMac, sessionId,
1747 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1748 REASON_CHANNEL_LIST_CHANGED);
1749 return status;
1750 }
1751 if (NULL != curchnl_list_info->ChannelList) {
1752 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1753 j += snprintf(oldChannelList + j,
1754 sizeof(oldChannelList) - j, "%d",
1755 curchnl_list_info->ChannelList[i]);
1756 }
1757 }
1758 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1759 pChannelList, numChannels,
1760 csr_get_current_band(hHal));
1761 if (QDF_IS_STATUS_SUCCESS(status)) {
1762 if (NULL != curchnl_list_info->ChannelList) {
1763 j = 0;
1764 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1765 j += snprintf(newChannelList + j,
1766 sizeof(newChannelList) - j, "%d",
1767 curchnl_list_info->ChannelList[i]);
1768 }
1769 }
1770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1771 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1772 newChannelList, oldChannelList,
1773 pNeighborRoamInfo->neighborRoamState);
1774 }
1775 sme_release_global_lock(&pMac->sme);
1776 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1777 csr_roam_offload_scan(pMac, sessionId,
1778 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1779 REASON_CHANNEL_LIST_CHANGED);
1780 return status;
1781}
1782
1783#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
Jeff Johnson49c02f92016-10-07 10:29:09 -07001785static
1786QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1787 tpSirIbssGetPeerInfoRspParams
1788 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001789{
1790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1791
1792 if (NULL == pMac) {
1793 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1794 "%s: pMac is null", __func__);
1795 return QDF_STATUS_E_FAILURE;
1796 }
1797 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1799 "%s: HDD callback is null", __func__);
1800 return QDF_STATUS_E_FAILURE;
1801 }
1802 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1803 &pIbssPeerInfoParams->
1804 ibssPeerInfoRspParams);
1805 return QDF_STATUS_SUCCESS;
1806}
1807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1810 * @mac: Global MAC pointer
1811 * @msg: Dual mac config response
1812 *
1813 * Processes the dual mac configuration response and invokes the HDD callback
1814 * to process further
1815 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 uint8_t *msg)
1818{
1819 tListElem *entry = NULL;
1820 tSmeCmd *command = NULL;
1821 bool found;
1822 dual_mac_cb callback = NULL;
1823 struct sir_dual_mac_config_resp *param;
1824
1825 param = (struct sir_dual_mac_config_resp *)msg;
1826 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001827 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 /* Not returning. Need to check if active command list
1829 * needs to be freed
1830 */
1831 }
1832
Krunal Sonia8270f52017-02-23 19:51:25 -08001833 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001835 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301836 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 }
1838
1839 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1840 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001841 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301842 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 }
1844
1845 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001846 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 }
1849
1850 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1851 if (callback) {
1852 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001853 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001855 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 callback(param->status,
1857 command->u.set_dual_mac_cmd.scan_config,
1858 command->u.set_dual_mac_cmd.fw_mode_config);
1859 }
1860 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001861 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 }
1863
Krunal Soni72dba662017-02-15 20:13:17 -08001864 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 if (found)
1866 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001867 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301869 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870}
1871
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001872/**
1873 * sme_process_antenna_mode_resp() - Process set antenna mode
1874 * response
1875 * @mac: Global MAC pointer
1876 * @msg: antenna mode response
1877 *
1878 * Processes the antenna mode response and invokes the HDD
1879 * callback to process further
1880 */
1881static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1882 uint8_t *msg)
1883{
1884 tListElem *entry;
1885 tSmeCmd *command;
1886 bool found;
1887 antenna_mode_cb callback;
1888 struct sir_antenna_mode_resp *param;
1889
1890 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301891 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001892 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001893 /* Not returning. Need to check if active command list
1894 * needs to be freed
1895 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001896
Krunal Sonia8270f52017-02-23 19:51:25 -08001897 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001898 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001899 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001900 return QDF_STATUS_E_FAILURE;
1901 }
1902
1903 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1904 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001905 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001906 return QDF_STATUS_E_FAILURE;
1907 }
1908
1909 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001910 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001911 return QDF_STATUS_E_FAILURE;
1912 }
1913
1914 callback =
1915 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1916 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301917 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001918 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301919 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001920 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001921 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001922 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 }
1924
Krunal Soni72dba662017-02-15 20:13:17 -08001925 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001926 if (found)
1927 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001928 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001929
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001930 return QDF_STATUS_SUCCESS;
1931}
1932
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301933/*
1934 * sme_process_msg() - The main message processor for SME.
1935 * The function is called by a message dispatcher when to process a message
1936 * targeted for SME.
1937 * This is a synchronous call
1938 *
1939 * hHal - The handle returned by mac_open.
1940 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1941 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1942 * Other status means SME failed to process the message to HAL.
1943 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001944QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301946 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301948 struct sir_peer_info *peer_stats;
1949 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950
1951 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001952 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 return status;
1954 }
1955 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301956 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001957 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301959 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 return status;
1961 }
1962 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001963 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 goto release_lock;
1967 }
1968 switch (pMsg->type) {
1969#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301971 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1973 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301974 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 break;
1976#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 case WNI_CFG_SET_CNF:
1978 case WNI_CFG_DNLD_CNF:
1979 case WNI_CFG_GET_RSP:
1980 case WNI_CFG_ADD_GRP_ADDR_CNF:
1981 case WNI_CFG_DEL_GRP_ADDR_CNF:
1982 break;
1983 case eWNI_SME_ADDTS_RSP:
1984 case eWNI_SME_DELTS_RSP:
1985 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 /* QoS */
1988 if (pMsg->bodyptr) {
1989#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1990 status = sme_qos_msg_processor(pMac, pMsg->type,
1991 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301992 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993#endif
1994 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001995 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 }
1997 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 case eWNI_SME_NEIGHBOR_REPORT_IND:
1999 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 if (pMsg->bodyptr) {
2001 status = sme_rrm_msg_processor(pMac, pMsg->type,
2002 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302003 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302005 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 }
2007 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 case eWNI_SME_ADD_STA_SELF_RSP:
2009 if (pMsg->bodyptr) {
2010 status = csr_process_add_sta_session_rsp(pMac,
2011 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302012 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002014 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 }
2016 break;
2017 case eWNI_SME_DEL_STA_SELF_RSP:
2018 if (pMsg->bodyptr) {
2019 status = csr_process_del_sta_session_rsp(pMac,
2020 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302021 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002023 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 }
2025 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 case eWNI_SME_CHANGE_COUNTRY_CODE:
2027 if (pMsg->bodyptr) {
2028 status = sme_handle_change_country_code((void *)pMac,
2029 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002032 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 }
2034 break;
2035 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2036 if (pMsg->bodyptr) {
2037 status = sme_handle_generic_change_country_code(
2038 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302039 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002041 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 }
2043 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045#ifdef WLAN_FEATURE_11W
2046 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2047 if (pMsg->bodyptr) {
2048 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002051 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 }
2053 break;
2054#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002055#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 case eWNI_SME_TSM_IE_IND:
2057 if (pMsg->bodyptr) {
2058 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302059 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002061 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 }
2063 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002064#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2066 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2067 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302068 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002070 case eWNI_SME_IBSS_PEER_INFO_RSP:
2071 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002072 sme_ibss_peer_info_response_handler(pMac,
2073 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002074 qdf_mem_free(pMsg->bodyptr);
2075 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002076 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002077 }
2078 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 case eWNI_SME_READY_TO_SUSPEND_IND:
2080 if (pMsg->bodyptr) {
2081 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302082 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002084 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 }
2086 break;
2087#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2088 case eWNI_SME_READY_TO_EXTWOW_IND:
2089 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002090 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302091 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002093 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 }
2095 break;
2096#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2098 case eWNI_SME_AUTO_SHUTDOWN_IND:
2099 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302100 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 FL("Auto shutdown notification"));
2102 pMac->sme.pAutoShutdownNotificationCb();
2103 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302104 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 break;
2106#endif
2107 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002108 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002110 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302111 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 break;
2113 case eWNI_SME_CHANNEL_CHANGE_RSP:
2114 if (pMsg->bodyptr) {
2115 status = sme_process_channel_change_resp(pMac,
2116 pMsg->type,
2117 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302118 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002120 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 }
2122 break;
2123#ifdef WLAN_FEATURE_STATS_EXT
2124 case eWNI_SME_STATS_EXT_EVENT:
2125 if (pMsg->bodyptr) {
2126 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002129 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 }
2131 break;
2132#endif
Will Huang558f8082017-05-31 16:22:24 +08002133 case eWNI_SME_GET_PEER_INFO_IND:
2134 if (pMac->sme.pget_peer_info_ind_cb)
2135 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2136 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302137 if (pMsg->bodyptr) {
2138 peer_info_rsp = (struct sir_peer_info_resp *)
2139 (pMsg->bodyptr);
2140 peer_stats = (struct sir_peer_info *)
2141 (peer_info_rsp->info);
2142 if (peer_stats) {
2143 pMac->peer_rssi = peer_stats[0].rssi;
2144 pMac->peer_txrate = peer_stats[0].tx_rate;
2145 pMac->peer_rxrate = peer_stats[0].rx_rate;
2146 }
2147 }
Will Huang558f8082017-05-31 16:22:24 +08002148 qdf_mem_free(pMsg->bodyptr);
2149 break;
2150 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2151 if (pMac->sme.pget_peer_info_ext_ind_cb)
2152 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2153 pMac->sme.pget_peer_info_ext_cb_context);
2154 qdf_mem_free(pMsg->bodyptr);
2155 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 case eWNI_SME_CSA_OFFLOAD_EVENT:
2157 if (pMsg->bodyptr) {
2158 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302159 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 }
2161 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002162 case eWNI_SME_TSF_EVENT:
2163 if (pMac->sme.get_tsf_cb) {
2164 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2165 (struct stsf *)pMsg->bodyptr);
2166 }
2167 if (pMsg->bodyptr)
2168 qdf_mem_free(pMsg->bodyptr);
2169 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170#ifdef WLAN_FEATURE_NAN
2171 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302172 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2173 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 if (pMsg->bodyptr) {
2175 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302176 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 }
2178 break;
2179#endif /* WLAN_FEATURE_NAN */
2180 case eWNI_SME_LINK_STATUS_IND:
2181 {
2182 tAniGetLinkStatus *pLinkStatus =
2183 (tAniGetLinkStatus *) pMsg->bodyptr;
2184 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302185 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 pMac->sme.linkStatusCallback(
2187 pLinkStatus->linkStatus,
2188 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 pMac->sme.linkStatusCallback = NULL;
2191 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302192 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 }
2194 break;
2195 }
2196 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302197 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2199 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 break;
2201 case eWNI_SME_SNR_IND:
2202 {
2203 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 if (pSnrReq) {
2206 if (pSnrReq->snrCallback) {
2207 ((tCsrSnrCallback)
2208 (pSnrReq->snrCallback))
2209 (pSnrReq->snr, pSnrReq->staId,
2210 pSnrReq->pDevContext);
2211 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 }
2214 break;
2215 }
2216#ifdef FEATURE_WLAN_EXTSCAN
2217 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2218 if (pMac->sme.pExtScanIndCb)
2219 pMac->sme.pExtScanIndCb(pMac->hHdd,
2220 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2221 pMsg->bodyptr);
2222 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002223 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 pMsg->type);
2225
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302226 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 break;
2228 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2229 if (pMac->sme.pExtScanIndCb)
2230 pMac->sme.pExtScanIndCb(pMac->hHdd,
2231 eSIR_EPNO_NETWORK_FOUND_IND,
2232 pMsg->bodyptr);
2233 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002234 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 pMsg->type);
2236
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302237 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 break;
2239#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 case eWNI_SME_SET_HW_MODE_RESP:
2241 if (pMsg->bodyptr) {
2242 status = sme_process_set_hw_mode_resp(pMac,
2243 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002246 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 }
2248 break;
2249 case eWNI_SME_HW_MODE_TRANS_IND:
2250 if (pMsg->bodyptr) {
2251 status = sme_process_hw_mode_trans_ind(pMac,
2252 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002255 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 }
2257 break;
2258 case eWNI_SME_NSS_UPDATE_RSP:
2259 if (pMsg->bodyptr) {
2260 status = sme_process_nss_update_resp(pMac,
2261 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302262 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002264 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 }
2266 break;
2267 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302268 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 pMac->sme.ocb_set_config_callback(
2270 pMac->sme.ocb_set_config_context,
2271 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302272 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002273 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 pMac->sme.ocb_set_config_callback = NULL;
2275 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302276 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 break;
2278 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302279 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 pMac->sme.ocb_get_tsf_timer_callback(
2281 pMac->sme.ocb_get_tsf_timer_context,
2282 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302283 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002284 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2286 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302287 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 break;
2289 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302290 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 pMac->sme.dcc_get_stats_callback(
2292 pMac->sme.dcc_get_stats_context,
2293 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302294 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002295 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 pMac->sme.dcc_get_stats_callback = NULL;
2297 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302298 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 break;
2300 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302301 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 pMac->sme.dcc_update_ndl_callback(
2303 pMac->sme.dcc_update_ndl_context,
2304 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302305 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002306 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 pMac->sme.dcc_update_ndl_callback = NULL;
2308 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302309 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 break;
2311 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302312 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 pMac->sme.dcc_stats_event_callback(
2314 pMac->sme.dcc_stats_event_context,
2315 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302316 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002317 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302318 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 break;
2320 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2321 if (pMsg->bodyptr) {
2322 status = sme_process_dual_mac_config_resp(pMac,
2323 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302324 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002326 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 }
2328 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2329 if (pMac->sme.set_thermal_level_cb)
2330 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2331 pMsg->bodyval);
2332 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302333 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2334 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302336 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002337 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2338 if (pMsg->bodyptr) {
2339 status = sme_process_antenna_mode_resp(pMac,
2340 pMsg->bodyptr);
2341 qdf_mem_free(pMsg->bodyptr);
2342 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002343 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002344 }
2345 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302346 case eWNI_SME_LOST_LINK_INFO_IND:
2347 if (pMac->sme.lost_link_info_cb)
2348 pMac->sme.lost_link_info_cb(pMac->hHdd,
2349 (struct sir_lost_link_info *)pMsg->bodyptr);
2350 qdf_mem_free(pMsg->bodyptr);
2351 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302352 case eWNI_SME_RSO_CMD_STATUS_IND:
2353 if (pMac->sme.rso_cmd_status_cb)
2354 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002355 qdf_mem_free(pMsg->bodyptr);
2356 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002357 case eWMI_SME_LL_STATS_IND:
2358 if (pMac->sme.link_layer_stats_ext_cb)
2359 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2360 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302361 qdf_mem_free(pMsg->bodyptr);
2362 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302363 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2364 if (pMac->sme.bt_activity_info_cb)
2365 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2366 pMsg->bodyval);
2367 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 default:
2369
2370 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2371 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2372 /* CSR */
2373 if (pMsg->bodyptr) {
2374 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302375 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302376 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002377 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002379 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302381 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 }
2383 } /* switch */
2384release_lock:
2385 sme_release_global_lock(&pMac->sme);
2386 return status;
2387}
2388
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002389QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2390{
2391 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2392
2393 if (mac_ctx == NULL) {
2394 QDF_ASSERT(0);
2395 return QDF_STATUS_E_FAILURE;
2396 }
2397
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002398 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002399}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401/**
2402 * sme_process_nss_update_resp() - Process nss update response
2403 * @mac: Global MAC pointer
2404 * @msg: nss update response
2405 *
2406 * Processes the nss update response and invokes the HDD
2407 * callback to process further
2408 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302409static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410{
2411 tListElem *entry = NULL;
2412 tSmeCmd *command = NULL;
2413 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002414 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 struct sir_beacon_tx_complete_rsp *param;
2416
2417 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302418 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002419 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 /* Not returning. Need to check if active command list
2421 * needs to be freed
2422 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423
Krunal Sonia8270f52017-02-23 19:51:25 -08002424 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002426 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302427 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 }
2429
2430 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2431 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002432 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302433 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 }
2435
2436 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002437 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302438 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 }
2440
2441 callback = command->u.nss_update_cmd.nss_update_cb;
2442 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302443 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002444 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302445 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 callback(command->u.nss_update_cmd.context,
2447 param->tx_status,
2448 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302449 command->u.nss_update_cmd.next_action,
2450 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002452 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 }
2454
Krunal Soni72dba662017-02-15 20:13:17 -08002455 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 if (found) {
2457 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002458 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002460
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302461 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462}
2463
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302464/* No need to hold the global lock here because this function can only be
2465 * called after sme_stop.
2466 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002467void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468{
2469 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302470 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302471 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 }
2473
2474}
2475
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302476/*
2477 * sme_stop() - Stop all SME modules and put them at idle state
2478 *
2479 * The function stops each module in SME, PMC, CSR, etc. . Upon
2480 * return, all modules are at idle state ready to start.
2481 * This is a synchronous call
2482 *
2483 * hHal - The handle returned by mac_open
2484 * tHalStopType - reason for stopping
2485 * Return QDF_STATUS_SUCCESS - SME is stopped.
2486 * Other status means SME is failed to stop but caller should still
2487 * consider SME is stopped.
2488 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302489QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302491 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2492 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2494
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002495 status = rrm_stop(pMac);
2496 if (!QDF_IS_STATUS_SUCCESS(status)) {
2497 sme_err("rrm_stop failed with status: %d", status);
2498 }
2499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302501 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002502 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 fail_status = status;
2504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302506 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508
2509 pMac->sme.state = SME_STATE_STOP;
2510
2511 return status;
2512}
2513
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302514/*
2515 * sme_close() - Release all SME modules and their resources.
2516 * The function release each module in SME, PMC, CSR, etc. . Upon
2517 * return, all modules are at closed state.
2518 *
2519 * No SME APIs can be involved after smeClose except smeOpen.
2520 * smeClose must be called before mac_close.
2521 * This is a synchronous call
2522 *
2523 * hHal - The handle returned by mac_open
2524 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2525 *
2526 * Other status means SME is failed to be closed but caller still cannot
2527 * call any other SME functions except smeOpen.
2528 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302529QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302531 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2532 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2534
2535 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302536 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538 /* Note: pSession will be invalid from here on, do not access */
2539 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302540 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002541 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 fail_status = status;
2543 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2545 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302546 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002547 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 fail_status = status;
2549 }
2550#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302552 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002553 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 fail_status = status;
2555 }
2556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302558 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002559 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 fail_status = status;
2561 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 free_sme_cmd_list(pMac);
2564
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302565 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302566 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302567 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302569 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571
2572 pMac->sme.state = SME_STATE_STOP;
2573
2574 return status;
2575}
2576
2577/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302578 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2579 * scan list
2580 * @hal: hal context.
2581 * @bssid: bssid to be removed
2582 *
2583 * This function remove the given bssid from scan list.
2584 *
2585 * Return: QDF status.
2586 */
2587QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2588 tSirMacAddr bssid)
2589{
2590 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2591 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2592
2593 status = sme_acquire_global_lock(&mac_ctx->sme);
2594 if (QDF_IS_STATUS_SUCCESS(status)) {
2595 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2596 sme_release_global_lock(&mac_ctx->sme);
2597 }
2598
2599 return status;
2600}
2601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302603/*
2604 * sme_scan_get_result
2605 * A wrapper function to request scan results from CSR.
2606 * This is a synchronous call
2607 *
2608 * pFilter - If pFilter is NULL, all cached results are returned
2609 * phResult - an object for the result.
2610 * Return QDF_STATUS
2611 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302612QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 tCsrScanResultFilter *pFilter,
2614 tScanResultHandle *phResult)
2615{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302616 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2618
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302619 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2621 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302623 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 status = csr_scan_get_result(hHal, pFilter, phResult);
2625 sme_release_global_lock(&pMac->sme);
2626 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627
2628 return status;
2629}
2630
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302631QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2632 struct qdf_mac_addr *bssid,
2633 tCsrScanResultInfo *res)
2634{
2635 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2636 QDF_STATUS status;
2637
2638 status = sme_acquire_global_lock(&mac_ctx->sme);
2639 if (QDF_IS_STATUS_SUCCESS(status)) {
2640 status = csr_scan_get_result_for_bssid(hal_handle, bssid, res);
2641 sme_release_global_lock(&mac_ctx->sme);
2642 }
2643
2644 return status;
2645}
2646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002648 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002649 * AP's channel id from
2650 * CSR by filtering the
2651 * result which matches
2652 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002653 * @profile: SAP profile
2654 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2655 * best ap from scan cache.
2656 *
2657 * This function is written to get AP's channel id from CSR by filtering
2658 * the result which matches our roam profile. This is a synchronous call.
2659 *
2660 * Return: QDF_STATUS.
2661 */
2662QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2663 tScanResultHandle *scan_cache,
2664 uint8_t *ap_chnl_id)
2665{
2666 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2667 profile,
2668 scan_cache,
2669 ap_chnl_id);
2670}
2671
2672/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2674 * channel id from CSR by filtering the
2675 * result which matches our roam profile.
2676 * @profile: SAP adapter
2677 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2678 * best ap from scan cache.
2679 *
2680 * This function is written to get AP's channel id from CSR by filtering
2681 * the result which matches our roam profile. This is a synchronous call.
2682 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302683 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002685QDF_STATUS sme_get_ap_channel_from_scan_cache(
2686 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2687 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302689 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002690 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691 tCsrScanResultFilter *scan_filter = NULL;
2692 tScanResultHandle filtered_scan_result = NULL;
2693 tSirBssDescription first_ap_profile;
2694
2695 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302700 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302702 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302704 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302705 }
2706 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2707 if (NULL == profile) {
2708 scan_filter->EncryptionType.numEntries = 1;
2709 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302711 } else {
2712 /* Here is the profile we need to connect to */
2713 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 profile,
2715 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302716 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302718 if (QDF_STATUS_SUCCESS == status) {
2719 /* Save the WPS info */
2720 if (NULL != profile) {
2721 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302723 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302726 scan_filter->bWPSAssociation = 0;
2727 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302729 } else {
2730 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2731 FL("Preparing the profile filter failed"));
2732 qdf_mem_free(scan_filter);
2733 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 }
2735 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302736 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002737 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302739 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2741 &first_ap_profile);
2742 *scan_cache = filtered_scan_result;
2743 if (0 != first_ap_profile.channelId) {
2744 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302745 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302746 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 FL("Found best AP & its on chnl[%d]"),
2748 first_ap_profile.channelId);
2749 } else {
2750 /*
2751 * This means scan result is empty
2752 * so set the channel to zero, caller should
2753 * take of zero channel id case.
2754 */
2755 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302756 QDF_TRACE(QDF_MODULE_ID_SME,
2757 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302759 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 }
2761 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302762 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302764 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 }
2766 csr_free_scan_filter(mac_ctx, scan_filter);
2767 sme_release_global_lock(&mac_ctx->sme);
2768 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302769 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002771 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302772 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302774 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 return status;
2776}
2777
2778/**
2779 * sme_store_joinreq_param() - This function will pass station's join
2780 * request to store to csr.
2781 * @hal_handle: pointer to hal context.
2782 * @profile: pointer to station's roam profile.
2783 * @scan_cache: pointer to station's scan cache.
2784 * @roam_id: reference to roam_id variable being passed.
2785 * @session_id: station's session id.
2786 *
2787 * This function will pass station's join request further down to csr
2788 * to store it. this stored parameter will be used later.
2789 *
2790 * Return: true or false based on function's overall success.
2791 **/
2792bool sme_store_joinreq_param(tHalHandle hal_handle,
2793 tCsrRoamProfile *profile,
2794 tScanResultHandle scan_cache,
2795 uint32_t *roam_id,
2796 uint32_t session_id)
2797{
2798 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302799 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 bool ret_status = true;
2801
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302802 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2804 session_id, 0));
2805 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302806 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302808 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 sme_release_global_lock(&mac_ctx->sme);
2811 } else {
2812 ret_status = false;
2813 }
2814
2815 return ret_status;
2816}
2817
2818/**
2819 * sme_clear_joinreq_param() - This function will pass station's clear
2820 * the join request to csr.
2821 * @hal_handle: pointer to hal context.
2822 * @session_id: station's session id.
2823 *
2824 * This function will pass station's clear join request further down to csr
2825 * to cleanup.
2826 *
2827 * Return: true or false based on function's overall success.
2828 **/
2829bool sme_clear_joinreq_param(tHalHandle hal_handle,
2830 uint32_t session_id)
2831{
2832 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302833 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 bool ret_status = true;
2835
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302836 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2838 session_id, 0));
2839 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302840 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302842 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 sme_release_global_lock(&mac_ctx->sme);
2845 } else {
2846 ret_status = false;
2847 }
2848
2849 return ret_status;
2850}
2851
2852/**
2853 * sme_issue_stored_joinreq() - This function will issues station's stored
2854 * the join request to csr.
2855 * @hal_handle: pointer to hal context.
2856 * @roam_id: reference to roam_id variable being passed.
2857 * @session_id: station's session id.
2858 *
2859 * This function will issue station's stored join request further down to csr
2860 * to proceed forward.
2861 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302862 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302864QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 uint32_t *roam_id,
2866 uint32_t session_id)
2867{
2868 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302869 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2870 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302872 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2874 session_id, 0));
2875 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302876 if (QDF_STATUS_SUCCESS == status) {
2877 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 roam_id,
2879 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302880 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 }
2882 sme_release_global_lock(&mac_ctx->sme);
2883 } else {
2884 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302885 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 }
2887 return ret_status;
2888}
2889
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302890/*
2891 * sme_scan_flush_result() -
2892 * A wrapper function to request CSR to clear scan results.
2893 * This is a synchronous call
2894 *
2895 * Return QDF_STATUS
2896 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302897QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302899 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2901
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302902 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2904 0, 0));
2905 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 status = csr_scan_flush_result(hHal);
2908 sme_release_global_lock(&pMac->sme);
2909 }
2910
2911 return status;
2912}
2913
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302914/*
2915 * sme_filter_scan_results() -
2916 * A wrapper function to request CSR to clear scan results.
2917 * This is a synchronous call
2918 *
2919 * tHalHandle - HAL context handle
2920 * sessionId - session id
2921 * Return QDF_STATUS
2922 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302923QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302925 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2927
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302928 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2930 sessionId, 0));
2931 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302932 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 csr_scan_filter_results(pMac);
2934 sme_release_global_lock(&pMac->sme);
2935 }
2936
2937 return status;
2938}
2939
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302940QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302942 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2944
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302945 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2947 sessionId, 0));
2948 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302949 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 status = csr_scan_flush_selective_result(hHal, true);
2951 sme_release_global_lock(&pMac->sme);
2952 }
2953
2954 return status;
2955}
2956
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302957/*
2958 * sme_scan_result_get_first() -
2959 * A wrapper function to request CSR to returns the first element of
2960 * scan result.
2961 * This is a synchronous call
2962 *
2963 * hScanResult - returned from csr_scan_get_result
2964 * Return tCsrScanResultInfo * - NULL if no result
2965 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2967 tScanResultHandle hScanResult)
2968{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2971 tCsrScanResultInfo *pRet = NULL;
2972
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302973 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2975 NO_SESSION, 0));
2976 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302977 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 pRet = csr_scan_result_get_first(pMac, hScanResult);
2979 sme_release_global_lock(&pMac->sme);
2980 }
2981
2982 return pRet;
2983}
2984
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302985/*
2986 * sme_scan_result_get_next() -
2987 * A wrapper function to request CSR to returns the next element of
2988 * scan result. It can be called without calling csr_scan_result_get_first first
2989 * This is a synchronous call
2990 *
2991 * hScanResult - returned from csr_scan_get_result
2992 * Return Null if no result or reach the end
2993 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
2995 tScanResultHandle hScanResult)
2996{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2999 tCsrScanResultInfo *pRet = NULL;
3000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303002 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 pRet = csr_scan_result_get_next(pMac, hScanResult);
3004 sme_release_global_lock(&pMac->sme);
3005 }
3006
3007 return pRet;
3008}
3009
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303010/*
3011 * sme_scan_result_purge() -
3012 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3013 * in the list and free memory for each item
3014 * This is a synchronous call
3015 *
3016 * hScanResult - returned from csr_scan_get_result. hScanResult is
3017 * considered gone by
3018 * calling this function and even before this function reutrns.
3019 * Return QDF_STATUS
3020 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003021QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303023 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003024 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303026 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3028 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003029 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303030 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003031 status = csr_scan_result_purge(mac_ctx, hScanResult);
3032 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 }
3034
3035 return status;
3036}
3037
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303038/*
3039 * sme_scan_get_pmkid_candidate_list() -
3040 * A wrapper function to return the PMKID candidate list
3041 * This is a synchronous call
3042 *
3043 * pPmkidList - caller allocated buffer point to an array of
3044 * tPmkidCandidateInfo
3045 * pNumItems - pointer to a variable that has the number of
3046 * tPmkidCandidateInfo allocated when retruning, this is
3047 * either the number needed or number of items put into
3048 * pPmkidList
3049 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3050 * big enough and pNumItems
3051 * has the number of tPmkidCandidateInfo.
3052 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3053 * not sizeof(tPmkidCandidateInfo) * something
3054 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303055QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 tPmkidCandidateInfo *pPmkidList,
3057 uint32_t *pNumItems)
3058{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303059 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3061
3062 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303063 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 status =
3065 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3066 pPmkidList,
3067 pNumItems);
3068 sme_release_global_lock(&pMac->sme);
3069 }
3070
3071 return status;
3072}
3073
3074eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3075{
3076 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 return pMac->roam.configParam.phyMode;
3079}
3080
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303081/*
jiadbdefb252018-01-03 14:27:06 +08003082 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303083 *
3084 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003085 * mode - channel bonding mode
3086 *
3087 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303088 */
jiadbdefb252018-01-03 14:27:06 +08003089QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090{
3091 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003092 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093
jiadbdefb252018-01-03 14:27:06 +08003094 if (!mode) {
3095 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3096 "%s: invalid mode", __func__);
3097 return QDF_STATUS_E_FAILURE;
3098 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099
jiadbdefb252018-01-03 14:27:06 +08003100 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3101 if (!smeConfig) {
3102 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3103 "%s: failed to alloc smeConfig", __func__);
3104 return QDF_STATUS_E_NOMEM;
3105 }
3106
3107 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3108 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3109 "%s: sme_get_config_param failed", __func__);
3110 qdf_mem_free(smeConfig);
3111 return QDF_STATUS_E_FAILURE;
3112 }
3113
3114 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3115 qdf_mem_free(smeConfig);
3116
3117 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118}
3119
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303120/*
jiadbdefb252018-01-03 14:27:06 +08003121 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3122 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303123 *
3124 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003125 * mode - channel bonding mode
3126 *
3127 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303128 */
jiadbdefb252018-01-03 14:27:06 +08003129QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130{
3131 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003132 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
jiadbdefb252018-01-03 14:27:06 +08003134 if (!mode) {
3135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3136 "%s: invalid mode", __func__);
3137 return QDF_STATUS_E_FAILURE;
3138 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139
jiadbdefb252018-01-03 14:27:06 +08003140 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3141 if (!smeConfig) {
3142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3143 "%s: failed to alloc smeConfig", __func__);
3144 return QDF_STATUS_E_NOMEM;
3145 }
3146
3147 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3148 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3149 "%s: sme_get_config_param failed", __func__);
3150 qdf_mem_free(smeConfig);
3151 return QDF_STATUS_E_FAILURE;
3152 }
3153
3154 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3155 qdf_mem_free(smeConfig);
3156
3157 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158}
3159
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303160/*
3161 * sme_roam_connect() -
3162 * A wrapper function to request CSR to inititiate an association
3163 * This is an asynchronous call.
3164 *
3165 * sessionId - the sessionId returned by sme_open_session.
3166 * pProfile - description of the network to which to connect
3167 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3168 * from csr_scan_get_result
3169 * pRoamId - to get back the request ID
3170 * Return QDF_STATUS
3171 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303172QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3174{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303175 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3177
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303178 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303179 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303181 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303184 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3186 status =
3187 csr_roam_connect(pMac, sessionId, pProfile,
3188 pRoamId);
3189 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003190 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 }
3193 sme_release_global_lock(&pMac->sme);
3194 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003195 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 }
3197
3198 return status;
3199}
3200
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303201/*
3202 * sme_set_phy_mode() -
3203 * Changes the PhyMode.
3204 *
3205 * hHal - The handle returned by mac_open.
3206 * phyMode new phyMode which is to set
3207 * Return QDF_STATUS SUCCESS.
3208 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303209QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210{
3211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3212
3213 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303214 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303216 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 }
3218
3219 pMac->roam.configParam.phyMode = phyMode;
3220 pMac->roam.configParam.uCfgDot11Mode =
3221 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303222 pMac->roam.configParam.phyMode,
3223 pMac->roam.configParam.
3224 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303226 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227}
3228
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303229/*
3230 * sme_roam_reassoc() -
3231 * A wrapper function to request CSR to inititiate a re-association
3232 *
3233 * pProfile - can be NULL to join the currently connected AP. In that
3234 * case modProfileFields should carry the modified field(s) which could trigger
3235 * reassoc
3236 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3237 * that might need modification dynamically once STA is up & running and this
3238 * could trigger a reassoc
3239 * pRoamId - to get back the request ID
3240 * Return QDF_STATUS
3241 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303242QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 tCsrRoamProfile *pProfile,
3244 tCsrRoamModifyProfileFields modProfileFields,
3245 uint32_t *pRoamId, bool fForce)
3246{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303247 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3249
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303250 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303253 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303255 if ((NULL == pProfile) && (fForce == 1))
3256 status = csr_reassoc(pMac, sessionId,
3257 &modProfileFields, pRoamId,
3258 fForce);
3259 else
3260 status = csr_roam_reassoc(pMac, sessionId,
3261 pProfile,
3262 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 }
3266 sme_release_global_lock(&pMac->sme);
3267 }
3268
3269 return status;
3270}
3271
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303272/*
3273 * sme_roam_connect_to_last_profile() -
3274 * A wrapper function to request CSR to disconnect and reconnect with
3275 * the same profile
3276 * This is an asynchronous call.
3277 *
3278 * Return QDF_STATUS. It returns fail if currently connected
3279 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303282 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3284
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303285 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3287 sessionId, 0));
3288 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303289 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303290 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3291 status = csr_roam_connect_to_last_profile(pMac,
3292 sessionId);
3293 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 sme_release_global_lock(&pMac->sme);
3296 }
3297
3298 return status;
3299}
3300
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303301/*
3302 * sme_roam_disconnect() -
3303 * A wrapper function to request CSR to disconnect from a network
3304 * This is an asynchronous call.
3305 *
3306 * reason -- To indicate the reason for disconnecting. Currently, only
3307 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3308 * Return QDF_STATUS
3309 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303310QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 eCsrRoamDisconnectReason reason)
3312{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303313 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3315
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303316 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3318 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303320 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303321 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303323 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303324 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 sme_release_global_lock(&pMac->sme);
3326 }
3327
3328 return status;
3329}
3330
Abhishek Singhca408032016-09-13 15:26:12 +05303331/* sme_dhcp_done_ind() - send dhcp done ind
3332 * @hal: hal context
3333 * @session_id: session id
3334 *
3335 * Return: void.
3336 */
3337void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3338{
3339 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303340 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303341
3342 if (!mac_ctx)
3343 return;
3344
3345 session = CSR_GET_SESSION(mac_ctx, session_id);
3346 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003347 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303348 return;
3349 }
3350 session->dhcp_done = true;
3351}
3352
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303353/*
3354 * sme_roam_stop_bss() -
3355 * To stop BSS for Soft AP. This is an asynchronous API.
3356 *
3357 * hHal - Global structure
3358 * sessionId - sessionId of SoftAP
3359 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3360 * actual results
3361 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303362QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303364 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303368 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303369 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3370 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303371 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303372 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 sme_release_global_lock(&pMac->sme);
3375 }
3376
3377 return status;
3378}
3379
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303380/**
3381 * sme_roam_disconnect_sta() - disassociate a station
3382 * @hHal: Global structure
3383 * @sessionId: SessionId of SoftAP
3384 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3385 *
3386 * To disassociate a station. This is an asynchronous API.
3387 *
3388 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3389 * be called to indicate actual result.
3390 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003392 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303394 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3396
3397 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303398 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 return status;
3400 }
3401
3402 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303403 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303404 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303406 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303407 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303408 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 sme_release_global_lock(&pMac->sme);
3410 }
3411
3412 return status;
3413}
3414
3415/**
3416 * sme_roam_deauth_sta() - deauthenticate a station
3417 * @hHal: Global structure
3418 * @sessionId: SessionId of SoftAP
3419 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3420 *
3421 * To disassociate a station. This is an asynchronous API.
3422 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 * code on error. Roam callback will be called to indicate actual
3425 * result
3426 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303427QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003428 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303430 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3432
3433 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303434 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 return status;
3436 }
3437
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303438 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303439 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3440 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303442 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303443 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 status =
3445 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3446 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303447 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303448 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449 sme_release_global_lock(&pMac->sme);
3450 }
3451
3452 return status;
3453}
3454
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303455/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303456 * sme_roam_get_associated_stas() -
3457 * To probe the list of associated stations from various modules
3458 * of CORE stack.
3459 * This is an asynchronous API.
3460 *
3461 * sessionId - sessionId of SoftAP
3462 * modId - Module from whom list of associtated stations is
3463 * to be probed. If an invalid module is passed then
3464 * by default QDF_MODULE_ID_PE will be probed.
3465 * pUsrContext - Opaque HDD context
3466 * pfnSapEventCallback - Sap event callback in HDD
3467 * pAssocBuf - Caller allocated memory to be filled with associatd
3468 * stations info
3469 * Return QDF_STATUS
3470 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303472 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 void *pfnSapEventCallback,
3474 uint8_t *pAssocStasBuf)
3475{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3478
3479 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303480 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 return status;
3482 }
3483
3484 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303485 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303486 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303488 csr_roam_get_associated_stas(pMac, sessionId,
3489 modId,
3490 pUsrContext,
3491 pfnSapEventCallback,
3492 pAssocStasBuf);
3493 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 sme_release_global_lock(&pMac->sme);
3496 }
3497
3498 return status;
3499}
3500
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303501/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303502 * sme_roam_get_connect_state() -
3503 * A wrapper function to request CSR to return the current connect state
3504 * of Roaming
3505 * This is a synchronous call.
3506 *
3507 * Return QDF_STATUS
3508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 eCsrConnectState *pState)
3511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303512 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3514
3515 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303516 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303517 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3518 status = csr_roam_get_connect_state(pMac, sessionId,
3519 pState);
3520 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 sme_release_global_lock(&pMac->sme);
3523 }
3524
3525 return status;
3526}
3527
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303528/*
3529 * sme_roam_get_connect_profile() -
3530 * A wrapper function to request CSR to return the current connect
3531 * profile. Caller must call csr_roam_free_connect_profile after it is done
3532 * and before reuse for another csr_roam_get_connect_profile call.
3533 * This is a synchronous call.
3534 *
3535 * pProfile - pointer to a caller allocated structure
3536 * tCsrRoamConnectedProfile
3537 * eturn QDF_STATUS. Failure if not connected
3538 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303539QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540 tCsrRoamConnectedProfile *pProfile)
3541{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3544
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303545 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3547 sessionId, 0));
3548 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303549 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303550 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3551 status = csr_roam_get_connect_profile(pMac, sessionId,
3552 pProfile);
3553 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555 sme_release_global_lock(&pMac->sme);
3556 }
3557
3558 return status;
3559}
3560
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003561/**
3562 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3563 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3564 *
3565 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3566 *
3567 * Return: none
3568 */
3569void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303571 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3573 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003574 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575}
3576
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303577/*
3578 * sme_roam_set_pmkid_cache() -
3579 * A wrapper function to request CSR to return the PMKID candidate list
3580 * This is a synchronous call.
3581
3582 * pPMKIDCache - caller allocated buffer point to an array of
3583 * tPmkidCacheInfo
3584 * numItems - a variable that has the number of tPmkidCacheInfo
3585 * allocated when retruning, this is either the number needed
3586 * or number of items put into pPMKIDCache
3587 * update_entire_cache - this bool value specifies if the entire pmkid
3588 * cache should be overwritten or should it be
3589 * updated entry by entry.
3590 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3591 * big enough and pNumItems has the number of
3592 * tPmkidCacheInfo.
3593 * \Note: pNumItems is a number of tPmkidCacheInfo,
3594 * not sizeof(tPmkidCacheInfo) * something
3595 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303596QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 tPmkidCacheInfo *pPMKIDCache,
3598 uint32_t numItems, bool update_entire_cache)
3599{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3602
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303603 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3605 numItems));
3606 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303607 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303608 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3609 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3610 pPMKIDCache,
3611 numItems, update_entire_cache);
3612 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303613 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 sme_release_global_lock(&pMac->sme);
3615 }
3616
3617 return status;
3618}
3619
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303620QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303621 tPmkidCacheInfo *pmksa,
3622 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303624 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303626
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303627 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303628 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3629 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303631 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303632 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303634 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303635 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303636 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 sme_release_global_lock(&pMac->sme);
3638 }
3639 return status;
3640}
3641
3642#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303643/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 * \fn sme_roam_set_psk_pmk
3645 * \brief a wrapper function to request CSR to save PSK/PMK
3646 * This is a synchronous call.
3647 * \param hHal - Global structure
3648 * \param sessionId - SME sessionId
3649 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3650 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3651 * connections. Need to pass this information to
3652 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303653 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303655QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 uint8_t *pPSK_PMK, size_t pmk_len)
3657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303658 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003659 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303663 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3664 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303666 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303667 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 sme_release_global_lock(&pMac->sme);
3669 }
3670 return status;
3671}
3672#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303673/*
3674 * sme_roam_get_security_req_ie() -
3675 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3676 * passes to PE to JOIN request or START_BSS request
3677 * This is a synchronous call.
3678 *
3679 * pLen - caller allocated memory that has the length of pBuf as input.
3680 * Upon returned, *pLen has the needed or IE length in pBuf.
3681 * pBuf - Caller allocated memory that contain the IE field, if any,
3682 * upon return
3683 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3684 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3685 * big enough
3686 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303687QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 uint32_t *pLen, uint8_t *pBuf,
3689 eCsrSecurityType secType)
3690{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3693
3694 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303695 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303696 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3697 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3698 pLen, pBuf);
3699 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 sme_release_global_lock(&pMac->sme);
3702 }
3703
3704 return status;
3705}
3706
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303707/*
3708 * sme_roam_get_security_rsp_ie() -
3709 * A wrapper function to request CSR to return the WPA or RSN or
3710 * WAPI IE from the beacon or probe rsp if connected
3711 * This is a synchronous call.
3712 *
3713 * pLen - caller allocated memory that has the length of pBuf as input.
3714 * Upon returned, *pLen has the needed or IE length in pBuf.
3715 * pBuf - Caller allocated memory that contain the IE field, if any,
3716 * upon return
3717 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3718 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3719 * big enough
3720 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303721QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 uint32_t *pLen, uint8_t *pBuf,
3723 eCsrSecurityType secType)
3724{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303725 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3727
3728 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303729 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303730 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3731 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3732 pLen, pBuf);
3733 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303734 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 sme_release_global_lock(&pMac->sme);
3736 }
3737
3738 return status;
3739
3740}
3741
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303742/*
3743 * sme_roam_get_num_pmkid_cache() -
3744 * A wrapper function to request CSR to return number of PMKID cache
3745 * entries
3746 * This is a synchronous call.
3747 *
3748 * Return uint32_t - the number of PMKID cache entries
3749 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003750uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3751{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303752 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3754 uint32_t numPmkidCache = 0;
3755
3756 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303757 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003758 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3759 numPmkidCache =
3760 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303761 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303762 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303763 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764 sme_release_global_lock(&pMac->sme);
3765 }
3766
3767 return numPmkidCache;
3768}
3769
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303770/*
3771 * sme_roam_get_pmkid_cache() -
3772 * A wrapper function to request CSR to return PMKID cache from CSR
3773 * This is a synchronous call.
3774 *
3775 * pNum - caller allocated memory that has the space of the number of
3776 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3777 * needed or actually number in tPmkidCacheInfo.
3778 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3779 * any, upon return
3780 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3781 * big enough
3782 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303783QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303784 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3788
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303789 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3791 0));
3792 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303793 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303794 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3795 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303797 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303798 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 sme_release_global_lock(&pMac->sme);
3800 }
3801
3802 return status;
3803}
3804
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303805/*
3806 * sme_get_config_param() -
3807 * A wrapper function that HDD calls to get the global settings
3808 * currently maintained by CSR.
3809 * This is a synchronous call.
3810 *
3811 * pParam - caller allocated memory
3812 * Return QDF_STATUS
3813 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303814QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3818
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303819 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3821 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303822 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303824 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003825 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 sme_release_global_lock(&pMac->sme);
3827 return status;
3828 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303829 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003830 &pMac->rrm.rrmSmeContext.rrmConfig,
3831 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303832 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 sme_release_global_lock(&pMac->sme);
3834 }
3835
3836 return status;
3837}
3838
3839/**
3840 * sme_cfg_set_int() - Sets the cfg parameter value.
3841 * @hal: Handle to hal.
3842 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003843 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 *
3845 * This function sets the string value in cfg parameter.
3846 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303847 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303849QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850{
3851 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303852 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853
3854 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856
3857 return status;
3858}
3859
3860/**
3861 * sme_cfg_set_str() - Sets the cfg parameter string.
3862 * @hal: Handle to hal.
3863 * @cfg_id: Configuration parameter ID.
3864 * @str: Pointer to the string buffer.
3865 * @length: Length of the string.
3866 *
3867 * This function sets the string value in cfg parameter.
3868 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303871QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 uint32_t length)
3873{
3874 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303875 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
3877 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303878 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879
3880 return status;
3881}
3882
3883/**
3884 * sme_cfg_get_int() - Gets the cfg parameter value.
3885 * @hal: Handle to hal.
3886 * @cfg_id: Configuration parameter ID.
3887 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003888 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 *
3890 * This function gets the value of the cfg parameter.
3891 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303892 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303894QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895{
3896 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303897 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898
3899 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303900 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901
3902 return status;
3903}
3904
3905/**
3906 * sme_cfg_get_str() - Gets the cfg parameter string.
3907 * @hal: Handle to hal.
3908 * @cfg_id: Configuration parameter ID.
3909 * @str: Pointer to the string buffer.
3910 * @length: Pointer to length of the string.
3911 *
3912 * This function gets the string value of the cfg parameter.
3913 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303914 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303916QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 uint32_t *length)
3918{
3919 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303920 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921
3922 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303923 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924
3925 return status;
3926}
3927
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303928/*
3929 * sme_get_modify_profile_fields() -
3930 * HDD or SME - QOS calls this function to get the current values of
3931 * connected profile fields, changing which can cause reassoc.
3932 * This function must be called after CFG is downloaded and STA is in connected
3933 * state. Also, make sure to call this function to get the current profile
3934 * fields before calling the reassoc. So that pModifyProfileFields will have
3935 * all the latest values plus the one(s) has been updated as part of reassoc
3936 * request.
3937 *
3938 * pModifyProfileFields - pointer to the connected profile fields
3939 * changing which can cause reassoc
3940 * Return QDF_STATUS
3941 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303942QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943 tCsrRoamModifyProfileFields *
3944 pModifyProfileFields)
3945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303946 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3948
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303949 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3951 0));
3952 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303954 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3955 status = csr_get_modify_profile_fields(pMac, sessionId,
3956 pModifyProfileFields);
3957 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303958 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 sme_release_global_lock(&pMac->sme);
3960 }
3961
3962 return status;
3963}
3964
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303965/*
3966 * sme_set_dhcp_till_power_active_flag() -
3967 * Sets/Clears DHCP related flag to disable/enable auto PS
3968 *
3969 * hal - The handle returned by mac_open.
3970 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3972{
3973 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3974 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3975
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303976 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3978 flag));
3979 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3980 ps_global_info->remain_in_power_active_till_dhcp = flag;
3981}
3982
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303983/*
3984 * sme_register11d_scan_done_callback() -
3985 * Register a routine of type csr_scan_completeCallback which is
3986 * called whenever an 11d scan is done
3987 *
3988 * hHal - The handle returned by mac_open.
3989 * callback - 11d scan complete routine to be registered
3990 * Return QDF_STATUS
3991 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303992QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303993 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303995 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3997
3998 pMac->scan.callback11dScanDone = callback;
3999
4000 return status;
4001}
4002
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304003/**
4004 * sme_deregister11d_scan_done_callback() - De-register scandone callback
4005 * @h_hal: Handler return by mac_open
4006 *
4007 * This function De-registers the scandone callback to SME
4008 *
4009 * Return: None
4010 */
4011void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
4012{
4013 tpAniSirGlobal pmac;
4014
4015 if (!h_hal) {
4016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4017 FL("hHal is not valid"));
4018 return;
4019 }
4020
4021 pmac = PMAC_STRUCT(h_hal);
4022 pmac->scan.callback11dScanDone = NULL;
4023}
4024
4025
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026#ifdef FEATURE_OEM_DATA_SUPPORT
4027/**
4028 * sme_register_oem_data_rsp_callback() - Register a routine of
4029 * type send_oem_data_rsp_msg
4030 * @h_hal: Handle returned by mac_open.
4031 * @callback: Callback to send response
4032 * to oem application.
4033 *
4034 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4035 * callback function.
4036 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304037 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 sme_send_oem_data_rsp_msg callback)
4041{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304042 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4044
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004045 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046
4047 return status;
4048
4049}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304050
4051/**
4052 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4053 * @h_hal: Handler return by mac_open
4054 * This function De-registers the OEM data response callback to SME
4055 *
4056 * Return: None
4057 */
4058void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4059{
4060 tpAniSirGlobal pmac;
4061
4062 if (!h_hal) {
4063 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4064 FL("hHal is not valid"));
4065 return;
4066 }
4067 pmac = PMAC_STRUCT(h_hal);
4068
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004069 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304070}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071
4072/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004073 * sme_oem_update_capability() - update UMAC's oem related capability.
4074 * @hal: Handle returned by mac_open
4075 * @oem_cap: pointer to oem_capability
4076 *
4077 * This function updates OEM capability to UMAC. Currently RTT
4078 * related capabilities are updated. More capabilities can be
4079 * added in future.
4080 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304081 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004082 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304083QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004084 struct sme_oem_capability *cap)
4085{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304086 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004087 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4088 uint8_t *bytes;
4089
4090 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4091
4092 if (cap->ftm_rr)
4093 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4094 if (cap->lci_capability)
4095 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4096
4097 return status;
4098}
4099
4100/**
4101 * sme_oem_get_capability() - get oem capability
4102 * @hal: Handle returned by mac_open
4103 * @oem_cap: pointer to oem_capability
4104 *
4105 * This function is used to get the OEM capability from UMAC.
4106 * Currently RTT related capabilities are received. More
4107 * capabilities can be added in future.
4108 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304109 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004110 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304111QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004112 struct sme_oem_capability *cap)
4113{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304114 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004115 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4116 uint8_t *bytes;
4117
4118 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4119
4120 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4121 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4122
4123 return status;
4124}
Naveen Rawat910726a2017-03-06 11:42:51 -08004125#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004126
4127/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4129 * @hal_ctx - The handle returned by mac_open.
4130 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4131 * Used for success/failure notification by SME
4132 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4133 * back to HDD at the time of callback.
4134 * @wake_reason_ind_cb - Callback routine provided by HDD.
4135 * Used for Wake Reason Indication by SME
4136 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4137 * back to HDD at the time of callback.
4138 *
4139 * WoWLAN works on top of BMPS mode.
4140 * If the device is not in BMPS mode,
4141 * SME will will cache the information that
4142 * WOWL has been enabled and attempt to put the device
4143 * in BMPS. On entry into BMPS, SME will enable the
4144 * WOWL mode.
4145 * Note 1: If we exit BMPS mode (someone requests full power),
4146 * we will NOT resume WOWL when we go back to BMPS again.
4147 * Request for full power (while in WOWL mode) means disable
4148 * WOWL and go to full power.
4149 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4150 * On entry into BMPS, SME will give priority to UAPSD and
4151 * enable only UAPSD if both UAPSD and WOWL are required.
4152 * Currently there is no requirement or use case to support
4153 * UAPSD and WOWL at the same time.
4154 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304155 * Return: QDF_STATUS
4156 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4157 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4158 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 * WOWL after BMPS mode is entered.
4160 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304161QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 void (*enter_wowl_callback_routine)(void
4163 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304164 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 void *enter_wowl_callback_context,
4166#ifdef WLAN_WAKEUP_EVENTS
4167 void (*wakeIndicationCB)(void *callback_context,
4168 tpSirWakeReasonInd
4169 wake_reason_ind),
4170 void *wakeIndicationCBContext,
4171#endif /* WLAN_WAKEUP_EVENTS */
4172 tpSirSmeWowlEnterParams wowl_enter_params,
4173 uint8_t session_id)
4174{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304175 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4177 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304178
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304179 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4181
4182 /* cache the WOWL information */
4183 ps_global_info->ps_params[session_id].wowl_enter_params =
4184 *wowl_enter_params;
4185 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4186 enter_wowl_callback_routine;
4187 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4188 enter_wowl_callback_context;
4189#ifdef WLAN_WAKEUP_EVENTS
4190 /* Cache the Wake Reason Indication callback information */
4191 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4192 wakeIndicationCB;
4193 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4194 wakeIndicationCBContext;
4195#endif /* WLAN_WAKEUP_EVENTS */
4196
4197 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4198 return status;
4199}
4200/**
4201 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4202 * @hal_ctx - The handle returned by mac_open.
4203 * @wowl_exit_params - Carries info on which smesession
4204 * wowl exit is requested.
4205 *
4206 * SME will initiate exit from WoWLAN mode and device will be
4207 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304208 * Return QDF_STATUS
4209 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4210 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304212QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 tpSirSmeWowlExitParams wowl_exit_params)
4214{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304215 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4217 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304218
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304219 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4221 session_id = wowl_exit_params->sessionId;
4222 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4223 return status;
4224}
4225
4226/**
4227 * sme_roam_set_key() - To set encryption key.
4228 * @hal: hal global context
4229 * @session_id: session id
4230 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4231 * @ptr_roam_id: Upon success return, this is the id caller can use to
4232 * identify the request in roamcallback
4233 *
4234 * This function should be called only when connected. This is an asynchronous
4235 * API.
4236 *
4237 * Return: Status of operation
4238 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304239QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4241{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304242 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4244 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304245 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4247
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304248 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 session_id, 0));
4250 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004251 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304252 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 }
4254 /*Once Setkey is done, we can go in BMPS */
4255 if (set_key->keyLength)
4256 ps_global_info->remain_in_power_active_till_dhcp = false;
4257
4258 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304259 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 return status;
4261
4262 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4263 if (ptr_roam_id)
4264 *ptr_roam_id = roam_id;
4265
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004266 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004268 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 session = CSR_GET_SESSION(mac_ctx, session_id);
4270 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004271 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304273 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 }
4275 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4276 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4277 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4278 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4279 set_key->encType)) {
4280 session->pCurRoamProfile->negotiatedUCEncryptionType =
4281 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4282 }
4283 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4284 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4285 set_key->encType)) {
4286 session->pCurRoamProfile->negotiatedUCEncryptionType =
4287 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4288 }
4289 }
4290 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4291 sme_release_global_lock(&mac_ctx->sme);
4292 return status;
4293}
4294
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304295/**
4296 * sme_roam_set_default_key_index - To set default wep key idx
4297 * @hal: pointer to hal handler
4298 * @session_id: session id
4299 * @default_idx: default wep key index
4300 *
4301 * This function prepares a message and post to WMA to set wep default
4302 * key index
4303 *
4304 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4305 */
4306QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4307 uint8_t default_idx)
4308{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004309 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304310 struct wep_update_default_key_idx *update_key;
4311
4312 update_key = qdf_mem_malloc(sizeof(*update_key));
4313 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004314 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304315 return QDF_STATUS_E_NOMEM;
4316 }
4317
4318 update_key->session_id = session_id;
4319 update_key->default_idx = default_idx;
4320
4321 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4322 msg.reserved = 0;
4323 msg.bodyptr = (void *)update_key;
4324
4325 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004326 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004327 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304328 qdf_mem_free(update_key);
4329 return QDF_STATUS_E_FAILURE;
4330 }
4331
4332 return QDF_STATUS_SUCCESS;
4333}
4334
4335
Jeff Johnson8bd23352017-09-26 11:39:24 -07004336/**
4337 * sme_get_rssi() - API to retrieve current RSSI
4338 * @hHal: HAL handle for device
4339 * @callback: SME sends back the requested stats using the callback
4340 * @staId: The station ID for which the RSSI is requested for
4341 * @bssid: The bssid of the connected session
4342 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4343 * RSSI, do not hold up but return this value.
4344 * @pContext: user context to be passed back along with the callback
4345 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304346 * A wrapper function that client calls to register a callback to get RSSI
4347 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004348 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304349 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304350QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304351 tCsrRssiCallback callback, uint8_t staId,
4352 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004353 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304355 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4357
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304358 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4360 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304361 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 status = csr_get_rssi(pMac, callback,
4363 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004364 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 sme_release_global_lock(&pMac->sme);
4366 }
4367 return status;
4368}
4369
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304370/*
4371 * sme_get_snr() -
4372 * A wrapper function that client calls to register a callback to get SNR
4373 *
4374 * callback - SME sends back the requested stats using the callback
4375 * staId - The station ID for which the stats is requested for
4376 * pContext - user context to be passed back along with the callback
4377 * p_cds_context - cds context
4378 * \return QDF_STATUS
4379 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304380QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304382 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304384 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4386
4387 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304388 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4390 sme_release_global_lock(&pMac->sme);
4391 }
4392 return status;
4393}
4394
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304395/*
4396 * sme_get_statistics() -
4397 * A wrapper function that client calls to register a callback to get
4398 * different PHY level statistics from CSR.
4399 *
4400 * requesterId - different client requesting for statistics,
4401 * HDD, UMA/GAN etc
4402 * statsMask - The different category/categories of stats requester
4403 * is looking for
4404 * callback - SME sends back the requested stats using the callback
4405 * periodicity - If requester needs periodic update in millisec, 0 means
4406 * it's an one time request
4407 * cache - If requester is happy with cached stats
4408 * staId - The station ID for which the stats is requested for
4409 * pContext - user context to be passed back along with the callback
4410 * sessionId - sme session interface
4411 * Return QDF_STATUS
4412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 eCsrStatsRequesterType requesterId,
4415 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004416 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304418 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4420
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304422 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304423 status = csr_get_statistics(pMac, requesterId, statsMask,
4424 callback, staId, pContext,
4425 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 sme_release_global_lock(&pMac->sme);
4427 }
4428
4429 return status;
4430
4431}
4432
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304433QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 tCsrLinkStatusCallback callback,
4435 void *pContext, uint8_t sessionId)
4436{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304437 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4439 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004440 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441
4442 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304443 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304444 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304446 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 "%s: Not able to allocate memory for link status",
4448 __func__);
4449 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304450 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 }
4452
4453 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4454 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4455 pMsg->sessionId = sessionId;
4456 pMac->sme.linkStatusContext = pContext;
4457 pMac->sme.linkStatusCallback = callback;
4458
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004459 message.type = WMA_LINK_STATUS_GET_REQ;
4460 message.bodyptr = pMsg;
4461 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304463 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004464 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4465 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304466 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 pMac->sme.linkStatusContext = NULL;
4470 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304471 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 }
4473
4474 sme_release_global_lock(&pMac->sme);
4475 }
4476
4477 return status;
4478}
4479
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304480/*
4481 * sme_get_country_code() -
4482 * To return the current country code. If no country code is applied,
4483 * default country code is used to fill the buffer.
4484 * If 11d supported is turned off, an error is return and the last
4485 * applied/default country code is used.
4486 * This is a synchronous API.
4487 *
4488 * pBuf - pointer to a caller allocated buffer for returned country code.
4489 * pbLen For input, this parameter indicates how big is the buffer.
4490 * Upon return, this parameter has the number of bytes for
4491 * country. If pBuf doesn't have enough space, this function
4492 * returns fail status and this parameter contains the number
4493 * that is needed.
4494 *
4495 * Return QDF_STATUS SUCCESS.
4496 *
4497 * FAILURE or RESOURCES The API finished and failed.
4498 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304499QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500{
4501 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4502
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304503 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4505
4506 return csr_get_country_code(pMac, pBuf, pbLen);
4507}
4508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509/* some support functions */
4510bool sme_is11d_supported(tHalHandle hHal)
4511{
4512 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4513
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004514 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515}
4516
4517bool sme_is11h_supported(tHalHandle hHal)
4518{
4519 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4520
4521 return csr_is11h_supported(pMac);
4522}
4523
4524bool sme_is_wmm_supported(tHalHandle hHal)
4525{
4526 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4527
4528 return csr_is_wmm_supported(pMac);
4529}
4530
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304531/*
4532 * sme_change_country_code() -
4533 * Change Country code from upperlayer during WLAN driver operation.
4534 * This is a synchronous API.
4535 *
4536 * hHal - The handle returned by mac_open.
4537 * pCountry New Country Code String
4538 * sendRegHint If we want to send reg hint to nl80211
4539 * Return QDF_STATUS SUCCESS.
4540 * FAILURE or RESOURCES The API finished and failed.
4541 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304542QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 tSmeChangeCountryCallback callback,
4544 uint8_t *pCountry,
4545 void *pContext,
4546 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004547 bool countryFromUserSpace,
4548 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304550 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004552 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 tAniChangeCountryCodeReq *pMsg;
4554
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304555 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4557 0));
4558 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304559 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4561 && (!pMac->roam.configParam.
4562 fSupplicantCountryCodeHasPriority)) {
4563
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004564 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565
4566 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 return status;
4569 }
4570
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304571 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004573 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304575 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 }
4577
4578 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4579 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304580 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 pMsg->countryFromUserSpace = countryFromUserSpace;
4582 pMsg->sendRegHint = sendRegHint;
4583 pMsg->changeCCCallback = callback;
4584 pMsg->pDevContext = pContext;
4585 pMsg->p_cds_context = p_cds_context;
4586
4587 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4588 msg.bodyptr = pMsg;
4589 msg.reserved = 0;
4590
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304591 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004592 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004593 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304594 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304595 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 sme_release_global_lock(&pMac->sme);
4598 }
4599
4600 return status;
4601}
4602
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304603/*
4604 * sme_generic_change_country_code() -
4605 * Change Country code from upperlayer during WLAN driver operation.
4606 * This is a synchronous API.
4607 *
4608 * hHal - The handle returned by mac_open.
4609 * pCountry New Country Code String
4610 * reg_domain regulatory domain
4611 * Return QDF_STATUS SUCCESS.
4612 * FAILURE or RESOURCES The API finished and failed.
4613 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304614QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004615 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304617 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004619 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 tAniGenericChangeCountryCodeReq *pMsg;
4621
4622 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304623 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 "%s: pMac is null", __func__);
4625 return status;
4626 }
4627
4628 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304629 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304630 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631
4632 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004633 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304635 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 }
4637
4638 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4639 pMsg->msgLen =
4640 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304641 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004642 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643
4644 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4645 msg.bodyptr = pMsg;
4646 msg.reserved = 0;
4647
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004649 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004650 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304651 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 sme_release_global_lock(&pMac->sme);
4655 }
4656
4657 return status;
4658}
4659
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304660/*
4661 * sme_dhcp_start_ind() -
4662 * API to signal the FW about the DHCP Start event.
4663 *
4664 * hHal - HAL handle for device.
4665 * device_mode - mode(AP,SAP etc) of the device.
4666 * macAddr - MAC address of the adapter.
4667 * sessionId - session ID.
4668 * Return QDF_STATUS SUCCESS.
4669 * FAILURE or RESOURCES The API finished and failed.
4670 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304671QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 uint8_t device_mode,
4673 uint8_t *macAddr, uint8_t sessionId)
4674{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304675 QDF_STATUS status;
4676 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004678 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304680 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
4682 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304683 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 pSession = CSR_GET_SESSION(pMac, sessionId);
4685
4686 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004687 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 }
Arif Hussain3316f402016-11-10 13:08:03 -08004691 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304693 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304695 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 "%s: Not able to allocate memory for dhcp start",
4697 __func__);
4698 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304699 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 }
4701 pMsg->msgType = WMA_DHCP_START_IND;
4702 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4703 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304704 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304705 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304706 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004707 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004709 message.type = WMA_DHCP_START_IND;
4710 message.bodyptr = pMsg;
4711 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304712 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004713 sessionId, message.type));
4714 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4715 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304716 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304719 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304720 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 }
4722 sme_release_global_lock(&pMac->sme);
4723 }
4724 return status;
4725}
4726
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304727/*
4728 * sme_dhcp_stop_ind() -
4729 * API to signal the FW about the DHCP complete event.
4730 *
4731 * hHal - HAL handle for device.
4732 * device_mode - mode(AP, SAP etc) of the device.
4733 * macAddr - MAC address of the adapter.
4734 * sessionId - session ID.
4735 * Return QDF_STATUS SUCCESS.
4736 * FAILURE or RESOURCES The API finished and failed.
4737 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304738QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 uint8_t device_mode,
4740 uint8_t *macAddr, uint8_t sessionId)
4741{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304742 QDF_STATUS status;
4743 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004745 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304747 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748
4749 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304750 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 pSession = CSR_GET_SESSION(pMac, sessionId);
4752
4753 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004754 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304756 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 }
Arif Hussain3316f402016-11-10 13:08:03 -08004758 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304760 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304762 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 "%s: Not able to allocate memory for dhcp stop",
4764 __func__);
4765 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304766 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 }
4768
4769 pMsg->msgType = WMA_DHCP_STOP_IND;
4770 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4771 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304772 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304773 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304774 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004775 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004777 message.type = WMA_DHCP_STOP_IND;
4778 message.bodyptr = pMsg;
4779 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304780 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004781 sessionId, message.type));
4782 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4783 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304784 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304787 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304788 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 }
4790
4791 sme_release_global_lock(&pMac->sme);
4792 }
4793 return status;
4794}
4795
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304796/*
4797 * sme_TXFailMonitorStopInd() -
4798 * API to signal the FW to start monitoring TX failures
4799 *
4800 * Return QDF_STATUS SUCCESS.
4801 * FAILURE or RESOURCES The API finished and failed.
4802 */
4803QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4804 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004805 void *txFailIndCallback)
4806{
4807 QDF_STATUS status;
4808 QDF_STATUS qdf_status;
4809 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004810 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004811 tAniTXFailMonitorInd *pMsg;
4812
4813 status = sme_acquire_global_lock(&pMac->sme);
4814 if (QDF_STATUS_SUCCESS == status) {
4815 pMsg = (tAniTXFailMonitorInd *)
4816 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4817 if (NULL == pMsg) {
4818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4819 "%s: Failed to allocate memory", __func__);
4820 sme_release_global_lock(&pMac->sme);
4821 return QDF_STATUS_E_NOMEM;
4822 }
4823
4824 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4825 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4826
4827 /* tx_fail_count = 0 should disable the Monitoring in FW */
4828 pMsg->tx_fail_count = tx_fail_count;
4829 pMsg->txFailIndCallback = txFailIndCallback;
4830
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004831 message.type = WMA_TX_FAIL_MONITOR_IND;
4832 message.bodyptr = pMsg;
4833 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004834
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004835 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4836 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004837 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4838 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4839 "%s: Post TX Fail monitor Start MSG fail",
4840 __func__);
4841 qdf_mem_free(pMsg);
4842 status = QDF_STATUS_E_FAILURE;
4843 }
4844 sme_release_global_lock(&pMac->sme);
4845 }
4846 return status;
4847}
4848
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304849/*
4850 * sme_set_cfg_privacy() -
4851 * API to set configure privacy parameters
4852 *
4853 * hHal - The handle returned by mac_open.
4854 * pProfile - Pointer CSR Roam profile.
4855 * fPrivacy - This parameter indicates status of privacy
4856 * Return void
4857 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858void sme_set_cfg_privacy(tHalHandle hHal,
4859 tCsrRoamProfile *pProfile, bool fPrivacy)
4860{
4861 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304862
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304863 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304865 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4867 sme_release_global_lock(&pMac->sme);
4868 }
4869}
4870
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304871/*
4872 * sme_neighbor_report_request() -
4873 * API to request neighbor report.
4874 *
4875 * hHal - The handle returned by mac_open.
4876 * pRrmNeighborReq - Pointer to a caller allocated object of type
4877 * tRrmNeighborReq. Caller owns the memory and is
4878 * responsible for freeing it.
4879 * Return QDF_STATUS
4880 * QDF_STATUS_E_FAILURE - failure
4881 * QDF_STATUS_SUCCESS success
4882 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304883QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304885 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304887 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304889
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304890 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4892 0));
4893
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304894 if (pRrmNeighborReq->neighbor_report_offload) {
4895 status = csr_invoke_neighbor_report_request(sessionId,
4896 pRrmNeighborReq,
4897 false);
4898 return status;
4899 }
4900
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304901 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 status =
4903 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304904 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 sme_release_global_lock(&pMac->sme);
4906 }
4907
4908 return status;
4909}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304911/*
4912 * sme_get_wcnss_wlan_compiled_version() -
4913 * This API returns the version of the WCNSS WLAN API with
4914 * which the HOST driver was built
4915 *
4916 * hHal - The handle returned by mac_open.
4917 * pVersion - Points to the Version structure to be filled
4918 * Return QDF_STATUS
4919 * QDF_STATUS_E_INVAL - failure
4920 * QDF_STATUS_SUCCESS success
4921 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304922QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 tSirVersionType *pVersion)
4924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304925 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4927
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304928 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304930 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304932 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934 sme_release_global_lock(&pMac->sme);
4935 }
4936
4937 return status;
4938}
4939
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304940/*
4941 * sme_get_wcnss_wlan_reported_version() -
4942 * This API returns the version of the WCNSS WLAN API with
4943 * which the WCNSS driver reports it was built
4944 * hHal - The handle returned by mac_open.
4945 * pVersion - Points to the Version structure to be filled
4946 * Return QDF_STATUS
4947 * QDF_STATUS_E_INVAL - failure
4948 * QDF_STATUS_SUCCESS success
4949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304950QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 tSirVersionType *pVersion)
4952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304953 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4955
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304956 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304960 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961
4962 sme_release_global_lock(&pMac->sme);
4963 }
4964
4965 return status;
4966}
4967
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304968/*
4969 * sme_get_wcnss_software_version() -
4970 * This API returns the version string of the WCNSS driver
4971 *
4972 * hHal - The handle returned by mac_open.
4973 * pVersion - Points to the Version string buffer to be filled
4974 * versionBufferSize - THe size of the Version string buffer
4975 * Return QDF_STATUS
4976 * QDF_STATUS_E_INVAL - failure
4977 * QDF_STATUS_SUCCESS success
4978 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304979QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 uint8_t *pVersion,
4981 uint32_t versionBufferSize)
4982{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304983 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304986 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304987 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004989 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990 pVersion,
4991 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304992 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304993 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 sme_release_global_lock(&pMac->sme);
4995 }
4996
4997 return status;
4998}
4999
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305000/*
5001 * sme_get_wcnss_hardware_version() -
5002 * This API returns the version string of the WCNSS hardware
5003 *
5004 * hHal - The handle returned by mac_open.
5005 * pVersion - Points to the Version string buffer to be filled
5006 * versionBufferSize - THe size of the Version string buffer
5007 * Return QDF_STATUS
5008 * QDF_STATUS_E_INVAL - failure
5009 * QDF_STATUS_SUCCESS success
5010 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305011QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 uint8_t *pVersion,
5013 uint32_t versionBufferSize)
5014{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305015 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5017
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305018 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305020 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305022 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023
5024 sme_release_global_lock(&pMac->sme);
5025 }
5026
5027 return status;
5028}
5029
5030#ifdef FEATURE_WLAN_WAPI
5031
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305032/*
5033 * sme_scan_get_bkid_candidate_list() -
5034 * A wrapper function to return the BKID candidate list
5035 *
5036 * pBkidList - caller allocated buffer point to an array of
5037 * tBkidCandidateInfo
5038 * pNumItems - pointer to a variable that has the number of
5039 * tBkidCandidateInfo allocated when retruning, this is
5040 * either the number needed or number of items put into
5041 * pPmkidList
5042 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5043 * big enough and pNumItems
5044 * has the number of tBkidCandidateInfo.
5045 * Note: pNumItems is a number of tBkidCandidateInfo,
5046 * not sizeof(tBkidCandidateInfo) * something
5047 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305048QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 tBkidCandidateInfo *pBkidList,
5050 uint32_t *pNumItems)
5051{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305052 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5054
5055 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305056 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305058 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5059 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 sme_release_global_lock(&pMac->sme);
5061 }
5062
5063 return status;
5064}
5065#endif /* FEATURE_WLAN_WAPI */
5066
5067#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005068/**
5069 * sme_oem_data_req() - send oem data request to WMA
5070 * @hal: HAL handle
5071 * @hdd_oem_req: OEM data request from HDD
5072 *
5073 * Return: QDF_STATUS
5074 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005075QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305077 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005078 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005079 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005081 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005082 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5083 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005084 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005085 return QDF_STATUS_E_FAILURE;
5086 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005088 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5089 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005090 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005091 return QDF_STATUS_E_NOMEM;
5092 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005094 oem_data_req->data_len = hdd_oem_req->data_len;
5095 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5096 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005097 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005098 return QDF_STATUS_E_NOMEM;
5099 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005101 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5102 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005104 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305106 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005107 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305108 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005109 sme_debug("OEM request(length: %d) sent to WMA",
5110 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005111
5112 if (oem_data_req->data_len)
5113 qdf_mem_free(oem_data_req->data);
5114 qdf_mem_free(oem_data_req);
5115
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005116 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 return status;
5118}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119#endif /*FEATURE_OEM_DATA_SUPPORT */
5120
Krunal Soni8d184fa2017-11-20 21:52:05 -08005121QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122{
Arif Hussainee677012017-01-26 17:50:13 -08005123 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005124 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08005125 struct cdp_pdev *pdev;
5126 ol_txrx_peer_handle peer;
5127 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005128 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305130 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005131 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08005132 __func__, params->type_of_persona,
5133 params->sme_session_id, params->subtype_of_persona,
5134 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135
Arif Hussainee677012017-01-26 17:50:13 -08005136 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5137
5138 if (NULL == pdev) {
5139 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5140 "%s: Failed to get pdev handler", __func__);
5141 return status;
5142 }
5143
Krunal Soni8d184fa2017-11-20 21:52:05 -08005144 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005145 if (QDF_IS_STATUS_ERROR(status))
5146 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147
Krunal Soni8d184fa2017-11-20 21:52:05 -08005148 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
5149 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005150 if (peer) {
5151 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5152 "%s: Peer=%d exist with same MAC",
5153 __func__, peer_id);
5154 status = QDF_STATUS_E_INVAL;
5155 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005156 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08005157 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08005158 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005159
5160 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005161 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162
5163 return status;
5164}
5165
Krunal Soni8d184fa2017-11-20 21:52:05 -08005166QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305168 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005169 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305171 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005172 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305174 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005175 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 sme_release_global_lock(&pMac->sme);
5177 }
5178
5179 return status;
5180}
5181
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305182/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305183 * sme_change_mcc_beacon_interval() -
5184 * To update P2P-GO beaconInterval. This function should be called after
5185 * disassociating all the station is done
5186 * This is an asynchronous API.
5187 *
5188 * @sessionId: Session Identifier
5189 * Return QDF_STATUS SUCCESS
5190 * FAILURE or RESOURCES
5191 * The API finished and failed.
5192 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005193QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305195 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005196 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197
Krunal Soni3fa80e22018-01-09 14:16:02 -08005198 if (!mac_ctx) {
5199 sme_err("mac_ctx is NULL");
5200 return status;
5201 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005202 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305203 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005204 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5205 sessionId);
5206 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 }
5208 return status;
5209}
5210
5211/**
5212 * sme_set_host_offload(): API to set the host offload feature.
5213 * @hHal: The handle returned by mac_open.
5214 * @sessionId: Session Identifier
5215 * @request: Pointer to the offload request.
5216 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305217 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305219QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 tpSirHostOffloadReq request)
5221{
5222 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305223 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305225 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5227 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305228 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229#ifdef WLAN_NS_OFFLOAD
5230 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5231 status = sme_set_ps_ns_offload(hHal, request,
5232 sessionId);
5233 } else
5234#endif /* WLAN_NS_OFFLOAD */
5235 {
5236 status = sme_set_ps_host_offload(hHal, request,
5237 sessionId);
5238 }
5239 sme_release_global_lock(&pMac->sme);
5240 }
5241
5242 return status;
5243}
5244
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305245/*
5246 * sme_set_keep_alive() -
5247 * API to set the Keep Alive feature.
5248 *
5249 * hHal - The handle returned by mac_open.
5250 * request - Pointer to the Keep Alive request.
5251 * Return QDF_STATUS
5252 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305253QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005254 tpSirKeepAliveReq request)
5255{
5256 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005257 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305259 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305261 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 FL("WMA_SET_KEEP_ALIVE message"));
5263
5264 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305267 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305269 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305271 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305272 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305273 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274 }
5275
Anurag Chouhanc5548422016-02-24 18:33:27 +05305276 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305279 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 "buff TP %d input TP %d ", request_buf->timePeriod,
5281 request->timePeriod);
5282 request_buf->sessionId = session_id;
5283
5284 msg.type = WMA_SET_KEEP_ALIVE;
5285 msg.reserved = 0;
5286 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305287 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5288 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305289 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005290 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305292 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305293 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305294 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 }
5296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305297 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298}
5299
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305300/*
5301 * sme_get_operation_channel() -
5302 * API to get current channel on which STA is parked his function gives
5303 * channel information only of infra station or IBSS station
5304 *
5305 * hHal, pointer to memory location and sessionId
5306 * Returns QDF_STATUS_SUCCESS
5307 * QDF_STATUS_E_FAILURE
5308 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305309QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 uint8_t sessionId)
5311{
5312 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305313 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314
5315 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5316 pSession = CSR_GET_SESSION(pMac, sessionId);
5317
5318 if ((pSession->connectedProfile.BSSType ==
5319 eCSR_BSS_TYPE_INFRASTRUCTURE)
5320 || (pSession->connectedProfile.BSSType ==
5321 eCSR_BSS_TYPE_IBSS)
5322 || (pSession->connectedProfile.BSSType ==
5323 eCSR_BSS_TYPE_INFRA_AP)
5324 || (pSession->connectedProfile.BSSType ==
5325 eCSR_BSS_TYPE_START_IBSS)) {
5326 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305327 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 }
5329 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305330 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331} /* sme_get_operation_channel ends here */
5332
Abhishek Singh7996eb72015-12-30 17:24:02 +05305333/**
5334 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5335 * management frame indication to PE.
5336 *
5337 * @hal: hal pointer
5338 * @callback: callback pointer to be registered
5339 *
5340 * This function is used to register a callback for management
5341 * frame indication to PE.
5342 *
5343 * Return: Success if msg is posted to PE else Failure.
5344 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305345QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305346 sir_mgmt_frame_ind_callback callback)
5347{
5348 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5349 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305351
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305353 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305354 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305355 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005356 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305357 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305358 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305359 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305360 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5361 msg->length = sizeof(*msg);
5362
5363 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005364 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305365 sme_release_global_lock(&mac_ctx->sme);
5366 return status;
5367 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305368 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305369}
5370
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305371/*
5372 * sme_RegisterMgtFrame() -
5373 * To register managment frame of specified type and subtype.
5374 *
5375 * frameType - type of the frame that needs to be passed to HDD.
5376 * matchData - data which needs to be matched before passing frame
5377 * to HDD.
5378 * matchDataLen - Length of matched data.
5379 * Return QDF_STATUS
5380 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305381QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 uint16_t frameType, uint8_t *matchData,
5383 uint16_t matchLen)
5384{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305385 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5387
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305389 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 tSirRegisterMgmtFrame *pMsg;
5391 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305392 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5393 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394
5395 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005396 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305398 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 }
5400
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305401 if (!CSR_IS_SESSION_ANY(sessionId) &&
5402 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 "%s Invalid Sessionid", __func__);
5405 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305406 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 }
5408
5409 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305411 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305413 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5416 pMsg->length = len;
5417 pMsg->sessionId = sessionId;
5418 pMsg->registerFrame = true;
5419 pMsg->frameType = frameType;
5420 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305421 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005422 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 }
5424 sme_release_global_lock(&pMac->sme);
5425 }
5426 return status;
5427}
5428
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305429/*
5430 * sme_DeregisterMgtFrame() -
5431 * To De-register managment frame of specified type and subtype.
5432 *
5433 * frameType - type of the frame that needs to be passed to HDD.
5434 * matchData - data which needs to be matched before passing frame
5435 * to HDD.
5436 * matchDataLen - Length of matched data.
5437 * Return QDF_STATUS
5438 */
5439QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 uint16_t frameType, uint8_t *matchData,
5441 uint16_t matchLen)
5442{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305443 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005444 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5445
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305446 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5448 0));
5449 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305450 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 tSirRegisterMgmtFrame *pMsg;
5452 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305453 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5454 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455
5456 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005457 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305459 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 }
5461
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305462 if (!CSR_IS_SESSION_ANY(sessionId) &&
5463 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 "%s Invalid Sessionid", __func__);
5466 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305467 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 }
5469
5470 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5471
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305472 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305474 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5477 pMsg->length = len;
5478 pMsg->registerFrame = false;
5479 pMsg->frameType = frameType;
5480 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305481 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005482 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 }
5484 sme_release_global_lock(&pMac->sme);
5485 }
5486 return status;
5487}
5488
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305489/**
5490 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5491 * @hal: The handle returned by mac_open
5492 * @session_id: session id
5493 * @buf: pointer to frame
5494 * @len: frame length
5495 *
5496 * Return: QDF_STATUS
5497 */
5498static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5499 const uint8_t *buf, uint32_t len)
5500{
5501 QDF_STATUS status = QDF_STATUS_SUCCESS;
5502 struct sir_mgmt_msg *msg;
5503 uint16_t msg_len;
5504 struct scheduler_msg sch_msg = {0};
5505
5506 sme_debug("prepares auth frame");
5507
5508 msg_len = sizeof(*msg) + len;
5509 msg = qdf_mem_malloc(msg_len);
5510 if (msg == NULL) {
5511 status = QDF_STATUS_E_NOMEM;
5512 } else {
5513 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5514 msg->msg_len = msg_len;
5515 msg->session_id = session_id;
5516 msg->data = (uint8_t *)msg + sizeof(*msg);
5517 qdf_mem_copy(msg->data, buf, len);
5518
5519 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5520 sch_msg.bodyptr = msg;
5521 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5522 }
5523 return status;
5524}
5525
5526QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5527 const uint8_t *buf, uint32_t len)
5528{
5529 QDF_STATUS status = QDF_STATUS_SUCCESS;
5530 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5531
5532 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5533 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5534
5535 status = sme_acquire_global_lock(&mac->sme);
5536 if (QDF_IS_STATUS_SUCCESS(status)) {
5537 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5538 sme_release_global_lock(&mac->sme);
5539 }
5540
5541 return status;
5542}
5543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005545/**
5546 * sme_configure_ext_wow() - configure Extr WoW
5547 * @hHal - The handle returned by mac_open.
5548 * @wlanExtParams - Depicts the wlan Ext params.
5549 * @callback - ext_wow callback to be registered.
5550 * @callback_context - ext_wow callback context
5551 *
5552 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305553 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005554 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305555QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 tpSirExtWoWParams wlanExtParams,
5557 csr_readyToExtWoWCallback callback,
5558 void *callback_context)
5559{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305560 QDF_STATUS status = QDF_STATUS_SUCCESS;
5561 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005563 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305564 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565
5566 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305567 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305569 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5571
5572 pMac->readyToExtWoWCallback = callback;
5573 pMac->readyToExtWoWContext = callback_context;
5574
5575 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305576 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577
5578 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305579 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005580 message.bodyptr = MsgPtr;
5581 message.type = WMA_WLAN_EXT_WOW;
5582 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5583 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305584 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 pMac->readyToExtWoWCallback = NULL;
5586 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305587 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305588 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 }
5590 sme_release_global_lock(&pMac->sme);
5591 } else {
5592 pMac->readyToExtWoWCallback = NULL;
5593 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305594 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 }
5596
5597 return status;
5598}
5599
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305600/*
5601 * sme_configure_app_type1_params() -
5602 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5603 *
5604 * hHal - The handle returned by mac_open.
5605 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5606 * Return QDF_STATUS
5607 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305608QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 tpSirAppType1Params wlanAppType1Params)
5610{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305611 QDF_STATUS status = QDF_STATUS_SUCCESS;
5612 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005614 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305615 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616
5617 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305618 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305620 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5622 0));
5623
5624 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305625 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305627 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005628 message.bodyptr = MsgPtr;
5629 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5630 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5631 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305632 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305633 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305634 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 }
5636 sme_release_global_lock(&pMac->sme);
5637 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305638 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 }
5640
5641 return status;
5642}
5643
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305644/*
5645 * sme_configure_app_type2_params() -
5646 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5647 *
5648 * hHal - The handle returned by mac_open.
5649 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5650 * Return QDF_STATUS
5651 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305652QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305653 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305655 QDF_STATUS status = QDF_STATUS_SUCCESS;
5656 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005658 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305659 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660
5661 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305662 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305664 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5666 0));
5667
5668 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305669 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305671 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005672 message.bodyptr = MsgPtr;
5673 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5674 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5675 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305676 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305677 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305678 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 }
5680 sme_release_global_lock(&pMac->sme);
5681 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305682 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 }
5684
5685 return status;
5686}
5687#endif
5688
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305689/*
5690 * sme_get_infra_session_id
5691 * To get the session ID for infra session, if connected
5692 * This is a synchronous API.
5693 *
5694 * hHal - The handle returned by mac_open.
5695 * sessionid, -1 if infra session is not connected
5696 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697int8_t sme_get_infra_session_id(tHalHandle hHal)
5698{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305699 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 int8_t sessionid = -1;
5701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5702
5703 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305704 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705
5706 sessionid = csr_get_infra_session_id(pMac);
5707
5708 sme_release_global_lock(&pMac->sme);
5709 }
5710
5711 return sessionid;
5712}
5713
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305714/*
5715 * sme_get_infra_operation_channel() -
5716 * To get the operating channel for infra session, if connected
5717 * This is a synchronous API.
5718 *
5719 * hHal - The handle returned by mac_open.
5720 * sessionId - the sessionId returned by sme_open_session.
5721 * Return operating channel, 0 if infra session is not connected
5722 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5724{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305725 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5727 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305730 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731
5732 channel = csr_get_infra_operation_channel(pMac, sessionId);
5733
5734 sme_release_global_lock(&pMac->sme);
5735 }
5736
5737 return channel;
5738}
5739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305740/* This routine will return poerating channel on which other BSS is operating
5741 * to be used for concurrency mode. If other BSS is not up or not connected it
5742 * will return 0
5743 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5745{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305746 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5748 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305751 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752
5753 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5755 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 sme_release_global_lock(&pMac->sme);
5757 }
5758
5759 return channel;
5760}
5761
5762#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5763uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5764 eCsrPhyMode sapPhyMode,
5765 uint8_t cc_switch_mode)
5766{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305767 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5769 uint16_t channel = 0;
5770
5771 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305772 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305774 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5775 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 cc_switch_mode);
5777 sme_release_global_lock(&pMac->sme);
5778 }
5779
5780 return channel;
5781}
5782#endif
5783
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305784/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005785 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005786 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005787 * @cb_fn: Callback function pointer
5788 * @db_ctx: Callback data
5789 *
5790 * Return: QDF_STATUS
5791 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005792QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005793 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5794{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005795 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005796 QDF_STATUS status;
5797
Manikandan Mohan976e7562016-03-15 16:33:31 -07005798 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005799 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005800 mac->sme.get_tsf_cb = cb_fn;
5801 mac->sme.get_tsf_cxt = cb_ctx;
5802 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005803 }
5804 return status;
5805}
5806
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305807/**
5808 * sme_reset_tsfcb() - Reset callback for TSF capture
5809 * @h_hal: Handler return by mac_open
5810 *
5811 * This function reset the tsf capture callback to SME
5812 *
5813 * Return: QDF_STATUS
5814 */
5815QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5816{
5817 tpAniSirGlobal mac;
5818 QDF_STATUS status;
5819
5820 if (!h_hal) {
5821 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5822 FL("h_hal is not valid"));
5823 return QDF_STATUS_E_INVAL;
5824 }
5825 mac = PMAC_STRUCT(h_hal);
5826
5827 status = sme_acquire_global_lock(&mac->sme);
5828 if (QDF_IS_STATUS_SUCCESS(status)) {
5829 mac->sme.get_tsf_cb = NULL;
5830 mac->sme.get_tsf_cxt = NULL;
5831 sme_release_global_lock(&mac->sme);
5832 }
5833 return status;
5834}
5835
Manikandan Mohan976e7562016-03-15 16:33:31 -07005836#ifdef WLAN_FEATURE_TSF
5837/*
5838 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5839 * @h_hal: Handler return by mac_open
5840 * @pinvalue: gpio pin id
5841 *
5842 * Return: QDF_STATUS
5843 */
5844QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5845{
5846 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005847 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005848 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5849
5850 status = sme_acquire_global_lock(&mac->sme);
5851 if (QDF_IS_STATUS_SUCCESS(status)) {
5852 tsf_msg.type = WMA_TSF_GPIO_PIN;
5853 tsf_msg.reserved = 0;
5854 tsf_msg.bodyval = pinvalue;
5855
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005856 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005857 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005858 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005859 status = QDF_STATUS_E_FAILURE;
5860 }
5861 sme_release_global_lock(&mac->sme);
5862 }
5863 return status;
5864}
5865#endif
5866
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005867QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 uint32_t *len)
5869{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305870 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005871 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005873 if (NULL == mac_ctx) {
5874 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5875 FL("Invalid MAC context"));
5876 return QDF_STATUS_E_FAILURE;
5877 }
5878
5879 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305880 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005881 status = csr_get_cfg_valid_channels(mac_ctx,
5882 aValidChannels, len);
5883 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 }
5885
5886 return status;
5887}
5888
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005889static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5890{
5891 switch (src) {
5892 case SOURCE_CORE:
5893 return "WORLD MODE";
5894
5895 case SOURCE_DRIVER:
5896 return "BDF file";
5897
5898 case SOURCE_USERSPACE:
5899 return "user-space";
5900
5901 case SOURCE_11D:
5902 return "802.11D IEs in beacons";
5903
5904 default:
5905 return "unknown";
5906 }
5907}
5908
Amar Singhal6edf9732016-11-20 21:43:40 -08005909void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5910{
5911 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5912
5913 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005914
5915 sme_debug("Country source is %s",
5916 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005917}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305918/*
5919 * sme_handle_change_country_code() -
5920 * Change Country code, Reg Domain and channel list
5921 *
5922 * Details Country Code Priority
5923 * If Supplicant country code is priority than 11d is disabled.
5924 * If 11D is enabled, we update the country code after every scan.
5925 * Hence when Supplicant country code is priority, we don't need 11D info.
5926 * Country code from Supplicant is set as current courtry code.
5927 * User can send reset command XX (instead of country code) to reset the
5928 * country code to default values. If 11D is priority,
5929 * Than Supplicant country code code is set to default code. But 11D code
5930 * is set as current country code
5931 *
5932 * pMac - The handle returned by mac_open.
5933 * pMsgBuf - MSG Buffer
5934 * Return QDF_STATUS
5935 */
5936static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5937 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305939 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 tAniChangeCountryCodeReq *pMsg;
5941 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305942 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005943 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305945 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 /*
5947 * if the reset Supplicant country code command is triggered,
5948 * enable 11D, reset the country code and return
5949 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005950 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 pMac->roam.configParam.Is11dSupportEnabled =
5952 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5953
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005954 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5955 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956
5957 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305958 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305959 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005960 default_country,
5961 WNI_CFG_COUNTRY_CODE_LEN);
5962 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305963 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 return status;
5965 }
5966 /*
5967 * Update the 11d country to default country so that when
5968 * callback is received for this default country, driver will
5969 * not disable the 11d taking it as valid country by user.
5970 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005971 sme_debug(
5972 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305974 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 pMsg->countryCode,
5976 WNI_CFG_COUNTRY_CODE_LEN);
5977 } else {
5978 /* if Supplicant country code has priority, disable 11d */
5979 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305980 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 }
5983
5984 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305985 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986
5987 /* Set Current Country code and Current Regulatory domain */
5988 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305989 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 /* Supplicant country code failed. So give 11D priority */
5991 pMac->roam.configParam.Is11dSupportEnabled =
5992 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005993 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 return status;
5995 }
5996
5997 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305998 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6000
6001 /* Get Domain ID from country code */
6002 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306003 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07006005 domainIdIoctl,
6006 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306007 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006008 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 return status;
6010 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306011 /* Supplicant country code is invalid, so we are on world mode
6012 * now. So give 11D chance to update
6013 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 pMac->roam.configParam.Is11dSupportEnabled =
6015 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006016 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 }
6018
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006019 if (domainIdIoctl >= REGDOMAIN_COUNT) {
6020 sme_err("Invalid regId %d", domainIdIoctl);
6021 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 } else {
6023 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
6024 /* set again if we find AP with 11d info during scan */
6025 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006026 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306027 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306028 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306029 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006030 sizeof(pMac->scan.countryCode11d));
6031 }
6032 }
6033
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306034 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306036 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306038 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006039}
6040
6041/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006042 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 * @mac_ctx: mac global context
6044 * @msg: request msg packet
6045 *
6046 * If Supplicant country code is priority than 11d is disabled.
6047 * If 11D is enabled, we update the country code after every scan.
6048 * Hence when Supplicant country code is priority, we don't need 11D info.
6049 * Country code from Supplicant is set as current country code.
6050 *
6051 * Return: status of operation
6052 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306053static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006054sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
6055 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306057 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006058 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006059 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006061 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062
Amar Singhal6edf9732016-11-20 21:43:40 -08006063 if (SOURCE_11D != mac_ctx->reg_hint_src) {
6064 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
6065 if (user_ctry_priority)
6066 mac_ctx->roam.configParam.Is11dSupportEnabled =
6067 false;
6068 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306069 if (mac_ctx->roam.configParam.
6070 Is11dSupportEnabled &&
6071 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006073 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006074
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306075 status =
6076 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08006077 mac_ctx,
6078 mac_ctx->scan.countryCode11d,
6079 &reg_domain_id,
6080 SOURCE_11D);
6081 return QDF_STATUS_E_FAILURE;
6082 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006083 }
6084 }
6085 } else {
6086 /* if kernel gets invalid country code; it
6087 * resets the country code to world
6088 */
6089 if (('0' != msg->countryCode[0]) ||
6090 ('0' != msg->countryCode[1]))
6091 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6092 msg->countryCode,
6093 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006094 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006095
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006096 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6097 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100 /* get the channels based on new cc */
6101 status = csr_get_channel_and_power_list(mac_ctx);
6102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306103 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006104 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 return status;
6106 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 /* reset info based on new cc, and we are done */
6109 csr_apply_channel_power_info_wrapper(mac_ctx);
6110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006112
6113 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 * Country IE
6115 */
6116 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006117
Amar Singhal6edf9732016-11-20 21:43:40 -08006118 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006121
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306122 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123}
6124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125static bool
6126sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6127{
6128 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306129 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 ch_lst_info = &mac_ctx->scan.base_channels;
6132 for (i = 0; i < ch_lst_info->numChannels; i++) {
6133 if (ch_lst_info->channelList[i] == curr_ch)
6134 return true;
6135 }
6136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 return false;
6138}
6139/**
6140 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6141 * if channel is not supported
6142 * @mac_ctx: mac global context
6143 *
6144 * If new country code does not support the channel on which STA/P2P client
6145 * is connetced, it sends the disconnect to the AP/P2P GO
6146 *
6147 * Return: void
6148 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306149static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150{
6151 uint8_t session_id, found = false;
6152 uint8_t curr_ch;
6153
6154 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6155 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6156 continue;
6157 found = false;
6158 /* Session is connected.Check the channel */
6159 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6160 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006161 sme_debug("Current Operating channel : %d, session :%d",
6162 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6164 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006165 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 csr_roam_disconnect(mac_ctx, session_id,
6167 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6168 }
6169 }
6170}
6171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006172#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306173QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 tpSirRcvFltMcAddrList pMulticastAddrs)
6175{
6176 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006177 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306179 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006180
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306181 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6182 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006183 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006184 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006185
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006186 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006187 pSession = CSR_GET_SESSION(pMac, sessionId);
6188 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6189 (!csr_is_conn_state_infra(pMac, sessionId) &&
6190 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306191 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006192 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006193 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006195 }
6196
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306197 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306199 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306200 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306202 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 }
6204
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006205 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6206 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006208 "%s: Request ignored, session %d is not connected or started",
6209 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306210 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306211 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006212 }
6213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306214 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006215 sizeof(tSirRcvFltMcAddrList));
6216
Anurag Chouhanc5548422016-02-24 18:33:27 +05306217 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6218 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006219 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006220
6221 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6222 msg.reserved = 0;
6223 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306224 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6225 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006226 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006227 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306228 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306229 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306231 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306232 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 }
6234
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306235 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006236}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237#endif /* WLAN_FEATURE_PACKET_FILTERING */
6238
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306239/*
6240 * sme_is_channel_valid() -
6241 * To check if the channel is valid for currently established domain
6242 * This is a synchronous API.
6243 *
6244 * hHal - The handle returned by mac_open.
6245 * channel - channel to verify
6246 * Return true/false, true if channel is valid
6247 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006248bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6249{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306250 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251 bool valid = false;
6252 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6253
6254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306255 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256
6257 valid = csr_roam_is_channel_valid(pMac, channel);
6258
6259 sme_release_global_lock(&pMac->sme);
6260 }
6261
6262 return valid;
6263}
6264
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306265/*
6266 * sme_set_freq_band() -
6267 * Used to set frequency band.
6268 *
6269 * hHal
6270 * sessionId - Session Identifier
6271 * band value to be configured
6272 * Return QDF_STATUS
6273 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006274QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
6275 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006276{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306277 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6279
6280 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306281 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 status = csr_set_band(hHal, sessionId, eBand);
6283 sme_release_global_lock(&pMac->sme);
6284 }
6285 return status;
6286}
6287
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306288/*
6289 * sme_get_freq_band() -
6290 * Used to get the current band settings.
6291 *
6292 * hHal
6293 * pBand pointer to hold band value
6294 * Return QDF_STATUS
6295 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006296QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306298 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6300
6301 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306302 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303 *pBand = csr_get_current_band(hHal);
6304 sme_release_global_lock(&pMac->sme);
6305 }
6306 return status;
6307}
6308
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306309/*
6310 * sme_set_max_tx_power_per_band() -
6311 * Set the Maximum Transmit Power specific to band dynamically.
6312 * Note: this setting will not persist over reboots.
6313 *
6314 * band
6315 * power to set in dB
6316 * Return QDF_STATUS
6317 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006318QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006319{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006320 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006321 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6322
6323 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306324 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006325 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6328 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306329 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006330 }
6331
6332 pMaxTxPowerPerBandParams->power = dB;
6333 pMaxTxPowerPerBandParams->bandInfo = band;
6334
6335 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6336 msg.reserved = 0;
6337 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306338 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6339 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006340 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006341 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306342 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006343 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6344 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306345 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306346 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006347 }
6348
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306349 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350}
6351
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306352/*
6353 * sme_set_max_tx_power() -
6354 * Set the Maximum Transmit Power dynamically. Note: this setting will
6355 * not persist over reboots.
6356 *
6357 * hHal
6358 * pBssid BSSID to set the power cap for
6359 * pBssid pSelfMacAddress self MAC Address
6360 * pBssid power to set in dB
6361 * Return QDF_STATUS
6362 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306363QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6364 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006366 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006367 tpMaxTxPowerParams pMaxTxParams = NULL;
6368
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306369 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306371 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006372 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306373 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 "%s: Not able to allocate memory for pMaxTxParams",
6375 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306376 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006377 }
6378
Anurag Chouhanc5548422016-02-24 18:33:27 +05306379 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6380 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 pMaxTxParams->power = dB;
6382
6383 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6384 msg.reserved = 0;
6385 msg.bodyptr = pMaxTxParams;
6386
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006387 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006388 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306389 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6391 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306392 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 }
6395
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306396 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397}
6398
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306399/*
6400 * sme_set_custom_mac_addr() -
6401 * Set the customer Mac Address.
6402 *
6403 * customMacAddr customer MAC Address
6404 * Return QDF_STATUS
6405 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306406QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006407{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006408 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 tSirMacAddr *pBaseMacAddr;
6410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306411 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306413 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006414 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306415 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 }
6417
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306418 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419
6420 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6421 msg.reserved = 0;
6422 msg.bodyptr = pBaseMacAddr;
6423
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006424 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006425 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306427 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306428 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306429 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006430 }
6431
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306432 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433}
6434
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306435/*
6436 * sme_set_tx_power() -
6437 * Set Transmit Power dynamically.
6438 *
6439 * hHal
6440 * sessionId Target Session ID
6441 * BSSID
6442 * dev_mode dev_mode such as station, P2PGO, SAP
6443 * dBm power to set
6444 * Return QDF_STATUS
6445 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306446QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306447 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006448 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006449{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006450 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006451 tpMaxTxPowerParams pTxParams = NULL;
6452 int8_t power = (int8_t) dBm;
6453
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306454 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6456
6457 /* make sure there is no overflow */
6458 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306461 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462 }
6463
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306464 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006465 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306466 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006467 "%s: Not able to allocate memory for pTxParams",
6468 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306469 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 }
6471
Anurag Chouhanc5548422016-02-24 18:33:27 +05306472 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006473 pTxParams->power = power; /* unit is dBm */
6474 pTxParams->dev_mode = dev_mode;
6475 msg.type = WMA_SET_TX_POWER_REQ;
6476 msg.reserved = 0;
6477 msg.bodyptr = pTxParams;
6478
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006479 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006480 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306481 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006482 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6483 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306484 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306485 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 }
6487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306488 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489}
6490
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306491QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6492 uint8_t param_val)
6493{
6494 QDF_STATUS status;
6495 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6496
6497 pMac->roam.configParam.is_fils_enabled = !param_val;
6498
6499 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6500 status = wma_cli_set_command((int)session_id,
6501 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6502 !param_val, VDEV_CMD);
6503 if (status)
6504 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6505 "%s: Failed to set enable bcast probe setting",
6506 __func__);
6507
6508 return status;
6509}
6510
6511QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306512 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306514 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306515 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516 uint16_t len;
6517
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306518 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306519 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306520 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306521 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6522 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006523
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306524 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006525 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306526 sme_release_global_lock(&mac_ctx->sme);
6527 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006528 }
6529
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306530 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6531 mac_ctx->ignore_assoc_disallowed = param_val;
6532
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306533 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306534 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006535
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306536 len = sizeof(*msg);
6537 msg = qdf_mem_malloc(len);
6538 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306539 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006540 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306541 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6542 msg->length = len;
6543 msg->session_id = session_id;
6544 msg->param_type = param_type;
6545 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006546 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306548 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 }
6550 return status;
6551}
6552
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306553/*
6554 * sme_set_tm_level() -
6555 * Set Thermal Mitigation Level to RIVA
6556 *
6557 * hHal - The handle returned by mac_open.
6558 * newTMLevel - new Thermal Mitigation Level
6559 * tmMode - Thermal Mitigation handle mode, default 0
6560 * Return QDF_STATUS
6561 */
6562QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6563 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006564{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306565 QDF_STATUS status = QDF_STATUS_SUCCESS;
6566 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006568 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006569 tAniSetTmLevelReq *setTmLevelReq = NULL;
6570
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306571 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6573 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306574 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006575 setTmLevelReq =
6576 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306577 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006578 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 "%s: Not able to allocate memory for sme_set_tm_level",
6581 __func__);
6582 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306583 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584 }
6585
6586 setTmLevelReq->tmMode = tmMode;
6587 setTmLevelReq->newTmLevel = newTMLevel;
6588
6589 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006590 message.bodyptr = setTmLevelReq;
6591 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306592 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006593 NO_SESSION, message.type));
6594 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6595 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306596 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306599 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306600 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006601 }
6602 sme_release_global_lock(&pMac->sme);
6603 }
6604 return status;
6605}
6606
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306607/*
6608 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6609 * Host and FW.
6610 *
6611 * hHal - HAL handle for device
6612 * Return NONE
6613 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006614void sme_feature_caps_exchange(tHalHandle hHal)
6615{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306616 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306617 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6618 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006619}
6620
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306621/*
6622 * sme_disable_feature_capablity() - SME interface to disable Active mode
6623 * offload capablity in Host.
6624 *
6625 * hHal - HAL handle for device
6626 * Return NONE
6627 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006628void sme_disable_feature_capablity(uint8_t feature_index)
6629{
6630}
6631
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306632/*
6633 * sme_reset_power_values_for5_g
6634 * Reset the power values for 5G band with default power values.
6635 *
6636 * hHal - HAL handle for device
6637 * Return NONE
6638 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006639void sme_reset_power_values_for5_g(tHalHandle hHal)
6640{
6641 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306642
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306643 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006644 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6645 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306646 /* Store the channel+power info in the global place: Cfg */
6647 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006648}
6649
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306650/*
6651 * sme_update_roam_prefer5_g_hz() -
6652 * Enable/disable Roam prefer 5G runtime option
6653 * This function is called through dynamic setConfig callback function
6654 * to configure the Roam prefer 5G runtime option
6655 *
6656 * hHal - HAL handle for device
6657 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6658 * Return Success or failure
6659 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306661QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6662 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006663{
6664 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306665 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006666
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306667 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6669 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306670 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 "%s: gRoamPrefer5GHz is changed from %d to %d",
6673 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6674 nRoamPrefer5GHz);
6675 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6676 sme_release_global_lock(&pMac->sme);
6677 }
6678
6679 return status;
6680}
6681
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306682/*
6683 * sme_set_roam_intra_band() -
6684 * enable/disable Intra band roaming
6685 * This function is called through dynamic setConfig callback function
6686 * to configure the intra band roaming
6687 * hHal - HAL handle for device
6688 * nRoamIntraBand Enable/Disable Intra band roaming
6689 * Return Success or failure
6690 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306691QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692{
6693 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306694 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006695
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306696 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006697 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6698 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306699 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701 "%s: gRoamIntraBand is changed from %d to %d",
6702 __func__, pMac->roam.configParam.nRoamIntraBand,
6703 nRoamIntraBand);
6704 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6705 sme_release_global_lock(&pMac->sme);
6706 }
6707
6708 return status;
6709}
6710
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306711/*
6712 * sme_update_roam_scan_n_probes() -
6713 * Function to update roam scan N probes
6714 * This function is called through dynamic setConfig callback function
6715 * to update roam scan N probes
6716 * hHal - HAL handle for device
6717 * sessionId - Session Identifier
6718 * nProbes number of probe requests to be sent out
6719 * Return Success or failure
6720 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306721QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006722 const uint8_t nProbes)
6723{
6724 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306725 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306727 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6729 NO_SESSION, 0));
6730 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306731 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306732 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006733 "%s: gRoamScanNProbes is changed from %d to %d",
6734 __func__, pMac->roam.configParam.nProbes, nProbes);
6735 pMac->roam.configParam.nProbes = nProbes;
6736 sme_release_global_lock(&pMac->sme);
6737 }
6738 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6739 csr_roam_offload_scan(pMac, sessionId,
6740 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6741 REASON_NPROBES_CHANGED);
6742 }
6743 return status;
6744}
6745
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306746/*
6747 * sme_update_roam_scan_home_away_time() -
6748 * Function to update roam scan Home away time
6749 * This function is called through dynamic setConfig callback function
6750 * to update roam scan home away time
6751 *
6752 * hHal - HAL handle for device
6753 * sessionId - Session Identifier
6754 * nRoamScanAwayTime Scan home away time
6755 * bSendOffloadCmd If true then send offload command to firmware
6756 * If false then command is not sent to firmware
6757 * Return Success or failure
6758 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306759QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006760 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306761 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006762 const bool bSendOffloadCmd)
6763{
6764 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306765 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306767 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6769 NO_SESSION, 0));
6770 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306771 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306772 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006773 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6774 __func__,
6775 pMac->roam.configParam.nRoamScanHomeAwayTime,
6776 nRoamScanHomeAwayTime);
6777 pMac->roam.configParam.nRoamScanHomeAwayTime =
6778 nRoamScanHomeAwayTime;
6779 sme_release_global_lock(&pMac->sme);
6780 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306781 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6782 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 csr_roam_offload_scan(pMac, sessionId,
6784 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6785 REASON_HOME_AWAY_TIME_CHANGED);
6786 }
6787 return status;
6788}
6789
Abhishek Singh518323d2015-10-19 17:42:01 +05306790/**
6791 * sme_ext_change_channel()- function to post send ECSA
6792 * action frame to csr.
6793 * @hHal: Hal context
6794 * @channel: new channel to switch
6795 * @session_id: senssion it should be sent on.
6796 *
6797 * This function is called to post ECSA frame to csr.
6798 *
6799 * Return: success if msg is sent else return failure
6800 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306801QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306802 uint8_t session_id)
6803{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306804 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306805 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6806 uint8_t channel_state;
6807
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006808 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306809 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006810 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306811
6812 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006813 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306814 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306815 }
6816
6817 status = sme_acquire_global_lock(&mac_ctx->sme);
6818
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306819 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306820 /* update the channel list to the firmware */
6821 status = csr_send_ext_change_channel(mac_ctx,
6822 channel, session_id);
6823 sme_release_global_lock(&mac_ctx->sme);
6824 }
6825
6826 return status;
6827}
6828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306829/*
6830 * sme_get_roam_intra_band() -
6831 * get Intra band roaming
6832 *
6833 * hHal - HAL handle for device
6834 * Return Success or failure
6835 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836bool sme_get_roam_intra_band(tHalHandle hHal)
6837{
6838 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306839
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306840 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6842 return pMac->roam.configParam.nRoamIntraBand;
6843}
6844
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306845/*
6846 * sme_get_roam_scan_n_probes() -
6847 * get N Probes
6848 *
6849 * hHal - HAL handle for device
6850 * Return Success or failure
6851 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6853{
6854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006856 return pMac->roam.configParam.nProbes;
6857}
6858
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306859/*
6860 * sme_get_roam_scan_home_away_time() -
6861 * get Roam scan home away time
6862 *
6863 * hHal - HAL handle for device
6864 * Return Success or failure
6865 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006866uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6867{
6868 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006870 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6871}
6872
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306873/*
6874 * sme_update_roam_rssi_diff() -
6875 * Update RoamRssiDiff
6876 * This function is called through dynamic setConfig callback function
6877 * to configure RoamRssiDiff
6878 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6879 *
6880 * hHal - HAL handle for device
6881 * sessionId - Session Identifier
6882 * RoamRssiDiff - minimum rssi difference between potential
6883 * candidate and current AP.
6884 * Return Success or failure
6885 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306887QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006888 uint8_t RoamRssiDiff)
6889{
6890 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306891 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006892
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006893 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6894 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6895 FL("Invalid sme session id: %d"), sessionId);
6896 return QDF_STATUS_E_INVAL;
6897 }
6898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306900 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306901 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006902 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6903 RoamRssiDiff,
6904 pMac->roam.configParam.RoamRssiDiff,
6905 mac_trace_get_neighbour_roam_state(pMac->roam.
6906 neighborRoamInfo
6907 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306908 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006909 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6910 sme_release_global_lock(&pMac->sme);
6911 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006912
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306913 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006914 csr_roam_offload_scan(pMac, sessionId,
6915 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6916 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 return status;
6918}
6919
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306920#ifdef WLAN_FEATURE_FILS_SK
6921QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6922 tCsrRoamProfile *src_profile)
6923{
6924 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6925 QDF_STATUS status = QDF_STATUS_SUCCESS;
6926 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6927 &mac->roam.neighborRoamInfo[session_id];
6928
6929 if (session_id >= CSR_ROAM_SESSION_MAX) {
6930 sme_err("Invalid sme session id: %d", session_id);
6931 return QDF_STATUS_E_INVAL;
6932 }
6933
6934 if (!src_profile) {
6935 sme_err("src roam profile NULL");
6936 return QDF_STATUS_E_INVAL;
6937 }
6938
6939 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6940 (neighbor_roam_info->neighborRoamState !=
6941 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6942 sme_info("Fast roam is disabled or not connected(%d)",
6943 neighbor_roam_info->neighborRoamState);
6944 return QDF_STATUS_E_PERM;
6945 }
6946
6947 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306948 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306949 sme_debug("Updating fils config to fw");
6950 csr_roam_offload_scan(mac, session_id,
6951 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6952 REASON_FILS_PARAMS_CHANGED);
6953 } else {
6954 sme_info("LFR3 not enabled");
6955 return QDF_STATUS_E_INVAL;
6956 }
6957
6958 return status;
6959}
6960
6961void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6962 tCsrRoamProfile *profile, uint32_t if_addr)
6963{
6964 int i;
6965 struct scheduler_msg msg;
6966 QDF_STATUS status;
6967 struct hlp_params *params;
6968 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6969 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6970 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6971 &mac->roam.neighborRoamInfo[session_id];
6972
6973 if (!session) {
6974 sme_err("session NULL");
6975 return;
6976 }
6977
6978 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6979 (neighbor_roam_info->neighborRoamState !=
6980 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6981 sme_debug("Fast roam is disabled or not connected(%d)",
6982 neighbor_roam_info->neighborRoamState);
6983 return;
6984 }
6985
6986 params = qdf_mem_malloc(sizeof(*params));
6987 if (!params) {
6988 sme_err("Mem alloc for HLP IE fails");
6989 return;
6990 }
6991 if ((profile->hlp_ie_len +
6992 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6993 sme_err("HLP IE len exceeds %d",
6994 profile->hlp_ie_len);
6995 qdf_mem_free(params);
6996 return;
6997 }
6998
6999 params->vdev_id = session_id;
7000 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
7001
7002 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
7003 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
7004
7005 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
7006 profile->hlp_ie, profile->hlp_ie_len);
7007
7008 msg.type = SIR_HAL_HLP_IE_INFO;
7009 msg.reserved = 0;
7010 msg.bodyptr = params;
7011 status = sme_acquire_global_lock(&mac->sme);
7012 if (status != QDF_STATUS_SUCCESS) {
7013 sme_err("sme lock acquire fails");
7014 qdf_mem_free(params);
7015 return;
7016 }
7017
7018 if (!QDF_IS_STATUS_SUCCESS
7019 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
7020 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
7021 sme_release_global_lock(&mac->sme);
7022 qdf_mem_free(params);
7023 return;
7024 }
7025
7026 sme_release_global_lock(&mac->sme);
7027}
7028
Jeff Johnson172237b2017-11-07 15:32:59 -08007029void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307030{
7031 struct fils_join_rsp_params *roam_fils_params;
7032
7033 if (!roam_info) {
7034 sme_err("FILS Roam Info NULL");
7035 return;
7036 }
7037
7038 roam_fils_params = roam_info->fils_join_rsp;
7039 if (!roam_fils_params) {
7040 sme_err("FILS Roam Param NULL");
7041 return;
7042 }
7043
7044 if (roam_fils_params->fils_pmk)
7045 qdf_mem_free(roam_fils_params->fils_pmk);
7046
7047 qdf_mem_free(roam_fils_params);
7048
7049 roam_info->fils_join_rsp = NULL;
7050}
7051
7052#else
7053inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
7054 tCsrRoamProfile *profile, uint32_t if_addr)
7055{}
7056#endif
7057
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307058/*
7059 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
7060 * support at runtime
7061 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7062 * isFastTransitionEnabled.
7063 * This is a synchronous call
7064 *
7065 * hHal - The handle returned by mac_open.
7066 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7067 * successfully.
7068 * Other status means SME is failed to update isFastTransitionEnabled.
7069 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307070QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071 bool isFastTransitionEnabled)
7072{
7073 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307074 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307076 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007077 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7078 0));
7079 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307080 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307081 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007082 "%s: FastTransitionEnabled is changed from %d to %d",
7083 __func__,
7084 pMac->roam.configParam.isFastTransitionEnabled,
7085 isFastTransitionEnabled);
7086 pMac->roam.configParam.isFastTransitionEnabled =
7087 isFastTransitionEnabled;
7088 sme_release_global_lock(&pMac->sme);
7089 }
7090
7091 return status;
7092}
7093
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307094/*
7095 * sme_update_wes_mode() -
7096 * Update WES Mode
7097 * This function is called through dynamic setConfig callback function
7098 * to configure isWESModeEnabled
7099 *
7100 * hHal - HAL handle for device
7101 * isWESModeEnabled - WES mode
7102 * sessionId - Session Identifier
7103 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7104 * Other status means SME is failed to update isWESModeEnabled.
7105 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307107QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007108 uint8_t sessionId)
7109{
7110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307111 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007112
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007113 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7114 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7115 FL("Invalid sme session id: %d"), sessionId);
7116 return QDF_STATUS_E_INVAL;
7117 }
7118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007119 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307120 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307121 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7123 isWESModeEnabled,
7124 pMac->roam.configParam.isWESModeEnabled,
7125 mac_trace_get_neighbour_roam_state(pMac->roam.
7126 neighborRoamInfo
7127 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307128 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007129 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7130 sme_release_global_lock(&pMac->sme);
7131 }
7132
7133 return status;
7134}
7135
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307136/*
7137 * sme_set_roam_scan_control() -
7138 * Set roam scan control
7139 * This function is called to set roam scan control
7140 * if roam scan control is set to 0, roaming scan cache is cleared
7141 * any value other than 0 is treated as invalid value
7142 * hHal - HAL handle for device
7143 * sessionId - Session Identifier
7144 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7145 * Other status means SME failure to update
7146 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307147QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007148 bool roamScanControl)
7149{
7150 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307151 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007152
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307153 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007154 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007155
7156 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7157 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7158 FL("Invalid sme session id: %d"), sessionId);
7159 return QDF_STATUS_E_INVAL;
7160 }
7161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007162 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307163 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307164 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007165 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7166 roamScanControl,
7167 pMac->roam.configParam.nRoamScanControl,
7168 mac_trace_get_neighbour_roam_state(pMac->roam.
7169 neighborRoamInfo
7170 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307171 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7173 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307174 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007175 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307176 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7177 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7179 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307180 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7181 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 }
7183 }
7184 sme_release_global_lock(&pMac->sme);
7185 }
7186 return status;
7187}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307189/*
7190 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7191 * support at runtime
7192 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7193 * isFastRoamIniFeatureEnabled.
7194 * This is a synchronous call
7195 *
7196 * hHal - The handle returned by mac_open.
7197 * sessionId - Session Identifier
7198 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7199 * successfully.
7200 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7201 */
7202QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7203 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7204{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007205 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7206
7207 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7208 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307209 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007210 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7211 __func__,
7212 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7213 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307214 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007215 }
7216
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307217 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007218 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7219 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7220 isFastRoamIniFeatureEnabled);
7221 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7222 isFastRoamIniFeatureEnabled;
7223 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307224 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007225
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307226 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007227}
7228
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307229/**
7230 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7231 * @hal - The handle returned by macOpen.
7232 * @session_id - Session Identifier
7233 * @is_fast_roam_enabled - flag to enable/disable roaming
7234 *
7235 * When Supplicant issues enabled/disable fast roaming on the basis
7236 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7237 *
7238 * Return: QDF_STATUS
7239 */
7240
7241QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7242 const bool is_fast_roam_enabled)
7243{
7244 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307245 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307246 QDF_STATUS status;
7247
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007248 /*
7249 * supplicant_disabled_roaming flag is set to true in
7250 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7251 * request with BSSID. This flag is reset when supplicant sends
7252 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007253 *
7254 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007255 * if roaming is disabled using driver command or INI and
7256 * supplicant_disabled_roaming flag remains set. So make sure to set
7257 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7258 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007259 */
7260 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007261 session->pCurRoamProfile->supplicant_disabled_roaming =
7262 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007263
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307264 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007265 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307266 if (!is_fast_roam_enabled)
7267 return QDF_STATUS_SUCCESS;
7268 return QDF_STATUS_E_FAILURE;
7269 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307270
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307271 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7272 session_id, is_fast_roam_enabled);
7273 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007274 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307275 return QDF_STATUS_E_FAILURE;
7276 }
7277
7278 return QDF_STATUS_SUCCESS;
7279}
7280
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307281/*
7282 * sme_update_is_mawc_ini_feature_enabled() -
7283 * Enable/disable LFR MAWC support at runtime
7284 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7285 * isMAWCIniFeatureEnabled.
7286 * This is a synchronous call
7287 *
7288 * hHal - The handle returned by mac_open.
7289 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7290 * Other status means SME is failed to update MAWCEnabled.
7291 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307292QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007293 const bool MAWCEnabled)
7294{
7295 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307296 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007297
7298 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307299 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307300 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007301 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007302 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7303 MAWCEnabled);
7304 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7305 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306 sme_release_global_lock(&pMac->sme);
7307 }
7308
7309 return status;
7310
7311}
7312
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007313/**
7314 * sme_stop_roaming() - Stop roaming for a given sessionId
7315 * This is a synchronous call
7316 *
7317 * @hHal - The handle returned by mac_open
7318 * @sessionId - Session Identifier
7319 *
7320 * Return QDF_STATUS_SUCCESS on success
7321 * Other status on failure
7322 */
7323QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007324{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007325 struct scheduler_msg wma_msg = {0};
7326 tSirRetStatus status;
7327 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007328 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7329 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007330 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007331
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007332 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007333 sme_err("incorrect session/vdev ID");
7334 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007335 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007336
7337 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05307338
7339 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
7340 if (!roam_info->b_roam_scan_offload_started) {
7341 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007342 return QDF_STATUS_SUCCESS;
7343 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007344 req = qdf_mem_malloc(sizeof(*req));
7345 if (!req) {
7346 sme_err("failed to allocated memory");
7347 return QDF_STATUS_E_NOMEM;
7348 }
7349
7350 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307351 if (reason == eCsrForcedDisassoc)
7352 req->reason = REASON_ROAM_STOP_ALL;
7353 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08007354 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007355 req->sessionId = session_id;
7356 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007357 req->middle_of_roaming = 1;
7358 else
7359 csr_roam_reset_roam_params(mac_ctx);
7360
7361 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7362 wma_msg.bodyptr = req;
7363
7364 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7365 if (eSIR_SUCCESS != status) {
7366 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007367 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007368 qdf_mem_free(req);
7369 return QDF_STATUS_E_FAULT;
7370 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007371 roam_info->b_roam_scan_offload_started = false;
7372 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007373
7374 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007375}
7376
Abhishek Singhd5686472017-09-20 15:18:50 +05307377void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7378{
7379 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7380 QDF_STATUS status = QDF_STATUS_SUCCESS;
7381 struct csr_roam_session *session;
7382
7383 status = sme_acquire_global_lock(&mac_ctx->sme);
7384 if (QDF_IS_STATUS_SUCCESS(status)) {
7385 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7386 session = CSR_GET_SESSION(mac_ctx, session_id);
7387 if (session)
7388 session->discon_in_progress = true;
7389 }
7390 sme_release_global_lock(&mac_ctx->sme);
7391 }
7392}
7393
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307394/*
7395 * sme_start_roaming() - Start roaming for a given sessionId
7396 * This is a synchronous call
7397 *
7398 * hHal - The handle returned by mac_open
7399 * sessionId - Session Identifier
7400 * Return QDF_STATUS_SUCCESS on success
7401 * Other status on failure
7402 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307403QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007404{
7405 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307406 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007407
7408 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307409 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007410 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7411 reason);
7412 sme_release_global_lock(&pMac->sme);
7413 }
7414
7415 return status;
7416}
7417
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307418/*
7419 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7420 * Concurrent session exists
7421 * This is a synchronuous call
7422 *
7423 * hHal - The handle returned by mac_open.
7424 * Return QDF_STATUS_SUCCESS
7425 * Other status means SME is failed
7426 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307427QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007428 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307429 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430{
7431
7432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307433 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434
7435 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307436 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007437 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7438 bFastRoamInConIniFeatureEnabled;
7439 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7440 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7441 0;
7442 }
7443 sme_release_global_lock(&pMac->sme);
7444 }
7445
7446 return status;
7447}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007448
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307449/*
7450 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7451 * Monitoring at runtime
7452 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7453 * fEnableFwRssiMonitoring.
7454 * This is a synchronous call
7455 *
7456 * hHal - The handle returned by mac_open.
7457 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7458 * config successfully.
7459 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7460 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307461QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007462 bool fEnableFwRssiMonitoring)
7463{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307464 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465
7466 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307467 fEnableFwRssiMonitoring) ==
7468 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307469 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307470 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007471 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7472 }
7473
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307474 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475}
7476
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307477/*
7478 * sme_set_roam_opportunistic_scan_threshold_diff() -
7479 * Update Opportunistic Scan threshold diff
7480 * This function is called through dynamic setConfig callback function
7481 * to configure nOpportunisticThresholdDiff
7482 *
7483 * hHal - HAL handle for device
7484 * sessionId - Session Identifier
7485 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7486 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7487 * successfully.
7488 * else SME is failed to update nOpportunisticThresholdDiff.
7489 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307490QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 uint8_t sessionId,
7492 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307493 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007494{
7495 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307496 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497
7498 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307499 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007500 status = csr_neighbor_roam_update_config(pMac, sessionId,
7501 nOpportunisticThresholdDiff,
7502 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307503 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007504 pMac->roam.configParam.neighborRoamConfig.
7505 nOpportunisticThresholdDiff =
7506 nOpportunisticThresholdDiff;
7507 }
7508 sme_release_global_lock(&pMac->sme);
7509 }
7510 return status;
7511}
7512
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307513/*
7514 * sme_get_roam_opportunistic_scan_threshold_diff()
7515 * gets Opportunistic Scan threshold diff
7516 * This is a synchronous call
7517 *
7518 * hHal - The handle returned by mac_open
7519 * Return uint8_t - nOpportunisticThresholdDiff
7520 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007521uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7522{
7523 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007525 return pMac->roam.configParam.neighborRoamConfig.
7526 nOpportunisticThresholdDiff;
7527}
7528
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307529/*
7530 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7531 * This function is called through dynamic setConfig callback function
7532 * to configure nRoamRescanRssiDiff
7533 *
7534 * hHal - HAL handle for device
7535 * sessionId - Session Identifier
7536 * nRoamRescanRssiDiff - roam rescan rssi diff
7537 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7538 * successfully.
7539 * else SME is failed to update nRoamRescanRssiDiff.
7540 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307541QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007542 uint8_t sessionId,
7543 const uint8_t nRoamRescanRssiDiff)
7544{
7545 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307546 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007547
7548 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307549 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007550 status = csr_neighbor_roam_update_config(pMac, sessionId,
7551 nRoamRescanRssiDiff,
7552 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307553 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007554 pMac->roam.configParam.neighborRoamConfig.
7555 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7556 }
7557 sme_release_global_lock(&pMac->sme);
7558 }
7559 return status;
7560}
7561
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307562/*
7563 * sme_get_roam_rescan_rssi_diff()
7564 * gets roam rescan rssi diff
7565 * This is a synchronous call
7566 *
7567 * hHal - The handle returned by mac_open
7568 * Return int8_t - nRoamRescanRssiDiff
7569 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007570uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7571{
7572 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7575}
7576
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307577/*
7578 * sme_set_roam_bmiss_first_bcnt() -
7579 * Update Roam count for first beacon miss
7580 * This function is called through dynamic setConfig callback function
7581 * to configure nRoamBmissFirstBcnt
7582 * hHal - HAL handle for device
7583 * sessionId - Session Identifier
7584 * nRoamBmissFirstBcnt - Roam first bmiss count
7585 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7586 * successfully.
7587 * else SME is failed to update nRoamBmissFirstBcnt
7588 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307589QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007590 uint8_t sessionId,
7591 const uint8_t nRoamBmissFirstBcnt)
7592{
7593 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307594 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007595
7596 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307597 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007598 status = csr_neighbor_roam_update_config(pMac, sessionId,
7599 nRoamBmissFirstBcnt,
7600 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307601 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007602 pMac->roam.configParam.neighborRoamConfig.
7603 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7604 }
7605 sme_release_global_lock(&pMac->sme);
7606 }
7607 return status;
7608}
7609
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307610/*
7611 * sme_get_roam_bmiss_first_bcnt() -
7612 * get neighbor roam beacon miss first count
7613 *
7614 * hHal - The handle returned by mac_open.
7615 * Return uint8_t - neighbor roam beacon miss first count
7616 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007617uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7618{
7619 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7622}
7623
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307624/*
7625 * sme_set_roam_bmiss_final_bcnt() -
7626 * Update Roam count for final beacon miss
7627 * This function is called through dynamic setConfig callback function
7628 * to configure nRoamBmissFinalBcnt
7629 * hHal - HAL handle for device
7630 * sessionId - Session Identifier
7631 * nRoamBmissFinalBcnt - Roam final bmiss count
7632 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7633 * successfully.
7634 * else SME is failed to update nRoamBmissFinalBcnt
7635 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307636QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007637 uint8_t sessionId,
7638 const uint8_t nRoamBmissFinalBcnt)
7639{
7640 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307641 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007642
7643 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307644 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007645 status = csr_neighbor_roam_update_config(pMac, sessionId,
7646 nRoamBmissFinalBcnt,
7647 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307648 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007649 pMac->roam.configParam.neighborRoamConfig.
7650 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7651 }
7652 sme_release_global_lock(&pMac->sme);
7653 }
7654 return status;
7655}
7656
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307657/*
7658 * sme_get_roam_bmiss_final_bcnt() -
7659 * gets Roam count for final beacon miss
7660 * This is a synchronous call
7661 *
7662 * hHal - The handle returned by mac_open
7663 * Return uint8_t - nRoamBmissFinalBcnt
7664 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007665uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7666{
7667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007669 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7670}
7671
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307672/*
7673 * sme_set_roam_beacon_rssi_weight() -
7674 * Update Roam beacon rssi weight
7675 * This function is called through dynamic setConfig callback function
7676 * to configure nRoamBeaconRssiWeight
7677 *
7678 * hHal - HAL handle for device
7679 * sessionId - Session Identifier
7680 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7681 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7682 * successfully.
7683 * else SME is failed to update nRoamBeaconRssiWeight
7684 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307685QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 uint8_t sessionId,
7687 const uint8_t nRoamBeaconRssiWeight)
7688{
7689 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307690 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007691
7692 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307693 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007694 status = csr_neighbor_roam_update_config(pMac, sessionId,
7695 nRoamBeaconRssiWeight,
7696 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307697 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698 pMac->roam.configParam.neighborRoamConfig.
7699 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7700 }
7701 sme_release_global_lock(&pMac->sme);
7702 }
7703 return status;
7704}
7705
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307706/*
7707 * sme_get_roam_beacon_rssi_weight() -
7708 * gets Roam beacon rssi weight
7709 * This is a synchronous call
7710 *
7711 * hHal - The handle returned by mac_open
7712 * Return uint8_t - nRoamBeaconRssiWeight
7713 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007714uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7715{
7716 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7719}
7720
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307721/*
7722 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7723 * rssi threshold
7724 * This is a synchronous call
7725 *
7726 * hHal - The handle returned by mac_open.
7727 * sessionId - Session Identifier
7728 * Return QDF_STATUS_SUCCESS - SME update config successful.
7729 * Other status means SME is failed to update
7730 */
7731QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7732 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7733{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007734 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307735 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007736
7737 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307738 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007739 status = csr_neighbor_roam_update_config(pMac,
7740 sessionId, neighborLookupRssiThreshold,
7741 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307742 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 pMac->roam.configParam.neighborRoamConfig.
7744 nNeighborLookupRssiThreshold =
7745 neighborLookupRssiThreshold;
7746 }
7747 sme_release_global_lock(&pMac->sme);
7748 }
7749 return status;
7750}
7751
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307752/*
7753 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7754 * This is a synchronous call
7755 *
7756 * hal - The handle returned by macOpen.
7757 * session_id - Session Identifier
7758 * delay_before_vdev_stop - value to be set
7759 * Return QDF_STATUS_SUCCESS - SME update config successful.
7760 * Other status means SME is failed to update
7761 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307762QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007763 uint8_t session_id,
7764 uint8_t delay_before_vdev_stop)
7765{
7766 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307767 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007768
7769 if (session_id >= CSR_ROAM_SESSION_MAX) {
7770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7771 FL("Invalid sme session id: %d"), session_id);
7772 return QDF_STATUS_E_INVAL;
7773 }
7774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307776 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307777 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7778 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007779 pMac->roam.configParam.neighborRoamConfig.
7780 delay_before_vdev_stop,
7781 delay_before_vdev_stop);
7782 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7783 delay_before_vdev_stop = delay_before_vdev_stop;
7784 pMac->roam.configParam.neighborRoamConfig.
7785 delay_before_vdev_stop = delay_before_vdev_stop;
7786 sme_release_global_lock(&pMac->sme);
7787 }
7788 return status;
7789}
7790
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307791/*
7792 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7793 * rssi threshold
7794 * This is a synchronous call
7795 *
7796 * hHal - The handle returned by mac_open.
7797 * Return QDF_STATUS_SUCCESS - SME update config successful.
7798 * Other status means SME is failed to update
7799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007800uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7801{
7802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804 return pMac->roam.configParam.neighborRoamConfig.
7805 nNeighborLookupRssiThreshold;
7806}
7807
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307808/*
7809 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7810 * refresh period
7811 * This is a synchronous call
7812 *
7813 * hHal - The handle returned by mac_open.
7814 * sessionId - Session Identifier
7815 * Return QDF_STATUS_SUCCESS - SME update config successful.
7816 * Other status means SME is failed to update
7817 */
7818QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7819 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7820{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007821 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307822 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307823 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007824 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7825
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007826 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7827 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7828 FL("Invalid sme session id: %d"), sessionId);
7829 return QDF_STATUS_E_INVAL;
7830 }
7831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007832 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307833 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 pNeighborRoamConfig =
7835 &pMac->roam.configParam.neighborRoamConfig;
7836 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307837 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007838 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7839 neighborScanResultsRefreshPeriod,
7840 pMac->roam.configParam.neighborRoamConfig.
7841 nNeighborResultsRefreshPeriod,
7842 mac_trace_get_neighbour_roam_state(pMac->roam.
7843 neighborRoamInfo
7844 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307845 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007846 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7847 neighborScanResultsRefreshPeriod;
7848 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7849 neighborScanResultsRefreshPeriod;
7850
7851 sme_release_global_lock(&pMac->sme);
7852 }
7853 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7854 csr_roam_offload_scan(pMac, sessionId,
7855 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307856 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 }
7858 return status;
7859}
7860
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307861/*
7862 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7863 * offload feaure
7864 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7865 * gRoamScanOffloadEnabled.
7866 * This is a synchronous call
7867 *
7868 * hHal - The handle returned by mac_open.
7869 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7870 * Other status means SME is failed to update.
7871 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307872QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007873 bool nRoamScanOffloadEnabled)
7874{
7875 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307876 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007877
7878 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307879 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307880 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307881 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007882 pMac->roam.configParam.isRoamOffloadScanEnabled,
7883 nRoamScanOffloadEnabled);
7884 pMac->roam.configParam.isRoamOffloadScanEnabled =
7885 nRoamScanOffloadEnabled;
7886 sme_release_global_lock(&pMac->sme);
7887 }
7888
7889 return status;
7890}
7891
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307892/*
7893 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7894 * refresh period
7895 * This is a synchronous call
7896 *
7897 * \param hHal - The handle returned by mac_open.
7898 * \return uint16_t - Neighbor scan results refresh period value
7899 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007900uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7901{
7902 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307903
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007904 return pMac->roam.configParam.neighborRoamConfig.
7905 nNeighborResultsRefreshPeriod;
7906}
7907
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307908/*
7909 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7910 * This is a synchronuous call
7911 *
7912 * hHal - The handle returned by mac_open.
7913 * Return QDF_STATUS_SUCCESS - SME update config successful.
7914 * Other status means SME is failed to update
7915 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7917{
7918 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920 return pMac->roam.configParam.neighborRoamConfig.
7921 nEmptyScanRefreshPeriod;
7922}
7923
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307924/*
7925 * sme_update_empty_scan_refresh_period
7926 * Update nEmptyScanRefreshPeriod
7927 * This function is called through dynamic setConfig callback function
7928 * to configure nEmptyScanRefreshPeriod
7929 * Usage: adb shell iwpriv wlan0 setConfig
7930 * nEmptyScanRefreshPeriod=[0 .. 60]
7931 *
7932 * hHal - HAL handle for device
7933 * sessionId - Session Identifier
7934 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7935 * Return Success or failure
7936 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007937
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307938QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7939 sessionId, uint16_t
7940 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007941{
7942 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307943 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307944 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007945 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7946
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007947 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7948 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7949 FL("Invalid sme session id: %d"), sessionId);
7950 return QDF_STATUS_E_INVAL;
7951 }
7952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307954 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007955 pNeighborRoamConfig =
7956 &pMac->roam.configParam.neighborRoamConfig;
7957 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007959 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7960 nEmptyScanRefreshPeriod,
7961 pMac->roam.configParam.neighborRoamConfig.
7962 nEmptyScanRefreshPeriod,
7963 mac_trace_get_neighbour_roam_state(pMac->roam.
7964 neighborRoamInfo
7965 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307966 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7968 nEmptyScanRefreshPeriod;
7969 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7970 nEmptyScanRefreshPeriod;
7971 sme_release_global_lock(&pMac->sme);
7972 }
7973 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7974 csr_roam_offload_scan(pMac, sessionId,
7975 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7976 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7977 }
7978 return status;
7979}
7980
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307981/*
7982 * sme_set_neighbor_scan_min_chan_time() -
7983 * Update nNeighborScanMinChanTime
7984 * This function is called through dynamic setConfig callback function
7985 * to configure gNeighborScanChannelMinTime
7986 * Usage: adb shell iwpriv wlan0 setConfig
7987 * gNeighborScanChannelMinTime=[0 .. 60]
7988 *
7989 * hHal - HAL handle for device
7990 * nNeighborScanMinChanTime - Channel minimum dwell time
7991 * sessionId - Session Identifier
7992 * Return Success or failure
7993 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307994QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007995 const uint16_t
7996 nNeighborScanMinChanTime,
7997 uint8_t sessionId)
7998{
7999 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308000 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008001
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008002 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8003 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8004 FL("Invalid sme session id: %d"), sessionId);
8005 return QDF_STATUS_E_INVAL;
8006 }
8007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008008 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308009 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008011 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
8012 nNeighborScanMinChanTime,
8013 pMac->roam.configParam.neighborRoamConfig.
8014 nNeighborScanMinChanTime,
8015 mac_trace_get_neighbour_roam_state(pMac->roam.
8016 neighborRoamInfo
8017 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308018 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019
8020 pMac->roam.configParam.neighborRoamConfig.
8021 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
8022 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8023 minChannelScanTime = nNeighborScanMinChanTime;
8024 sme_release_global_lock(&pMac->sme);
8025 }
8026
8027 return status;
8028}
8029
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308030/*
8031 * sme_set_neighbor_scan_max_chan_time() -
8032 * Update nNeighborScanMaxChanTime
8033 * This function is called through dynamic setConfig callback function
8034 * to configure gNeighborScanChannelMaxTime
8035 * Usage: adb shell iwpriv wlan0 setConfig
8036 * gNeighborScanChannelMaxTime=[0 .. 60]
8037 *
8038 * hHal - HAL handle for device
8039 * sessionId - Session Identifier
8040 * nNeighborScanMinChanTime - Channel maximum dwell time
8041 * Return Success or failure
8042 */
8043QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
8044 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045 const uint16_t
8046 nNeighborScanMaxChanTime)
8047{
8048 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308049 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308050 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008051 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8052
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008053 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8054 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8055 FL("Invalid sme session id: %d"), sessionId);
8056 return QDF_STATUS_E_INVAL;
8057 }
8058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008059 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308060 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008061 pNeighborRoamConfig =
8062 &pMac->roam.configParam.neighborRoamConfig;
8063 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008065 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8066 nNeighborScanMaxChanTime,
8067 pMac->roam.configParam.neighborRoamConfig.
8068 nNeighborScanMaxChanTime,
8069 mac_trace_get_neighbour_roam_state(pMac->roam.
8070 neighborRoamInfo
8071 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308072 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8074 nNeighborScanMaxChanTime;
8075 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8076 nNeighborScanMaxChanTime;
8077 sme_release_global_lock(&pMac->sme);
8078 }
8079 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8080 csr_roam_offload_scan(pMac, sessionId,
8081 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8082 REASON_SCAN_CH_TIME_CHANGED);
8083 }
8084
8085 return status;
8086}
8087
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308088/*
8089 * sme_get_neighbor_scan_min_chan_time() -
8090 * get neighbor scan min channel time
8091 *
8092 * hHal - The handle returned by mac_open.
8093 * sessionId - Session Identifier
8094 * Return uint16_t - channel min time value
8095 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8097{
8098 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008099
8100 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8101 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8102 FL("Invalid sme session id: %d"), sessionId);
8103 return 0;
8104 }
8105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8107 minChannelScanTime;
8108}
8109
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308110/*
8111 * sme_get_neighbor_roam_state() -
8112 * get neighbor roam state
8113 *
8114 * hHal - The handle returned by mac_open.
8115 * sessionId - Session Identifier
8116 * Return uint32_t - neighbor roam state
8117 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008118uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8119{
8120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008121
8122 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8124 FL("Invalid sme session id: %d"), sessionId);
8125 return 0;
8126 }
8127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008128 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8129}
8130
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308131/*
8132 * sme_get_current_roam_state() -
8133 * get current roam state
8134 *
8135 * hHal - The handle returned by mac_open.
8136 * sessionId - Session Identifier
8137 * Return uint32_t - current roam state
8138 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8140{
8141 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008143 return pMac->roam.curState[sessionId];
8144}
8145
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308146/*
8147 * sme_get_current_roam_sub_state() -
8148 * \brief get neighbor roam sub state
8149 *
8150 * hHal - The handle returned by mac_open.
8151 * sessionId - Session Identifier
8152 * Return uint32_t - current roam sub state
8153 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8155{
8156 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008158 return pMac->roam.curSubState[sessionId];
8159}
8160
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308161/*
8162 * sme_get_lim_sme_state() -
8163 * get Lim Sme state
8164 *
8165 * hHal - The handle returned by mac_open.
8166 * Return uint32_t - Lim Sme state
8167 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8169{
8170 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 return pMac->lim.gLimSmeState;
8173}
8174
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308175/*
8176 * sme_get_lim_mlm_state() -
8177 * get Lim Mlm state
8178 *
8179 * hHal - The handle returned by mac_open.
8180 * Return uint32_t - Lim Mlm state
8181 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8183{
8184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308185
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008186 return pMac->lim.gLimMlmState;
8187}
8188
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308189/*
8190 * sme_is_lim_session_valid() -
8191 * is Lim session valid
8192 *
8193 * hHal - The handle returned by mac_open.
8194 * sessionId - Session Identifier
8195 * Return bool - true or false
8196 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8198{
8199 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308200
8201 if (sessionId > pMac->lim.maxBssId)
8202 return false;
8203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008204 return pMac->lim.gpSession[sessionId].valid;
8205}
8206
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308207/*
8208 * sme_get_lim_sme_session_state() -
8209 * get Lim Sme session state
8210 *
8211 * hHal - The handle returned by mac_open.
8212 * sessionId - Session Identifier
8213 * Return uint32_t - Lim Sme session state
8214 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008215uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8216{
8217 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008219 return pMac->lim.gpSession[sessionId].limSmeState;
8220}
8221
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308222/*
8223 * sme_get_lim_mlm_session_state() -
8224 * \brief get Lim Mlm session state
8225 *
8226 * hHal - The handle returned by mac_open.
8227 * sessionId - Session Identifier
8228 * Return uint32_t - Lim Mlm session state
8229 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008230uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8231{
8232 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008234 return pMac->lim.gpSession[sessionId].limMlmState;
8235}
8236
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308237/*
8238 * sme_get_neighbor_scan_max_chan_time() -
8239 * get neighbor scan max channel time
8240 *
8241 * hHal - The handle returned by mac_open.
8242 * sessionId - Session Identifier
8243 * Return uint16_t - channel max time value
8244 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008245uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8246{
8247 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008248
8249 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8250 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8251 FL("Invalid sme session id: %d"), sessionId);
8252 return 0;
8253 }
8254
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008255 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8256 maxChannelScanTime;
8257}
8258
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308259/*
8260 * sme_set_neighbor_scan_period() -
8261 * Update nNeighborScanPeriod
8262 * This function is called through dynamic setConfig callback function
8263 * to configure nNeighborScanPeriod
8264 * Usage: adb shell iwpriv wlan0 setConfig
8265 * nNeighborScanPeriod=[0 .. 1000]
8266 *
8267 * hHal - HAL handle for device
8268 * sessionId - Session Identifier
8269 * nNeighborScanPeriod - neighbor scan period
8270 * Return Success or failure
8271 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308272QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008273 const uint16_t nNeighborScanPeriod)
8274{
8275 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308276 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308277 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008278 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8279
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008280 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8281 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8282 FL("Invalid sme session id: %d"), sessionId);
8283 return QDF_STATUS_E_INVAL;
8284 }
8285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008286 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308287 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008288 pNeighborRoamConfig =
8289 &pMac->roam.configParam.neighborRoamConfig;
8290 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308292 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008293 nNeighborScanPeriod,
8294 pMac->roam.configParam.neighborRoamConfig.
8295 nNeighborScanTimerPeriod,
8296 mac_trace_get_neighbour_roam_state(pMac->roam.
8297 neighborRoamInfo
8298 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308299 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008300 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8301 nNeighborScanPeriod;
8302 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8303 nNeighborScanPeriod;
8304 sme_release_global_lock(&pMac->sme);
8305 }
8306 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8307 csr_roam_offload_scan(pMac, sessionId,
8308 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8309 REASON_SCAN_HOME_TIME_CHANGED);
8310 }
8311
8312 return status;
8313}
8314
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308315/*
8316 * sme_get_neighbor_scan_period() -
8317 * get neighbor scan period
8318 *
8319 * hHal - The handle returned by mac_open.
8320 * sessionId - Session Identifier
8321 * Return uint16_t - neighbor scan period
8322 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008323uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8324{
8325 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008326
8327 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8328 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8329 FL("Invalid sme session id: %d"), sessionId);
8330 return 0;
8331 }
8332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008333 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8334 neighborScanPeriod;
8335}
8336
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308337/**
8338 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8339 * This function is called through dynamic setConfig callback function
8340 * to configure neighbor_scan_min_period
8341 *
8342 * @hal - HAL handle for device
8343 * @session_id - Session Identifier
8344 * @neighbor_scan_min_period - neighbor scan min period
8345 *
8346 * Return - QDF_STATUS
8347 */
8348QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8349 uint8_t session_id,
8350 const uint16_t
8351 neighbor_scan_min_period)
8352{
8353 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8354 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308355 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308356 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008357
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308358 if (session_id >= CSR_ROAM_SESSION_MAX) {
8359 sme_err("Invalid sme session id: %d", session_id);
8360 return QDF_STATUS_E_INVAL;
8361 }
8362
8363 status = sme_acquire_global_lock(&pmac->sme);
8364 if (QDF_IS_STATUS_SUCCESS(status)) {
8365 p_neighbor_roam_config =
8366 &pmac->roam.configParam.neighborRoamConfig;
8367 p_neighbor_roam_info = &pmac->
8368 roam.neighborRoamInfo[session_id];
8369 sme_debug("LFR:set neighbor scan min period, old:%d, "
8370 "new: %d, state: %s",
8371 pmac->roam.configParam.neighborRoamConfig.
8372 neighbor_scan_min_timer_period,
8373 neighbor_scan_min_period,
8374 mac_trace_get_neighbour_roam_state(pmac->roam.
8375 neighborRoamInfo[session_id].
8376 neighborRoamState));
8377 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8378 neighbor_scan_min_period;
8379 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8380 neighbor_scan_min_period;
8381 sme_release_global_lock(&pmac->sme);
8382 }
8383
8384 return status;
8385}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008386
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308387/*
8388 * sme_get_roam_rssi_diff() - get Roam rssi diff
8389 * This is a synchronous call
8390 *
8391 * hHal - The handle returned by mac_open.
8392 * Return uint16_t - Rssi diff value
8393 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008394uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8395{
8396 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008398 return pMac->roam.configParam.RoamRssiDiff;
8399}
8400
8401/**
8402 * sme_change_roam_scan_channel_list() - to change scan channel list
8403 * @hHal: pointer HAL handle returned by mac_open
8404 * @sessionId: sme session id
8405 * @pChannelList: Output channel list
8406 * @numChannels: Output number of channels
8407 *
8408 * This routine is called to Change roam scan channel list.
8409 * This is a synchronous call
8410 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308411 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308413QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008414 uint8_t *pChannelList,
8415 uint8_t numChannels)
8416{
8417 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308418 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008419 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008420 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8421 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8422 uint8_t i = 0, j = 0;
8423 tCsrChannelInfo *chan_info;
8424
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008425 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8427 FL("Invalid sme session id: %d"), sessionId);
8428 return QDF_STATUS_E_INVAL;
8429 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008431 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008432 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308433 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008434 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8435 csr_roam_offload_scan(pMac, sessionId,
8436 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8437 REASON_CHANNEL_LIST_CHANGED);
8438 return status;
8439 }
8440 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8441
8442 if (NULL != chan_info->ChannelList) {
8443 for (i = 0; i < chan_info->numOfChannels; i++) {
8444 if (j < sizeof(oldChannelList))
8445 j += snprintf(oldChannelList + j,
8446 sizeof(oldChannelList) -
8447 j, "%d",
8448 chan_info->ChannelList[i]);
8449 else
8450 break;
8451 }
8452 }
8453 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8454 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8455 numChannels);
8456 sme_set_roam_scan_control(hHal, sessionId, 1);
8457 if (NULL != chan_info->ChannelList) {
8458 j = 0;
8459 for (i = 0; i < chan_info->numOfChannels; i++) {
8460 if (j < sizeof(newChannelList))
8461 j += snprintf(newChannelList + j,
8462 sizeof(newChannelList) -
8463 j, " %d",
8464 chan_info->ChannelList[i]);
8465 else
8466 break;
8467 }
8468 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308469 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308470 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008471 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308472 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008473 sme_release_global_lock(&pMac->sme);
8474
8475 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8476 csr_roam_offload_scan(pMac, sessionId,
8477 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8478 REASON_CHANNEL_LIST_CHANGED);
8479 return status;
8480}
8481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482/**
8483 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8484 * @hHal: HAL pointer
8485 * @pChannelList: Output channel list
8486 * @pNumChannels: Output number of channels
8487 * @sessionId: Session Identifier
8488 *
8489 * To get roam scan channel list This is a synchronous call
8490 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308491 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008492 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308493QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494 uint8_t *pChannelList, uint8_t *pNumChannels,
8495 uint8_t sessionId)
8496{
8497 int i = 0;
8498 uint8_t *pOutPtr = pChannelList;
8499 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008500 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308501 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008502
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008503 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8504 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8505 FL("Invalid sme session id: %d"), sessionId);
8506 return QDF_STATUS_E_INVAL;
8507 }
8508
8509 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308511 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512 return status;
8513 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308514 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 FL("Roam Scan channel list is NOT yet initialized"));
8516 *pNumChannels = 0;
8517 sme_release_global_lock(&pMac->sme);
8518 return status;
8519 }
8520
8521 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308522 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523 pOutPtr[i] =
8524 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008526 pOutPtr[i] = '\0';
8527 sme_release_global_lock(&pMac->sme);
8528 return status;
8529}
8530
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308531/*
8532 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8533 * This is a synchronuous call
8534 *
8535 * hHal - The handle returned by mac_open.
8536 * Return true (1) - if the ESE feature is enabled
8537 * false (0) - if feature is disabled (compile or runtime)
8538 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8540{
8541#ifdef FEATURE_WLAN_ESE
8542 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008544 return csr_roam_is_ese_ini_feature_enabled(pMac);
8545#else
8546 return false;
8547#endif
8548}
8549
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308550/*
8551 * sme_get_wes_mode() - get WES Mode
8552 * This is a synchronous call
8553 *
8554 * hHal - The handle returned by mac_open
8555 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008557bool sme_get_wes_mode(tHalHandle hHal)
8558{
8559 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308560
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008561 return pMac->roam.configParam.isWESModeEnabled;
8562}
8563
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308564/*
8565 * sme_get_roam_scan_control() - get scan control
8566 * This is a synchronous call
8567 *
8568 * hHal - The handle returned by mac_open.
8569 * Return bool - Enabled(1)/Disabled(0)
8570 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008571bool sme_get_roam_scan_control(tHalHandle hHal)
8572{
8573 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008575 return pMac->roam.configParam.nRoamScanControl;
8576}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008577
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308578/*
8579 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8580 * This is a synchronuous call
8581 * hHal - The handle returned by mac_open.
8582 * Return true (1) - if the feature is enabled
8583 * false (0) - if feature is disabled (compile or runtime)
8584 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8586{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008589 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008590}
8591
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308592/*
8593 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8594 * This is a synchronuous call
8595 *
8596 * hHal - The handle returned by mac_open.
8597 * Return true (1) - if the feature is enabled
8598 * false (0) - if feature is disabled (compile or runtime)
8599 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008600bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8601{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308603
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008604 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605}
8606
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008607/**
8608 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8609 * @feature: enum value of requested feature.
8610 *
8611 * Retrun: 1 if supported; 0 otherwise
8612 */
8613bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008614{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008615 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616}
8617
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308618QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008619 void *plsContext,
8620 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8621 void *pContext))
8622{
8623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308624 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008625 tpAniSirGlobal pMac;
8626 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308627 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008628
Jeff Johnsona5317a62017-01-26 08:51:25 -08008629 if (!hHal || !pCallbackfn || !lsReq) {
8630 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8631 FL("Invalid parameter"));
8632 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008633 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008634
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308635 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8636 if (!wma_handle) {
8637 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8638 "wma handle is NULL");
8639 return QDF_STATUS_E_FAILURE;
8640 }
8641
Jeff Johnsona5317a62017-01-26 08:51:25 -08008642 pMac = PMAC_STRUCT(hHal);
8643 req = qdf_mem_malloc(sizeof(*req));
8644 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008645 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008646 return QDF_STATUS_E_NOMEM;
8647 }
8648 *req = *lsReq;
8649
8650 status = sme_acquire_global_lock(&pMac->sme);
8651 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008652 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008653 qdf_mem_free(req);
8654 return QDF_STATUS_E_FAILURE;
8655 }
8656
8657 pMac->sme.pLinkSpeedCbContext = plsContext;
8658 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308659 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008660 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008662 return status;
8663}
8664
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308665QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8666 struct sir_peer_info_req req)
8667{
8668 QDF_STATUS qdf_status;
8669 struct scheduler_msg message = {0};
8670
8671 qdf_status = sme_acquire_global_lock(&mac->sme);
8672 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8673 sme_debug("Failed to get Lock");
8674 return qdf_status;
8675 }
8676 /* serialize the req through MC thread */
8677 message.bodyptr = qdf_mem_malloc(sizeof(req));
8678 if (NULL == message.bodyptr) {
8679 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8680 "%s: Memory allocation failed.", __func__);
8681 sme_release_global_lock(&mac->sme);
8682 return QDF_STATUS_E_NOMEM;
8683 }
8684 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8685 message.type = WMA_GET_PEER_INFO;
8686 message.reserved = 0;
8687 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8688 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8689 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8690 "%s: Post get peer info msg fail", __func__);
8691 qdf_mem_free(message.bodyptr);
8692 qdf_status = QDF_STATUS_E_FAILURE;
8693 }
8694 sme_release_global_lock(&mac->sme);
8695 return qdf_status;
8696}
8697
Will Huang558f8082017-05-31 16:22:24 +08008698QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8699 void *context,
8700 void (*callbackfn)(struct sir_peer_info_resp *param,
8701 void *pcontext))
8702{
8703
8704 QDF_STATUS status;
8705 QDF_STATUS qdf_status;
8706 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008707 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008708
8709 status = sme_acquire_global_lock(&mac->sme);
8710 if (QDF_STATUS_SUCCESS == status) {
8711 if (NULL == callbackfn) {
8712 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8713 "%s: Indication Call back is NULL",
8714 __func__);
8715 sme_release_global_lock(&mac->sme);
8716 return QDF_STATUS_E_FAILURE;
8717 }
8718
8719 mac->sme.pget_peer_info_ind_cb = callbackfn;
8720 mac->sme.pget_peer_info_cb_context = context;
8721
8722 /* serialize the req through MC thread */
8723 message.bodyptr = qdf_mem_malloc(sizeof(req));
8724 if (NULL == message.bodyptr) {
8725 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8726 "%s: Memory allocation failed.", __func__);
8727 sme_release_global_lock(&mac->sme);
8728 return QDF_STATUS_E_NOMEM;
8729 }
8730 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8731 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308732 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008733 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8734 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8735 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8736 "%s: Post get peer info msg fail", __func__);
8737 qdf_mem_free(message.bodyptr);
8738 status = QDF_STATUS_E_FAILURE;
8739 }
8740 sme_release_global_lock(&mac->sme);
8741 }
8742 return status;
8743}
8744
8745QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8746 struct sir_peer_info_ext_req *req,
8747 void *context,
8748 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8749 void *pcontext))
8750{
8751 QDF_STATUS status;
8752 QDF_STATUS qdf_status;
8753 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008754 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008755
8756 status = sme_acquire_global_lock(&mac->sme);
8757 if (QDF_STATUS_SUCCESS == status) {
8758 if (NULL == callbackfn) {
8759 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8760 "%s: Indication Call back is NULL",
8761 __func__);
8762 sme_release_global_lock(&mac->sme);
8763 return QDF_STATUS_E_FAILURE;
8764 }
8765
8766 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8767 mac->sme.pget_peer_info_ext_cb_context = context;
8768
8769 /* serialize the req through MC thread */
8770 message.bodyptr =
8771 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8772 if (NULL == message.bodyptr) {
8773 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8774 "%s: Memory allocation failed.", __func__);
8775 sme_release_global_lock(&mac->sme);
8776 return QDF_STATUS_E_NOMEM;
8777 }
8778 qdf_mem_copy(message.bodyptr,
8779 req,
8780 sizeof(struct sir_peer_info_ext_req));
8781 message.type = WMA_GET_PEER_INFO_EXT;
8782 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8783 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8784 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8785 "%s: Post get rssi msg fail", __func__);
8786 qdf_mem_free(message.bodyptr);
8787 status = QDF_STATUS_E_FAILURE;
8788 }
8789 sme_release_global_lock(&mac->sme);
8790 }
8791 return status;
8792}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008793
8794/*
8795 * SME API to enable/disable WLAN driver initiated SSR
8796 */
8797void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8798{
8799 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308800 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008801
8802 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308803 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008804 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008805 /* not serializing this messsage, as this is only going
8806 * to set a variable in WMA/WDI
8807 */
8808 WMA_SetEnableSSR(enableSSR);
8809 sme_release_global_lock(&pMac->sme);
8810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008811}
8812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008813/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8814ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8815{
8816 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8817}
8818
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308819/*
8820 * sme_set_curr_device_mode() - Sets the current operating device mode.
8821 *
8822 * hHal - The handle returned by mac_open.
8823 * currDeviceMode - Current operating device mode.
8824 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008825void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008826 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827{
8828 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008831}
8832
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308833/*
8834 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8835 * This is a synchronous call
8836 *
8837 * hHal - The handle returned by mac_open
8838 * sessionId - Session Identifier
8839 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8840 * BSSID, channel etc.)
8841 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8842 * Other status means SME is failed to send the request.
8843 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008844
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308845QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008846 uint8_t sessionId,
8847 tCsrHandoffRequest *pHandoffInfo)
8848{
8849 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308850 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851
8852 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308853 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308854 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008855 "%s: invoked", __func__);
8856 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8857 sme_release_global_lock(&pMac->sme);
8858 }
8859
8860 return status;
8861}
8862
8863#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308864/*
8865 * sme_ipa_offload_enable_disable() -
8866 * API to enable/disable IPA offload
8867 *
8868 * hal - The handle returned by macOpen.
8869 * session_id - Session Identifier
8870 * request - Pointer to the offload request.
8871 * Return QDF_STATUS
8872 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308873QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 struct sir_ipa_offload_enable_disable *request)
8875{
8876 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308877 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008879 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880
8881 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308882 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308883 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308885 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308886 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308888 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008889 }
8890
8891 request_buf->offload_type = request->offload_type;
8892 request_buf->vdev_id = request->vdev_id;
8893 request_buf->enable = request->enable;
8894
8895 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8896 msg.reserved = 0;
8897 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308898 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008899 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308901 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308902 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008903 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308904 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008905 }
8906
8907 sme_release_global_lock(&pMac->sme);
8908 }
8909
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308910 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008911}
8912#endif /* IPA_OFFLOAD */
8913
8914/*
8915 * SME API to check if there is any infra station or
8916 * P2P client is connected
8917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308918QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008919{
8920 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308921
8922 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308923 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308924
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308925 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926}
8927
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928/**
8929 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8930 * @hal: global hal handle
8931 * @addPeriodicTxPtrnParams: request message
8932 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308933 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008934 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308935QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936sme_add_periodic_tx_ptrn(tHalHandle hal,
8937 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8938{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308939 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8941 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008942 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008944 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008945
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308946 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008947 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008948 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308949 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950 }
8951
8952 *req_msg = *addPeriodicTxPtrnParams;
8953
8954 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308955 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008956 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008957 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308958 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008959 return status;
8960 }
8961
8962 /* Serialize the req through MC thread */
8963 msg.bodyptr = req_msg;
8964 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308965 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8966 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008967 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308968 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008969 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008970 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308971 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008972 }
8973 sme_release_global_lock(&mac->sme);
8974 return status;
8975}
8976
8977/**
8978 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8979 * @hal: global hal handle
8980 * @delPeriodicTxPtrnParams: request message
8981 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308982 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008983 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308984QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008985sme_del_periodic_tx_ptrn(tHalHandle hal,
8986 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8987{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308988 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008989 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8990 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008991 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008992
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008993 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008994
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308995 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008997 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308998 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008999 }
9000
9001 *req_msg = *delPeriodicTxPtrnParams;
9002
9003 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309004 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009005 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009006 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309007 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 return status;
9009 }
9010
9011 /* Serialize the req through MC thread */
9012 msg.bodyptr = req_msg;
9013 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309014 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9015 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009016 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309017 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009018 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009019 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309020 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 }
9022 sme_release_global_lock(&mac->sme);
9023 return status;
9024}
9025
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309026/*
9027 * sme_enable_rmc() - enables RMC
9028 * @hHal : Pointer to global HAL handle
9029 * @sessionId : Session ID
9030 *
9031 * Return: QDF_STATUS
9032 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009033QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
9034{
9035 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9036 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009037 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009038 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9039
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009040 SME_ENTER();
9041
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009042 status = sme_acquire_global_lock(&pMac->sme);
9043 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009044 message.bodyptr = NULL;
9045 message.type = WMA_RMC_ENABLE_IND;
9046 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9047 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009048 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9050 "%s: failed to post message to WMA",
9051 __func__);
9052 status = QDF_STATUS_E_FAILURE;
9053 }
9054 sme_release_global_lock(&pMac->sme);
9055 }
9056 return status;
9057}
9058
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309059/*
9060 * sme_disable_rmc() - disables RMC
9061 * @hHal : Pointer to global HAL handle
9062 * @sessionId : Session ID
9063 *
9064 * Return: QDF_STATUS
9065 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009066QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9067{
9068 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9069 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009070 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009071 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9072
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009073 SME_ENTER();
9074
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009075 status = sme_acquire_global_lock(&pMac->sme);
9076 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009077 message.bodyptr = NULL;
9078 message.type = WMA_RMC_DISABLE_IND;
9079 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9080 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009081 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9083 "%s: failed to post message to WMA",
9084 __func__);
9085 status = QDF_STATUS_E_FAILURE;
9086 }
9087 sme_release_global_lock(&pMac->sme);
9088 }
9089 return status;
9090}
9091
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309092/*
9093 * sme_send_rmc_action_period() - sends RMC action period param to target
9094 * @hHal : Pointer to global HAL handle
9095 * @sessionId : Session ID
9096 *
9097 * Return: QDF_STATUS
9098 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009099QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9100{
9101 QDF_STATUS status = QDF_STATUS_SUCCESS;
9102 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9103 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009104 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009105
9106 status = sme_acquire_global_lock(&pMac->sme);
9107 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009108 message.bodyptr = NULL;
9109 message.type = WMA_RMC_ACTION_PERIOD_IND;
9110 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9111 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009112 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9113 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9114 "%s: failed to post message to WMA",
9115 __func__);
9116 status = QDF_STATUS_E_FAILURE;
9117 }
9118 sme_release_global_lock(&pMac->sme);
9119 }
9120
9121 return status;
9122}
9123
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309124/*
9125 * sme_request_ibss_peer_info() - request ibss peer info
9126 * @hHal : Pointer to global HAL handle
9127 * @pUserData : Pointer to user data
9128 * @peerInfoCbk : Peer info callback
9129 * @allPeerInfoReqd : All peer info required or not
9130 * @staIdx : sta index
9131 *
9132 * Return: QDF_STATUS
9133 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009134QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9135 pIbssPeerInfoCb peerInfoCbk,
9136 bool allPeerInfoReqd, uint8_t staIdx)
9137{
9138 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9139 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9140 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009141 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009142 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9143
9144 status = sme_acquire_global_lock(&pMac->sme);
9145 if (QDF_STATUS_SUCCESS == status) {
9146 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9147 pMac->sme.peerInfoParams.pUserData = pUserData;
9148
9149 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309150 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009151 if (NULL == pIbssInfoReqParams) {
9152 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9153 "%s: Not able to allocate memory for dhcp start",
9154 __func__);
9155 sme_release_global_lock(&pMac->sme);
9156 return QDF_STATUS_E_NOMEM;
9157 }
9158 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9159 pIbssInfoReqParams->staIdx = staIdx;
9160
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009161 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9162 message.bodyptr = pIbssInfoReqParams;
9163 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009164
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009165 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9166 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009167 if (QDF_STATUS_SUCCESS != qdf_status) {
9168 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9169 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9170 __func__);
9171 qdf_mem_free(pIbssInfoReqParams);
9172 qdf_status = QDF_STATUS_E_FAILURE;
9173 }
9174 sme_release_global_lock(&pMac->sme);
9175 }
9176
9177 return qdf_status;
9178}
9179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309180/*
9181 * sme_send_cesium_enable_ind() -
9182 * Used to send proprietary cesium enable indication to fw
9183 *
9184 * hHal
9185 * sessionId
9186 * Return QDF_STATUS
9187 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009188QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9189{
9190 QDF_STATUS status = QDF_STATUS_SUCCESS;
9191 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9192 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009193 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009194
9195 status = sme_acquire_global_lock(&pMac->sme);
9196 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009197 message.bodyptr = NULL;
9198 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9199 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9200 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009201 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9203 "%s: failed to post message to WMA",
9204 __func__);
9205 status = QDF_STATUS_E_FAILURE;
9206 }
9207 sme_release_global_lock(&pMac->sme);
9208 }
9209
9210 return status;
9211}
9212
Paul Zhang99fe8842017-12-08 14:43:46 +08009213QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
9214 uint16_t latency_level)
9215{
9216 QDF_STATUS status;
9217 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9218 struct wlm_latency_level_param params;
9219 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
9220
9221 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
9222 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9223 "%s: WLM latency level setting is disabled",
9224 __func__);
9225 return QDF_STATUS_E_FAILURE;
9226 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08009227 if (!wma) {
9228 sme_err("wma is NULL");
9229 return QDF_STATUS_E_FAILURE;
9230 }
Paul Zhang99fe8842017-12-08 14:43:46 +08009231
9232 params.wlm_latency_level = latency_level;
9233 params.wlm_latency_flags =
9234 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
9235 params.vdev_id = session_id;
9236
9237 status = wma_set_wlm_latency_level(wma, &params);
9238 if (!QDF_IS_STATUS_SUCCESS(status))
9239 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9240 "%s: failed to set latency level",
9241 __func__);
9242
9243 return status;
9244}
9245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009246void sme_get_command_q_status(tHalHandle hHal)
9247{
9248 tSmeCmd *pTempCmd = NULL;
9249 tListElem *pEntry;
9250 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9251
9252 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309253 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009254 "%s: pMac is NULL", __func__);
9255 return;
9256 }
9257
Krunal Sonia8270f52017-02-23 19:51:25 -08009258 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309259 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309261
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009262 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009263 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9264 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309265 if (eSmeCsrCommandMask & pTempCmd->command)
9266 /* CSR command is stuck. See what the reason code is
9267 * for that command
9268 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 } /* if(pTempCmd) */
9271
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009272 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009273 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009276/**
9277 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9278 * @hal: The handle returned by macOpen
9279 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9280 */
9281void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9282 bool sta_prefer_80MHz_over_160MHz)
9283{
9284 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309285
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009286 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9287}
9288
Agrawal Ashishb141b092016-09-02 19:59:26 +05309289#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290/**
9291 * sme_set_dot11p_config() - API to set the 802.11p config
9292 * @hHal: The handle returned by macOpen
9293 * @enable_dot11p: 802.11p config param
9294 */
9295void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9296{
9297 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 pMac->enable_dot11p = enable_dot11p;
9300}
9301
9302/**
9303 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9304 * @src: the source configuration
9305 *
9306 * Return: pointer to the copied OCB configuration
9307 */
9308static struct sir_ocb_config *sme_copy_sir_ocb_config(
9309 struct sir_ocb_config *src)
9310{
9311 struct sir_ocb_config *dst;
9312 uint32_t length;
9313 void *cursor;
9314
9315 length = sizeof(*src) +
9316 src->channel_count * sizeof(*src->channels) +
9317 src->schedule_size * sizeof(*src->schedule) +
9318 src->dcc_ndl_chan_list_len +
9319 src->dcc_ndl_active_state_list_len;
9320
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309321 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 if (!dst)
9323 return NULL;
9324
9325 *dst = *src;
9326
9327 cursor = dst;
9328 cursor += sizeof(*dst);
9329 dst->channels = cursor;
9330 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309331 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 src->channel_count * sizeof(*src->channels));
9333 dst->schedule = cursor;
9334 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309335 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 src->schedule_size * sizeof(*src->schedule));
9337 dst->dcc_ndl_chan_list = cursor;
9338 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309339 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 src->dcc_ndl_chan_list_len);
9341 dst->dcc_ndl_active_state_list = cursor;
9342 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309343 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009344 src->dcc_ndl_active_state_list,
9345 src->dcc_ndl_active_state_list_len);
9346 return dst;
9347}
9348
9349/**
9350 * sme_ocb_set_config() - Set the OCB configuration
9351 * @hHal: reference to the HAL
9352 * @context: the context of the call
9353 * @callback: the callback to hdd
9354 * @config: the OCB configuration
9355 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309356 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309358QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 ocb_callback callback,
9360 struct sir_ocb_config *config)
9361{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309362 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009364 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 struct sir_ocb_config *msg_body;
9366
9367 /* Lock the SME structure */
9368 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309369 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 return status;
9371
9372 /*
9373 * Check if there is a pending request and return an error if one
9374 * exists
9375 */
9376 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309377 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378 goto end;
9379 }
9380
9381 msg_body = sme_copy_sir_ocb_config(config);
9382
9383 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309384 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 goto end;
9386 }
9387
9388 msg.type = WMA_OCB_SET_CONFIG_CMD;
9389 msg.bodyptr = msg_body;
9390
9391 /* Set the request callback and context */
9392 pMac->sme.ocb_set_config_callback = callback;
9393 pMac->sme.ocb_set_config_context = context;
9394
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009395 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309396 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309397 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009398 FL("Error posting message to WDA: %d"), status);
9399 pMac->sme.ocb_set_config_callback = callback;
9400 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309401 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 goto end;
9403 }
9404
9405end:
9406 sme_release_global_lock(&pMac->sme);
9407
9408 return status;
9409}
9410
9411/**
9412 * sme_ocb_set_utc_time() - Set the OCB UTC time
9413 * @hHal: reference to the HAL
9414 * @utc: the UTC time struct
9415 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309416 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009417 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309418QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309420 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009421 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009422 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009423 struct sir_ocb_utc *sme_utc;
9424
9425 /* Lock the SME structure */
9426 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309427 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009428 return status;
9429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309430 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009431 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309432 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009433 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309434 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009435 goto end;
9436 }
9437 *sme_utc = *utc;
9438
9439 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9440 msg.reserved = 0;
9441 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009442 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309443 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309444 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009445 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309446 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 goto end;
9448 }
9449
9450end:
9451 sme_release_global_lock(&pMac->sme);
9452
9453 return status;
9454}
9455
9456/**
9457 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9458 * @hHal: reference to the HAL
9459 * @timing_advert: the timing advertisement struct
9460 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309461 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009462 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309463QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009464 struct sir_ocb_timing_advert *timing_advert)
9465{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309466 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009468 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009469 void *buf;
9470 struct sir_ocb_timing_advert *sme_timing_advert;
9471
9472 /* Lock the SME structure */
9473 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309474 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009475 return status;
9476
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309477 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009478 timing_advert->template_length);
9479 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309480 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009481 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309482 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009483 goto end;
9484 }
9485
9486 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9487 *sme_timing_advert = *timing_advert;
9488 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309489 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009490 timing_advert->template_value, timing_advert->template_length);
9491
9492 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9493 msg.reserved = 0;
9494 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009495 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309496 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498 FL("Not able to post msg to WDA"));
9499 goto end;
9500 }
9501
9502end:
9503 sme_release_global_lock(&pMac->sme);
9504
9505 return status;
9506}
9507
9508/**
9509 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9510 * @hHal: reference to the HAL
9511 * @timing_advert: the timing advertisement struct
9512 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309513 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309515QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009516 struct sir_ocb_timing_advert *timing_advert)
9517{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309518 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009519 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009520 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 struct sir_ocb_timing_advert *sme_timing_advert;
9522
9523 /* Lock the SME structure */
9524 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309525 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009526 return status;
9527
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309528 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009529 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309530 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309532 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009533 goto end;
9534 }
9535 *sme_timing_advert = *timing_advert;
9536
9537 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9538 msg.reserved = 0;
9539 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009540 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309541 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309542 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009543 FL("Not able to post msg to WDA"));
9544 goto end;
9545 }
9546
9547end:
9548 sme_release_global_lock(&pMac->sme);
9549
9550 return status;
9551}
9552
9553/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009554 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9555 * @hal_handle: reference to the HAL
9556 * @self_addr: the self MAC address
9557 * @buf: the buffer that will contain the frame
9558 * @timestamp_offset: return for the offset of the timestamp field
9559 * @time_value_offset: return for the time_value field in the TA IE
9560 *
9561 * Return: the length of the buffer.
9562 */
9563int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9564 tSirMacAddr self_addr, uint8_t **buf,
9565 uint32_t *timestamp_offset,
9566 uint32_t *time_value_offset)
9567{
9568 int template_length;
9569 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9570
9571 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9572 timestamp_offset,
9573 time_value_offset);
9574 return template_length;
9575}
9576/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009577 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9578 * @hHal: reference to the HAL
9579 * @context: the context of the call
9580 * @callback: the callback to hdd
9581 * @request: the TSF timer request
9582 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309583 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009584 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309585QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009586 ocb_callback callback,
9587 struct sir_ocb_get_tsf_timer *request)
9588{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309589 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009591 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 struct sir_ocb_get_tsf_timer *msg_body;
9593
9594 /* Lock the SME structure */
9595 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309596 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 return status;
9598
9599 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309600 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009601 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309602 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603 goto end;
9604 }
9605 *msg_body = *request;
9606
9607 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9608 msg.bodyptr = msg_body;
9609
9610 /* Set the request callback and the context */
9611 pMac->sme.ocb_get_tsf_timer_callback = callback;
9612 pMac->sme.ocb_get_tsf_timer_context = context;
9613
9614 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009615 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309616 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009618 FL("Error posting message to WDA: %d"), status);
9619 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9620 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309621 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009622 goto end;
9623 }
9624
9625end:
9626 sme_release_global_lock(&pMac->sme);
9627
9628 return status;
9629}
9630
9631/**
9632 * sme_dcc_get_stats() - Get the DCC stats
9633 * @hHal: reference to the HAL
9634 * @context: the context of the call
9635 * @callback: the callback to hdd
9636 * @request: the get DCC stats request
9637 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309638 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309640QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009641 ocb_callback callback,
9642 struct sir_dcc_get_stats *request)
9643{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309644 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009646 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 struct sir_dcc_get_stats *msg_body;
9648
9649 /* Lock the SME structure */
9650 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309651 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 return status;
9653
9654 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309655 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 request->request_array_len);
9657 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309658 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659 goto end;
9660 }
9661 *msg_body = *request;
9662 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309663 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 request->request_array_len);
9665
9666 msg.type = WMA_DCC_GET_STATS_CMD;
9667 msg.bodyptr = msg_body;
9668
9669 /* Set the request callback and context */
9670 pMac->sme.dcc_get_stats_callback = callback;
9671 pMac->sme.dcc_get_stats_context = context;
9672
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009673 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309674 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009676 FL("Error posting message to WDA: %d"), status);
9677 pMac->sme.dcc_get_stats_callback = callback;
9678 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309679 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009680 goto end;
9681 }
9682
9683end:
9684 sme_release_global_lock(&pMac->sme);
9685
9686 return status;
9687}
9688
9689/**
9690 * sme_dcc_clear_stats() - Clear the DCC stats
9691 * @hHal: reference to the HAL
9692 * @vdev_id: vdev id for OCB interface
9693 * @dcc_stats_bitmap: the entries in the stats to clear
9694 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309695 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009696 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309697QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009698 uint32_t dcc_stats_bitmap)
9699{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309700 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009702 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009703 struct sir_dcc_clear_stats *request;
9704
9705 /* Lock the SME structure */
9706 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309707 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009708 return status;
9709
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309710 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009711 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309712 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309714 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009715 goto end;
9716 }
9717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718 request->vdev_id = vdev_id;
9719 request->dcc_stats_bitmap = dcc_stats_bitmap;
9720
9721 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9722 msg.bodyptr = request;
9723
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009724 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309725 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309726 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009727 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309728 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009729 goto end;
9730 }
9731
9732end:
9733 sme_release_global_lock(&pMac->sme);
9734
9735 return status;
9736}
9737
9738/**
9739 * sme_dcc_update_ndl() - Update the DCC settings
9740 * @hHal: reference to the HAL
9741 * @context: the context of the call
9742 * @callback: the callback to hdd
9743 * @request: the update DCC request
9744 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309745 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309747QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009748 ocb_callback callback,
9749 struct sir_dcc_update_ndl *request)
9750{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309751 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009752 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009753 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754 struct sir_dcc_update_ndl *msg_body;
9755
9756 /* Lock the SME structure */
9757 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309758 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009759 return status;
9760
9761 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309762 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009763 request->dcc_ndl_chan_list_len +
9764 request->dcc_ndl_active_state_list_len);
9765 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309766 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009767 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309768 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009769 goto end;
9770 }
9771
9772 *msg_body = *request;
9773
9774 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9775 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9776 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309777 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009778 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309779 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009780 request->dcc_ndl_active_state_list,
9781 request->dcc_ndl_active_state_list_len);
9782
9783 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9784 msg.bodyptr = msg_body;
9785
9786 /* Set the request callback and the context */
9787 pMac->sme.dcc_update_ndl_callback = callback;
9788 pMac->sme.dcc_update_ndl_context = context;
9789
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009790 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309791 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309792 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793 FL("Error posting message to WDA: %d"), status);
9794 pMac->sme.dcc_update_ndl_callback = NULL;
9795 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309796 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009797 goto end;
9798 }
9799
9800end:
9801 sme_release_global_lock(&pMac->sme);
9802
9803 return status;
9804}
9805
9806/**
9807 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9808 * event
9809 * @hHal: reference to the HAL
9810 * @context: the context of the call
9811 * @callback: the callback to hdd
9812 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309813 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009814 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309815QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009816 ocb_callback callback)
9817{
9818 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309819 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009820
9821 status = sme_acquire_global_lock(&pMac->sme);
9822 pMac->sme.dcc_stats_event_callback = callback;
9823 pMac->sme.dcc_stats_event_context = context;
9824 sme_release_global_lock(&pMac->sme);
9825
9826 return 0;
9827}
9828
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309829/**
9830 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9831 * event
9832 * @h_hal: Hal Handle
9833 *
9834 * This function de-registers the DCC perioc stats callback
9835 *
9836 * Return: QDF_STATUS Enumeration
9837 */
9838QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9839{
9840 tpAniSirGlobal mac;
9841 QDF_STATUS status;
9842
9843 if (!h_hal) {
9844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9845 FL("h_hal is not valid"));
9846 return QDF_STATUS_E_INVAL;
9847 }
9848 mac = PMAC_STRUCT(h_hal);
9849
9850 status = sme_acquire_global_lock(&mac->sme);
9851 if (!QDF_IS_STATUS_SUCCESS(status)) {
9852 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9853 FL("Failed to acquire global lock"));
9854 return status;
9855 }
9856 mac->sme.dcc_stats_event_callback = NULL;
9857 mac->sme.dcc_stats_event_context = NULL;
9858 sme_release_global_lock(&mac->sme);
9859
9860 return status;
9861}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309862#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309863
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009864void sme_get_recovery_stats(tHalHandle hHal)
9865{
9866 uint8_t i;
9867
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309868 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009869 "Self Recovery Stats");
9870 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9871 if (eSmeNoCommand !=
9872 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309873 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009874 "timestamp %llu: command 0x%0X: reason %d: session %d",
9875 g_self_recovery_stats.activeCmdStats[i].
9876 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309877 g_self_recovery_stats.activeCmdStats[i].command,
9878 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009879 g_self_recovery_stats.activeCmdStats[i].
9880 sessionId);
9881 }
9882 }
9883}
9884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309885QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009886{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009887 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888 tpSirModemPowerStateInd request_buf;
9889 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9890
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309891 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309892 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009893
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309894 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009895 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309896 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009897 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9898 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309899 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009900 }
9901
9902 request_buf->param = value;
9903
9904 msg.type = WMA_MODEM_POWER_STATE_IND;
9905 msg.reserved = 0;
9906 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309907 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009908 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309909 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309910 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9911 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309912 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309913 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009914 }
9915
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309916 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009917}
9918
9919#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309920QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309921 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009922 uint8_t sessionId,
9923 uint8_t channel_type)
9924{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009925 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009926 tUpdateVHTOpMode *pHtOpMode = NULL;
9927 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9928
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309929 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309930 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009931
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309932 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309934 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009935 "%s: Not able to allocate memory for setting OP mode",
9936 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309937 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009938 }
9939
9940 switch (channel_type) {
9941 case eHT_CHAN_HT20:
9942 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9943 break;
9944
9945 case eHT_CHAN_HT40MINUS:
9946 case eHT_CHAN_HT40PLUS:
9947 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9948 break;
9949
9950 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009952 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309953 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009954 }
9955
9956 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309957 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009958 sizeof(tSirMacAddr));
9959 pHtOpMode->smesessionId = sessionId;
9960
9961 msg.type = WMA_UPDATE_OP_MODE;
9962 msg.reserved = 0;
9963 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309964 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009965 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309966 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309967 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9968 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309969 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309970 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 }
9972
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309973 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009974 "%s: Notifed FW about OP mode: %d for staId=%d",
9975 __func__, pHtOpMode->opMode, staId);
9976
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309977 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978}
9979
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309980/*
9981 * sme_set_ht2040_mode() -
9982 * To update HT Operation beacon IE.
9983 *
9984 * Return QDF_STATUS SUCCESS
9985 * FAILURE or RESOURCES
9986 * The API finished and failed.
9987 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309988QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009989 uint8_t channel_type, bool obssEnabled)
9990{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309991 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009992 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9993 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309994 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309996 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9997 sme_err("Session not valid for session id %d", sessionId);
9998 return QDF_STATUS_E_INVAL;
9999 }
10000 session = CSR_GET_SESSION(pMac, sessionId);
10001 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
10002 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010003
10004 switch (channel_type) {
10005 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010006 if (!session->bssParams.cbMode)
10007 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010008 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
10009 break;
10010 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010011 if (session->bssParams.cbMode)
10012 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010013 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10014 break;
10015 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010016 if (session->bssParams.cbMode)
10017 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10019 break;
10020 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010021 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010022 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010023 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010024 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010025 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010026 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010027 status = csr_set_ht2040_mode(pMac, sessionId,
10028 cbMode, obssEnabled);
10029 sme_release_global_lock(&pMac->sme);
10030 }
10031 return status;
10032}
10033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010034#endif
10035
10036/*
10037 * SME API to enable/disable idle mode powersave
10038 * This should be called only if powersave offload
10039 * is enabled
10040 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010041QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010042{
Anurag Chouhan6d760662016-02-20 16:05:43 +053010043 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010044
10045 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010046 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010047 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010048 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010049 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010050 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010051 " Idle Ps Set Value %d", value);
10052
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010053 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010054 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010055 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010056 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010057 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010058
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010059 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010060}
10061
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010062int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
10063 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010064{
10065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010066 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010067
10068 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010069 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070 "%s: pSession is NULL", __func__);
10071 return -EIO;
10072 }
10073 switch (ht_capab) {
10074 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10075 return pSession->htConfig.ht_rx_ldpc;
10076 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10077 return pSession->htConfig.ht_tx_stbc;
10078 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10079 return pSession->htConfig.ht_rx_stbc;
10080 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010081 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010082 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010083 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010084 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010085 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010086 "invalid ht capability");
10087 return -EIO;
10088 }
10089}
10090
10091int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
10092 int value)
10093{
10094 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010095 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010096
10097 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010099 "%s: pSession is NULL", __func__);
10100 return -EIO;
10101 }
10102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010103 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010105 "Failed to set ht capability in target");
10106 return -EIO;
10107 }
10108
10109 switch (htCapab) {
10110 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10111 pSession->htConfig.ht_rx_ldpc = value;
10112 break;
10113 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10114 pSession->htConfig.ht_tx_stbc = value;
10115 break;
10116 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10117 pSession->htConfig.ht_rx_stbc = value;
10118 break;
10119 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010120 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010121 pSession->htConfig.ht_sgi20 = value;
10122 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010123 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010124 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010125 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010126 break;
10127 }
10128
Naveen Rawat8029a402017-06-01 10:54:19 -070010129 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010130 return 0;
10131}
10132
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -080010133int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
10134{
10135 struct sme_addba_accept *addba_accept;
10136 struct scheduler_msg msg = {0};
10137 QDF_STATUS status;
10138
10139 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
10140 if (!addba_accept) {
10141 sme_err("mem alloc failed for addba_accept");
10142 return -EIO;
10143 }
10144 addba_accept->session_id = session_id;
10145 addba_accept->addba_accept = value;
10146 qdf_mem_zero(&msg, sizeof(msg));
10147 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
10148 msg.reserved = 0;
10149 msg.bodyptr = addba_accept;
10150 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
10151 if (status != QDF_STATUS_SUCCESS) {
10152 sme_err("Not able to post addba reject");
10153 qdf_mem_free(addba_accept);
10154 return -EIO;
10155 }
10156 return 0;
10157}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010158#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010159/*
10160 * sme_send_rate_update_ind() -
10161 * API to Update rate
10162 *
10163 * hHal - The handle returned by mac_open
10164 * rateUpdateParams - Pointer to rate update params
10165 * Return QDF_STATUS
10166 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010167QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010168 tSirRateUpdateInd *rateUpdateParams)
10169{
10170 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010171 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010172 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010173 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010174
10175 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010176 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010177 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010178 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010179 }
10180 *rate_upd = *rateUpdateParams;
10181
10182 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10183 rate_upd->mcastDataRate24GHzTxFlag =
10184 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10185 else if (rate_upd->reliableMcastDataRate ==
10186 HT20_SHORT_GI_MCS7_RATE)
10187 rate_upd->reliableMcastDataRateTxFlag =
10188 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10189
10190 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010191 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010192 msg.type = WMA_RATE_UPDATE_IND;
10193 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010194 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10195 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010196 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010197 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010198 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010199 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010200 __func__);
10201
10202 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010203 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010204 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010205 }
10206
10207 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010208 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010209 }
10210
10211 return status;
10212}
10213
10214/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010215 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10216 * @hal: Pointer to the mac context
10217 * @session_id: sme session id
10218 * @vendor_ie: vendor ie
10219 * @access_policy: vendor ie access policy
10220 *
10221 * This function updates the vendor ie and access policy to lim.
10222 *
10223 * Return: success or failure.
10224 */
10225QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10226 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10227{
10228 struct sme_update_access_policy_vendor_ie *msg;
10229 uint16_t msg_len;
10230 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010231
10232 msg_len = sizeof(*msg);
10233
10234 msg = qdf_mem_malloc(msg_len);
10235 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010236 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010237 return QDF_STATUS_E_FAILURE;
10238 }
10239
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010240 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10241 msg->length = (uint16_t)msg_len;
10242
10243 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10244
10245 msg->sme_session_id = session_id;
10246 msg->access_policy = access_policy;
10247
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010248 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10249 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010250
Rajeev Kumard138ac52017-01-30 18:38:37 -080010251 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010252
10253 return status;
10254}
10255
10256/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010257 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10258 * @hal: Handle returned by mac_open
10259 * @session_id: Session ID on which short frame retry limit needs to be
10260 * updated to FW
10261 * @short_limit_count_th: Retry count TH to retry short frame.
10262 *
10263 * This function is used to configure count to retry short frame.
10264 *
10265 * Return: QDF_STATUS
10266 */
10267QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10268 struct sme_short_retry_limit *short_retry_limit_th)
10269{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010270 QDF_STATUS status = QDF_STATUS_SUCCESS;
10271 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010272 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010273
10274 srl = qdf_mem_malloc(sizeof(*srl));
10275 if (NULL == srl) {
10276 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10277 "%s: fail to alloc short retry limit", __func__);
10278 return QDF_STATUS_E_FAILURE;
10279 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010280 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010281 short_retry_limit_th->session_id,
10282 short_retry_limit_th->short_retry_limit);
10283
10284 srl->session_id = short_retry_limit_th->session_id;
10285 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10286
10287 qdf_mem_zero(&msg, sizeof(msg));
10288 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10289 msg.reserved = 0;
10290 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010291 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010292 if (status != QDF_STATUS_SUCCESS) {
10293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10294 FL("Not able to post short retry limit count to WDA"));
10295 qdf_mem_free(srl);
10296 return QDF_STATUS_E_FAILURE;
10297 }
10298
10299 return status;
10300}
10301
10302/**
10303 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10304 * @hal: Handle returned by mac_open
10305 * @session_id: Session ID on which long frames retry TH needs to be updated
10306 * to FW
10307 * @long_limit_count_th: Retry count to retry long frame.
10308 *
10309 * This function is used to configure TH to retry long frame.
10310 *
10311 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010312 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010313QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10314 struct sme_long_retry_limit *long_retry_limit_th)
10315{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010316 QDF_STATUS status = QDF_STATUS_SUCCESS;
10317 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010318 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010319
10320 lrl = qdf_mem_malloc(sizeof(*lrl));
10321 if (NULL == lrl) {
10322 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10323 "%s: fail to alloc long retry limit", __func__);
10324 return QDF_STATUS_E_FAILURE;
10325 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010326 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010327 long_retry_limit_th->session_id,
10328 long_retry_limit_th->long_retry_limit);
10329
10330 lrl->session_id = long_retry_limit_th->session_id;
10331 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10332
10333 qdf_mem_zero(&msg, sizeof(msg));
10334 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10335 msg.reserved = 0;
10336 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010337 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010338
10339 if (status != QDF_STATUS_SUCCESS) {
10340 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10341 FL("Not able to post long retry limit count to WDA"));
10342 qdf_mem_free(lrl);
10343 return QDF_STATUS_E_FAILURE;
10344 }
10345
10346 return status;
10347}
10348
10349/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010350 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10351 * @hal: Handle returned by mac_open
10352 * @session_id: Session ID on which sta_inactivity_timeout needs
10353 * to be updated to FW
10354 * @sta_inactivity_timeout: sta inactivity timeout.
10355 *
10356 * If a station does not send anything in sta_inactivity_timeout seconds, an
10357 * empty data frame is sent to it in order to verify whether it is
10358 * still in range. If this frame is not ACKed, the station will be
10359 * disassociated and then deauthenticated.
10360 *
10361 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010362 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010363QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10364 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10365{
10366 struct sme_sta_inactivity_timeout *inactivity_time;
10367 void *wma_handle;
10368
10369 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10370 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10371 if (NULL == inactivity_time) {
10372 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10373 "%s: fail to alloc inactivity_time", __func__);
10374 return QDF_STATUS_E_FAILURE;
10375 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010376 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010377 FL("sta_inactivity_timeout: %d"),
10378 sta_inactivity_timer->sta_inactivity_timeout);
10379 inactivity_time->session_id = sta_inactivity_timer->session_id;
10380 inactivity_time->sta_inactivity_timeout =
10381 sta_inactivity_timer->sta_inactivity_timeout;
10382
10383 wma_update_sta_inactivity_timeout(wma_handle,
10384 inactivity_time);
10385 return QDF_STATUS_SUCCESS;
10386}
10387
10388/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389 * sme_get_reg_info() - To get registration info
10390 * @hHal: HAL context
10391 * @chanId: channel id
10392 * @regInfo1: first reg info to fill
10393 * @regInfo2: second reg info to fill
10394 *
10395 * This routine will give you reg info
10396 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010397 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010398 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010399QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010400 uint32_t *regInfo1, uint32_t *regInfo2)
10401{
10402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010403 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010404 uint8_t i;
10405 bool found = false;
10406
10407 status = sme_acquire_global_lock(&pMac->sme);
10408 *regInfo1 = 0;
10409 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010410 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010411 return status;
10412
10413 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010414 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010415 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010416 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010417
10418 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010419 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 found = true;
10421 break;
10422 }
10423 }
10424 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010425 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010426
10427 sme_release_global_lock(&pMac->sme);
10428 return status;
10429}
10430
10431#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010432/*
10433 * sme_auto_shutdown_cb() -
10434 * Used to plug in callback function for receiving auto shutdown evt
10435 *
10436 * hHal
10437 * pCallbackfn : callback function pointer should be plugged in
10438 * Return QDF_STATUS
10439 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010440QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010442 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10444
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446 "%s: Plug in Auto shutdown event callback", __func__);
10447
10448 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010449 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010450 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010451 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010452 sme_release_global_lock(&pMac->sme);
10453 }
10454
10455 return status;
10456}
10457
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010458/*
10459 * sme_set_auto_shutdown_timer() -
10460 * API to set auto shutdown timer value in FW.
10461 *
10462 * hHal - The handle returned by mac_open
10463 * timer_val - The auto shutdown timer value to be set
10464 * Return Configuration message posting status, SUCCESS or Fail
10465 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010466QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010467{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010468 QDF_STATUS status = QDF_STATUS_SUCCESS;
10469 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10471 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010472 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010473
10474 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010475 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010476 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010477 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010478 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010479 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010480 "%s Request Buffer Alloc Fail", __func__);
10481 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010482 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010483 }
10484
10485 auto_sh_cmd->timer_val = timer_val;
10486
10487 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010488 message.bodyptr = auto_sh_cmd;
10489 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10490 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10491 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010492 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010493 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010495 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010496 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010497 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010498 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010500 "%s: Posted Auto shutdown MSG", __func__);
10501 sme_release_global_lock(&pMac->sme);
10502 }
10503
10504 return status;
10505}
10506#endif
10507
Nirav Shaheb017be2018-02-15 11:20:58 +053010508#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010509/*
10510 * sme_ch_avoid_update_req() -
10511 * API to request channel avoidance update from FW.
10512 *
10513 * hHal - The handle returned by mac_open
10514 * update_type - The udpate_type parameter of this request call
10515 * Return Configuration message posting status, SUCCESS or Fail
10516 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010517QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010519 QDF_STATUS status = QDF_STATUS_SUCCESS;
10520 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10522 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010523 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010524
10525 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010526 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010528 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010530 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010531 "%s Request Buffer Alloc Fail", __func__);
10532 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010533 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010534 }
10535
10536 cauReq->reserved_param = 0;
10537
10538 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010539 message.bodyptr = cauReq;
10540 message.type = WMA_CH_AVOID_UPDATE_REQ;
10541 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10542 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010543 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
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: Post Ch Avoid Update MSG fail",
10546 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010547 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010548 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010549 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010550 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010552 "%s: Posted Ch Avoid Update MSG", __func__);
10553 sme_release_global_lock(&pMac->sme);
10554 }
10555
10556 return status;
10557}
Nirav Shaheb017be2018-02-15 11:20:58 +053010558#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010559
10560/**
10561 * sme_set_miracast() - Function to set miracast value to UMAC
10562 * @hal: Handle returned by macOpen
10563 * @filter_type: 0-Disabled, 1-Source, 2-sink
10564 *
10565 * This function passes down the value of miracast set by
10566 * framework to UMAC
10567 *
10568 * Return: Configuration message posting status, SUCCESS or Fail
10569 *
10570 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010571QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010572{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010573 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010574 uint32_t *val;
10575 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10576
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010577 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010578 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010580 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010581 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582 }
10583
10584 *val = filter_type;
10585
10586 msg.type = SIR_HAL_SET_MIRACAST;
10587 msg.reserved = 0;
10588 msg.bodyptr = val;
10589
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010590 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010591 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010592 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010593 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10594 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010595 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010596 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010597 }
10598
10599 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010600 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601}
10602
10603/**
10604 * sme_set_mas() - Function to set MAS value to UMAC
10605 * @val: 1-Enable, 0-Disable
10606 *
10607 * This function passes down the value of MAS to the UMAC. A
10608 * value of 1 will enable MAS and a value of 0 will disable MAS
10609 *
10610 * Return: Configuration message posting status, SUCCESS or Fail
10611 *
10612 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010613QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010614{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010615 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010616 uint32_t *ptr_val;
10617
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010618 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010619 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010620 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010621 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010622 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010623 }
10624
10625 *ptr_val = val;
10626
10627 msg.type = SIR_HAL_SET_MAS;
10628 msg.reserved = 0;
10629 msg.bodyptr = ptr_val;
10630
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010631 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010632 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010633 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010634 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10635 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010636 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010637 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010638 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010639 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010640}
10641
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010642/**
10643 * sme_roam_channel_change_req() - Channel change to new target channel
10644 * @hHal: handle returned by mac_open
10645 * @bssid: mac address of BSS
10646 * @ch_params: target channel information
10647 * @profile: CSR profile
10648 *
10649 * API to Indicate Channel change to new target channel
10650 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010651 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010652 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010653QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010654 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010655 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010656 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010658 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660
10661 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010662 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010663
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010664 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665 profile);
10666 sme_release_global_lock(&pMac->sme);
10667 }
10668 return status;
10669}
10670
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010671/*
10672 * sme_process_channel_change_resp() -
10673 * API to Indicate Channel change response message to SAP.
10674 *
10675 * Return QDF_STATUS
10676 */
10677static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010678 uint16_t msg_type, void *pMsgBuf)
10679{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010680 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010681 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010682 eCsrRoamResult roamResult;
10683 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10684 uint32_t SessionId = pChnlParams->peSessionId;
10685
10686 proam_info.channelChangeRespEvent =
10687 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010688 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010689 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010690 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010691 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010692 return status;
10693 }
10694 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10695 proam_info.channelChangeRespEvent->sessionId = SessionId;
10696 proam_info.channelChangeRespEvent->newChannelNumber =
10697 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010699 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010701 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10702 SessionId);
10703 proam_info.channelChangeRespEvent->channelChangeStatus =
10704 1;
10705 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10706 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10709 SessionId);
10710 proam_info.channelChangeRespEvent->channelChangeStatus =
10711 0;
10712 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10713 }
10714
10715 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10716 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10717
10718 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010719 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010720 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010721 status);
10722 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010723 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010724
10725 return status;
10726}
10727
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010728/*
10729 * sme_roam_start_beacon_req() -
10730 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10731 *
10732 * hHal - The handle returned by mac_open
10733 * sessionId - session ID
10734 * dfsCacWaitStatus - CAC WAIT status flag
10735 * Return QDF_STATUS
10736 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010737QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010738 uint8_t dfsCacWaitStatus)
10739{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010740 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010741 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010743 status = sme_acquire_global_lock(&pMac->sme);
10744
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010745 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010746 status = csr_roam_start_beacon_req(pMac, bssid,
10747 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010748 sme_release_global_lock(&pMac->sme);
10749 }
10750 return status;
10751}
10752
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010753/**
10754 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10755 * @hHal: handle returned by mac_open
10756 * @bssid: SAP bssid
10757 * @targetChannel: target channel information
10758 * @csaIeReqd: CSA IE Request
10759 * @ch_params: channel information
10760 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010761 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010762 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010763QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010764 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010765 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010766{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010767 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010768 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010771 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010772 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10773 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010774 sme_release_global_lock(&pMac->sme);
10775 }
10776 return status;
10777}
10778
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010779/*
10780 * sme_init_thermal_info() -
10781 * SME API to initialize the thermal mitigation parameters
10782 *
10783 * hHal
10784 * thermalParam : thermal mitigation parameters
10785 * Return QDF_STATUS
10786 */
10787QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10788 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010789{
10790 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010791 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010792 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10793
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010794 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010795 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010797 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010798 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 }
10800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010801 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10802 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010803
10804 pWmaParam->throttle_duty_cycle_tbl[0] =
10805 thermalParam.sme_throttle_duty_cycle_tbl[0];
10806 pWmaParam->throttle_duty_cycle_tbl[1] =
10807 thermalParam.sme_throttle_duty_cycle_tbl[1];
10808 pWmaParam->throttle_duty_cycle_tbl[2] =
10809 thermalParam.sme_throttle_duty_cycle_tbl[2];
10810 pWmaParam->throttle_duty_cycle_tbl[3] =
10811 thermalParam.sme_throttle_duty_cycle_tbl[3];
10812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813 pWmaParam->thermalLevels[0].minTempThreshold =
10814 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10815 pWmaParam->thermalLevels[0].maxTempThreshold =
10816 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10817 pWmaParam->thermalLevels[1].minTempThreshold =
10818 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10819 pWmaParam->thermalLevels[1].maxTempThreshold =
10820 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10821 pWmaParam->thermalLevels[2].minTempThreshold =
10822 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10823 pWmaParam->thermalLevels[2].maxTempThreshold =
10824 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10825 pWmaParam->thermalLevels[3].minTempThreshold =
10826 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10827 pWmaParam->thermalLevels[3].maxTempThreshold =
10828 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10829
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010830 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010831 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10832 msg.bodyptr = pWmaParam;
10833
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010834 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010835 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010836 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010837 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10838 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010839 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010840 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010841 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010842 }
10843 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010844 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010845 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010846 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010848}
10849
10850/**
10851 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10852 * @hal: Handle returned by macOpen
10853 * @callback: sme_set_thermal_level_callback
10854 *
10855 * Plug in set thermal level callback
10856 *
10857 * Return: none
10858 */
10859void sme_add_set_thermal_level_callback(tHalHandle hal,
10860 sme_set_thermal_level_callback callback)
10861{
10862 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10863
10864 pMac->sme.set_thermal_level_cb = callback;
10865}
10866
10867/**
10868 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10869 * @hal: Handler to HAL
10870 * @level: Thermal mitigation level
10871 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010872 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010873 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010874QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010876 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010878 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010879
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010880 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010881 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 msg.type = WMA_SET_THERMAL_LEVEL;
10883 msg.bodyval = level;
10884
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010885 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010886 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010887 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010888 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10889 __func__);
10890 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010891 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010892 }
10893 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010894 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010895 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010896 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010897}
10898
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010899/*
10900 * sme_txpower_limit() -
10901 * SME API to set txpower limits
10902 *
10903 * hHal
10904 * psmetx : power limits for 2g/5g
10905 * Return QDF_STATUS
10906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010907QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010908{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010909 QDF_STATUS status = QDF_STATUS_SUCCESS;
10910 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010911 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010912 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010913 tSirTxPowerLimit *tx_power_limit;
10914
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010915 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010916 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010918 "%s: Memory allocation for TxPowerLimit failed!",
10919 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010920 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010921 }
10922
10923 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924
10925 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010926 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010927 message.type = WMA_TX_POWER_LIMIT;
10928 message.reserved = 0;
10929 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010930
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010931 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10932 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010933 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010934 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010935 "%s: not able to post WMA_TX_POWER_LIMIT",
10936 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010937 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010938 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010939 }
10940 sme_release_global_lock(&pMac->sme);
10941 }
10942 return status;
10943}
10944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010945QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010946{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010947 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010950 pMac->fEnableDebugLog = set_value;
10951 return status;
10952}
10953
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010954/*
10955 * sme_ap_disable_intra_bss_fwd() -
10956 * SME will send message to WMA to set Intra BSS in txrx
10957 *
10958 * hHal - The handle returned by mac_open
10959 * sessionId - session id ( vdev id)
10960 * disablefwd - bool value that indicate disable intrabss fwd disable
10961 * Return QDF_STATUS
10962 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010963QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010964 bool disablefwd)
10965{
10966 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010967 int status = QDF_STATUS_SUCCESS;
10968 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010969 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010970 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10971
10972 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010973 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010974 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010975 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010976 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010977 }
10978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010979 pSapDisableIntraFwd->sessionId = sessionId;
10980 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10981
10982 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010983 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010984 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010985 message.bodyptr = pSapDisableIntraFwd;
10986 message.type = WMA_SET_SAP_INTRABSS_DIS;
10987 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10988 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010989 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10990 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010991 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010992 }
10993 sme_release_global_lock(&pMac->sme);
10994 }
10995 return status;
10996}
10997
10998#ifdef WLAN_FEATURE_STATS_EXT
10999
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011000/*
11001 * sme_stats_ext_register_callback() -
11002 * This function called to register the callback that send vendor event for
11003 * stats ext
11004 *
11005 * callback - callback to be registered
11006 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011007void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
11008{
11009 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11010
11011 pMac->sme.StatsExtCallback = callback;
11012}
11013
lifeng66831662017-05-19 16:01:35 +080011014void sme_stats_ext2_register_callback(tHalHandle hal_handle,
11015 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
11016{
11017 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
11018
11019 pmac->sme.stats_ext2_cb = stats_ext2_cb;
11020}
11021
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011022/**
11023 * sme_stats_ext_deregister_callback() - De-register ext stats callback
11024 * @h_hal: Hal Handle
11025 *
11026 * This function is called to de initialize the HDD NAN feature. Currently
11027 * the only operation required is to de-register a callback with SME.
11028 *
11029 * Return: None
11030 */
11031void sme_stats_ext_deregister_callback(tHalHandle h_hal)
11032{
11033 tpAniSirGlobal pmac;
11034
11035 if (!h_hal) {
11036 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11037 FL("hHal is not valid"));
11038 return;
11039 }
11040
11041 pmac = PMAC_STRUCT(h_hal);
11042 pmac->sme.StatsExtCallback = NULL;
11043}
11044
11045
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011046/*
11047 * sme_stats_ext_request() -
11048 * Function called when HDD receives STATS EXT vendor command from userspace
11049 *
11050 * sessionID - vdevID for the stats ext request
11051 * input - Stats Ext Request structure ptr
11052 * Return QDF_STATUS
11053 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011054QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011055{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011056 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011057 tpStatsExtRequest data;
11058 size_t data_len;
11059
11060 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011061 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011062
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011063 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011064 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011066 data->vdev_id = session_id;
11067 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011068 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011069 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011070 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011071
11072 msg.type = WMA_STATS_EXT_REQUEST;
11073 msg.reserved = 0;
11074 msg.bodyptr = data;
11075
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011076 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080011077 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011079 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
11080 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011081 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011082 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011083 }
11084
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011085 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086}
11087
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011088/*
11089 * sme_stats_ext_event() -
11090 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
11091 * response from WMA
11092 *
11093 * hHal - HAL handle for device
11094 * pMsg - Message body passed from WMA; includes NAN header
11095 * Return QDF_STATUS
11096 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011097QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011098{
11099 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011100 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011101
11102 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011103 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011104 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011105 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011106 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011107 pMac->sme.StatsExtCallback(pMac->hHdd,
11108 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011109 }
11110
11111 return status;
11112}
11113
11114#endif
11115
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011116/*
11117 * sme_update_dfs_scan_mode() -
11118 * Update DFS roam scan mode
11119 * This function is called through dynamic setConfig callback function
11120 * to configure allowDFSChannelRoam.
11121 * hHal - HAL handle for device
11122 * sessionId - Session Identifier
11123 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
11124 * 1 (passive), 2 (active)
11125 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11126 * successfully.
11127 * Other status means SME failed to update DFS roaming scan config.
11128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011129QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011130 uint8_t allowDFSChannelRoam)
11131{
11132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011133 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011135 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11136 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11137 FL("Invalid sme session id: %d"), sessionId);
11138 return QDF_STATUS_E_INVAL;
11139 }
11140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011141 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011142 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011143 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011144 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145 allowDFSChannelRoam,
11146 pMac->roam.configParam.allowDFSChannelRoam,
11147 mac_trace_get_neighbour_roam_state(pMac->roam.
11148 neighborRoamInfo
11149 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011150 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011151 pMac->roam.configParam.allowDFSChannelRoam =
11152 allowDFSChannelRoam;
11153 sme_release_global_lock(&pMac->sme);
11154 }
11155 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11156 csr_roam_offload_scan(pMac, sessionId,
11157 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11158 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11159 }
11160
11161 return status;
11162}
11163
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011164/*
11165 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11166 * This is a synchronous call
11167 *
11168 * hHal - The handle returned by mac_open.
11169 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11170 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011171uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11172{
11173 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175 return pMac->roam.configParam.allowDFSChannelRoam;
11176}
11177
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011178/*
11179 * sme_modify_add_ie() -
11180 * This function sends msg to updates the additional IE buffers in PE
11181 *
11182 * hHal - global structure
11183 * pModifyIE - pointer to tModifyIE structure
11184 * updateType - type of buffer
11185 * Return Success or failure
11186 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011187QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011188 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11189{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011190 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011191 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011192
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011193 status = sme_acquire_global_lock(&pMac->sme);
11194
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011195 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11197 sme_release_global_lock(&pMac->sme);
11198 }
11199 return status;
11200}
11201
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011202/*
11203 * sme_update_add_ie() -
11204 * This function sends msg to updates the additional IE buffers in PE
11205 *
11206 * hHal - global structure
11207 * pUpdateIE - pointer to structure tUpdateIE
11208 * updateType - type of buffer
11209 * Return Success or failure
11210 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011211QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011212 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11213{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011214 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011215 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011217 status = sme_acquire_global_lock(&pMac->sme);
11218
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011219 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11221 sme_release_global_lock(&pMac->sme);
11222 }
11223 return status;
11224}
11225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011226/**
11227 * sme_update_dsc_pto_up_mapping()
11228 * @hHal: HAL context
11229 * @dscpmapping: pointer to DSCP mapping structure
11230 * @sessionId: SME session id
11231 *
11232 * This routine is called to update dscp mapping
11233 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011234 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011236QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011237 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011238 uint8_t sessionId)
11239{
11240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011241 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011243 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244 tpPESession pSession = NULL;
11245
11246 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011247 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011248 return status;
11249 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11250 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011251 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011252 FL("Session lookup fails for CSR session"));
11253 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011255 }
11256 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011257 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011258 FL("Invalid session Id %u"), sessionId);
11259 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011260 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 }
11262
11263 pSession = pe_find_session_by_bssid(pMac,
11264 pCsrSession->connectedProfile.bssid.bytes,
11265 &peSessionId);
11266
11267 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011268 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011269 FL(" Session lookup fails for BSSID"));
11270 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011271 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011272 }
11273
11274 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011275 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011276 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011277 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011278 }
11279 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11280 for (j = pSession->QosMapSet.dscp_range[i][0];
11281 j <= pSession->QosMapSet.dscp_range[i][1];
11282 j++) {
11283 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11284 && (pSession->QosMapSet.dscp_range[i][1] ==
11285 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011286 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011287 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 FL("User Priority %d isn't used"), i);
11289 break;
11290 } else {
11291 dscpmapping[j] = i;
11292 }
11293 }
11294 }
11295 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11296 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11297 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11298 pSession->QosMapSet.dscp_exceptions[i][1];
11299
11300 sme_release_global_lock(&pMac->sme);
11301 return status;
11302}
11303
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011304/*
11305 * sme_abort_roam_scan() -
11306 * API to abort current roam scan cycle by roam scan offload module.
11307 *
11308 * hHal - The handle returned by mac_open.
11309 * sessionId - Session Identifier
11310 * Return QDF_STATUS
11311 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011312
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011313QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011314{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011315 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011316 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011318 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11319 /* acquire the lock for the sme object */
11320 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011321 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011322 csr_roam_offload_scan(pMac, sessionId,
11323 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11324 REASON_ROAM_ABORT_ROAM_SCAN);
11325 /* release the lock for the sme object */
11326 sme_release_global_lock(&pMac->sme);
11327 }
11328 }
11329
11330 return status;
11331}
11332
11333#ifdef FEATURE_WLAN_EXTSCAN
11334/**
11335 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11336 * @hHal: HAL context
11337 * @wifiBand: RF band information
11338 * @aValidChannels: output array to store channel info
11339 * @pNumChannels: output number of channels
11340 *
11341 * SME API to fetch all valid channels filtered by band
11342 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011343 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011344 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011345QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011346 uint8_t wifiBand,
11347 uint32_t *aValidChannels,
11348 uint8_t *pNumChannels)
11349{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011352 uint8_t numChannels = 0;
11353 uint8_t i = 0;
11354 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011355 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011356
11357 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011358 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011359 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011360 }
11361
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011362 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011363 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011364 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011365 }
11366
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011367 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011368 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011369 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011370 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 return status;
11372 }
11373
11374 switch (wifiBand) {
11375 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011376 sme_debug("Unspec Band, return all %d valid channels",
11377 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011378 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011379 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011380 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011381 break;
11382
11383 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011384 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011385 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011386 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 aValidChannels[numChannels++] =
11388 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389 }
11390 break;
11391
11392 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011393 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011394 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011395 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011396 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011397 aValidChannels[numChannels++] =
11398 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011399 }
11400 break;
11401
11402 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011403 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011404 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011405 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11406 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011407 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 aValidChannels[numChannels++] =
11409 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011410 }
11411 break;
11412
11413 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011414 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011416 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011417 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011418 aValidChannels[numChannels++] =
11419 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011420 }
11421 break;
11422
11423 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011424 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011425 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011426 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011427 aValidChannels[numChannels++] =
11428 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011429 }
11430 break;
11431
11432 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011433 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011434 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011435 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011436 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011437 aValidChannels[numChannels++] =
11438 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439 }
11440 break;
11441
11442 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011443 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011444 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011445 }
11446 *pNumChannels = numChannels;
11447
11448 return status;
11449}
11450
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011451/*
11452 * sme_ext_scan_get_capabilities() -
11453 * SME API to fetch extscan capabilities
11454 *
11455 * hHal
11456 * pReq: extscan capabilities structure
11457 * Return QDF_STATUS
11458 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011459QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011460 tSirGetExtScanCapabilitiesReqParams *
11461 pReq)
11462{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011463 QDF_STATUS status = QDF_STATUS_SUCCESS;
11464 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011465 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011466 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011467
11468 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011469 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011470 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011471 message.bodyptr = pReq;
11472 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011473 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011474 NO_SESSION, message.type));
11475 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11476 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011477 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11478 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011479
11480 sme_release_global_lock(&pMac->sme);
11481 }
11482 return status;
11483}
11484
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011485/*
11486 * sme_ext_scan_start() -
11487 * SME API to issue extscan start
11488 *
11489 * hHal
11490 * pStartCmd: extscan start structure
11491 * Return QDF_STATUS
11492 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011493QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494 tSirWifiScanCmdReqParams *pStartCmd)
11495{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011496 QDF_STATUS status = QDF_STATUS_SUCCESS;
11497 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011498 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011499 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011500
11501 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011502 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011503 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011504 message.bodyptr = pStartCmd;
11505 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011506 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011507 NO_SESSION, message.type));
11508 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11509 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011510 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11511 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011512
11513 sme_release_global_lock(&pMac->sme);
11514 }
11515 return status;
11516}
11517
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011518/*
11519 * sme_ext_scan_stop() -
11520 * SME API to issue extscan stop
11521 *
11522 * hHal
11523 * pStopReq: extscan stop structure
11524 * Return QDF_STATUS
11525 */
11526QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11527 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011528{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011529 QDF_STATUS status = QDF_STATUS_SUCCESS;
11530 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011531 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011532 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011533
11534 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011535 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011536 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011537 message.bodyptr = pStopReq;
11538 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011539 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011540 NO_SESSION, message.type));
11541 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11542 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011543 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11544 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011545 sme_release_global_lock(&pMac->sme);
11546 }
11547 return status;
11548}
11549
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011550/*
11551 * sme_set_bss_hotlist() -
11552 * SME API to set BSSID hotlist
11553 *
11554 * hHal
11555 * pSetHotListReq: extscan set hotlist structure
11556 * Return QDF_STATUS
11557 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011558QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011559 tSirExtScanSetBssidHotListReqParams *
11560 pSetHotListReq)
11561{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011562 QDF_STATUS status = QDF_STATUS_SUCCESS;
11563 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011564 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011565 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011566
11567 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011568 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011569 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011570 message.bodyptr = pSetHotListReq;
11571 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011572 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011573 NO_SESSION, message.type));
11574 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11575 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011576 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11577 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011578
11579 sme_release_global_lock(&pMac->sme);
11580 }
11581 return status;
11582}
11583
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011584/*
11585 * sme_reset_bss_hotlist() -
11586 * SME API to reset BSSID hotlist
11587 *
11588 * hHal
11589 * pSetHotListReq: extscan set hotlist structure
11590 * Return QDF_STATUS
11591 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011592QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011593 tSirExtScanResetBssidHotlistReqParams *
11594 pResetReq)
11595{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011596 QDF_STATUS status = QDF_STATUS_SUCCESS;
11597 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011598 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011599 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011600
11601 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011602 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011603 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011604 message.bodyptr = pResetReq;
11605 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011606 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011607 NO_SESSION, message.type));
11608 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11609 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011610 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11611 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612
11613 sme_release_global_lock(&pMac->sme);
11614 }
11615 return status;
11616}
11617
Manikandan Mohan80dea792016-04-28 16:36:48 -070011618/**
11619 * sme_send_wisa_params(): Pass WISA mode to WMA
11620 * @hal: HAL context
11621 * @wisa_params: pointer to WISA params struct
11622 * @sessionId: SME session id
11623 *
11624 * Pass WISA params to WMA
11625 *
11626 * Return: QDF_STATUS
11627 */
11628QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11629 struct sir_wisa_params *wisa_params)
11630{
11631 QDF_STATUS status = QDF_STATUS_SUCCESS;
11632 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011633 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011634 struct sir_wisa_params *cds_msg_wisa_params;
11635
11636 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11637 if (!cds_msg_wisa_params)
11638 return QDF_STATUS_E_NOMEM;
11639
11640 *cds_msg_wisa_params = *wisa_params;
11641 status = sme_acquire_global_lock(&mac->sme);
11642 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011643 message.bodyptr = cds_msg_wisa_params;
11644 message.type = WMA_SET_WISA_PARAMS;
11645 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011646 sme_release_global_lock(&mac->sme);
11647 }
11648 return status;
11649}
11650
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011651/*
11652 * sme_set_significant_change() -
11653 * SME API to set significant change
11654 *
11655 * hHal
11656 * pSetSignificantChangeReq: extscan set significant change structure
11657 * Return QDF_STATUS
11658 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011659QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 tSirExtScanSetSigChangeReqParams *
11661 pSetSignificantChangeReq)
11662{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011663 QDF_STATUS status = QDF_STATUS_SUCCESS;
11664 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011665 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011666 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011667
11668 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011669 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011671 message.bodyptr = pSetSignificantChangeReq;
11672 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011673 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011674 NO_SESSION, message.type));
11675 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11676 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011677 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11678 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011679
11680 sme_release_global_lock(&pMac->sme);
11681 }
11682 return status;
11683}
11684
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011685/*
11686 * sme_reset_significant_change
11687 * SME API to reset significant change
11688 *
11689 * hHal
11690 * pResetReq: extscan reset significant change structure
11691 * Return QDF_STATUS
11692 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011693QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011694 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011695 *pResetReq)
11696{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011697 QDF_STATUS status = QDF_STATUS_SUCCESS;
11698 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011700 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011701
11702 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011703 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011704 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011705 message.bodyptr = pResetReq;
11706 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011707 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011708 NO_SESSION, message.type));
11709 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11710 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011711 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11712 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011713
11714 sme_release_global_lock(&pMac->sme);
11715 }
11716 return status;
11717}
11718
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011719/*
11720 * sme_get_cached_results() -
11721 * SME API to get cached results
11722 *
11723 * hHal
11724 * pCachedResultsReq: extscan get cached results structure
11725 * Return QDF_STATUS
11726 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011727QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728 tSirExtScanGetCachedResultsReqParams *
11729 pCachedResultsReq)
11730{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011731 QDF_STATUS status = QDF_STATUS_SUCCESS;
11732 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011734 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735
11736 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011737 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011738 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011739 message.bodyptr = pCachedResultsReq;
11740 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011741 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011742 NO_SESSION, message.type));
11743 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11744 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011745 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11746 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011747
11748 sme_release_global_lock(&pMac->sme);
11749 }
11750 return status;
11751}
11752
11753/**
11754 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011755 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011756 * @input: request message
11757 *
11758 * This function constructs the cds message and fill in message type,
11759 * bodyptr with %input and posts it to WDA queue.
11760 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011761 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011763QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011764 struct wifi_epno_params *input)
11765{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011766 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011767 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011768 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011769 struct wifi_epno_params *req_msg;
11770 int len, i;
11771
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011772 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011773 len = sizeof(*req_msg) +
11774 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011775
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011776 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011777 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011778 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011779 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011780 }
11781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011782 req_msg->num_networks = input->num_networks;
11783 req_msg->request_id = input->request_id;
11784 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011785
11786 /* Fill only when num_networks are non zero */
11787 if (req_msg->num_networks) {
11788 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11789 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11790 req_msg->initial_score_max = input->initial_score_max;
11791 req_msg->same_network_bonus = input->same_network_bonus;
11792 req_msg->secure_bonus = input->secure_bonus;
11793 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11794 req_msg->current_connection_bonus =
11795 input->current_connection_bonus;
11796
11797 for (i = 0; i < req_msg->num_networks; i++) {
11798 req_msg->networks[i].flags = input->networks[i].flags;
11799 req_msg->networks[i].auth_bit_field =
11800 input->networks[i].auth_bit_field;
11801 req_msg->networks[i].ssid.length =
11802 input->networks[i].ssid.length;
11803 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11804 input->networks[i].ssid.ssId,
11805 req_msg->networks[i].ssid.length);
11806 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 }
11808
11809 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011810 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011811 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011813 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011814 return status;
11815 }
11816
11817 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011818 message.bodyptr = req_msg;
11819 message.type = WMA_SET_EPNO_LIST_REQ;
11820 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011821 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011822 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011823 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011824 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011825 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011826 }
11827 sme_release_global_lock(&mac->sme);
11828 return status;
11829}
11830
11831/**
11832 * sme_set_passpoint_list() - set passpoint network list
11833 * @hal: global hal handle
11834 * @input: request message
11835 *
11836 * This function constructs the cds message and fill in message type,
11837 * bodyptr with @input and posts it to WDA queue.
11838 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011839 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011841QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011842 struct wifi_passpoint_req *input)
11843{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011844 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011845 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011846 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011847 struct wifi_passpoint_req *req_msg;
11848 int len, i;
11849
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011850 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011851 len = sizeof(*req_msg) +
11852 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011853 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011854 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011855 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011856 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 }
11858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011859 req_msg->num_networks = input->num_networks;
11860 req_msg->request_id = input->request_id;
11861 req_msg->session_id = input->session_id;
11862 for (i = 0; i < req_msg->num_networks; i++) {
11863 req_msg->networks[i].id =
11864 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011865 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011866 input->networks[i].realm,
11867 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011868 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011869 input->networks[i].plmn,
11870 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011871 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011872 input->networks[i].roaming_consortium_ids,
11873 sizeof(req_msg->networks[i].roaming_consortium_ids));
11874 }
11875
11876 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011877 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011878 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011879 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011880 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 return status;
11882 }
11883
11884 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011885 message.bodyptr = req_msg;
11886 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11887 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011888 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011889 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011890 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011891 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011892 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011893 }
11894 sme_release_global_lock(&mac->sme);
11895 return status;
11896}
11897
11898/**
11899 * sme_reset_passpoint_list() - reset passpoint network list
11900 * @hHal: global hal handle
11901 * @input: request message
11902 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011903 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011904 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011905QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011906 struct wifi_passpoint_req *input)
11907{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011908 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011909 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011910 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011911 struct wifi_passpoint_req *req_msg;
11912
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011913 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011914 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011915 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011916 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011917 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011918 }
11919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011920 req_msg->request_id = input->request_id;
11921 req_msg->session_id = input->session_id;
11922
11923 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011924 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011925 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011926 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011927 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011928 return status;
11929 }
11930
11931 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011932 message.bodyptr = req_msg;
11933 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11934 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011935 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011936 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011938 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011939 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011940 }
11941 sme_release_global_lock(&mac->sme);
11942 return status;
11943}
11944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011945QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011946 void (*pExtScanIndCb)(void *,
11947 const uint16_t,
11948 void *))
11949{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011950 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011951 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11952
11953 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011954 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011955 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11956 sme_release_global_lock(&pMac->sme);
11957 }
11958 return status;
11959}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011960#endif /* FEATURE_WLAN_EXTSCAN */
11961
11962#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11963
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011964/*
11965 * sme_ll_stats_clear_req() -
11966 * SME API to clear Link Layer Statistics
11967 *
11968 * hHal
11969 * pclearStatsReq: Link Layer clear stats request params structure
11970 * Return QDF_STATUS
11971 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011972QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011973 tSirLLStatsClearReq *pclearStatsReq)
11974{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011975 QDF_STATUS status = QDF_STATUS_SUCCESS;
11976 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011977 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011978 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011979 tSirLLStatsClearReq *clear_stats_req;
11980
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011981 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011982 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011983 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011984 "statsClearReqMask = 0x%X",
11985 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011986 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011987 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011988 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11989 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11990 "%s: invalid staId %d",
11991 __func__, pclearStatsReq->staId);
11992 return QDF_STATUS_E_INVAL;
11993 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011994
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011995 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996
11997 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011999 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
12000 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012001 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012002 }
12003
12004 *clear_stats_req = *pclearStatsReq;
12005
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012006 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012007 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012008 message.bodyptr = clear_stats_req;
12009 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012010 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012011 NO_SESSION, message.type));
12012 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12013 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012014 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012016 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
12017 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012018 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012019 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012020 }
12021 sme_release_global_lock(&pMac->sme);
12022 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012023 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12024 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012025 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012026 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012027 }
12028
12029 return status;
12030}
12031
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012032/*
12033 * sme_ll_stats_set_req() -
12034 * SME API to set the Link Layer Statistics
12035 *
12036 * hHal
12037 * psetStatsReq: Link Layer set stats request params structure
12038 * Return QDF_STATUS
12039 */
12040QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
12041 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012043 QDF_STATUS status = QDF_STATUS_SUCCESS;
12044 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012045 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012046 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012047 tSirLLStatsSetReq *set_stats_req;
12048
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012050 "%s: MPDU Size = %u", __func__,
12051 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012052 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012053 " Aggressive Stats Collections = %u",
12054 psetStatsReq->aggressiveStatisticsGathering);
12055
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012056 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012057
12058 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012059 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012060 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
12061 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012062 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012063 }
12064
12065 *set_stats_req = *psetStatsReq;
12066
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012067 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012068 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012069 message.bodyptr = set_stats_req;
12070 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012071 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012072 NO_SESSION, message.type));
12073 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12074 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012075 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012077 "%s: not able to post WMA_LL_STATS_SET_REQ",
12078 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012079 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012080 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012081 }
12082 sme_release_global_lock(&pMac->sme);
12083 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12085 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012086 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012087 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012088 }
12089
12090 return status;
12091}
12092
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012093/*
12094 * sme_ll_stats_get_req() -
12095 * SME API to get the Link Layer Statistics
12096 *
12097 * hHal
12098 * pgetStatsReq: Link Layer get stats request params structure
12099 * Return QDF_STATUS
12100 */
12101QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
12102 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012103{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012104 QDF_STATUS status = QDF_STATUS_SUCCESS;
12105 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012106 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012107 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012108 tSirLLStatsGetReq *get_stats_req;
12109
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012110 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012111
12112 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012113 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012114 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
12115 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012116 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012117 }
12118
12119 *get_stats_req = *pgetStatsReq;
12120
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012121 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012122 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012123 message.bodyptr = get_stats_req;
12124 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012125 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012126 NO_SESSION, message.type));
12127 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12128 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012129 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012131 "%s: not able to post WMA_LL_STATS_GET_REQ",
12132 __func__);
12133
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012134 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012135 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012136
12137 }
12138 sme_release_global_lock(&pMac->sme);
12139 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012140 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12141 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012142 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012143 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012144 }
12145
12146 return status;
12147}
12148
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012149/*
12150 * sme_set_link_layer_stats_ind_cb() -
12151 * SME API to trigger the stats are available after get request
12152 *
12153 * hHal
12154 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012155 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012156 * Return QDF_STATUS
12157 */
12158QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12159 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12160{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012161 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012162 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12163
12164 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012165 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12167 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012168 } else
12169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12170 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012171
12172 return status;
12173}
12174
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012175/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012176 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12177 * @hal: Mac global handle
12178 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12179 * status notification from FW
12180 *
12181 * Return: eHalStatus
12182 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012183QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12184 (tHddHandle callback_ctx, tSirLLStatsResults
12185 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012186{
12187 QDF_STATUS status;
12188 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12189
12190 status = sme_acquire_global_lock(&mac->sme);
12191 if (status == QDF_STATUS_SUCCESS) {
12192 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12193 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012194 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12196 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012197 return status;
12198}
12199
12200/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012201 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12202 * indication
12203 * @h_hal: Hal Handle
12204 *
12205 * This function reset's the link layer stats indication
12206 *
12207 * Return: QDF_STATUS Enumeration
12208 */
12209
12210QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12211{
12212 QDF_STATUS status;
12213 tpAniSirGlobal pmac;
12214
12215 if (!h_hal) {
12216 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12217 FL("hHal is not valid"));
12218 return QDF_STATUS_E_INVAL;
12219 }
12220 pmac = PMAC_STRUCT(h_hal);
12221
12222 status = sme_acquire_global_lock(&pmac->sme);
12223 if (QDF_IS_STATUS_SUCCESS(status)) {
12224 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12225 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012226 } else
12227 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12228 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012229
12230 return status;
12231}
12232
Zhang Qian73c348a2017-03-13 16:15:55 +080012233/**
12234 * sme_ll_stats_set_thresh - set threshold for mac counters
12235 * @hal, hal layer handle
12236 * @threshold, threshold for mac counters
12237 *
12238 * Return: QDF_STATUS Enumeration
12239 */
12240QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12241 struct sir_ll_ext_stats_threshold *threshold)
12242{
12243 QDF_STATUS status;
12244 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080012245 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080012246 struct sir_ll_ext_stats_threshold *thresh;
12247
12248 if (!threshold) {
12249 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12250 FL("threshold is not valid"));
12251 return QDF_STATUS_E_INVAL;
12252 }
12253
12254 if (!hal) {
12255 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12256 FL("hal is not valid"));
12257 return QDF_STATUS_E_INVAL;
12258 }
12259 mac = PMAC_STRUCT(hal);
12260
12261 thresh = qdf_mem_malloc(sizeof(*thresh));
12262 if (!thresh) {
12263 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12264 "%s: Fail to alloc mem", __func__);
12265 return QDF_STATUS_E_NOMEM;
12266 }
12267 *thresh = *threshold;
12268
12269 status = sme_acquire_global_lock(&mac->sme);
12270 if (QDF_IS_STATUS_SUCCESS(status)) {
12271 /* Serialize the req through MC thread */
12272 message.bodyptr = thresh;
12273 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12274 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12275 NO_SESSION, message.type));
12276 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12277 if (!QDF_IS_STATUS_SUCCESS(status)) {
12278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12279 "%s: not able to post WDA_LL_STATS_GET_REQ",
12280 __func__);
12281 qdf_mem_free(thresh);
12282 }
12283 sme_release_global_lock(&mac->sme);
12284 } else {
12285 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12286 FL("sme_acquire_global_lock error"));
12287 qdf_mem_free(thresh);
12288 }
12289 return status;
12290}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012292#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12293
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012294#ifdef WLAN_POWER_DEBUGFS
12295/**
12296 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12297 * @callback_fn: Pointer to the callback function for Power stats event
12298 * @power_stats_context: Pointer to context
12299 *
12300 * Return: QDF_STATUS
12301 */
12302QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12303 (struct power_stats_response *response,
12304 void *context), void *power_stats_context)
12305{
12306 QDF_STATUS status = QDF_STATUS_SUCCESS;
12307 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012308 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012309
12310 status = sme_acquire_global_lock(&mac_ctx->sme);
12311 if (QDF_IS_STATUS_SUCCESS(status)) {
12312 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012313 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012314 sme_release_global_lock(&mac_ctx->sme);
12315 return QDF_STATUS_E_FAILURE;
12316 }
12317
12318 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12319 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12320 msg.bodyptr = NULL;
12321 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012322 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012323 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012324 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012325 sme_release_global_lock(&mac_ctx->sme);
12326 }
12327 return status;
12328}
12329#endif
12330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012331#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012332/*
12333 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12334 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12335 *
12336 * hHal - The handle returned by mac_open.
12337 * nRoamOffloadEnabled - The bool to update with
12338 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12339 * Other status means SME is failed to update.
12340 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012341
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012342QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012343 bool nRoamOffloadEnabled)
12344{
12345 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012346 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012347
12348 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012349 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012350 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012351 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12352 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12353 nRoamOffloadEnabled);
12354 pMac->roam.configParam.isRoamOffloadEnabled =
12355 nRoamOffloadEnabled;
12356 sme_release_global_lock(&pMac->sme);
12357 }
12358
12359 return status;
12360}
12361
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012362/**
12363 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12364 * This is a synchronous call
12365 * @hal_ctx: The handle returned by mac_open.
12366 * @session_id: Session Identifier
12367 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012368 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012369 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12370 * Other status means SME is failed to update.
12371 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012372
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012373QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012374 uint8_t session_id,
12375 bool key_mgmt_offload_enabled,
12376 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012377{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012378 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012379 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012380
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012381 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012382 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012383 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012384 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012385 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12386 __func__, key_mgmt_offload_enabled);
12387 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12388 session_id,
12389 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012390 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012391 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012392 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012393 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012394 }
12395
12396 return status;
12397}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012398#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012399
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012400/*
12401 * sme_get_temperature() -
12402 * SME API to get the pdev temperature
12403 *
12404 * hHal
12405 * temperature context
12406 * pCallbackfn: callback fn with response (temperature)
12407 * Return QDF_STATUS
12408 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012409QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012410 void *tempContext,
12411 void (*pCallbackfn)(int temperature,
12412 void *pContext))
12413{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012414 QDF_STATUS status = QDF_STATUS_SUCCESS;
12415 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012416 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012417 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012418
12419 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012420 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421 if ((NULL == pCallbackfn) &&
12422 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012423 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012424 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012425 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012426 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012427 } else if (NULL != pCallbackfn) {
12428 pMac->sme.pTemperatureCbContext = tempContext;
12429 pMac->sme.pGetTemperatureCb = pCallbackfn;
12430 }
12431 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012432 message.bodyptr = NULL;
12433 message.type = WMA_GET_TEMPERATURE_REQ;
12434 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12435 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012436 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012439 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440 }
12441 sme_release_global_lock(&pMac->sme);
12442 }
12443 return status;
12444}
12445
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012446/*
12447 * sme_set_scanning_mac_oui() -
12448 * SME API to set scanning mac oui
12449 *
12450 * hHal
12451 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12452 * Return QDF_STATUS
12453 */
12454QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12455 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012456{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012457 QDF_STATUS status = QDF_STATUS_SUCCESS;
12458 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012460 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012461
12462 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012463 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012465 message.bodyptr = pScanMacOui;
12466 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12467 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12468 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012469 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012470 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012471 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012472 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473 }
12474 sme_release_global_lock(&pMac->sme);
12475 }
12476 return status;
12477}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012478
12479#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012480/*
12481 * sme_set_dhcp_srv_offload() -
12482 * SME API to set DHCP server offload info
12483 *
12484 * hHal
12485 * pDhcpSrvInfo : DHCP server offload info struct
12486 * Return QDF_STATUS
12487 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012488QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012489 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12490{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012491 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012492 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012493 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12495
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012496 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012497
12498 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012500 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12501 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012502 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012503 }
12504
12505 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12506
12507 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012508 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012509 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012510 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12511 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012512
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012513 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012514 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12515 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012516 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012517 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012518 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012519 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012520 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012521 }
12522 sme_release_global_lock(&pMac->sme);
12523 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012524 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012525 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012526 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012527 }
12528
12529 return status;
12530}
12531#endif /* DHCP_SERVER_OFFLOAD */
12532
Krunal Soniaadaa272017-10-04 16:42:55 -070012533QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12534 uint32_t arg_count, uint32_t *arg)
12535{
12536 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12537 arg_count, arg);
12538}
12539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012540#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012541/*
12542 * sme_set_led_flashing() -
12543 * API to set the Led flashing parameters.
12544 *
12545 * hHal - The handle returned by mac_open.
12546 * x0, x1 - led flashing parameters
12547 * Return QDF_STATUS
12548 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012549QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012550 uint32_t x0, uint32_t x1)
12551{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012552 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012553 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012554 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012555 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012556
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012557 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012558 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012559 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012560 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012561 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562 }
12563
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012564 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012565 ledflashing->pattern_id = type;
12566 ledflashing->led_x0 = x0;
12567 ledflashing->led_x1 = x1;
12568
12569 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012570 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012571 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012572 message.bodyptr = ledflashing;
12573 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012574 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012575 sme_release_global_lock(&pMac->sme);
12576 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012577 if (!QDF_IS_STATUS_SUCCESS(status))
12578 qdf_mem_free(ledflashing);
12579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012580 return status;
12581}
12582#endif
12583
12584/**
12585 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12586 * @h_hal: corestack handler
12587 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012588 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012590QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012591{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012592 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012593 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12594
12595 status = sme_acquire_global_lock(&mac->sme);
12596
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012597 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012598
12599 mac->scan.fEnableDFSChnlScan = dfs_flag;
12600
12601 /* update the channel list to the firmware */
12602 status = csr_update_channel_list(mac);
12603
12604 sme_release_global_lock(&mac->sme);
12605 }
12606
12607 return status;
12608}
12609
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012610#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12611/**
12612 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12613 * concurreny rules set to avoid channel interference.
12614 * @hal - Hal context
12615 * @sap_ch - channel to switch
12616 * @sap_phy_mode - phy mode of SAP
12617 * @cc_switch_mode - concurreny switch mode
12618 * @session_id - sme session id.
12619 *
12620 * Return: true if there is no channel interference else return false
12621 */
12622bool sme_validate_sap_channel_switch(tHalHandle hal,
12623 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12624 uint8_t session_id)
12625{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012626 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012627 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012628 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012629 uint16_t intf_channel = 0;
12630
12631 if (!session)
12632 return false;
12633
12634 session->ch_switch_in_progress = true;
12635 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012636 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012637 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12638 sap_phy_mode,
12639 cc_switch_mode);
12640 sme_release_global_lock(&mac->sme);
12641 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012643 FL("sme_acquire_global_lock error!"));
12644 session->ch_switch_in_progress = false;
12645 return false;
12646 }
12647
12648 session->ch_switch_in_progress = false;
12649 return (intf_channel == 0) ? true : false;
12650}
12651#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012652
12653/**
12654 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12655 * @hal: hal
12656 * @session_id: session ID
12657 * @stats_avg_factor: average stats factor
12658 *
12659 * This function configures the stats avg factor in firmware
12660 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012661 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012662 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012663QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012664 uint16_t stats_avg_factor)
12665{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012666 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012667 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012668 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12669 struct sir_stats_avg_factor *stats_factor;
12670
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012671 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012672
12673 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012674 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012675 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12676 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012677 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012678 }
12679
12680 status = sme_acquire_global_lock(&mac->sme);
12681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012682 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012683
12684 stats_factor->vdev_id = session_id;
12685 stats_factor->stats_avg_factor = stats_avg_factor;
12686
12687 /* serialize the req through MC thread */
12688 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12689 msg.bodyptr = stats_factor;
12690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012691 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012692 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012694 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12695 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012696 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012697 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012698 }
12699 sme_release_global_lock(&mac->sme);
12700 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012701 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012702 "%s: sme_acquire_global_lock error!",
12703 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012704 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012705 }
12706
12707 return status;
12708}
12709
12710/**
12711 * sme_configure_guard_time() - function to configure guard time
12712 * @hal: hal
12713 * @session_id: session id
12714 * @guard_time: guard time
12715 *
12716 * This function configures the guard time in firmware
12717 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012718 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012719 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012720QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012721 uint32_t guard_time)
12722{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012723 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012724 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012725 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12726 struct sir_guard_time_request *g_time;
12727
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012728 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729
12730 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012731 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012732 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12733 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012734 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012735 }
12736
12737 status = sme_acquire_global_lock(&mac->sme);
12738
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012739 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012740
12741 g_time->vdev_id = session_id;
12742 g_time->guard_time = guard_time;
12743
12744 /* serialize the req through MC thread */
12745 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12746 msg.bodyptr = g_time;
12747
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012748 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012749 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012750 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012751 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12752 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012753 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012754 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012755 }
12756 sme_release_global_lock(&mac->sme);
12757 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012759 "%s: sme_acquire_global_lock error!",
12760 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012761 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012762 }
12763
12764 return status;
12765}
12766
12767/**
12768 * sme_configure_modulated_dtim() - function to configure modulated dtim
12769 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12770 * @session_id: session ID
12771 * @modulated_dtim: modulated dtim value
12772 *
12773 * This function configures the modulated dtim in firmware
12774 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012775 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012776 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012777QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012778 uint32_t modulated_dtim)
12779{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012780 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012781 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012782 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12783 wma_cli_set_cmd_t *iwcmd;
12784
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012785 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012787 QDF_TRACE(QDF_MODULE_ID_SME,
12788 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012789 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012790 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012791 }
12792
12793 status = sme_acquire_global_lock(&mac->sme);
12794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012795 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012797 iwcmd->param_value = modulated_dtim;
12798 iwcmd->param_vdev_id = session_id;
12799 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12800 iwcmd->param_vp_dev = GEN_CMD;
12801 msg.type = WMA_CLI_SET_CMD;
12802 msg.reserved = 0;
12803 msg.bodyptr = (void *)iwcmd;
12804
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012805 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012806 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012808 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12809 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012810 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012811 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012812 }
12813 sme_release_global_lock(&mac->sme);
12814 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012816 "%s: sme_acquire_global_lock error!",
12817 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012818 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012819 }
12820
12821 return status;
12822}
12823
Mukul Sharma6398b252017-05-01 17:58:12 +053012824/**
12825 * sme_override_listen_interval() - function to override static LI
12826 * @h_hal: SME API to override listen interval
12827 * @session_id: session ID
12828 * @override_li: new LI value passed by user
12829 *
12830 * This function override (enable/disable) static a.k.a ini based LI
12831 *
12832 * Return: QDF_STATUS
12833 */
12834QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12835 uint32_t override_li)
12836{
12837 struct scheduler_msg msg = {0};
12838 QDF_STATUS status = QDF_STATUS_SUCCESS;
12839 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12840 wma_cli_set_cmd_t *iwcmd;
12841
12842 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12843 if (!iwcmd) {
12844 QDF_TRACE(QDF_MODULE_ID_SME,
12845 QDF_TRACE_LEVEL_FATAL,
12846 "%s: qdf_mem_malloc failed", __func__);
12847 return QDF_STATUS_E_NOMEM;
12848 }
12849
12850 status = sme_acquire_global_lock(&mac->sme);
12851
12852 if (status == QDF_STATUS_SUCCESS) {
12853
12854 iwcmd->param_value = override_li;
12855 iwcmd->param_vdev_id = session_id;
12856 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12857 iwcmd->param_vp_dev = GEN_CMD;
12858 msg.type = WMA_CLI_SET_CMD;
12859 msg.reserved = 0;
12860 msg.bodyptr = (void *)iwcmd;
12861
12862 if (!QDF_IS_STATUS_SUCCESS(
12863 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12864 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12865 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12866 __func__);
12867 qdf_mem_free(iwcmd);
12868 status = QDF_STATUS_E_FAILURE;
12869 }
12870 sme_release_global_lock(&mac->sme);
12871 } else {
12872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12873 "%s: sme_acquire_global_lock error!",
12874 __func__);
12875 qdf_mem_free(iwcmd);
12876 }
12877
12878 return status;
12879}
12880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012881/*
12882 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12883 * to either start/stop logging
12884 * @hal: HAL context
12885 * @start_log: Structure containing the wifi start logger params
12886 *
12887 * This function sends the start/stop logging command to WMA
12888 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012889 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012890 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012891QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012892 struct sir_wifi_start_log start_log)
12893{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012894 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012895 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012896 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012897 struct sir_wifi_start_log *req_msg;
12898 uint32_t len;
12899
12900 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012901 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012902 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012903 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012904 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012905 }
12906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012907 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012908 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012909 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012910 req_msg->ini_triggered = start_log.ini_triggered;
12911 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012912 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012913 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012914
12915 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012916 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012917 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012918 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012919 return status;
12920 }
12921
12922 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012923 message.bodyptr = req_msg;
12924 message.type = SIR_HAL_START_STOP_LOGGING;
12925 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012926 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012927 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012928 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012929 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012930 }
12931 sme_release_global_lock(&mac->sme);
12932
12933 return status;
12934}
12935
12936/**
12937 * sme_neighbor_middle_of_roaming() - Function to know if
12938 * STA is in the middle of roaming states
12939 * @hal: Handle returned by macOpen
12940 * @sessionId: sessionId of the STA session
12941 *
12942 * This function is a wrapper to call
12943 * csr_neighbor_middle_of_roaming to know STA is in the
12944 * middle of roaming states
12945 *
12946 * Return: True or False
12947 *
12948 */
12949bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12950{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012951 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12952 bool val = false;
12953
12954 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12955 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12956 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012957 sme_err("Invalid Session: %d", sessionId);
12958
Sandeep Puligillaca631612016-11-08 11:53:52 -080012959 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012960}
12961
12962/*
12963 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12964 * @mac: MAC handle
12965 *
12966 * This function is used to send the command that will
12967 * be used to flush the logs in the firmware
12968 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012969 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012970 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012971QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012972{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012973 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012974 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012976 /* Serialize the req through MC thread */
12977 message.bodyptr = NULL;
12978 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012979 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012980 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012981 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012982 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012983 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012984 return status;
12985}
12986
Jeff Johnsona1e92612017-09-24 15:33:44 -070012987QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012988 sme_ac_enum_type ac, uint8_t tid,
12989 uint8_t pri, uint32_t srvc_int,
12990 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012991 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012992 uint8_t psb, uint32_t sessionId,
12993 uint32_t delay_interval)
12994{
12995 void *wma_handle;
12996 t_wma_trigger_uapsd_params uapsd_params;
12997 enum uapsd_ac access_category;
12998
12999 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013000 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013001 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013002 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013003 }
13004
Anurag Chouhan6d760662016-02-20 16:05:43 +053013005 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013006 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013007 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013008 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013009 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010 }
13011
13012 switch (ac) {
13013 case SME_AC_BK:
13014 access_category = UAPSD_BK;
13015 break;
13016 case SME_AC_BE:
13017 access_category = UAPSD_BE;
13018 break;
13019 case SME_AC_VI:
13020 access_category = UAPSD_VI;
13021 break;
13022 case SME_AC_VO:
13023 access_category = UAPSD_VO;
13024 break;
13025 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013026 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013027 }
13028
13029 uapsd_params.wmm_ac = access_category;
13030 uapsd_params.user_priority = pri;
13031 uapsd_params.service_interval = srvc_int;
13032 uapsd_params.delay_interval = delay_interval;
13033 uapsd_params.suspend_interval = sus_int;
13034
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013035 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013036 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013037 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013038 "Failed to Trigger Uapsd params for sessionId %d",
13039 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013040 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013041 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013042 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013043}
13044
Jeff Johnsona1e92612017-09-24 15:33:44 -070013045QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013046 sme_ac_enum_type ac,
13047 uint32_t sessionId)
13048{
13049 void *wma_handle;
13050 enum uapsd_ac access_category;
13051
13052 switch (ac) {
13053 case SME_AC_BK:
13054 access_category = UAPSD_BK;
13055 break;
13056 case SME_AC_BE:
13057 access_category = UAPSD_BE;
13058 break;
13059 case SME_AC_VI:
13060 access_category = UAPSD_VI;
13061 break;
13062 case SME_AC_VO:
13063 access_category = UAPSD_VO;
13064 break;
13065 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013066 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013067 }
13068
Anurag Chouhan6d760662016-02-20 16:05:43 +053013069 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013070 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013071 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013072 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013073 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013074 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013075 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013076 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013078 "Failed to disable uapsd for ac %d for sessionId %d",
13079 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013080 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013081 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013082 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013083}
13084
13085/**
13086 * sme_update_nss() - SME API to change the number for spatial streams
13087 * (1 or 2)
13088 * @hal: Handle returned by mac open
13089 * @nss: Number of spatial streams
13090 *
13091 * This function is used to update the number of spatial streams supported.
13092 *
13093 * Return: Success upon successfully changing nss else failure
13094 *
13095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013096QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013097{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013098 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013099 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13100 uint32_t i, value = 0;
13101 union {
13102 uint16_t cfg_value16;
13103 tSirMacHTCapabilityInfo ht_cap_info;
13104 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013105 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013106
13107 status = sme_acquire_global_lock(&mac_ctx->sme);
13108
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013109 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013110 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13111
13112 /* get the HT capability info*/
13113 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13114 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13115
13116 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13117 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13118 csr_session = &mac_ctx->roam.roamSession[i];
13119 csr_session->htConfig.ht_tx_stbc =
13120 uHTCapabilityInfo.ht_cap_info.txSTBC;
13121 }
13122 }
13123
13124 sme_release_global_lock(&mac_ctx->sme);
13125 }
13126 return status;
13127}
13128
13129/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013130 * sme_update_user_configured_nss() - sets the nss based on user request
13131 * @hal: Pointer to HAL
13132 * @nss: number of streams
13133 *
13134 * Return: None
13135 */
13136void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13137{
13138 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13139
13140 mac_ctx->user_configured_nss = nss;
13141}
13142
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013143#ifdef WLAN_FEATURE_11AX
13144void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
13145 uint8_t nss)
13146{
13147 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13148 struct csr_roam_session *csr_session;
13149 uint32_t tx_mcs_map = 0;
13150 uint32_t rx_mcs_map = 0;
13151
13152 if (!nss || (nss > 2)) {
13153 sme_err("invalid Nss value %d", nss);
13154 }
13155 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13156 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
13157 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
13158 if (nss == 1) {
13159 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
13160 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
13161 } else {
13162 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_0_11, 2);
13163 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_0_11, 2);
13164 }
13165 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
13166 rx_mcs_map, tx_mcs_map);
13167 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
13168 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
13169 csr_update_session_he_cap(mac_ctx, csr_session);
13170
13171}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080013172
13173int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
13174{
13175 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13176 struct csr_roam_session *csr_session;
13177 uint16_t mcs_val = 0;
13178 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
13179 uint32_t wni_cfg_tx_param = 0;
13180 uint32_t wni_cfg_rx_param = 0;
13181
13182 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13183 if (!csr_session) {
13184 sme_err("No session for id %d", session_id);
13185 return -EINVAL;
13186 }
13187 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
13188 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
13189 he_mcs);
13190 return -EINVAL;
13191 }
13192 mcs_val = he_mcs & 0x3;
13193 switch (he_mcs) {
13194 case HE_80_MCS0_7:
13195 case HE_80_MCS0_9:
13196 case HE_80_MCS0_11:
13197 if (mac_ctx->roam.configParam.enable2x2) {
13198 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13199 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
13200 } else {
13201 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13202 }
13203 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
13204 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
13205 break;
13206
13207 case HE_160_MCS0_7:
13208 case HE_160_MCS0_9:
13209 case HE_160_MCS0_11:
13210 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13211 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
13212 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
13213 break;
13214
13215 case HE_80p80_MCS0_7:
13216 case HE_80p80_MCS0_9:
13217 case HE_80p80_MCS0_11:
13218 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13219 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
13220 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
13221 break;
13222
13223 default:
13224 sme_err("Invalid HE MCS 0x%0x", he_mcs);
13225 return -EINVAL;
13226 }
13227 sme_info("new HE MCS 0x%0x", mcs_map);
13228 sme_cfg_set_int(mac_ctx, wni_cfg_tx_param, mcs_map);
13229 sme_cfg_set_int(mac_ctx, wni_cfg_rx_param, mcs_map);
13230 csr_update_session_he_cap(mac_ctx, csr_session);
13231
13232 return 0;
13233}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013234
13235static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
13236 uint16_t he_cap, int value)
13237{
13238 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13239 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013240
13241 session = CSR_GET_SESSION(mac_ctx, session_id);
13242 if (!session) {
13243 sme_err("No session for id %d", session_id);
13244 return -EINVAL;
13245 }
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013246 sme_cfg_set_int(mac_ctx, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013247 csr_update_session_he_cap(mac_ctx, session);
13248
13249 return 0;
13250}
13251
13252int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13253{
13254 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013255 uint32_t he_cap_val = 0;
13256
13257 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013258
13259 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013260 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013261 if (ret)
13262 return ret;
13263
13264 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013265 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013266}
13267
13268int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13269{
13270 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013271 uint32_t he_cap_val = 0;
13272
13273 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013274
13275 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013276 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013277 if (ret)
13278 return ret;
13279
13280 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013281 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
13282}
13283
13284int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
13285 uint16_t he_frag)
13286{
13287 return sme_update_he_cap(hal, session_id,
13288 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013289}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013290#endif
13291
Archana Ramachandran5041b252016-04-25 14:29:25 -070013292/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013293 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13294 * @hal: global hal handle
13295 * @cb: callback function pointer
13296 *
13297 * This function stores nud debug stats callback function.
13298 *
13299 * Return: QDF_STATUS enumeration.
13300 */
13301QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13302 void (*cb)(void *, struct rsp_stats *))
13303{
13304 QDF_STATUS status = QDF_STATUS_SUCCESS;
13305 tpAniSirGlobal mac;
13306
13307 if (!hal) {
13308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13309 FL("hal is not valid"));
13310 return QDF_STATUS_E_INVAL;
13311 }
13312 mac = PMAC_STRUCT(hal);
13313
13314 status = sme_acquire_global_lock(&mac->sme);
13315 if (!QDF_IS_STATUS_SUCCESS(status)) {
13316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13317 FL("sme_acquire_global_lock failed!(status=%d)"),
13318 status);
13319 return status;
13320 }
13321
13322 mac->sme.get_arp_stats_cb = cb;
13323 sme_release_global_lock(&mac->sme);
13324 return status;
13325}
13326
13327/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013328 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013329 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013330 * @cb: callback function pointer
13331 *
13332 * This function stores the rssi threshold breached callback function.
13333 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013334 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013335 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013336QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013337 void (*cb)(void *, struct rssi_breach_event *))
13338{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013339 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013340 tpAniSirGlobal mac;
13341
13342 if (!h_hal) {
13343 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13344 FL("hHal is not valid"));
13345 return QDF_STATUS_E_INVAL;
13346 }
13347 mac = PMAC_STRUCT(h_hal);
13348
13349 status = sme_acquire_global_lock(&mac->sme);
13350 if (!QDF_IS_STATUS_SUCCESS(status)) {
13351 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13352 FL("sme_acquire_global_lock failed!(status=%d)"),
13353 status);
13354 return status;
13355 }
13356
13357 mac->sme.rssi_threshold_breached_cb = cb;
13358 sme_release_global_lock(&mac->sme);
13359 return status;
13360}
13361
13362/**
13363 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13364 * @hal: global hal handle
13365 *
13366 * This function de-registers the rssi threshold breached callback function.
13367 *
13368 * Return: QDF_STATUS enumeration.
13369 */
13370QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13371{
13372 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013373 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13374
13375 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013376 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013377 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 return status;
13379 }
13380
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013381 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013382 sme_release_global_lock(&mac->sme);
13383 return status;
13384}
13385
13386/**
13387 * sme_is_any_session_in_connected_state() - SME wrapper API to
13388 * check if any session is in connected state or not.
13389 *
13390 * @hal: Handle returned by mac open
13391 *
13392 * This function is used to check if any valid sme session is in
13393 * connected state or not.
13394 *
13395 * Return: true if any session is connected, else false.
13396 *
13397 */
13398bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13399{
13400 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013401 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013402 bool ret = false;
13403
13404 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013405 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013406 ret = csr_is_any_session_in_connect_state(mac_ctx);
13407 sme_release_global_lock(&mac_ctx->sme);
13408 }
13409 return ret;
13410}
13411
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013412QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13413 void (*cb)(void *,
13414 struct chip_pwr_save_fail_detected_params *)) {
13415
13416 QDF_STATUS status = QDF_STATUS_SUCCESS;
13417 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13418
13419 status = sme_acquire_global_lock(&mac->sme);
13420 if (status != QDF_STATUS_SUCCESS) {
13421 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13422 return status;
13423 }
13424 mac->sme.chip_power_save_fail_cb = cb;
13425 sme_release_global_lock(&mac->sme);
13426 return status;
13427}
13428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429/**
13430 * sme_set_rssi_monitoring() - set rssi monitoring
13431 * @hal: global hal handle
13432 * @input: request message
13433 *
13434 * This function constructs the vos message and fill in message type,
13435 * bodyptr with @input and posts it to WDA queue.
13436 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013437 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013438 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013439QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013440 struct rssi_monitor_req *input)
13441{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013442 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013443 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013444 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013445 struct rssi_monitor_req *req_msg;
13446
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013447 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013448 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013449 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013450 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013451 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013452 }
13453
13454 *req_msg = *input;
13455
13456 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013457 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013458 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013459 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 return status;
13461 }
13462
13463 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013464 message.bodyptr = req_msg;
13465 message.type = WMA_SET_RSSI_MONITOR_REQ;
13466 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013467 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013468 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013469 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013470 }
13471 sme_release_global_lock(&mac->sme);
13472
13473 return status;
13474}
13475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013476/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013477 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 * @hal: Handle returned by macOpen
13479 * @msg: PCL channel list and length structure
13480 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013481 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013482 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013483 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013484QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013485{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013486 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013487 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013488 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013489 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013490 uint32_t len, i;
13491
Krunal Soni3fa80e22018-01-09 14:16:02 -080013492 if (!mac) {
13493 sme_err("mac is NULL");
13494 return QDF_STATUS_E_FAILURE;
13495 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013496 len = sizeof(*req_msg);
13497
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013498 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013499 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013500 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013501 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013502 }
13503
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013504 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013505 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013506 req_msg->weight_list[i] = msg.weight_list[i];
13507 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013508
13509 req_msg->pcl_len = msg.pcl_len;
13510
13511 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013512 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013513 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013514 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013515 return status;
13516 }
13517
13518 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013519 message.bodyptr = req_msg;
13520 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13521 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013522 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013523 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013524 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013525 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013526 }
13527 sme_release_global_lock(&mac->sme);
13528
13529 return status;
13530}
13531
13532/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013533 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013534 * @hal: Handle returned by macOpen
13535 * @msg: HW mode structure containing hw mode and callback details
13536 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013537 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013538 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013539 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013540QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013541{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013542 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013543 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013544 tSmeCmd *cmd = NULL;
13545
Krunal Soni3fa80e22018-01-09 14:16:02 -080013546 if (!mac) {
13547 sme_err("mac is NULL");
13548 return QDF_STATUS_E_FAILURE;
13549 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013550 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013551 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013552 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013553 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013554 }
13555
Krunal Soni78618d92017-02-14 21:46:31 -080013556 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013557 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013558 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013559 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013560 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013561 }
13562
13563 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013564 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013565 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13566 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013567 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13568 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013569 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013570 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013571
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013572 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013573 cmd->u.set_hw_mode_cmd.session_id,
13574 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013575 csr_queue_sme_command(mac, cmd, false);
13576
13577 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013578 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013579}
13580
13581/**
13582 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13583 * @hal: Handle returned by macOpen
13584 * @callback: HDD callback to be registered
13585 *
13586 * Registers the HDD callback with SME. This callback will be invoked when
13587 * HW mode transition event is received from the FW
13588 *
13589 * Return: None
13590 */
13591void sme_register_hw_mode_trans_cb(tHalHandle hal,
13592 hw_mode_transition_cb callback)
13593{
13594 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13595
13596 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013597}
13598
13599/**
13600 * sme_nss_update_request() - Send beacon templete update to FW with new
13601 * nss value
13602 * @hal: Handle returned by macOpen
13603 * @vdev_id: the session id
13604 * @new_nss: the new nss value
13605 * @cback: hdd callback
13606 * @next_action: next action to happen at policy mgr after beacon update
13607 *
13608 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013609 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013610 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013611QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13612 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13613 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13614 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013615{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013616 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013617 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013618 tSmeCmd *cmd = NULL;
13619
Krunal Soni3fa80e22018-01-09 14:16:02 -080013620 if (!mac) {
13621 sme_err("mac is null");
13622 return status;
13623 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013624 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013625 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013626 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013627 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013628 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013629 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013630 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013631 }
13632 cmd->command = e_sme_command_nss_update;
13633 /* Sessionized modules may require this info */
13634 cmd->sessionId = vdev_id;
13635 cmd->u.nss_update_cmd.new_nss = new_nss;
13636 cmd->u.nss_update_cmd.session_id = vdev_id;
13637 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013638 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013639 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013640 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013641
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013642 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013643 csr_queue_sme_command(mac, cmd, false);
13644 sme_release_global_lock(&mac->sme);
13645 }
13646 return status;
13647}
13648
13649/**
13650 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13651 * @hal: Handle returned by macOpen
13652 * @msg: Structure containing the dual mac config parameters
13653 *
13654 * Queues configuration information to CSR to configure
13655 * WLAN firmware for the dual MAC features
13656 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013657 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013658 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013659QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013660{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013661 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013662 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013663 tSmeCmd *cmd;
13664
Krunal Soni3fa80e22018-01-09 14:16:02 -080013665 if (!mac) {
13666 sme_err("mac is null");
13667 return QDF_STATUS_E_FAILURE;
13668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013670 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013671 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013672 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013673 }
13674
Krunal Soni78618d92017-02-14 21:46:31 -080013675 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013676 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013677 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013679 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013680 }
13681
13682 cmd->command = e_sme_command_set_dual_mac_config;
13683 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13684 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13685 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13686
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013687 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013688 cmd->u.set_dual_mac_cmd.scan_config,
13689 cmd->u.set_dual_mac_cmd.fw_mode_config);
13690 csr_queue_sme_command(mac, cmd, false);
13691
13692 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013693 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013694}
13695
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013696#ifdef FEATURE_LFR_SUBNET_DETECTION
13697/**
13698 * sme_gateway_param_update() - to update gateway parameters with WMA
13699 * @Hal: hal handle
13700 * @gw_params: request parameters from HDD
13701 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013702 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013703 *
13704 * This routine will update gateway parameters to WMA
13705 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013706QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013707 struct gateway_param_update_req *gw_params)
13708{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013709 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013710 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013711 struct gateway_param_update_req *request_buf;
13712
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013713 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013714 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013716 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013717 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013718 }
13719
13720 *request_buf = *gw_params;
13721
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013722 message.type = WMA_GW_PARAM_UPDATE_REQ;
13723 message.reserved = 0;
13724 message.bodyptr = request_buf;
13725 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013726 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013728 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013729 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013730 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013731 }
13732
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013733 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013734}
13735#endif /* FEATURE_LFR_SUBNET_DETECTION */
13736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013737/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013738 * sme_soc_set_antenna_mode() - set antenna mode
13739 * @hal: Handle returned by macOpen
13740 * @msg: Structure containing the antenna mode parameters
13741 *
13742 * Send the command to CSR to send
13743 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13744 *
13745 * Return: QDF_STATUS
13746 */
13747QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13748 struct sir_antenna_mode_param *msg)
13749{
13750 QDF_STATUS status = QDF_STATUS_SUCCESS;
13751 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13752 tSmeCmd *cmd;
13753
13754 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013755 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013756 return QDF_STATUS_E_FAILURE;
13757 }
13758
13759 status = sme_acquire_global_lock(&mac->sme);
13760 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013761 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013762 return QDF_STATUS_E_RESOURCES;
13763 }
13764
Krunal Soni78618d92017-02-14 21:46:31 -080013765 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013766 if (!cmd) {
13767 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013768 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013769 return QDF_STATUS_E_NULL_VALUE;
13770 }
13771
13772 cmd->command = e_sme_command_set_antenna_mode;
13773 cmd->u.set_antenna_mode_cmd = *msg;
13774
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013775 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013776 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13777 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13778
13779 csr_queue_sme_command(mac, cmd, false);
13780 sme_release_global_lock(&mac->sme);
13781
13782 return QDF_STATUS_SUCCESS;
13783}
13784
13785/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013786 * sme_set_peer_authorized() - call peer authorized callback
13787 * @peer_addr: peer mac address
13788 * @auth_cb: auth callback
13789 * @vdev_id: vdev id
13790 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013791 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013792 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013793QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013794 sme_peer_authorized_fp auth_cb,
13795 uint32_t vdev_id)
13796{
13797 void *wma_handle;
13798
Anurag Chouhan6d760662016-02-20 16:05:43 +053013799 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013800 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013801 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013802 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013803 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013804 }
13805
13806 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13807 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13808 1, vdev_id);
13809}
13810
13811/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013812 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013813 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013814 * @fcc_constraint: flag to enable/disable the constraint
13815 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013816 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013817 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013818 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013819QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13820 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013821{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013822 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013823 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13824
13825 status = sme_acquire_global_lock(&mac_ptr->sme);
13826
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013827 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013828
13829 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13830 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013831 if (scan_pending)
13832 mac_ptr->scan.defer_update_channel_list = true;
13833 else
13834 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013835 }
13836
13837 sme_release_global_lock(&mac_ptr->sme);
13838 }
13839
13840 return status;
13841}
13842/**
13843 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13844 * @hal: Global MAC pointer
13845 *
13846 * Return: NULL.
13847 */
13848void sme_setdef_dot11mode(tHalHandle hal)
13849{
13850 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013852 csr_set_default_dot11_mode(mac_ctx);
13853}
13854
13855/**
13856 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13857 * params
13858 * @hal_handle - The handle returned by macOpen.
13859 * @session_id - Session Identifier
13860 * @notify_id - Identifies 1 of the 4 parameters to be modified
13861 * @val New value of the parameter
13862 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013863 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013864 * Other status means SME failed to update
13865 */
13866
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013867QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013868 uint8_t session_id,
13869 uint32_t notify_id,
13870 int32_t val)
13871{
13872 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013873 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013874 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013875 tpCsrNeighborRoamControlInfo nr_info = NULL;
13876 uint32_t reason = 0;
13877
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013878 if (session_id >= CSR_ROAM_SESSION_MAX) {
13879 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13880 FL("Invalid sme session id: %d"), session_id);
13881 return QDF_STATUS_E_INVAL;
13882 }
13883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013884 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013885 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013886 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13887 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13888 switch (notify_id) {
13889 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013890 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013891 "%s: gRoamScanHirssiMaxCount %d => %d",
13892 __func__, nr_config->nhi_rssi_scan_max_count,
13893 val);
13894 nr_config->nhi_rssi_scan_max_count = val;
13895 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13896 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13897 break;
13898
13899 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013901 FL("gRoamScanHiRssiDelta %d => %d"),
13902 nr_config->nhi_rssi_scan_rssi_delta,
13903 val);
13904 nr_config->nhi_rssi_scan_rssi_delta = val;
13905 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13906 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13907 break;
13908
13909 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013910 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013911 FL("gRoamScanHiRssiDelay %d => %d"),
13912 nr_config->nhi_rssi_scan_delay,
13913 val);
13914 nr_config->nhi_rssi_scan_delay = val;
13915 nr_info->cfgParams.hi_rssi_scan_delay = val;
13916 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13917 break;
13918
13919 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013920 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013921 FL("gRoamScanHiRssiUpperBound %d => %d"),
13922 nr_config->nhi_rssi_scan_rssi_ub,
13923 val);
13924 nr_config->nhi_rssi_scan_rssi_ub = val;
13925 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13926 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13927 break;
13928
13929 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013930 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013931 FL("invalid parameter notify_id %d"),
13932 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013933 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013934 break;
13935 }
13936 sme_release_global_lock(&mac_ctx->sme);
13937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013938 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013939 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013940 csr_roam_offload_scan(mac_ctx, session_id,
13941 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13942 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013943
13944 return status;
13945}
13946
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013947/**
13948 * sme_update_tgt_services() - update the target services config.
13949 * @hal: HAL pointer.
13950 * @cfg: wma_tgt_services parameters.
13951 *
13952 * update the target services config.
13953 *
13954 * Return: None.
13955 */
13956void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13957{
13958 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13959
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013960 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013961 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013962 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013963 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013964 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013965 mac_ctx->is_fils_roaming_supported =
13966 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013967 mac_ctx->is_11k_offload_supported =
13968 cfg->is_11k_offload_supported;
13969 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13970 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13971 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013972}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013973
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013974/**
13975 * sme_is_session_id_valid() - Check if the session id is valid
13976 * @hal: Pointer to HAL
13977 * @session_id: Session id
13978 *
13979 * Checks if the session id is valid or not
13980 *
13981 * Return: True is the session id is valid, false otherwise
13982 */
13983bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13984{
13985 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013986
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013987 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13989 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013990 return false;
13991 }
13992
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013993 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013994 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013995
13996 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013997}
13998
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013999#ifdef FEATURE_WLAN_TDLS
14000
14001/**
14002 * sme_get_opclass() - determine operating class
14003 * @hal: Pointer to HAL
14004 * @channel: channel id
14005 * @bw_offset: bandwidth offset
14006 * @opclass: pointer to operating class
14007 *
14008 * Function will determine operating class from regdm_get_opclass_from_channel
14009 *
14010 * Return: none
14011 */
14012void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
14013 uint8_t *opclass)
14014{
14015 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14016
14017 /* redgm opclass table contains opclass for 40MHz low primary,
14018 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
14019 * first we will check if bit for 40MHz is set and if so find
14020 * matching opclass either with low primary or high primary
14021 * (a channel would never be in both) and then search for opclass
14022 * matching 20MHz, else for any BW.
14023 */
14024 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014025 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014026 mac_ctx->scan.countryCodeCurrent,
14027 channel, BW40_LOW_PRIMARY);
14028 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014029 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014030 mac_ctx->scan.countryCodeCurrent,
14031 channel, BW40_HIGH_PRIMARY);
14032 }
14033 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014034 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014035 mac_ctx->scan.countryCodeCurrent,
14036 channel, BW20);
14037 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014038 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014039 mac_ctx->scan.countryCodeCurrent,
14040 channel, BWALL);
14041 }
14042}
14043#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014044
Sandeep Puligillae0875662016-02-12 16:09:21 -080014045/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053014046 * sme_set_fw_test() - set fw test
14047 * @fw_test: fw test param
14048 *
14049 * Return: Return QDF_STATUS, otherwise appropriate failure code
14050 */
14051QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
14052{
14053 void *wma_handle;
14054
14055 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14056 if (!wma_handle) {
14057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14058 "wma handle is NULL");
14059 return QDF_STATUS_E_FAILURE;
14060 }
14061 wma_process_fw_test_cmd(wma_handle, fw_test);
14062 return QDF_STATUS_SUCCESS;
14063}
14064
14065/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080014066 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
14067 * @hal: mac handel
14068 * @vdev_id: vdev identifier
14069 *
14070 * Return: Return QDF_STATUS, otherwise appropriate failure code
14071 */
14072QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
14073{
14074 void *wma_handle;
14075
14076 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14077 if (!wma_handle) {
14078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14079 "wma handle is NULL");
14080 return QDF_STATUS_E_FAILURE;
14081 }
14082 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
14083 return QDF_STATUS_SUCCESS;
14084}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014085
14086/**
14087 * sme_update_mimo_power_save() - Update MIMO power save
14088 * configuration
14089 * @hal: The handle returned by macOpen
14090 * @is_ht_smps_enabled: enable/disable ht smps
14091 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080014092 * @send_smps_action: flag to send smps force mode command
14093 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014094 *
14095 * Return: QDF_STATUS if SME update mimo power save
14096 * configuration sucsess else failue status
14097 */
14098QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
14099 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080014100 uint8_t ht_smps_mode,
14101 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014102{
14103 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080014104
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014105 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080014106 is_ht_smps_enabled, ht_smps_mode,
14107 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014108 mac_ctx->roam.configParam.enableHtSmps =
14109 is_ht_smps_enabled;
14110 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080014111 mac_ctx->roam.configParam.send_smps_action =
14112 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014113
14114 return QDF_STATUS_SUCCESS;
14115}
14116
14117/**
14118 * sme_is_sta_smps_allowed() - check if the supported nss for
14119 * the session is greater than 1x1 to enable sta SMPS
14120 * @hal: The handle returned by macOpen
14121 * @session_id: session id
14122 *
14123 * Return: bool returns true if supported nss is greater than
14124 * 1x1 else false
14125 */
14126bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
14127{
14128 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014129 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014130
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014131 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
14132 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014133 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053014134 return false;
14135 }
14136
14137 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014138 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014139 return false;
14140 }
14141
14142 return (csr_session->supported_nss_1x1 == true) ? false : true;
14143}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014144
14145/**
14146 * sme_add_beacon_filter() - set the beacon filter configuration
14147 * @hal: The handle returned by macOpen
14148 * @session_id: session id
14149 * @ie_map: bitwise array of IEs
14150 *
14151 * Return: Return QDF_STATUS, otherwise appropriate failure code
14152 */
14153QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
14154 uint32_t session_id,
14155 uint32_t *ie_map)
14156{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014157 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014158 QDF_STATUS qdf_status;
14159 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14160 struct beacon_filter_param *filter_param;
14161
14162 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014163 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014164 return QDF_STATUS_E_FAILURE;
14165 }
14166
14167 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14168 if (NULL == filter_param) {
14169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14170 "%s: fail to alloc filter_param", __func__);
14171 return QDF_STATUS_E_FAILURE;
14172 }
14173
14174 filter_param->vdev_id = session_id;
14175
14176 qdf_mem_copy(filter_param->ie_map, ie_map,
14177 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14178
14179 message.type = WMA_ADD_BCN_FILTER_CMDID;
14180 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014181 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014182 &message);
14183 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14184 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14185 "%s: Not able to post msg to WDA!",
14186 __func__);
14187
14188 qdf_mem_free(filter_param);
14189 }
14190 return qdf_status;
14191}
14192
14193/**
14194 * sme_remove_beacon_filter() - set the beacon filter configuration
14195 * @hal: The handle returned by macOpen
14196 * @session_id: session id
14197 *
14198 * Return: Return QDF_STATUS, otherwise appropriate failure code
14199 */
14200QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14201{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014202 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014203 QDF_STATUS qdf_status;
14204 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14205 struct beacon_filter_param *filter_param;
14206
14207 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014208 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014209 return QDF_STATUS_E_FAILURE;
14210 }
14211
14212 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14213 if (NULL == filter_param) {
14214 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14215 "%s: fail to alloc filter_param", __func__);
14216 return QDF_STATUS_E_FAILURE;
14217 }
14218
14219 filter_param->vdev_id = session_id;
14220
14221 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14222 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014223 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014224 &message);
14225 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14226 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14227 "%s: Not able to post msg to WDA!",
14228 __func__);
14229
14230 qdf_mem_free(filter_param);
14231 }
14232 return qdf_status;
14233}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014234
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014235/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014236 * sme_send_disassoc_req_frame - send disassoc req
14237 * @hal: handler to hal
14238 * @session_id: session id
14239 * @peer_mac: peer mac address
14240 * @reason: reason for disassociation
14241 * wait_for_ack: wait for acknowledgment
14242 *
14243 * function to send disassoc request to lim
14244 *
14245 * return: none
14246 */
14247void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14248 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14249{
14250 struct sme_send_disassoc_frm_req *msg;
14251 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14252 A_UINT8 *buf;
14253 A_UINT16 tmp;
14254
14255 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14256
14257 if (NULL == msg)
14258 qdf_status = QDF_STATUS_E_FAILURE;
14259 else
14260 qdf_status = QDF_STATUS_SUCCESS;
14261
14262 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14263 return;
14264
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014265 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14266
14267 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14268
14269 buf = &msg->session_id;
14270
14271 /* session id */
14272 *buf = (A_UINT8) session_id;
14273 buf += sizeof(A_UINT8);
14274
14275 /* transaction id */
14276 *buf = 0;
14277 *(buf + 1) = 0;
14278 buf += sizeof(A_UINT16);
14279
14280 /* Set the peer MAC address before sending the message to LIM */
14281 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14282
14283 buf += QDF_MAC_ADDR_SIZE;
14284
14285 /* reasoncode */
14286 tmp = (uint16_t) reason;
14287 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14288 buf += sizeof(uint16_t);
14289
14290 *buf = wait_for_ack;
14291 buf += sizeof(uint8_t);
14292
Rajeev Kumard138ac52017-01-30 18:38:37 -080014293 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014294
14295 if (qdf_status != QDF_STATUS_SUCCESS)
14296 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14297 FL("cds_send_mb_message Failed"));
14298}
14299
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014300QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14301 bpf_get_offload_cb callback,
14302 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014303{
14304 QDF_STATUS status = QDF_STATUS_SUCCESS;
14305 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014306 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014307
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014308 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014309
14310 status = sme_acquire_global_lock(&mac_ctx->sme);
14311 if (QDF_STATUS_SUCCESS == status) {
14312 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014313 mac_ctx->sme.bpf_get_offload_cb = callback;
14314 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014315 cds_msg.bodyptr = NULL;
14316 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014317 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014318 if (!QDF_IS_STATUS_SUCCESS(status)) {
14319 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14320 FL("Post bpf get offload msg fail"));
14321 status = QDF_STATUS_E_FAILURE;
14322 }
14323 sme_release_global_lock(&mac_ctx->sme);
14324 } else {
14325 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14326 FL("sme_acquire_global_lock error"));
14327 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014328 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014329 return status;
14330}
14331
14332
14333/**
14334 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14335 * @hal: HAL handle
14336 * @bpf_set_offload: struct to set bpf filter instructions.
14337 *
14338 * Return: QDF_STATUS enumeration.
14339 */
14340QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14341 struct sir_bpf_set_offload *req)
14342{
14343 QDF_STATUS status = QDF_STATUS_SUCCESS;
14344 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014345 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014346 struct sir_bpf_set_offload *set_offload;
14347
Arun Khandavallica198b52016-04-26 20:53:35 +053014348 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14349 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014350
14351 if (NULL == set_offload) {
14352 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14353 FL("Failed to alloc set_offload"));
14354 return QDF_STATUS_E_NOMEM;
14355 }
14356
14357 set_offload->session_id = req->session_id;
14358 set_offload->filter_id = req->filter_id;
14359 set_offload->current_offset = req->current_offset;
14360 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014361 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014362 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014363 set_offload->program = ((uint8_t *)set_offload) +
14364 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014365 qdf_mem_copy(set_offload->program, req->program,
14366 set_offload->current_length);
14367 }
14368 status = sme_acquire_global_lock(&mac_ctx->sme);
14369 if (QDF_STATUS_SUCCESS == status) {
14370 /* Serialize the req through MC thread */
14371 cds_msg.bodyptr = set_offload;
14372 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014373 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014374
14375 if (!QDF_IS_STATUS_SUCCESS(status)) {
14376 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14377 FL("Post BPF set offload msg fail"));
14378 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014379 qdf_mem_free(set_offload);
14380 }
14381 sme_release_global_lock(&mac_ctx->sme);
14382 } else {
14383 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14384 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014385 qdf_mem_free(set_offload);
14386 }
14387 return status;
14388}
14389
14390/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014391 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14392 * @hal: hal pointer
14393 *
14394 * Return: wni dot11 mode.
14395 */
14396uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14397{
14398 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14399
14400 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14401 mac_ctx->roam.configParam.uCfgDot11Mode);
14402}
14403
14404/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014405 * sme_create_mon_session() - post message to create PE session for monitormode
14406 * operation
14407 * @hal_handle: Handle to the HAL
14408 * @bssid: pointer to bssid
14409 *
14410 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14411 */
14412QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14413{
14414 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14415 struct sir_create_session *msg;
14416
14417 msg = qdf_mem_malloc(sizeof(*msg));
14418 if (NULL != msg) {
14419 msg->type = eWNI_SME_MON_INIT_SESSION;
14420 msg->msg_len = sizeof(*msg);
14421 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014422 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014423 }
14424 return status;
14425}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014426
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014427void sme_set_chan_info_callback(tHalHandle hal_handle,
14428 void (*callback)(struct scan_chan_info *chan_info))
14429{
14430 tpAniSirGlobal mac;
14431
14432 if (hal_handle == NULL) {
14433 QDF_ASSERT(0);
14434 return;
14435 }
14436 mac = PMAC_STRUCT(hal_handle);
14437 mac->chan_info_cb = callback;
14438}
14439
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014440/**
14441 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14442 * @hal: The handle returned by macOpen
14443 * @params: adaptive_dwelltime_params config
14444 *
14445 * Return: QDF_STATUS if adaptive dwell time update
14446 * configuration sucsess else failure status
14447 */
14448QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14449 struct adaptive_dwelltime_params *params)
14450{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014451 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014452 QDF_STATUS status;
14453 struct adaptive_dwelltime_params *dwelltime_params;
14454
14455 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14456 if (NULL == dwelltime_params) {
14457 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14458 "%s: fail to alloc dwelltime_params", __func__);
14459 return QDF_STATUS_E_NOMEM;
14460 }
14461
14462 dwelltime_params->is_enabled = params->is_enabled;
14463 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14464 dwelltime_params->lpf_weight = params->lpf_weight;
14465 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14466 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14467
14468 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14469 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014470 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014471 if (!QDF_IS_STATUS_SUCCESS(status)) {
14472 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14473 "%s: Not able to post msg to WMA!", __func__);
14474
14475 qdf_mem_free(dwelltime_params);
14476 }
14477 return status;
14478}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014479
14480/**
14481 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14482 * @hal: Pointer to HAL
14483 * @vdev_id: vdev_id for which IE is targeted
14484 *
14485 * Return: None
14486 */
14487void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14488{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014489 struct sir_set_vdev_ies_per_band *p_msg;
14490 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14491
14492 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14493 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014494 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014495 return;
14496 }
14497
14498 p_msg->vdev_id = vdev_id;
14499 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14500 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014501 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014502 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014503 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014504 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014505 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014506}
14507
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014508/**
14509 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14510 * @hal: Pointer to HAL
14511 * @enable2x2: 1x1 or 2x2 mode.
14512 *
14513 * Sends the set pdev IE req with Nss value.
14514 *
14515 * Return: None
14516 */
14517void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14518{
14519 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14520 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14521 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14522
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014523 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14524 eCSR_CFG_DOT11_MODE_AUTO) ||
14525 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14526 eCSR_CFG_DOT11_MODE_11N) ||
14527 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14528 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14529 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14530 eCSR_CFG_DOT11_MODE_11AC) ||
14531 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14532 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14533 return;
14534
14535 status = sme_acquire_global_lock(&mac_ctx->sme);
14536 if (QDF_STATUS_SUCCESS == status) {
14537 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14538 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014539 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014540 sme_release_global_lock(&mac_ctx->sme);
14541 return;
14542 }
14543
14544 ht_vht_cfg->pdev_id = 0;
14545 if (enable2x2)
14546 ht_vht_cfg->nss = 2;
14547 else
14548 ht_vht_cfg->nss = 1;
14549 ht_vht_cfg->dot11mode =
14550 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14551 mac_ctx->roam.configParam.uCfgDot11Mode);
14552
14553 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14554 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014555 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14556 ht_vht_cfg->nss,
14557 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014558 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014559 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014560 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014561
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014562 sme_release_global_lock(&mac_ctx->sme);
14563 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014564}
14565
14566/**
14567 * sme_update_vdev_type_nss() - sets the nss per vdev type
14568 * @hal: Pointer to HAL
14569 * @max_supp_nss: max_supported Nss
14570 * @band: 5G or 2.4G band
14571 *
14572 * Sets the per band Nss for each vdev type based on INI and configured
14573 * chain mask value.
14574 *
14575 * Return: None
14576 */
14577void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014578 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014579{
14580 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14581 struct vdev_type_nss *vdev_nss;
14582
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014583 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014584 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14585 else
14586 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14587
14588 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14589 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14590 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14591 CFG_P2P_GO_NSS(vdev_type_nss));
14592 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14593 CFG_P2P_CLI_NSS(vdev_type_nss));
14594 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14595 CFG_P2P_DEV_NSS(vdev_type_nss));
14596 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14597 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14598 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14599
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014600 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 -070014601 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14602 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14603 vdev_nss->tdls, vdev_nss->ocb);
14604}
Peng Xu8fdaa492016-06-22 10:20:47 -070014605
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014606#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14607#define MAX_BSS_COLOR_VAL 63
14608#define MIN_BSS_COLOR_VAL 1
14609
14610QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14611 uint8_t bss_color)
14612
14613{
14614 struct sir_set_he_bss_color *bss_color_msg;
14615 uint8_t len;
14616
14617 if (!hal) {
14618 sme_err("Invalid hal pointer");
14619 return QDF_STATUS_E_FAULT;
14620 }
14621
14622 sme_debug("Set HE bss_color %d", bss_color);
14623
14624 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14625 sme_debug("Invalid HE bss_color %d", bss_color);
14626 return QDF_STATUS_E_INVAL;
14627 }
14628 len = sizeof(*bss_color_msg);
14629 bss_color_msg = qdf_mem_malloc(len);
14630 if (!bss_color_msg) {
14631 sme_err("mem alloc failed");
14632 return QDF_STATUS_E_NOMEM;
14633 }
14634 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14635 bss_color_msg->length = len;
14636 bss_color_msg->session_id = session_id;
14637 bss_color_msg->bss_color = bss_color;
14638 return umac_send_mb_message_to_mac(bss_color_msg);
14639}
14640#endif
14641
Peng Xu8fdaa492016-06-22 10:20:47 -070014642/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014643 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14644 * @hal: Pointer to HAL
14645 * @hw_dbs_capable: HW DBS capability
14646 *
14647 * Sets HW DBS capability based on INI and fw capability.
14648 *
14649 * Return: None
14650 */
14651void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14652{
14653 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014654
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014655 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14656}
14657
14658/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014659 * sme_register_p2p_lo_event() - Register for the p2p lo event
14660 * @hHal: reference to the HAL
14661 * @context: the context of the call
14662 * @callback: the callback to hdd
14663 *
14664 * This function registers the callback function for P2P listen
14665 * offload stop event.
14666 *
14667 * Return: none
14668 */
14669void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14670 p2p_lo_callback callback)
14671{
14672 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14673 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14674
14675 status = sme_acquire_global_lock(&pMac->sme);
14676 pMac->sme.p2p_lo_event_callback = callback;
14677 pMac->sme.p2p_lo_event_context = context;
14678 sme_release_global_lock(&pMac->sme);
14679}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014680
14681/**
14682 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14683 * @hal: The handle returned by macOpen
14684 * @session_id: session id
14685 * @dbg_args: args for mac pwr debug command
14686 * Return: Return QDF_STATUS, otherwise appropriate failure code
14687 */
14688QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14689 struct sir_mac_pwr_dbg_cmd*
14690 dbg_args)
14691{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014692 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014693 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14694 struct sir_mac_pwr_dbg_cmd *req;
14695 int i;
14696
14697 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014698 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014699 return QDF_STATUS_E_FAILURE;
14700 }
14701
14702 req = qdf_mem_malloc(sizeof(*req));
14703 if (NULL == req) {
14704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14705 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14706 return QDF_STATUS_E_FAILURE;
14707 }
14708 req->module_id = dbg_args->module_id;
14709 req->pdev_id = dbg_args->pdev_id;
14710 req->num_args = dbg_args->num_args;
14711 for (i = 0; i < req->num_args; i++)
14712 req->args[i] = dbg_args->args[i];
14713
14714 message.type = SIR_HAL_POWER_DBG_CMD;
14715 message.bodyptr = req;
14716
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014717 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014718 (QDF_MODULE_ID_WMA, &message))) {
14719 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14720 "%s: Not able to post msg to WDA!",
14721 __func__);
14722 qdf_mem_free(req);
14723 }
14724 return QDF_STATUS_SUCCESS;
14725}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014726/**
14727 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014728 * @dev_mode: connection type.
14729 * @nss2g: Pointer to the 2G Nss parameter.
14730 * @nss5g: Pointer to the 5G Nss parameter.
14731 *
14732 * Fills the 2G and 5G Nss values based on connection type.
14733 *
14734 * Return: None
14735 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014736void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14737 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014738{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014739 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14740
14741 if (NULL == mac_ctx) {
14742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14743 FL("Invalid MAC context"));
14744 return;
14745 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014746 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14747}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014748
14749/**
14750 * sme_update_sta_roam_policy() - update sta roam policy for
14751 * unsafe and DFS channels.
14752 * @hal_handle: hal handle for getting global mac struct
14753 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14754 * skipped or not
14755 * @skip_unsafe_channels: Param to tell if driver needs to
14756 * skip unsafe channels or not.
14757 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014758 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014759 *
14760 * sme_update_sta_roam_policy update sta rome policies to csr
14761 * this function will call csrUpdateChannelList as well
14762 * to include/exclude DFS channels and unsafe channels.
14763 *
14764 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14765 */
14766QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14767 enum sta_roam_policy_dfs_mode dfs_mode,
14768 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014769 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014770{
14771 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14772 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014773 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014774
14775 if (!mac_ctx) {
14776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14777 "%s: mac_ctx is null", __func__);
14778 return QDF_STATUS_E_FAILURE;
14779 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014780
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014781 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14782 if (!sme_config) {
14783 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14784 FL("failed to allocate memory for sme_config"));
14785 return QDF_STATUS_E_FAILURE;
14786 }
14787 qdf_mem_zero(sme_config, sizeof(*sme_config));
14788 sme_get_config_param(hal_handle, sme_config);
14789
14790 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014791 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014792 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014793 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014794 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014795 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014796
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014797 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014798
14799 status = csr_update_channel_list(mac_ctx);
14800 if (QDF_STATUS_SUCCESS != status) {
14801 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14802 FL("failed to update the supported channel list"));
14803 }
14804 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14805 csr_roam_offload_scan(mac_ctx, session_id,
14806 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14807 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014808
14809 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014810 return status;
14811}
14812
14813/**
14814 * sme_enable_disable_chanavoidind_event - configure ca event ind
14815 * @hal: handler to hal
14816 * @set_value: enable/disable
14817 *
14818 * function to enable/disable chan avoidance indication
14819 *
14820 * Return: QDF_STATUS
14821 */
14822QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14823 uint8_t set_value)
14824{
14825 QDF_STATUS status;
14826 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014827 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014828
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014829 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014830 status = sme_acquire_global_lock(&mac_ctx->sme);
14831 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014832 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014833 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14834 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014835 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014836 sme_release_global_lock(&mac_ctx->sme);
14837 return status;
14838 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014839 return status;
14840}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014841
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014842/*
14843 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14844 * @hal: reference to the HAL
14845 * @session_id: current session ID
14846 * @ie_data: Pointer to Scan IE data
14847 * @ie_len: Length of @ie_data
14848 *
14849 * Return: QDF_STATUS
14850 */
14851QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14852 uint8_t *ie_data, uint16_t ie_len)
14853{
14854 QDF_STATUS status;
14855 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14856 struct hdd_default_scan_ie *set_ie_params;
14857
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014858 if (!ie_data)
14859 return QDF_STATUS_E_INVAL;
14860
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014861 status = sme_acquire_global_lock(&mac_ctx->sme);
14862 if (QDF_IS_STATUS_SUCCESS(status)) {
14863 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14864 if (!set_ie_params)
14865 status = QDF_STATUS_E_NOMEM;
14866 else {
14867 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14868 set_ie_params->length = sizeof(*set_ie_params);
14869 set_ie_params->session_id = session_id;
14870 set_ie_params->ie_len = ie_len;
14871 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014872 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014873 }
14874 sme_release_global_lock(&mac_ctx->sme);
14875 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014876 return status;
14877}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014878
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014879QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14880 wma_sar_cb callback, void *context)
14881{
14882 void *wma_handle;
14883
14884 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14885 if (!wma_handle) {
14886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14887 "wma handle is NULL");
14888 return QDF_STATUS_E_FAILURE;
14889 }
14890
14891 return wma_get_sar_limit(wma_handle, callback, context);
14892}
14893
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014894QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14895 struct sar_limit_cmd_params *sar_limit_cmd)
14896{
14897 void *wma_handle;
14898
14899 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14900 if (!wma_handle) {
14901 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14902 "wma handle is NULL");
14903 return QDF_STATUS_E_FAILURE;
14904 }
14905
14906 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14907}
14908
Jeff Johnson6136fb92017-03-30 15:21:49 -070014909#ifdef WLAN_FEATURE_FIPS
14910QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14911 wma_fips_cb callback, void *context)
14912{
14913 void *wma_handle;
14914
14915 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14916 if (!wma_handle) {
14917 sme_err("wma handle is NULL");
14918 return QDF_STATUS_E_FAILURE;
14919 }
14920
14921 return wma_fips_request(wma_handle, param, callback, context);
14922}
14923#endif
14924
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014925QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14926{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014927 void *wma_handle;
14928
14929 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14930 if (!wma_handle) {
14931 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14932 "wma_handle is NULL");
14933 return QDF_STATUS_E_FAILURE;
14934 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014935 if (QDF_STATUS_SUCCESS !=
14936 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14938 "%s: Failed to set cts2self for p2p GO to firmware",
14939 __func__);
14940 return QDF_STATUS_E_FAILURE;
14941 }
14942 return QDF_STATUS_SUCCESS;
14943}
Yingying Tang95409972016-10-20 15:16:15 +080014944
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014945/**
14946 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14947 * @hal: Handle returned by mac_open
14948 * @session_id: Session ID on which tx fail count needs to be updated to FW
14949 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14950 *
14951 * This function is used to set tx fail count threshold to firmware.
14952 * firmware will issue disocnnect with peer device once this threshold is
14953 * reached.
14954 *
14955 * Return: Return QDF_STATUS, otherwise appropriate failure code
14956 */
14957QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14958 uint8_t session_id, uint32_t tx_fail_count)
14959{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014960 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14961 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014962 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014963
14964 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14965 if (NULL == tx_fail_cnt) {
14966 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14967 "%s: fail to alloc filter_param", __func__);
14968 return QDF_STATUS_E_FAILURE;
14969 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014970 sme_debug("session_id: %d tx_fail_count: %d",
14971 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014972 tx_fail_cnt->session_id = session_id;
14973 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14974
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014975 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014976 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14977 msg.reserved = 0;
14978 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014979 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014980
14981 if (!QDF_IS_STATUS_SUCCESS(status)) {
14982 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014983 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014984 qdf_mem_free(tx_fail_cnt);
14985 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014986 return status;
14987}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014988
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014989QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14990 void (*cb)(void *, struct sir_lost_link_info *))
14991{
14992 QDF_STATUS status = QDF_STATUS_SUCCESS;
14993 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14994
14995 status = sme_acquire_global_lock(&mac->sme);
14996 if (QDF_IS_STATUS_SUCCESS(status)) {
14997 mac->sme.lost_link_info_cb = cb;
14998 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014999 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015000 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015001 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015002
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015003 return status;
15004}
Yingying Tang95409972016-10-20 15:16:15 +080015005
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015006#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080015007bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015008{
15009 return roam_info->isESEAssoc;
15010}
Manjeet Singh2f785062017-03-08 18:14:18 +053015011#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053015012/**
Manjeet Singh2f785062017-03-08 18:14:18 +053015013 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053015014 * params from ini.
15015 * @hal_handle: Handle returned by mac_open
15016 * @5g_pref_params: pref params from ini.
15017 *
15018 * Returns: None
15019 */
15020void sme_set_5g_band_pref(tHalHandle hal_handle,
15021 struct sme_5g_band_pref_params *pref_params)
15022{
15023
15024 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
15025 struct roam_ext_params *roam_params;
15026 QDF_STATUS status = QDF_STATUS_SUCCESS;
15027
15028 if (!pref_params) {
15029 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15030 "Invalid 5G pref params!");
15031 return;
15032 }
15033 status = sme_acquire_global_lock(&mac_ctx->sme);
15034 if (QDF_STATUS_SUCCESS == status) {
15035 roam_params = &mac_ctx->roam.configParam.roam_params;
15036 roam_params->raise_rssi_thresh_5g =
15037 pref_params->rssi_boost_threshold_5g;
15038 roam_params->raise_factor_5g =
15039 pref_params->rssi_boost_factor_5g;
15040 roam_params->max_raise_rssi_5g =
15041 pref_params->max_rssi_boost_5g;
15042 roam_params->drop_rssi_thresh_5g =
15043 pref_params->rssi_penalize_threshold_5g;
15044 roam_params->drop_factor_5g =
15045 pref_params->rssi_penalize_factor_5g;
15046 roam_params->max_drop_rssi_5g =
15047 pref_params->max_rssi_penalize_5g;
15048
15049 sme_release_global_lock(&mac_ctx->sme);
15050 } else
15051 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15052 "Unable to acquire global sme lock");
15053}
15054
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015055
15056bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
15057{
15058 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015059
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015060 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
15061}
Yingying Tang95409972016-10-20 15:16:15 +080015062
15063#ifdef WLAN_FEATURE_WOW_PULSE
15064/**
15065 * sme_set_wow_pulse() - set wow pulse info
15066 * @wow_pulse_set_info: wow_pulse_mode structure pointer
15067 *
15068 * Return: QDF_STATUS
15069 */
15070QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
15071{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015072 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080015073 QDF_STATUS status;
15074 struct wow_pulse_mode *wow_pulse_set_cmd;
15075
15076 if (!wow_pulse_set_info) {
15077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15078 "%s: invalid wow_pulse_set_info pointer", __func__);
15079 return QDF_STATUS_E_FAILURE;
15080 }
15081
15082 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
15083 if (NULL == wow_pulse_set_cmd) {
15084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15085 "%s: fail to alloc wow_pulse_set_cmd", __func__);
15086 return QDF_STATUS_E_NOMEM;
15087 }
15088
15089 *wow_pulse_set_cmd = *wow_pulse_set_info;
15090
15091 message.type = WMA_SET_WOW_PULSE_CMD;
15092 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015093 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080015094 &message);
15095 if (!QDF_IS_STATUS_SUCCESS(status)) {
15096 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15097 "%s: Not able to post msg to WDA!",
15098 __func__);
15099 qdf_mem_free(wow_pulse_set_cmd);
15100 status = QDF_STATUS_E_FAILURE;
15101 }
15102
15103 return status;
15104}
15105#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015106
15107/**
15108 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
15109 * different fields and IEs from bss descriptor.
15110 * @frame_buf: frame buffer to populate
15111 * @bss_descp: bss descriptor
15112 * @bssid: bssid of the beacon frame to populate
15113 * @ie_len: length of IE fields
15114 *
15115 * Return: None
15116 */
15117static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
15118 tSirBssDescription *bss_descp,
15119 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080015120 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015121{
15122 tDot11fBeacon1 *bcn_fixed;
15123 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
15124
15125 /* populate mac header first to indicate beacon */
15126 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15127 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
15128 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
15129 qdf_mem_copy((uint8_t *) mac_hdr->da,
15130 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
15131 sizeof(struct qdf_mac_addr));
15132 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15133 sizeof(struct qdf_mac_addr));
15134 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15135 sizeof(struct qdf_mac_addr));
15136
15137 /* now populate fixed params */
15138 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15139 /* populate timestamp */
15140 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15141 sizeof(bss_descp->timeStamp));
15142 /* populate beacon interval */
15143 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15144 /* populate capability */
15145 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15146 sizeof(bss_descp->capabilityInfo));
15147
15148 /* copy IEs now */
15149 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15150 + SIR_MAC_B_PR_SSID_OFFSET,
15151 &bss_descp->ieFields, ie_len);
15152}
15153
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015154QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
15155 tCsrRoamProfile *profile,
15156 const uint8_t *bssid,
15157 int8_t *rssi, int8_t *snr)
15158{
15159 tSirBssDescription *bss_descp;
15160 tCsrScanResultFilter *scan_filter;
15161 struct scan_result_list *bss_list;
15162 tScanResultHandle result_handle = NULL;
15163 QDF_STATUS status = QDF_STATUS_SUCCESS;
15164 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15165
15166 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15167 if (NULL == scan_filter) {
15168 sme_err("memory allocation failed");
15169 status = QDF_STATUS_E_NOMEM;
15170 goto free_scan_flter;
15171 }
15172
15173 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15174 profile, scan_filter);
15175 if (QDF_STATUS_SUCCESS != status) {
15176 sme_err("prepare_filter failed");
15177 goto free_scan_flter;
15178 }
15179
15180 /* update filter to get scan result with just target BSSID */
15181 if (NULL == scan_filter->BSSIDs.bssid) {
15182 scan_filter->BSSIDs.bssid =
15183 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15184 if (scan_filter->BSSIDs.bssid == NULL) {
15185 sme_err("malloc failed");
15186 status = QDF_STATUS_E_NOMEM;
15187 goto free_scan_flter;
15188 }
15189 }
15190
15191 scan_filter->BSSIDs.numOfBSSIDs = 1;
15192 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15193 bssid, sizeof(struct qdf_mac_addr));
15194
15195 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15196 if (QDF_STATUS_SUCCESS != status) {
15197 sme_err("parse_scan_result failed");
15198 goto free_scan_flter;
15199 }
15200
15201 bss_list = (struct scan_result_list *)result_handle;
15202 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15203 if (!bss_descp) {
15204 sme_err("unable to fetch bss descriptor");
15205 status = QDF_STATUS_E_FAULT;
15206 goto free_scan_flter;
15207 }
15208
15209 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15210 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15211
15212 if (rssi)
15213 *rssi = bss_descp->rssi;
15214 if (snr)
15215 *snr = bss_descp->sinr;
15216
15217free_scan_flter:
15218 /* free scan filter and exit */
15219 if (scan_filter) {
15220 csr_free_scan_filter(mac_ctx, scan_filter);
15221 qdf_mem_free(scan_filter);
15222 }
15223
15224 if (result_handle)
15225 csr_scan_result_purge(mac_ctx, result_handle);
15226
15227 return status;
15228}
15229
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015230QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15231 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015232 uint8_t **frame_buf, uint32_t *frame_len,
15233 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015234{
15235 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015236 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015237 tCsrScanResultFilter *scan_filter;
15238 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15239 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015240 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015241 uint32_t ie_len;
15242
15243 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15244 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015245 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015246 status = QDF_STATUS_E_NOMEM;
15247 goto free_scan_flter;
15248 }
15249 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15250 profile, scan_filter);
15251 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015252 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015253 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015254 goto free_scan_flter;
15255 }
15256
15257 /* update filter to get scan result with just target BSSID */
15258 if (NULL == scan_filter->BSSIDs.bssid) {
15259 scan_filter->BSSIDs.bssid =
15260 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15261 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015262 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015263 status = QDF_STATUS_E_NOMEM;
15264 goto free_scan_flter;
15265 }
15266 }
15267 scan_filter->BSSIDs.numOfBSSIDs = 1;
15268 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15269 bssid, sizeof(struct qdf_mac_addr));
15270
15271 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15272 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015273 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015274 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015275 goto free_scan_flter;
15276 }
15277
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015278 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015279 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015280 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015281 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015282 status = QDF_STATUS_E_FAULT;
15283 goto free_scan_flter;
15284 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015285
Naveen Rawat81f058c2017-06-02 16:02:39 -070015286 /**
15287 * Length of BSS descriptor is without length of
15288 * length itself and length of pointer that holds ieFields.
15289 *
15290 * tSirBssDescription
15291 * +--------+---------------------------------+---------------+
15292 * | length | other fields | pointer to IEs|
15293 * +--------+---------------------------------+---------------+
15294 * ^
15295 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015296 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015297 ie_len = bss_descp->length + sizeof(bss_descp->length)
15298 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015299 sme_debug("found bss_descriptor ie_len: %d channel %d",
15300 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015301
15302 /* include mac header and fixed params along with IEs in frame */
15303 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15304 *frame_buf = qdf_mem_malloc(*frame_len);
15305 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015306 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015307 status = QDF_STATUS_E_NOMEM;
15308 goto free_scan_flter;
15309 }
15310
15311 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15312
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015313 if (!*channel)
15314 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015315free_scan_flter:
15316 /* free scan filter and exit */
15317 if (scan_filter) {
15318 csr_free_scan_filter(mac_ctx, scan_filter);
15319 qdf_mem_free(scan_filter);
15320 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015321 if (result_handle)
15322 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015323
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015324 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015325}
15326
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015327#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015328QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15329 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015330 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015331{
15332 QDF_STATUS status;
15333 struct wma_roam_invoke_cmd *fastreassoc;
15334 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015335 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015336
15337 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15338 if (NULL == fastreassoc) {
15339 sme_err("qdf_mem_malloc failed for fastreassoc");
15340 return QDF_STATUS_E_NOMEM;
15341 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015342 /* if both are same then set the flag */
15343 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15344 fastreassoc->is_same_bssid = true;
15345 sme_debug("bssid same, bssid[%pM]", bssid);
15346 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015347 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015348 fastreassoc->bssid[0] = bssid[0];
15349 fastreassoc->bssid[1] = bssid[1];
15350 fastreassoc->bssid[2] = bssid[2];
15351 fastreassoc->bssid[3] = bssid[3];
15352 fastreassoc->bssid[4] = bssid[4];
15353 fastreassoc->bssid[5] = bssid[5];
15354
15355 status = sme_get_beacon_frm(hal, profile, bssid,
15356 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015357 &fastreassoc->frame_len,
15358 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015359
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015360 if (!channel) {
15361 sme_err("channel retrieval from BSS desc fails!");
15362 qdf_mem_free(fastreassoc);
15363 return QDF_STATUS_E_FAULT;
15364 }
15365
15366 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015367 if (QDF_STATUS_SUCCESS != status) {
15368 sme_warn("sme_get_beacon_frm failed");
15369 fastreassoc->frame_buf = NULL;
15370 fastreassoc->frame_len = 0;
15371 }
15372
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015373 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15374 connectedProfile.AuthType)) {
15375 sme_debug("Beacon is not required for ESE");
15376 if (fastreassoc->frame_len) {
15377 qdf_mem_free(fastreassoc->frame_buf);
15378 fastreassoc->frame_buf = NULL;
15379 fastreassoc->frame_len = 0;
15380 }
15381 }
15382
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015383 msg.type = SIR_HAL_ROAM_INVOKE;
15384 msg.reserved = 0;
15385 msg.bodyptr = fastreassoc;
15386 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15387 if (QDF_STATUS_SUCCESS != status) {
15388 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15389 qdf_mem_free(fastreassoc);
15390 }
15391
15392 return status;
15393}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015394#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015395
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015396QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15397 tPmkidCacheInfo *pmk_cache_info,
15398 bool is_add)
15399{
15400 struct wmi_unified_pmk_cache *pmk_cache;
15401 struct scheduler_msg msg;
15402
15403 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15404 if (!pmk_cache) {
15405 sme_err("Memory allocation failure");
15406 return QDF_STATUS_E_NOMEM;
15407 }
15408
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015409 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15410
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015411 pmk_cache->session_id = session_id;
15412
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015413 if (!pmk_cache_info)
15414 goto send_flush_cmd;
15415
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015416 if (!pmk_cache_info->ssid_len) {
15417 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15418 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15419 &pmk_cache->bssid);
15420 } else {
15421 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15422 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15423 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15424 pmk_cache_info->ssid,
15425 pmk_cache->ssid.length);
15426 }
15427 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15428 pmk_cache_info->cache_id[1]);
15429
15430 if (is_add)
15431 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15432 else
15433 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15434
15435 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15436 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15437 CSR_RSN_PMKID_SIZE);
15438
15439 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15440 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15441 pmk_cache->pmk_len);
15442
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015443send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015444 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15445 msg.reserved = 0;
15446 msg.bodyptr = pmk_cache;
15447 if (QDF_STATUS_SUCCESS !=
15448 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15449 sme_err("Not able to post message to WDA");
15450 qdf_mem_free(pmk_cache);
15451 return QDF_STATUS_E_FAILURE;
15452 }
15453
15454 return QDF_STATUS_SUCCESS;
15455}
15456
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015457/* ARP DEBUG STATS */
15458
15459/**
15460 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15461 * @hal: handle to hal
15462 * @set_stats_param: pointer to set stats param
15463 *
15464 * Return: Return QDF_STATUS.
15465 */
15466QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15467 struct set_arp_stats_params
15468 *set_stats_param)
15469{
15470 struct set_arp_stats_params *arp_set_param;
15471 struct scheduler_msg msg;
15472
15473 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15474 if (arp_set_param == NULL) {
15475 sme_err("Memory allocation failure");
15476 return QDF_STATUS_E_NOMEM;
15477 }
15478
15479 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15480
15481 msg.type = WMA_SET_ARP_STATS_REQ;
15482 msg.reserved = 0;
15483 msg.bodyptr = arp_set_param;
15484
15485 if (QDF_STATUS_SUCCESS !=
15486 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15487 sme_err("Not able to post message to WDA");
15488 qdf_mem_free(arp_set_param);
15489 return QDF_STATUS_E_FAILURE;
15490 }
15491
15492 return QDF_STATUS_SUCCESS;
15493}
15494
15495/**
15496 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15497 * @hal: handle to hal
15498 * @get_stats_param: pointer to set stats param
15499 *
15500 * Return: Return QDF_STATUS.
15501 */
15502QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15503 struct get_arp_stats_params
15504 *get_stats_param)
15505{
15506 struct get_arp_stats_params *arp_get_param;
15507 struct scheduler_msg msg;
15508
15509 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15510 if (arp_get_param == NULL) {
15511 sme_err("Memory allocation failure");
15512 return QDF_STATUS_E_NOMEM;
15513 }
15514
15515 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15516
15517 msg.type = WMA_GET_ARP_STATS_REQ;
15518 msg.reserved = 0;
15519 msg.bodyptr = arp_get_param;
15520
15521 if (QDF_STATUS_SUCCESS !=
15522 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15523 sme_err("Not able to post message to WDA");
15524 qdf_mem_free(arp_get_param);
15525 return QDF_STATUS_E_FAILURE;
15526 }
15527
15528 return QDF_STATUS_SUCCESS;
15529}
15530
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015531QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15532 uint32_t param_value, uint32_t vdev_id)
15533{
15534 void *wma_handle;
15535
15536 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15537 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015538 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015539 return QDF_STATUS_E_FAILURE;
15540 }
15541
15542 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15543 param_value, vdev_id);
15544}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015545
15546QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015547 bool (*set_connection_info_cb)(bool),
15548 bool (*get_connection_info_cb)(uint8_t *session_id,
15549 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015550{
15551 QDF_STATUS status = QDF_STATUS_SUCCESS;
15552 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15553
15554 status = sme_acquire_global_lock(&pMac->sme);
15555 if (QDF_IS_STATUS_SUCCESS(status)) {
15556 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015557 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015558 sme_release_global_lock(&pMac->sme);
15559 }
15560 return status;
15561}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015562
15563QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15564 void (*cb)(void *, struct rso_cmd_status *))
15565{
15566 QDF_STATUS status = QDF_STATUS_SUCCESS;
15567 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15568
15569 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015570 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015571 return status;
15572}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015573
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015574QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15575 struct wmi_dbs_scan_sel_params *params)
15576{
15577 struct scheduler_msg message = {0};
15578 QDF_STATUS status;
15579 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15580 uint32_t i;
15581
15582 if (0 == params->num_clients) {
15583 sme_err("Num of clients is 0");
15584 return QDF_STATUS_E_FAILURE;
15585 }
15586
15587 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15588 if (!dbs_scan_params) {
15589 sme_err("fail to alloc dbs_scan_params");
15590 return QDF_STATUS_E_NOMEM;
15591 }
15592
15593 dbs_scan_params->num_clients = params->num_clients;
15594 dbs_scan_params->pdev_id = params->pdev_id;
15595 for (i = 0; i < params->num_clients; i++) {
15596 dbs_scan_params->module_id[i] = params->module_id[i];
15597 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15598 dbs_scan_params->num_non_dbs_scans[i] =
15599 params->num_non_dbs_scans[i];
15600 }
15601 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15602 message.bodyptr = dbs_scan_params;
15603 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15604 if (!QDF_IS_STATUS_SUCCESS(status)) {
15605 sme_err("Not able to post msg to WMA!");
15606 qdf_mem_free(dbs_scan_params);
15607 }
15608
15609 return status;
15610}
15611
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015612QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15613{
15614 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15615 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015616 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015617 struct sme_rcpi_req *rcpi_req;
15618
15619 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15620 if (rcpi_req == NULL) {
15621 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15622 "%s: Not able to allocate memory for rcpi req",
15623 __func__);
15624 return QDF_STATUS_E_NOMEM;
15625 }
15626 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15627
15628 status = sme_acquire_global_lock(&pMac->sme);
15629 if (QDF_IS_STATUS_SUCCESS(status)) {
15630 msg.bodyptr = rcpi_req;
15631 msg.type = WMA_GET_RCPI_REQ;
15632 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15633 sme_release_global_lock(&pMac->sme);
15634 if (!QDF_IS_STATUS_SUCCESS(status)) {
15635 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15636 FL("post get rcpi req failed"));
15637 status = QDF_STATUS_E_FAILURE;
15638 qdf_mem_free(rcpi_req);
15639 }
15640 } else {
15641 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15642 FL("sme_acquire_global_lock failed"));
15643 qdf_mem_free(rcpi_req);
15644 }
15645
15646 return status;
15647}
15648
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015649void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15650{
15651 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15652 void *wma_handle;
15653 QDF_STATUS status;
15654
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015655 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015656 if (QDF_STATUS_SUCCESS != status) {
15657 mac_ctx->pdev = NULL;
15658 return;
15659 }
15660 mac_ctx->pdev = pdev;
15661 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15662 if (!wma_handle) {
15663 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015664 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015665 return;
15666 }
15667 wma_store_pdev(wma_handle, pdev);
15668}
15669
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015670QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15671 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15672{
15673 QDF_STATUS status;
15674 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15675
15676 status = sme_acquire_global_lock(&mac->sme);
15677 if (QDF_IS_STATUS_SUCCESS(status)) {
15678 mac->sme.congestion_cb = congestion_cb;
15679 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015680 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015681 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015682 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015683 }
15684
15685 return status;
15686}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015687
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015688QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
15689 void (*tx_queue_cb)(void *,
15690 uint32_t vdev_id,
15691 enum netif_action_type action,
15692 enum netif_reason_type reason))
15693{
15694 QDF_STATUS status;
15695 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15696
15697 status = sme_acquire_global_lock(&mac->sme);
15698 if (QDF_IS_STATUS_SUCCESS(status)) {
15699 mac->sme.tx_queue_cb = tx_queue_cb;
15700 sme_release_global_lock(&mac->sme);
15701 sme_debug("Tx queue callback set");
15702 } else {
15703 sme_err("Aquiring lock failed %d", status);
15704 }
15705
15706 return status;
15707}
15708
15709QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
15710{
15711 return sme_register_tx_queue_cb(hal, NULL);
15712}
15713
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015714QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15715 uint32_t param_val)
15716{
15717 return wma_configure_smps_params(vdev_id, param_id, param_val);
15718}
15719
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015720QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15721 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15722{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015723 wma_cli_set_cmd_t *iwcmd;
15724 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015725
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015726 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15727 if (!iwcmd) {
15728 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015729 return QDF_STATUS_E_NOMEM;
15730 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015731
15732 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15733 iwcmd->param_sec_value = 0;
15734 iwcmd->param_vdev_id = vdev_id;
15735 iwcmd->param_id = param_id;
15736 iwcmd->param_vp_dev = req_cat;
15737 iwcmd->param_value = param_val;
15738 wma_ipa_uc_stat_request(iwcmd);
15739 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015740
15741 return status;
15742}
lifeng66831662017-05-19 16:01:35 +080015743
15744QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15745 struct sir_set_rx_reorder_timeout_val *req)
15746{
15747 QDF_STATUS status;
15748
15749 status = wma_set_rx_reorder_timeout_val(hal, req);
15750
15751 return status;
15752}
15753
15754QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15755 struct sir_peer_set_rx_blocksize *req)
15756{
15757 QDF_STATUS status;
15758
15759 status = wma_set_rx_blocksize(hal, req);
15760
15761 return status;
15762}
Naveen Rawat247a8682017-06-05 15:00:31 -070015763
15764int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15765{
15766 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15767}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015768
15769QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15770 void (*cb)(void *, uint32_t bt_activity))
15771{
15772 QDF_STATUS status;
15773 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15774
15775 status = sme_acquire_global_lock(&mac->sme);
15776 if (QDF_IS_STATUS_SUCCESS(status)) {
15777 mac->sme.bt_activity_info_cb = cb;
15778 sme_release_global_lock(&mac->sme);
15779 sme_debug("bt activity info callback set");
15780 } else {
15781 sme_debug("sme_acquire_global_lock failed %d", status);
15782 }
15783
15784 return status;
15785}
lifengd217d192017-05-09 19:44:16 +080015786
15787QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15788 struct get_chain_rssi_req_params *input,
15789 get_chain_rssi_callback callback,
15790 void *context)
15791{
15792 QDF_STATUS status = QDF_STATUS_SUCCESS;
15793 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15794
15795 SME_ENTER();
15796
15797 if (NULL == input) {
15798 sme_err("Invalid req params");
15799 return QDF_STATUS_E_INVAL;
15800 }
15801
15802 mac_ctx->sme.get_chain_rssi_cb = callback;
15803 mac_ctx->sme.get_chain_rssi_context = context;
15804 wma_get_chain_rssi(hal, input);
15805
15806 SME_EXIT();
15807 return status;
15808}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015809
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015810QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15811 struct scheduler_msg *msg)
15812{
15813 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15814
15815 if (msg == NULL) {
15816 sme_err("Empty message for SME Msg callback");
15817 return status;
15818 }
15819 status = sme_process_msg(hal, msg);
15820 return status;
15821}
15822
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015823void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15824{
15825 struct csr_roam_session *session;
15826 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15827
15828 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15829 sme_err("%s Invalid session id: %d", __func__, session_id);
15830 return;
15831 }
15832
15833 session = CSR_GET_SESSION(mac_ctx, session_id);
15834 if (!session) {
15835 sme_err("%s Failed to get session for id: %d",
15836 __func__, session_id);
15837 return;
15838 }
15839
15840 sme_debug("Total No. of Disconnections: %d",
15841 session->disconnect_stats.disconnection_cnt);
15842
15843 sme_debug("No. of Diconnects Triggered by Application: %d",
15844 session->disconnect_stats.disconnection_by_app);
15845
15846 sme_debug("No. of Disassoc Sent by Peer: %d",
15847 session->disconnect_stats.disassoc_by_peer);
15848
15849 sme_debug("No. of Deauth Sent by Peer: %d",
15850 session->disconnect_stats.deauth_by_peer);
15851
15852 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15853 session->disconnect_stats.bmiss);
15854
15855 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15856 session->disconnect_stats.peer_kickout);
15857}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015858
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015859 /**
15860 * sme_set_vc_mode_config() - Set voltage corner config to FW
15861 * @bitmap: Bitmap that referes to voltage corner config with
15862 * different phymode and bw configuration
15863 *
15864 * Return: QDF_STATUS
15865 */
15866QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15867{
15868 void *wma_handle;
15869
15870 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15871 if (!wma_handle) {
15872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15873 "wma_handle is NULL");
15874 return QDF_STATUS_E_FAILURE;
15875 }
15876 if (QDF_STATUS_SUCCESS !=
15877 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15878 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15879 "%s: Failed to set Voltage Control config to FW",
15880 __func__);
15881 return QDF_STATUS_E_FAILURE;
15882 }
15883 return QDF_STATUS_SUCCESS;
15884}
15885
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015886/**
15887 * sme_set_bmiss_bcnt() - set bmiss config parameters
15888 * @vdev_id: virtual device for the command
15889 * @first_cnt: bmiss first value
15890 * @final_cnt: bmiss final value
15891 *
15892 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15893 */
15894QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15895 uint32_t final_cnt)
15896{
15897 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15898}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015899
15900QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15901 bool is_tos_active, uint32_t max_off_chan_time,
15902 uint32_t rest_time, bool skip_dfs_chan)
15903{
15904 struct sir_limit_off_chan *cmd;
15905 struct scheduler_msg msg = {0};
15906
15907 cmd = qdf_mem_malloc(sizeof(*cmd));
15908 if (!cmd) {
15909 sme_err("qdf_mem_malloc failed for limit off channel");
15910 return QDF_STATUS_E_NOMEM;
15911 }
15912
15913 cmd->vdev_id = vdev_id;
15914 cmd->is_tos_active = is_tos_active;
15915 cmd->max_off_chan_time = max_off_chan_time;
15916 cmd->rest_time = rest_time;
15917 cmd->skip_dfs_chans = skip_dfs_chan;
15918
15919 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15920 msg.reserved = 0;
15921 msg.bodyptr = cmd;
15922
15923 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15924 &msg))) {
15925 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15926 qdf_mem_free(cmd);
15927 return QDF_STATUS_E_FAILURE;
15928 }
15929
15930 return QDF_STATUS_SUCCESS;
15931}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015932
15933/**
15934 * sme_get_status_for_candidate() - Get bss transition status for candidate
15935 * @hal: Handle for HAL
15936 * @conn_bss_desc: connected bss descriptor
15937 * @bss_desc: candidate bss descriptor
15938 * @info: candiadate bss information
15939 * @trans_reason: transition reason code
15940 * @is_bt_in_progress: bt activity indicator
15941 *
15942 * Return : true if candidate is rejected and reject reason is filled
15943 * @info->status. Otherwise returns false.
15944 */
15945static bool sme_get_status_for_candidate(tHalHandle *hal,
15946 tSirBssDescription *conn_bss_desc,
15947 tSirBssDescription *bss_desc,
15948 struct bss_candidate_info *info,
15949 uint8_t trans_reason,
15950 bool is_bt_in_progress)
15951{
15952 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15953
15954 /*
15955 * Low RSSI based rejection
15956 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15957 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15958 * candidate with MBO reason code 4.
15959 */
15960 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15961 mbo_candidate_rssi_thres) &&
15962 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15963 mbo_current_rssi_thres)) {
15964 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15965 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15966 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15967 return true;
15968 }
15969
15970 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15971 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15972 /*
15973 * MCC rejection
15974 * If moving to candidate's channel will result in MCC scenario
15975 * and the rssi of connected bss is greater than
15976 * mbo_current_rssi_mss_thres, then reject the candidate with
15977 * MBO reason code 3.
15978 */
15979 if ((conn_bss_desc->rssi >
15980 mac_ctx->roam.configParam.mbo_thresholds.
15981 mbo_current_rssi_mcc_thres) &&
15982 csr_is_mcc_channel(hal, bss_desc->channelId)) {
15983 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15984 MAC_ADDR_ARRAY(bss_desc->bssId));
15985 info->status =
15986 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15987 return true;
15988 }
15989
15990 /*
15991 * BT coex rejection
15992 * If AP is trying to move the client from 5G to 2.4G and moving
15993 * to 2.4G will result in BT coex and candidate channel rssi is
15994 * less than mbo_candidate_rssi_btc_thres, then reject the
15995 * candidate with MBO reason code 2.
15996 */
15997 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15998 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15999 is_bt_in_progress &&
16000 (bss_desc->rssi <
16001 mac_ctx->roam.configParam.mbo_thresholds.
16002 mbo_candidate_rssi_btc_thres)) {
16003 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
16004 MAC_ADDR_ARRAY(bss_desc->bssId));
16005 info->status =
16006 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
16007 return true;
16008 }
16009
16010 /*
16011 * LTE coex rejection
16012 * If moving to candidate's channel can cause LTE coex, then
16013 * reject the candidate with MBO reason code 5.
16014 */
16015 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
16016 conn_bss_desc->channelId) &&
16017 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
16018 bss_desc->channelId))) {
16019 sme_err("High interference expected if transitioned to BSS "
16020 MAC_ADDRESS_STR" hence reject",
16021 MAC_ADDR_ARRAY(bss_desc->bssId));
16022 info->status =
16023 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
16024 return true;
16025 }
16026 }
16027
16028 return false;
16029}
16030
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053016031uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
16032 uint8_t buf_len, tDot11fIERSN *rsn_ie,
16033 bool append_ie)
16034{
16035 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16036
Abhishek Singh3f13a812018-01-16 14:24:44 +053016037 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053016038}
16039
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053016040/**
16041 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
16042 * @adapter : Pointer to adapter
16043 * @transition_reason : Transition reason
16044 * @info : bss candidate information
16045 * @n_candidates : number of candidates
16046 *
16047 * Return : 0 on success otherwise errno
16048 */
16049int sme_get_bss_transition_status(tHalHandle hal,
16050 uint8_t transition_reason,
16051 struct qdf_mac_addr *bssid,
16052 struct bss_candidate_info *info,
16053 uint16_t n_candidates,
16054 bool is_bt_in_progress)
16055{
16056 QDF_STATUS status = QDF_STATUS_SUCCESS;
16057 tSirBssDescription *bss_desc, *conn_bss_desc;
16058 tCsrScanResultInfo *res, *conn_res;
16059 uint16_t i;
16060
16061 if (!n_candidates || !info) {
16062 sme_err("No candidate info available");
16063 return QDF_STATUS_E_INVAL;
16064 }
16065
16066 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16067 if (!conn_res) {
16068 sme_err("Failed to allocate memory for conn_res");
16069 return QDF_STATUS_E_NOMEM;
16070 }
16071
16072 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16073 if (!res) {
16074 sme_err("Failed to allocate memory for conn_res");
16075 status = QDF_STATUS_E_NOMEM;
16076 goto free;
16077 }
16078
16079 /* Get the connected BSS descriptor */
16080 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
16081 if (!QDF_IS_STATUS_SUCCESS(status)) {
16082 sme_err("Failed to find connected BSS in scan list");
16083 goto free;
16084 }
16085 conn_bss_desc = &conn_res->BssDescriptor;
16086
16087 for (i = 0; i < n_candidates; i++) {
16088 /* Get candidate BSS descriptors */
16089 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
16090 res);
16091 if (!QDF_IS_STATUS_SUCCESS(status)) {
16092 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
16093 MAC_ADDR_ARRAY(info[i].bssid.bytes));
16094 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
16095 continue;
16096 }
16097
16098 bss_desc = &res->BssDescriptor;
16099 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
16100 &info[i], transition_reason, is_bt_in_progress)) {
16101 /*
16102 * If status is not over written, it means it is a
16103 * candidate for accept.
16104 */
16105 info[i].status = QCA_STATUS_ACCEPT;
16106 }
16107 }
16108
16109 /* success */
16110 status = QDF_STATUS_SUCCESS;
16111
16112free:
16113 /* free allocated memory */
16114 if (conn_res)
16115 qdf_mem_free(conn_res);
16116 if (res)
16117 qdf_mem_free(res);
16118
16119 return status;
16120}
16121
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016122void sme_enable_roaming_on_connected_sta(tHalHandle hal)
16123{
16124 uint8_t session_id;
16125 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16126 QDF_STATUS status;
16127
16128 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
16129 if (session_id != CSR_SESSION_ID_INVALID)
16130 return;
16131
16132 session_id = csr_get_connected_infra(mac_ctx);
16133 if (session_id == CSR_SESSION_ID_INVALID) {
16134 sme_debug("No STA in conencted state");
16135 return;
16136 }
16137
16138 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
16139 session_id);
16140 status = sme_acquire_global_lock(&mac_ctx->sme);
16141 if (QDF_IS_STATUS_SUCCESS(status)) {
16142 csr_roam_offload_scan(mac_ctx, session_id,
16143 ROAM_SCAN_OFFLOAD_START,
16144 REASON_CTX_INIT);
16145 sme_release_global_lock(&mac_ctx->sme);
16146 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016147}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016148
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016149int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
16150{
16151 uint8_t vdev_id, chan;
16152 struct csr_roam_session *session;
16153 tpAniSirGlobal mac_ctx;
16154 tHalHandle h_hal;
16155 int16_t freq = 0;
16156
16157 if (vdev == NULL) {
16158 sme_err("Invalid vdev id is passed");
16159 return 0;
16160 }
16161
16162 h_hal = cds_get_context(QDF_MODULE_ID_SME);
16163 mac_ctx = PMAC_STRUCT(h_hal);
16164 vdev_id = wlan_vdev_get_id(vdev);
16165 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16166 sme_err("Invalid vdev id is passed");
16167 return 0;
16168 }
16169
16170 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16171 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
16172 if (chan)
16173 freq = cds_chan_to_freq(chan);
16174
16175 return freq;
16176}
16177
16178enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
16179{
16180 uint8_t vdev_id;
16181 struct csr_roam_session *session;
16182 tpAniSirGlobal mac_ctx;
16183 tHalHandle h_hal;
16184 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
16185
16186 if (vdev == NULL) {
16187 sme_err("Invalid vdev id is passed");
16188 return CH_WIDTH_INVALID;
16189 }
16190
16191 h_hal = cds_get_context(QDF_MODULE_ID_SME);
16192 mac_ctx = PMAC_STRUCT(h_hal);
16193 vdev_id = wlan_vdev_get_id(vdev);
16194 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16195 sme_err("Invalid vdev id is passed");
16196 return CH_WIDTH_INVALID;
16197 }
16198
16199 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16200
16201 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16202 ch_width = session->connectedProfile.vht_channel_width;
16203
16204 return ch_width;
16205}
16206
16207int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16208 uint16_t *sec20chan_freq)
16209{
16210 uint8_t vdev_id;
16211
16212 vdev_id = wlan_vdev_get_id(vdev);
16213 /* Need to extend */
16214 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016215}
16216
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016217#ifdef WLAN_FEATURE_SAE
16218QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16219 uint8_t sae_status)
16220{
16221 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16222 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16223 struct sir_sae_msg *sae_msg;
16224 struct scheduler_msg sch_msg = {0};
16225
16226 qdf_status = sme_acquire_global_lock(&mac->sme);
16227 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16228 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16229 if (!sae_msg) {
16230 qdf_status = QDF_STATUS_E_NOMEM;
16231 sme_err("SAE: memory allocation failed");
16232 } else {
16233 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16234 sae_msg->length = sizeof(*sae_msg);
16235 sae_msg->session_id = session_id;
16236 sae_msg->sae_status = sae_status;
16237 sme_debug("SAE: sae_status %d session_id %d",
16238 sae_msg->sae_status,
16239 sae_msg->session_id);
16240
16241 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16242 sch_msg.bodyptr = sae_msg;
16243
16244 qdf_status =
16245 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16246 }
16247 sme_release_global_lock(&mac->sme);
16248 }
16249
16250 return qdf_status;
16251}
16252#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016253
16254bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16255{
16256 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16257
16258 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16259 sme_err("Invalid session id: %d", session_id);
16260 return false;
16261 }
16262
16263 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16264}