blob: c50a988090e1ac200d9c0a317529657cd1b8bbf3 [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_roam_set_key() - To set encryption key.
4129 * @hal: hal global context
4130 * @session_id: session id
4131 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4132 * @ptr_roam_id: Upon success return, this is the id caller can use to
4133 * identify the request in roamcallback
4134 *
4135 * This function should be called only when connected. This is an asynchronous
4136 * API.
4137 *
4138 * Return: Status of operation
4139 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304140QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4142{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304143 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4145 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304146 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4148
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304149 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 session_id, 0));
4151 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004152 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304153 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 }
4155 /*Once Setkey is done, we can go in BMPS */
4156 if (set_key->keyLength)
4157 ps_global_info->remain_in_power_active_till_dhcp = false;
4158
4159 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304160 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 return status;
4162
4163 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4164 if (ptr_roam_id)
4165 *ptr_roam_id = roam_id;
4166
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004167 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004169 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 session = CSR_GET_SESSION(mac_ctx, session_id);
4171 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004172 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304174 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 }
4176 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4177 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4178 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4179 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4180 set_key->encType)) {
4181 session->pCurRoamProfile->negotiatedUCEncryptionType =
4182 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4183 }
4184 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4185 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4186 set_key->encType)) {
4187 session->pCurRoamProfile->negotiatedUCEncryptionType =
4188 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4189 }
4190 }
4191 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4192 sme_release_global_lock(&mac_ctx->sme);
4193 return status;
4194}
4195
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304196/**
4197 * sme_roam_set_default_key_index - To set default wep key idx
4198 * @hal: pointer to hal handler
4199 * @session_id: session id
4200 * @default_idx: default wep key index
4201 *
4202 * This function prepares a message and post to WMA to set wep default
4203 * key index
4204 *
4205 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4206 */
4207QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4208 uint8_t default_idx)
4209{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004210 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304211 struct wep_update_default_key_idx *update_key;
4212
4213 update_key = qdf_mem_malloc(sizeof(*update_key));
4214 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004215 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304216 return QDF_STATUS_E_NOMEM;
4217 }
4218
4219 update_key->session_id = session_id;
4220 update_key->default_idx = default_idx;
4221
4222 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4223 msg.reserved = 0;
4224 msg.bodyptr = (void *)update_key;
4225
4226 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004227 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004228 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304229 qdf_mem_free(update_key);
4230 return QDF_STATUS_E_FAILURE;
4231 }
4232
4233 return QDF_STATUS_SUCCESS;
4234}
4235
4236
Jeff Johnson8bd23352017-09-26 11:39:24 -07004237/**
4238 * sme_get_rssi() - API to retrieve current RSSI
4239 * @hHal: HAL handle for device
4240 * @callback: SME sends back the requested stats using the callback
4241 * @staId: The station ID for which the RSSI is requested for
4242 * @bssid: The bssid of the connected session
4243 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4244 * RSSI, do not hold up but return this value.
4245 * @pContext: user context to be passed back along with the callback
4246 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304247 * A wrapper function that client calls to register a callback to get RSSI
4248 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004249 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304250 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304251QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304252 tCsrRssiCallback callback, uint8_t staId,
4253 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004254 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304256 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4258
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304259 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4261 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304262 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 status = csr_get_rssi(pMac, callback,
4264 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004265 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 sme_release_global_lock(&pMac->sme);
4267 }
4268 return status;
4269}
4270
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304271/*
4272 * sme_get_snr() -
4273 * A wrapper function that client calls to register a callback to get SNR
4274 *
4275 * callback - SME sends back the requested stats using the callback
4276 * staId - The station ID for which the stats is requested for
4277 * pContext - user context to be passed back along with the callback
4278 * p_cds_context - cds context
4279 * \return QDF_STATUS
4280 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304281QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304283 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304285 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4287
4288 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304289 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4291 sme_release_global_lock(&pMac->sme);
4292 }
4293 return status;
4294}
4295
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304296/*
4297 * sme_get_statistics() -
4298 * A wrapper function that client calls to register a callback to get
4299 * different PHY level statistics from CSR.
4300 *
4301 * requesterId - different client requesting for statistics,
4302 * HDD, UMA/GAN etc
4303 * statsMask - The different category/categories of stats requester
4304 * is looking for
4305 * callback - SME sends back the requested stats using the callback
4306 * periodicity - If requester needs periodic update in millisec, 0 means
4307 * it's an one time request
4308 * cache - If requester is happy with cached stats
4309 * staId - The station ID for which the stats is requested for
4310 * pContext - user context to be passed back along with the callback
4311 * sessionId - sme session interface
4312 * Return QDF_STATUS
4313 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304314QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 eCsrStatsRequesterType requesterId,
4316 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004317 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304319 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304323 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304324 status = csr_get_statistics(pMac, requesterId, statsMask,
4325 callback, staId, pContext,
4326 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 sme_release_global_lock(&pMac->sme);
4328 }
4329
4330 return status;
4331
4332}
4333
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304334QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 tCsrLinkStatusCallback callback,
4336 void *pContext, uint8_t sessionId)
4337{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304338 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4340 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004341 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
4343 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304344 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304345 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304347 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 "%s: Not able to allocate memory for link status",
4349 __func__);
4350 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304351 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 }
4353
4354 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4355 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4356 pMsg->sessionId = sessionId;
4357 pMac->sme.linkStatusContext = pContext;
4358 pMac->sme.linkStatusCallback = callback;
4359
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004360 message.type = WMA_LINK_STATUS_GET_REQ;
4361 message.bodyptr = pMsg;
4362 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304364 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004365 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4366 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304369 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 pMac->sme.linkStatusContext = NULL;
4371 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304372 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 }
4374
4375 sme_release_global_lock(&pMac->sme);
4376 }
4377
4378 return status;
4379}
4380
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304381/*
4382 * sme_get_country_code() -
4383 * To return the current country code. If no country code is applied,
4384 * default country code is used to fill the buffer.
4385 * If 11d supported is turned off, an error is return and the last
4386 * applied/default country code is used.
4387 * This is a synchronous API.
4388 *
4389 * pBuf - pointer to a caller allocated buffer for returned country code.
4390 * pbLen For input, this parameter indicates how big is the buffer.
4391 * Upon return, this parameter has the number of bytes for
4392 * country. If pBuf doesn't have enough space, this function
4393 * returns fail status and this parameter contains the number
4394 * that is needed.
4395 *
4396 * Return QDF_STATUS SUCCESS.
4397 *
4398 * FAILURE or RESOURCES The API finished and failed.
4399 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401{
4402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4403
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304404 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4406
4407 return csr_get_country_code(pMac, pBuf, pbLen);
4408}
4409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410/* some support functions */
4411bool sme_is11d_supported(tHalHandle hHal)
4412{
4413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4414
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004415 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416}
4417
4418bool sme_is11h_supported(tHalHandle hHal)
4419{
4420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4421
4422 return csr_is11h_supported(pMac);
4423}
4424
4425bool sme_is_wmm_supported(tHalHandle hHal)
4426{
4427 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4428
4429 return csr_is_wmm_supported(pMac);
4430}
4431
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304432/*
4433 * sme_change_country_code() -
4434 * Change Country code from upperlayer during WLAN driver operation.
4435 * This is a synchronous API.
4436 *
4437 * hHal - The handle returned by mac_open.
4438 * pCountry New Country Code String
4439 * sendRegHint If we want to send reg hint to nl80211
4440 * Return QDF_STATUS SUCCESS.
4441 * FAILURE or RESOURCES The API finished and failed.
4442 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304443QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 tSmeChangeCountryCallback callback,
4445 uint8_t *pCountry,
4446 void *pContext,
4447 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004448 bool countryFromUserSpace,
4449 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304451 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004453 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454 tAniChangeCountryCodeReq *pMsg;
4455
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304456 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4458 0));
4459 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304460 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4462 && (!pMac->roam.configParam.
4463 fSupplicantCountryCodeHasPriority)) {
4464
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004465 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466
4467 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304468 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 return status;
4470 }
4471
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304472 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004474 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 }
4478
4479 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4480 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304481 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 pMsg->countryFromUserSpace = countryFromUserSpace;
4483 pMsg->sendRegHint = sendRegHint;
4484 pMsg->changeCCCallback = callback;
4485 pMsg->pDevContext = pContext;
4486 pMsg->p_cds_context = p_cds_context;
4487
4488 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4489 msg.bodyptr = pMsg;
4490 msg.reserved = 0;
4491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304492 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004493 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004494 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304495 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304496 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 sme_release_global_lock(&pMac->sme);
4499 }
4500
4501 return status;
4502}
4503
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304504/*
4505 * sme_generic_change_country_code() -
4506 * Change Country code from upperlayer during WLAN driver operation.
4507 * This is a synchronous API.
4508 *
4509 * hHal - The handle returned by mac_open.
4510 * pCountry New Country Code String
4511 * reg_domain regulatory domain
4512 * Return QDF_STATUS SUCCESS.
4513 * FAILURE or RESOURCES The API finished and failed.
4514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304515QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004516 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304518 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004520 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 tAniGenericChangeCountryCodeReq *pMsg;
4522
4523 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304524 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 "%s: pMac is null", __func__);
4526 return status;
4527 }
4528
4529 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304530 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304531 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532
4533 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004534 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304536 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 }
4538
4539 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4540 pMsg->msgLen =
4541 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304542 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004543 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544
4545 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4546 msg.bodyptr = pMsg;
4547 msg.reserved = 0;
4548
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304549 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004550 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004551 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304552 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304553 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 sme_release_global_lock(&pMac->sme);
4556 }
4557
4558 return status;
4559}
4560
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304561/*
4562 * sme_dhcp_start_ind() -
4563 * API to signal the FW about the DHCP Start event.
4564 *
4565 * hHal - HAL handle for device.
4566 * device_mode - mode(AP,SAP etc) of the device.
4567 * macAddr - MAC address of the adapter.
4568 * sessionId - session ID.
4569 * Return QDF_STATUS SUCCESS.
4570 * FAILURE or RESOURCES The API finished and failed.
4571 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304572QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 uint8_t device_mode,
4574 uint8_t *macAddr, uint8_t sessionId)
4575{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304576 QDF_STATUS status;
4577 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004579 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304581 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582
4583 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304584 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 pSession = CSR_GET_SESSION(pMac, sessionId);
4586
4587 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004588 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304590 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 }
Arif Hussain3316f402016-11-10 13:08:03 -08004592 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304594 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304596 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 "%s: Not able to allocate memory for dhcp start",
4598 __func__);
4599 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304600 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 }
4602 pMsg->msgType = WMA_DHCP_START_IND;
4603 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4604 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304605 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304606 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304607 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004608 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004610 message.type = WMA_DHCP_START_IND;
4611 message.bodyptr = pMsg;
4612 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304613 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004614 sessionId, message.type));
4615 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4616 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304617 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304618 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304620 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304621 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 }
4623 sme_release_global_lock(&pMac->sme);
4624 }
4625 return status;
4626}
4627
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304628/*
4629 * sme_dhcp_stop_ind() -
4630 * API to signal the FW about the DHCP complete event.
4631 *
4632 * hHal - HAL handle for device.
4633 * device_mode - mode(AP, SAP etc) of the device.
4634 * macAddr - MAC address of the adapter.
4635 * sessionId - session ID.
4636 * Return QDF_STATUS SUCCESS.
4637 * FAILURE or RESOURCES The API finished and failed.
4638 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304639QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 uint8_t device_mode,
4641 uint8_t *macAddr, uint8_t sessionId)
4642{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304643 QDF_STATUS status;
4644 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004646 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304648 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649
4650 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304651 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 pSession = CSR_GET_SESSION(pMac, sessionId);
4653
4654 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004655 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304657 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 }
Arif Hussain3316f402016-11-10 13:08:03 -08004659 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304661 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304663 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 "%s: Not able to allocate memory for dhcp stop",
4665 __func__);
4666 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304667 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 }
4669
4670 pMsg->msgType = WMA_DHCP_STOP_IND;
4671 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4672 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304673 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304674 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304675 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004676 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004678 message.type = WMA_DHCP_STOP_IND;
4679 message.bodyptr = pMsg;
4680 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304681 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004682 sessionId, message.type));
4683 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4684 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304685 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304688 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 }
4691
4692 sme_release_global_lock(&pMac->sme);
4693 }
4694 return status;
4695}
4696
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304697/*
4698 * sme_TXFailMonitorStopInd() -
4699 * API to signal the FW to start monitoring TX failures
4700 *
4701 * Return QDF_STATUS SUCCESS.
4702 * FAILURE or RESOURCES The API finished and failed.
4703 */
4704QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4705 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004706 void *txFailIndCallback)
4707{
4708 QDF_STATUS status;
4709 QDF_STATUS qdf_status;
4710 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004711 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004712 tAniTXFailMonitorInd *pMsg;
4713
4714 status = sme_acquire_global_lock(&pMac->sme);
4715 if (QDF_STATUS_SUCCESS == status) {
4716 pMsg = (tAniTXFailMonitorInd *)
4717 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4718 if (NULL == pMsg) {
4719 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4720 "%s: Failed to allocate memory", __func__);
4721 sme_release_global_lock(&pMac->sme);
4722 return QDF_STATUS_E_NOMEM;
4723 }
4724
4725 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4726 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4727
4728 /* tx_fail_count = 0 should disable the Monitoring in FW */
4729 pMsg->tx_fail_count = tx_fail_count;
4730 pMsg->txFailIndCallback = txFailIndCallback;
4731
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004732 message.type = WMA_TX_FAIL_MONITOR_IND;
4733 message.bodyptr = pMsg;
4734 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004735
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004736 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4737 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004738 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4740 "%s: Post TX Fail monitor Start MSG fail",
4741 __func__);
4742 qdf_mem_free(pMsg);
4743 status = QDF_STATUS_E_FAILURE;
4744 }
4745 sme_release_global_lock(&pMac->sme);
4746 }
4747 return status;
4748}
4749
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304750/*
4751 * sme_set_cfg_privacy() -
4752 * API to set configure privacy parameters
4753 *
4754 * hHal - The handle returned by mac_open.
4755 * pProfile - Pointer CSR Roam profile.
4756 * fPrivacy - This parameter indicates status of privacy
4757 * Return void
4758 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759void sme_set_cfg_privacy(tHalHandle hHal,
4760 tCsrRoamProfile *pProfile, bool fPrivacy)
4761{
4762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304763
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304764 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304766 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4768 sme_release_global_lock(&pMac->sme);
4769 }
4770}
4771
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304772/*
4773 * sme_neighbor_report_request() -
4774 * API to request neighbor report.
4775 *
4776 * hHal - The handle returned by mac_open.
4777 * pRrmNeighborReq - Pointer to a caller allocated object of type
4778 * tRrmNeighborReq. Caller owns the memory and is
4779 * responsible for freeing it.
4780 * Return QDF_STATUS
4781 * QDF_STATUS_E_FAILURE - failure
4782 * QDF_STATUS_SUCCESS success
4783 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304784QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304786 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304788 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304790
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304791 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4793 0));
4794
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304795 if (pRrmNeighborReq->neighbor_report_offload) {
4796 status = csr_invoke_neighbor_report_request(sessionId,
4797 pRrmNeighborReq,
4798 false);
4799 return status;
4800 }
4801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304802 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 status =
4804 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304805 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806 sme_release_global_lock(&pMac->sme);
4807 }
4808
4809 return status;
4810}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304812/*
4813 * sme_get_wcnss_wlan_compiled_version() -
4814 * This API returns the version of the WCNSS WLAN API with
4815 * which the HOST driver was built
4816 *
4817 * hHal - The handle returned by mac_open.
4818 * pVersion - Points to the Version structure to be filled
4819 * Return QDF_STATUS
4820 * QDF_STATUS_E_INVAL - failure
4821 * QDF_STATUS_SUCCESS success
4822 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304823QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 tSirVersionType *pVersion)
4825{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304826 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304829 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304831 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304833 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834
4835 sme_release_global_lock(&pMac->sme);
4836 }
4837
4838 return status;
4839}
4840
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304841/*
4842 * sme_get_wcnss_wlan_reported_version() -
4843 * This API returns the version of the WCNSS WLAN API with
4844 * which the WCNSS driver reports it was built
4845 * hHal - The handle returned by mac_open.
4846 * pVersion - Points to the Version structure to be filled
4847 * Return QDF_STATUS
4848 * QDF_STATUS_E_INVAL - failure
4849 * QDF_STATUS_SUCCESS success
4850 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304851QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852 tSirVersionType *pVersion)
4853{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304854 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4856
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304857 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304859 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304861 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862
4863 sme_release_global_lock(&pMac->sme);
4864 }
4865
4866 return status;
4867}
4868
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304869/*
4870 * sme_get_wcnss_software_version() -
4871 * This API returns the version string of the WCNSS driver
4872 *
4873 * hHal - The handle returned by mac_open.
4874 * pVersion - Points to the Version string buffer to be filled
4875 * versionBufferSize - THe size of the Version string buffer
4876 * Return QDF_STATUS
4877 * QDF_STATUS_E_INVAL - failure
4878 * QDF_STATUS_SUCCESS success
4879 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304880QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 uint8_t *pVersion,
4882 uint32_t versionBufferSize)
4883{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304884 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304887 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304888 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004890 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 pVersion,
4892 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304893 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304894 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 sme_release_global_lock(&pMac->sme);
4896 }
4897
4898 return status;
4899}
4900
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304901/*
4902 * sme_get_wcnss_hardware_version() -
4903 * This API returns the version string of the WCNSS hardware
4904 *
4905 * hHal - The handle returned by mac_open.
4906 * pVersion - Points to the Version string buffer to be filled
4907 * versionBufferSize - THe size of the Version string buffer
4908 * Return QDF_STATUS
4909 * QDF_STATUS_E_INVAL - failure
4910 * QDF_STATUS_SUCCESS success
4911 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304912QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 uint8_t *pVersion,
4914 uint32_t versionBufferSize)
4915{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304916 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4918
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304919 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304921 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924
4925 sme_release_global_lock(&pMac->sme);
4926 }
4927
4928 return status;
4929}
4930
4931#ifdef FEATURE_WLAN_WAPI
4932
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304933/*
4934 * sme_scan_get_bkid_candidate_list() -
4935 * A wrapper function to return the BKID candidate list
4936 *
4937 * pBkidList - caller allocated buffer point to an array of
4938 * tBkidCandidateInfo
4939 * pNumItems - pointer to a variable that has the number of
4940 * tBkidCandidateInfo allocated when retruning, this is
4941 * either the number needed or number of items put into
4942 * pPmkidList
4943 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
4944 * big enough and pNumItems
4945 * has the number of tBkidCandidateInfo.
4946 * Note: pNumItems is a number of tBkidCandidateInfo,
4947 * not sizeof(tBkidCandidateInfo) * something
4948 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304949QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 tBkidCandidateInfo *pBkidList,
4951 uint32_t *pNumItems)
4952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304953 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4955
4956 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304957 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304959 csr_scan_get_bkid_candidate_list(pMac, sessionId,
4960 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 sme_release_global_lock(&pMac->sme);
4962 }
4963
4964 return status;
4965}
4966#endif /* FEATURE_WLAN_WAPI */
4967
4968#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004969/**
4970 * sme_oem_data_req() - send oem data request to WMA
4971 * @hal: HAL handle
4972 * @hdd_oem_req: OEM data request from HDD
4973 *
4974 * Return: QDF_STATUS
4975 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004976QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304978 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004979 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004980 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004982 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004983 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4984 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004985 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004986 return QDF_STATUS_E_FAILURE;
4987 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004989 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
4990 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004991 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004992 return QDF_STATUS_E_NOMEM;
4993 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004995 oem_data_req->data_len = hdd_oem_req->data_len;
4996 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
4997 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004998 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004999 return QDF_STATUS_E_NOMEM;
5000 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005002 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5003 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005005 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305007 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005008 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305009 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005010 sme_debug("OEM request(length: %d) sent to WMA",
5011 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005012
5013 if (oem_data_req->data_len)
5014 qdf_mem_free(oem_data_req->data);
5015 qdf_mem_free(oem_data_req);
5016
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005017 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018 return status;
5019}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020#endif /*FEATURE_OEM_DATA_SUPPORT */
5021
Krunal Soni8d184fa2017-11-20 21:52:05 -08005022QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023{
Arif Hussainee677012017-01-26 17:50:13 -08005024 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005025 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08005026 struct cdp_pdev *pdev;
5027 ol_txrx_peer_handle peer;
5028 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005029 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305031 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005032 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08005033 __func__, params->type_of_persona,
5034 params->sme_session_id, params->subtype_of_persona,
5035 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036
Arif Hussainee677012017-01-26 17:50:13 -08005037 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5038
5039 if (NULL == pdev) {
5040 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5041 "%s: Failed to get pdev handler", __func__);
5042 return status;
5043 }
5044
Krunal Soni8d184fa2017-11-20 21:52:05 -08005045 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005046 if (QDF_IS_STATUS_ERROR(status))
5047 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048
Krunal Soni8d184fa2017-11-20 21:52:05 -08005049 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
5050 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005051 if (peer) {
5052 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5053 "%s: Peer=%d exist with same MAC",
5054 __func__, peer_id);
5055 status = QDF_STATUS_E_INVAL;
5056 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005057 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08005058 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08005059 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005060
5061 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005062 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063
5064 return status;
5065}
5066
Krunal Soni8d184fa2017-11-20 21:52:05 -08005067QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305069 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005070 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305072 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005073 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305075 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005076 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 sme_release_global_lock(&pMac->sme);
5078 }
5079
5080 return status;
5081}
5082
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305083/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305084 * sme_change_mcc_beacon_interval() -
5085 * To update P2P-GO beaconInterval. This function should be called after
5086 * disassociating all the station is done
5087 * This is an asynchronous API.
5088 *
5089 * @sessionId: Session Identifier
5090 * Return QDF_STATUS SUCCESS
5091 * FAILURE or RESOURCES
5092 * The API finished and failed.
5093 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005094QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305096 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005097 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098
Krunal Soni3fa80e22018-01-09 14:16:02 -08005099 if (!mac_ctx) {
5100 sme_err("mac_ctx is NULL");
5101 return status;
5102 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005103 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305104 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005105 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5106 sessionId);
5107 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108 }
5109 return status;
5110}
5111
5112/**
5113 * sme_set_host_offload(): API to set the host offload feature.
5114 * @hHal: The handle returned by mac_open.
5115 * @sessionId: Session Identifier
5116 * @request: Pointer to the offload request.
5117 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305118 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305120QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 tpSirHostOffloadReq request)
5122{
5123 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305124 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305126 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5128 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305129 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130#ifdef WLAN_NS_OFFLOAD
5131 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5132 status = sme_set_ps_ns_offload(hHal, request,
5133 sessionId);
5134 } else
5135#endif /* WLAN_NS_OFFLOAD */
5136 {
5137 status = sme_set_ps_host_offload(hHal, request,
5138 sessionId);
5139 }
5140 sme_release_global_lock(&pMac->sme);
5141 }
5142
5143 return status;
5144}
5145
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305146/*
5147 * sme_set_keep_alive() -
5148 * API to set the Keep Alive feature.
5149 *
5150 * hHal - The handle returned by mac_open.
5151 * request - Pointer to the Keep Alive request.
5152 * Return QDF_STATUS
5153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305154QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 tpSirKeepAliveReq request)
5156{
5157 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005158 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305160 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 FL("WMA_SET_KEEP_ALIVE message"));
5164
5165 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305168 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305170 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305172 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305173 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305174 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 }
5176
Anurag Chouhanc5548422016-02-24 18:33:27 +05305177 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305178 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 "buff TP %d input TP %d ", request_buf->timePeriod,
5182 request->timePeriod);
5183 request_buf->sessionId = session_id;
5184
5185 msg.type = WMA_SET_KEEP_ALIVE;
5186 msg.reserved = 0;
5187 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305188 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5189 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305190 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005191 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305192 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305193 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305194 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305195 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 }
5197
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305198 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199}
5200
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305201/*
5202 * sme_get_operation_channel() -
5203 * API to get current channel on which STA is parked his function gives
5204 * channel information only of infra station or IBSS station
5205 *
5206 * hHal, pointer to memory location and sessionId
5207 * Returns QDF_STATUS_SUCCESS
5208 * QDF_STATUS_E_FAILURE
5209 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305210QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211 uint8_t sessionId)
5212{
5213 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305214 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215
5216 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5217 pSession = CSR_GET_SESSION(pMac, sessionId);
5218
5219 if ((pSession->connectedProfile.BSSType ==
5220 eCSR_BSS_TYPE_INFRASTRUCTURE)
5221 || (pSession->connectedProfile.BSSType ==
5222 eCSR_BSS_TYPE_IBSS)
5223 || (pSession->connectedProfile.BSSType ==
5224 eCSR_BSS_TYPE_INFRA_AP)
5225 || (pSession->connectedProfile.BSSType ==
5226 eCSR_BSS_TYPE_START_IBSS)) {
5227 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305228 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005229 }
5230 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305231 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232} /* sme_get_operation_channel ends here */
5233
Abhishek Singh7996eb72015-12-30 17:24:02 +05305234/**
5235 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5236 * management frame indication to PE.
5237 *
5238 * @hal: hal pointer
5239 * @callback: callback pointer to be registered
5240 *
5241 * This function is used to register a callback for management
5242 * frame indication to PE.
5243 *
5244 * Return: Success if msg is posted to PE else Failure.
5245 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305246QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305247 sir_mgmt_frame_ind_callback callback)
5248{
5249 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5250 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305251 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305252
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305253 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305254 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305255 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305256 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005257 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305258 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305259 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305260 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305261 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5262 msg->length = sizeof(*msg);
5263
5264 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005265 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305266 sme_release_global_lock(&mac_ctx->sme);
5267 return status;
5268 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305269 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305270}
5271
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305272/*
5273 * sme_RegisterMgtFrame() -
5274 * To register managment frame of specified type and subtype.
5275 *
5276 * frameType - type of the frame that needs to be passed to HDD.
5277 * matchData - data which needs to be matched before passing frame
5278 * to HDD.
5279 * matchDataLen - Length of matched data.
5280 * Return QDF_STATUS
5281 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305282QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 uint16_t frameType, uint8_t *matchData,
5284 uint16_t matchLen)
5285{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305286 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305290 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 tSirRegisterMgmtFrame *pMsg;
5292 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305293 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5294 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295
5296 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005297 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305299 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 }
5301
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305302 if (!CSR_IS_SESSION_ANY(sessionId) &&
5303 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305304 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 "%s Invalid Sessionid", __func__);
5306 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305307 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 }
5309
5310 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5311
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305312 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305314 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5317 pMsg->length = len;
5318 pMsg->sessionId = sessionId;
5319 pMsg->registerFrame = true;
5320 pMsg->frameType = frameType;
5321 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305322 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005323 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 }
5325 sme_release_global_lock(&pMac->sme);
5326 }
5327 return status;
5328}
5329
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305330/*
5331 * sme_DeregisterMgtFrame() -
5332 * To De-register managment frame of specified type and subtype.
5333 *
5334 * frameType - type of the frame that needs to be passed to HDD.
5335 * matchData - data which needs to be matched before passing frame
5336 * to HDD.
5337 * matchDataLen - Length of matched data.
5338 * Return QDF_STATUS
5339 */
5340QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 uint16_t frameType, uint8_t *matchData,
5342 uint16_t matchLen)
5343{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305344 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5346
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305347 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5349 0));
5350 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305351 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 tSirRegisterMgmtFrame *pMsg;
5353 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305354 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5355 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356
5357 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005358 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305360 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 }
5362
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305363 if (!CSR_IS_SESSION_ANY(sessionId) &&
5364 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305365 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 "%s Invalid Sessionid", __func__);
5367 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305368 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 }
5370
5371 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5372
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305373 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305375 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5378 pMsg->length = len;
5379 pMsg->registerFrame = false;
5380 pMsg->frameType = frameType;
5381 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305382 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005383 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 }
5385 sme_release_global_lock(&pMac->sme);
5386 }
5387 return status;
5388}
5389
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305390/**
5391 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5392 * @hal: The handle returned by mac_open
5393 * @session_id: session id
5394 * @buf: pointer to frame
5395 * @len: frame length
5396 *
5397 * Return: QDF_STATUS
5398 */
5399static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5400 const uint8_t *buf, uint32_t len)
5401{
5402 QDF_STATUS status = QDF_STATUS_SUCCESS;
5403 struct sir_mgmt_msg *msg;
5404 uint16_t msg_len;
5405 struct scheduler_msg sch_msg = {0};
5406
5407 sme_debug("prepares auth frame");
5408
5409 msg_len = sizeof(*msg) + len;
5410 msg = qdf_mem_malloc(msg_len);
5411 if (msg == NULL) {
5412 status = QDF_STATUS_E_NOMEM;
5413 } else {
5414 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5415 msg->msg_len = msg_len;
5416 msg->session_id = session_id;
5417 msg->data = (uint8_t *)msg + sizeof(*msg);
5418 qdf_mem_copy(msg->data, buf, len);
5419
5420 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5421 sch_msg.bodyptr = msg;
5422 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5423 }
5424 return status;
5425}
5426
5427QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5428 const uint8_t *buf, uint32_t len)
5429{
5430 QDF_STATUS status = QDF_STATUS_SUCCESS;
5431 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5432
5433 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5434 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5435
5436 status = sme_acquire_global_lock(&mac->sme);
5437 if (QDF_IS_STATUS_SUCCESS(status)) {
5438 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5439 sme_release_global_lock(&mac->sme);
5440 }
5441
5442 return status;
5443}
5444
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005446/**
5447 * sme_configure_ext_wow() - configure Extr WoW
5448 * @hHal - The handle returned by mac_open.
5449 * @wlanExtParams - Depicts the wlan Ext params.
5450 * @callback - ext_wow callback to be registered.
5451 * @callback_context - ext_wow callback context
5452 *
5453 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305454 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005455 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305456QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 tpSirExtWoWParams wlanExtParams,
5458 csr_readyToExtWoWCallback callback,
5459 void *callback_context)
5460{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305461 QDF_STATUS status = QDF_STATUS_SUCCESS;
5462 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005464 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305465 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466
5467 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305468 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305470 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5472
5473 pMac->readyToExtWoWCallback = callback;
5474 pMac->readyToExtWoWContext = callback_context;
5475
5476 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305477 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478
5479 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305480 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005481 message.bodyptr = MsgPtr;
5482 message.type = WMA_WLAN_EXT_WOW;
5483 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5484 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305485 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 pMac->readyToExtWoWCallback = NULL;
5487 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305488 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305489 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 }
5491 sme_release_global_lock(&pMac->sme);
5492 } else {
5493 pMac->readyToExtWoWCallback = NULL;
5494 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305495 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 }
5497
5498 return status;
5499}
5500
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305501/*
5502 * sme_configure_app_type1_params() -
5503 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5504 *
5505 * hHal - The handle returned by mac_open.
5506 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5507 * Return QDF_STATUS
5508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305509QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005510 tpSirAppType1Params wlanAppType1Params)
5511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305512 QDF_STATUS status = QDF_STATUS_SUCCESS;
5513 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005515 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517
5518 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305519 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305521 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5523 0));
5524
5525 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305526 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305528 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005529 message.bodyptr = MsgPtr;
5530 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5531 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5532 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305533 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305534 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305535 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005536 }
5537 sme_release_global_lock(&pMac->sme);
5538 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305539 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 }
5541
5542 return status;
5543}
5544
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305545/*
5546 * sme_configure_app_type2_params() -
5547 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5548 *
5549 * hHal - The handle returned by mac_open.
5550 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5551 * Return QDF_STATUS
5552 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305553QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305554 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305556 QDF_STATUS status = QDF_STATUS_SUCCESS;
5557 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005559 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305560 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561
5562 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305563 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305565 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5567 0));
5568
5569 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305570 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305572 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005573 message.bodyptr = MsgPtr;
5574 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5575 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5576 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305577 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305578 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305579 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 }
5581 sme_release_global_lock(&pMac->sme);
5582 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305583 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 }
5585
5586 return status;
5587}
5588#endif
5589
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305590/*
5591 * sme_get_infra_session_id
5592 * To get the session ID for infra session, if connected
5593 * This is a synchronous API.
5594 *
5595 * hHal - The handle returned by mac_open.
5596 * sessionid, -1 if infra session is not connected
5597 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598int8_t sme_get_infra_session_id(tHalHandle hHal)
5599{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305600 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 int8_t sessionid = -1;
5602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5603
5604 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305605 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606
5607 sessionid = csr_get_infra_session_id(pMac);
5608
5609 sme_release_global_lock(&pMac->sme);
5610 }
5611
5612 return sessionid;
5613}
5614
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305615/*
5616 * sme_get_infra_operation_channel() -
5617 * To get the operating channel for infra session, if connected
5618 * This is a synchronous API.
5619 *
5620 * hHal - The handle returned by mac_open.
5621 * sessionId - the sessionId returned by sme_open_session.
5622 * Return operating channel, 0 if infra session is not connected
5623 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5625{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305626 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005627 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5628 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305631 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632
5633 channel = csr_get_infra_operation_channel(pMac, sessionId);
5634
5635 sme_release_global_lock(&pMac->sme);
5636 }
5637
5638 return channel;
5639}
5640
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305641/* This routine will return poerating channel on which other BSS is operating
5642 * to be used for concurrency mode. If other BSS is not up or not connected it
5643 * will return 0
5644 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5646{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305647 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5649 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305652 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653
5654 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305655 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5656 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 sme_release_global_lock(&pMac->sme);
5658 }
5659
5660 return channel;
5661}
5662
5663#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5664uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5665 eCsrPhyMode sapPhyMode,
5666 uint8_t cc_switch_mode)
5667{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305668 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5670 uint16_t channel = 0;
5671
5672 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305673 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305675 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5676 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 cc_switch_mode);
5678 sme_release_global_lock(&pMac->sme);
5679 }
5680
5681 return channel;
5682}
5683#endif
5684
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305685/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005686 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005687 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005688 * @cb_fn: Callback function pointer
5689 * @db_ctx: Callback data
5690 *
5691 * Return: QDF_STATUS
5692 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005693QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005694 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5695{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005696 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005697 QDF_STATUS status;
5698
Manikandan Mohan976e7562016-03-15 16:33:31 -07005699 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005700 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005701 mac->sme.get_tsf_cb = cb_fn;
5702 mac->sme.get_tsf_cxt = cb_ctx;
5703 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005704 }
5705 return status;
5706}
5707
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305708/**
5709 * sme_reset_tsfcb() - Reset callback for TSF capture
5710 * @h_hal: Handler return by mac_open
5711 *
5712 * This function reset the tsf capture callback to SME
5713 *
5714 * Return: QDF_STATUS
5715 */
5716QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5717{
5718 tpAniSirGlobal mac;
5719 QDF_STATUS status;
5720
5721 if (!h_hal) {
5722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5723 FL("h_hal is not valid"));
5724 return QDF_STATUS_E_INVAL;
5725 }
5726 mac = PMAC_STRUCT(h_hal);
5727
5728 status = sme_acquire_global_lock(&mac->sme);
5729 if (QDF_IS_STATUS_SUCCESS(status)) {
5730 mac->sme.get_tsf_cb = NULL;
5731 mac->sme.get_tsf_cxt = NULL;
5732 sme_release_global_lock(&mac->sme);
5733 }
5734 return status;
5735}
5736
Manikandan Mohan976e7562016-03-15 16:33:31 -07005737#ifdef WLAN_FEATURE_TSF
5738/*
5739 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5740 * @h_hal: Handler return by mac_open
5741 * @pinvalue: gpio pin id
5742 *
5743 * Return: QDF_STATUS
5744 */
5745QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5746{
5747 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005748 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005749 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5750
5751 status = sme_acquire_global_lock(&mac->sme);
5752 if (QDF_IS_STATUS_SUCCESS(status)) {
5753 tsf_msg.type = WMA_TSF_GPIO_PIN;
5754 tsf_msg.reserved = 0;
5755 tsf_msg.bodyval = pinvalue;
5756
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005757 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005758 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005759 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005760 status = QDF_STATUS_E_FAILURE;
5761 }
5762 sme_release_global_lock(&mac->sme);
5763 }
5764 return status;
5765}
5766#endif
5767
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005768QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 uint32_t *len)
5770{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305771 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005772 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005774 if (NULL == mac_ctx) {
5775 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5776 FL("Invalid MAC context"));
5777 return QDF_STATUS_E_FAILURE;
5778 }
5779
5780 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305781 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005782 status = csr_get_cfg_valid_channels(mac_ctx,
5783 aValidChannels, len);
5784 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 }
5786
5787 return status;
5788}
5789
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005790static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5791{
5792 switch (src) {
5793 case SOURCE_CORE:
5794 return "WORLD MODE";
5795
5796 case SOURCE_DRIVER:
5797 return "BDF file";
5798
5799 case SOURCE_USERSPACE:
5800 return "user-space";
5801
5802 case SOURCE_11D:
5803 return "802.11D IEs in beacons";
5804
5805 default:
5806 return "unknown";
5807 }
5808}
5809
Amar Singhal6edf9732016-11-20 21:43:40 -08005810void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5811{
5812 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5813
5814 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005815
5816 sme_debug("Country source is %s",
5817 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005818}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305819/*
5820 * sme_handle_change_country_code() -
5821 * Change Country code, Reg Domain and channel list
5822 *
5823 * Details Country Code Priority
5824 * If Supplicant country code is priority than 11d is disabled.
5825 * If 11D is enabled, we update the country code after every scan.
5826 * Hence when Supplicant country code is priority, we don't need 11D info.
5827 * Country code from Supplicant is set as current courtry code.
5828 * User can send reset command XX (instead of country code) to reset the
5829 * country code to default values. If 11D is priority,
5830 * Than Supplicant country code code is set to default code. But 11D code
5831 * is set as current country code
5832 *
5833 * pMac - The handle returned by mac_open.
5834 * pMsgBuf - MSG Buffer
5835 * Return QDF_STATUS
5836 */
5837static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5838 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305840 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 tAniChangeCountryCodeReq *pMsg;
5842 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305843 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005844 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305846 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 /*
5848 * if the reset Supplicant country code command is triggered,
5849 * enable 11D, reset the country code and return
5850 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005851 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 pMac->roam.configParam.Is11dSupportEnabled =
5853 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5854
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005855 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5856 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857
5858 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305859 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305860 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 default_country,
5862 WNI_CFG_COUNTRY_CODE_LEN);
5863 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305864 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 return status;
5866 }
5867 /*
5868 * Update the 11d country to default country so that when
5869 * callback is received for this default country, driver will
5870 * not disable the 11d taking it as valid country by user.
5871 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005872 sme_debug(
5873 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305875 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 pMsg->countryCode,
5877 WNI_CFG_COUNTRY_CODE_LEN);
5878 } else {
5879 /* if Supplicant country code has priority, disable 11d */
5880 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305881 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 }
5884
5885 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305886 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887
5888 /* Set Current Country code and Current Regulatory domain */
5889 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305890 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 /* Supplicant country code failed. So give 11D priority */
5892 pMac->roam.configParam.Is11dSupportEnabled =
5893 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005894 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895 return status;
5896 }
5897
5898 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305899 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
5901
5902 /* Get Domain ID from country code */
5903 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305904 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005905 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07005906 domainIdIoctl,
5907 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305908 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005909 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 return status;
5911 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305912 /* Supplicant country code is invalid, so we are on world mode
5913 * now. So give 11D chance to update
5914 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 pMac->roam.configParam.Is11dSupportEnabled =
5916 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005917 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 }
5919
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005920 if (domainIdIoctl >= REGDOMAIN_COUNT) {
5921 sme_err("Invalid regId %d", domainIdIoctl);
5922 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 } else {
5924 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
5925 /* set again if we find AP with 11d info during scan */
5926 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005927 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305928 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305929 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305930 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 sizeof(pMac->scan.countryCode11d));
5932 }
5933 }
5934
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305935 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305937 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305939 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940}
5941
5942/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005943 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 * @mac_ctx: mac global context
5945 * @msg: request msg packet
5946 *
5947 * If Supplicant country code is priority than 11d is disabled.
5948 * If 11D is enabled, we update the country code after every scan.
5949 * Hence when Supplicant country code is priority, we don't need 11D info.
5950 * Country code from Supplicant is set as current country code.
5951 *
5952 * Return: status of operation
5953 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305954static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005955sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5956 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305958 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005959 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005960 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005962 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963
Amar Singhal6edf9732016-11-20 21:43:40 -08005964 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5965 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5966 if (user_ctry_priority)
5967 mac_ctx->roam.configParam.Is11dSupportEnabled =
5968 false;
5969 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305970 if (mac_ctx->roam.configParam.
5971 Is11dSupportEnabled &&
5972 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005974 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005975
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305976 status =
5977 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005978 mac_ctx,
5979 mac_ctx->scan.countryCode11d,
5980 &reg_domain_id,
5981 SOURCE_11D);
5982 return QDF_STATUS_E_FAILURE;
5983 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005984 }
5985 }
5986 } else {
5987 /* if kernel gets invalid country code; it
5988 * resets the country code to world
5989 */
5990 if (('0' != msg->countryCode[0]) ||
5991 ('0' != msg->countryCode[1]))
5992 qdf_mem_copy(mac_ctx->scan.countryCode11d,
5993 msg->countryCode,
5994 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005996
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005997 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
5998 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006001 /* get the channels based on new cc */
6002 status = csr_get_channel_and_power_list(mac_ctx);
6003
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306004 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006005 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 return status;
6007 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 /* reset info based on new cc, and we are done */
6010 csr_apply_channel_power_info_wrapper(mac_ctx);
6011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006013
6014 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 * Country IE
6016 */
6017 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006018
Amar Singhal6edf9732016-11-20 21:43:40 -08006019 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006022
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306023 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024}
6025
Mukul Sharmaecf8e092017-12-19 22:36:31 +05306026/**
6027 * sme_update_channel_list() - Update configured channel list to fwr
6028 * This is a synchronous API.
6029 *
6030 * @mac_ctx - The handle returned by mac_open.
6031 *
6032 * Return QDF_STATUS SUCCESS.
6033 * FAILURE or RESOURCES The API finished and failed.
6034 */
6035QDF_STATUS
6036sme_update_channel_list(tpAniSirGlobal mac_ctx)
6037{
6038 QDF_STATUS status = QDF_STATUS_SUCCESS;
6039
6040 status = sme_acquire_global_lock(&mac_ctx->sme);
6041 if (QDF_IS_STATUS_SUCCESS(status)) {
6042 /* Update umac channel (enable/disable) from cds channels */
6043 status = csr_get_channel_and_power_list(mac_ctx);
6044 if (status != QDF_STATUS_SUCCESS) {
6045 sme_err("fail to get Channels");
6046 sme_release_global_lock(&mac_ctx->sme);
6047 return status;
6048 }
6049
6050 csr_apply_channel_power_info_wrapper(mac_ctx);
6051 csr_scan_filter_results(mac_ctx);
6052 sme_disconnect_connected_sessions(mac_ctx);
6053 sme_release_global_lock(&mac_ctx->sme);
6054 }
6055
6056 return status;
6057}
6058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059static bool
6060sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6061{
6062 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306063 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 ch_lst_info = &mac_ctx->scan.base_channels;
6066 for (i = 0; i < ch_lst_info->numChannels; i++) {
6067 if (ch_lst_info->channelList[i] == curr_ch)
6068 return true;
6069 }
6070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 return false;
6072}
6073/**
6074 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6075 * if channel is not supported
6076 * @mac_ctx: mac global context
6077 *
6078 * If new country code does not support the channel on which STA/P2P client
6079 * is connetced, it sends the disconnect to the AP/P2P GO
6080 *
6081 * Return: void
6082 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306083static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006084{
6085 uint8_t session_id, found = false;
6086 uint8_t curr_ch;
6087
6088 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6089 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6090 continue;
6091 found = false;
6092 /* Session is connected.Check the channel */
6093 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6094 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006095 sme_debug("Current Operating channel : %d, session :%d",
6096 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006097 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6098 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006099 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100 csr_roam_disconnect(mac_ctx, session_id,
6101 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6102 }
6103 }
6104}
6105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306107QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 tpSirRcvFltMcAddrList pMulticastAddrs)
6109{
6110 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006111 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306113 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6116 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006117 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006118 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006120 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006121 pSession = CSR_GET_SESSION(pMac, sessionId);
6122 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6123 (!csr_is_conn_state_infra(pMac, sessionId) &&
6124 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006126 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306128 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 }
6130
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306131 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306133 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306134 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006135 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306136 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 }
6138
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006139 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6140 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006142 "%s: Request ignored, session %d is not connected or started",
6143 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306144 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306145 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 }
6147
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306148 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 sizeof(tSirRcvFltMcAddrList));
6150
Anurag Chouhanc5548422016-02-24 18:33:27 +05306151 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6152 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006153 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154
6155 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6156 msg.reserved = 0;
6157 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306158 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6159 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006160 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006161 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306163 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306165 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306166 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006167 }
6168
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306169 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006170}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171#endif /* WLAN_FEATURE_PACKET_FILTERING */
6172
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306173/*
6174 * sme_is_channel_valid() -
6175 * To check if the channel is valid for currently established domain
6176 * This is a synchronous API.
6177 *
6178 * hHal - The handle returned by mac_open.
6179 * channel - channel to verify
6180 * Return true/false, true if channel is valid
6181 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006182bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6183{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306184 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006185 bool valid = false;
6186 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6187
6188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306189 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190
6191 valid = csr_roam_is_channel_valid(pMac, channel);
6192
6193 sme_release_global_lock(&pMac->sme);
6194 }
6195
6196 return valid;
6197}
6198
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306199/*
6200 * sme_set_freq_band() -
6201 * Used to set frequency band.
6202 *
6203 * hHal
6204 * sessionId - Session Identifier
6205 * band value to be configured
6206 * Return QDF_STATUS
6207 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006208QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
6209 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306211 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006212 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6213
6214 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306215 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006216 status = csr_set_band(hHal, sessionId, eBand);
6217 sme_release_global_lock(&pMac->sme);
6218 }
6219 return status;
6220}
6221
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306222/*
6223 * sme_get_freq_band() -
6224 * Used to get the current band settings.
6225 *
6226 * hHal
6227 * pBand pointer to hold band value
6228 * Return QDF_STATUS
6229 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006230QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306232 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6234
6235 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306236 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237 *pBand = csr_get_current_band(hHal);
6238 sme_release_global_lock(&pMac->sme);
6239 }
6240 return status;
6241}
6242
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306243/*
6244 * sme_set_max_tx_power_per_band() -
6245 * Set the Maximum Transmit Power specific to band dynamically.
6246 * Note: this setting will not persist over reboots.
6247 *
6248 * band
6249 * power to set in dB
6250 * Return QDF_STATUS
6251 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006252QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006254 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6256
6257 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306258 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306260 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6262 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306263 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006264 }
6265
6266 pMaxTxPowerPerBandParams->power = dB;
6267 pMaxTxPowerPerBandParams->bandInfo = band;
6268
6269 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6270 msg.reserved = 0;
6271 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306272 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6273 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006274 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006275 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306276 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6278 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306279 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306280 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006281 }
6282
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306283 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284}
6285
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306286/*
6287 * sme_set_max_tx_power() -
6288 * Set the Maximum Transmit Power dynamically. Note: this setting will
6289 * not persist over reboots.
6290 *
6291 * hHal
6292 * pBssid BSSID to set the power cap for
6293 * pBssid pSelfMacAddress self MAC Address
6294 * pBssid power to set in dB
6295 * Return QDF_STATUS
6296 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306297QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6298 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006300 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006301 tpMaxTxPowerParams pMaxTxParams = NULL;
6302
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306303 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306305 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006306 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006308 "%s: Not able to allocate memory for pMaxTxParams",
6309 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306310 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006311 }
6312
Anurag Chouhanc5548422016-02-24 18:33:27 +05306313 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6314 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 pMaxTxParams->power = dB;
6316
6317 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6318 msg.reserved = 0;
6319 msg.bodyptr = pMaxTxParams;
6320
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006321 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006322 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306323 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6325 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306326 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306327 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006328 }
6329
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306330 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006331}
6332
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306333/*
6334 * sme_set_custom_mac_addr() -
6335 * Set the customer Mac Address.
6336 *
6337 * customMacAddr customer MAC Address
6338 * Return QDF_STATUS
6339 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306340QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006342 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006343 tSirMacAddr *pBaseMacAddr;
6344
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306345 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306347 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006348 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306349 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350 }
6351
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306352 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006353
6354 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6355 msg.reserved = 0;
6356 msg.bodyptr = pBaseMacAddr;
6357
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006358 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006359 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306360 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306361 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306362 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306363 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364 }
6365
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306366 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006367}
6368
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306369/*
6370 * sme_set_tx_power() -
6371 * Set Transmit Power dynamically.
6372 *
6373 * hHal
6374 * sessionId Target Session ID
6375 * BSSID
6376 * dev_mode dev_mode such as station, P2PGO, SAP
6377 * dBm power to set
6378 * Return QDF_STATUS
6379 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306380QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306381 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006382 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006384 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006385 tpMaxTxPowerParams pTxParams = NULL;
6386 int8_t power = (int8_t) dBm;
6387
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306388 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006389 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6390
6391 /* make sure there is no overflow */
6392 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306393 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306395 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006396 }
6397
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306398 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306400 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006401 "%s: Not able to allocate memory for pTxParams",
6402 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306403 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404 }
6405
Anurag Chouhanc5548422016-02-24 18:33:27 +05306406 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006407 pTxParams->power = power; /* unit is dBm */
6408 pTxParams->dev_mode = dev_mode;
6409 msg.type = WMA_SET_TX_POWER_REQ;
6410 msg.reserved = 0;
6411 msg.bodyptr = pTxParams;
6412
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006413 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006414 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306415 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6417 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306418 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306419 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006420 }
6421
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306422 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006423}
6424
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306425QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6426 uint8_t param_val)
6427{
6428 QDF_STATUS status;
6429 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6430
6431 pMac->roam.configParam.is_fils_enabled = !param_val;
6432
6433 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6434 status = wma_cli_set_command((int)session_id,
6435 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6436 !param_val, VDEV_CMD);
6437 if (status)
6438 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6439 "%s: Failed to set enable bcast probe setting",
6440 __func__);
6441
6442 return status;
6443}
6444
6445QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306446 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306448 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306449 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006450 uint16_t len;
6451
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306452 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306453 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306454 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306455 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6456 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006457
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306458 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006459 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306460 sme_release_global_lock(&mac_ctx->sme);
6461 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006462 }
6463
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306464 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6465 mac_ctx->ignore_assoc_disallowed = param_val;
6466
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306467 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306468 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306470 len = sizeof(*msg);
6471 msg = qdf_mem_malloc(len);
6472 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306473 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306475 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6476 msg->length = len;
6477 msg->session_id = session_id;
6478 msg->param_type = param_type;
6479 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006480 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006481 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306482 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 }
6484 return status;
6485}
6486
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306487/*
6488 * sme_set_tm_level() -
6489 * Set Thermal Mitigation Level to RIVA
6490 *
6491 * hHal - The handle returned by mac_open.
6492 * newTMLevel - new Thermal Mitigation Level
6493 * tmMode - Thermal Mitigation handle mode, default 0
6494 * Return QDF_STATUS
6495 */
6496QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6497 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006498{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306499 QDF_STATUS status = QDF_STATUS_SUCCESS;
6500 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006502 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006503 tAniSetTmLevelReq *setTmLevelReq = NULL;
6504
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306505 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6507 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306508 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 setTmLevelReq =
6510 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306511 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006512 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306513 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514 "%s: Not able to allocate memory for sme_set_tm_level",
6515 __func__);
6516 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306517 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006518 }
6519
6520 setTmLevelReq->tmMode = tmMode;
6521 setTmLevelReq->newTmLevel = newTMLevel;
6522
6523 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006524 message.bodyptr = setTmLevelReq;
6525 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306526 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006527 NO_SESSION, message.type));
6528 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6529 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306530 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306531 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006532 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306533 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306534 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006535 }
6536 sme_release_global_lock(&pMac->sme);
6537 }
6538 return status;
6539}
6540
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306541/*
6542 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6543 * Host and FW.
6544 *
6545 * hHal - HAL handle for device
6546 * Return NONE
6547 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006548void sme_feature_caps_exchange(tHalHandle hHal)
6549{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306550 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306551 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6552 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006553}
6554
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306555/*
6556 * sme_disable_feature_capablity() - SME interface to disable Active mode
6557 * offload capablity in Host.
6558 *
6559 * hHal - HAL handle for device
6560 * Return NONE
6561 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562void sme_disable_feature_capablity(uint8_t feature_index)
6563{
6564}
6565
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306566/*
6567 * sme_reset_power_values_for5_g
6568 * Reset the power values for 5G band with default power values.
6569 *
6570 * hHal - HAL handle for device
6571 * Return NONE
6572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006573void sme_reset_power_values_for5_g(tHalHandle hHal)
6574{
6575 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306576
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306577 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006578 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6579 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306580 /* Store the channel+power info in the global place: Cfg */
6581 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582}
6583
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306584/*
6585 * sme_update_roam_prefer5_g_hz() -
6586 * Enable/disable Roam prefer 5G runtime option
6587 * This function is called through dynamic setConfig callback function
6588 * to configure the Roam prefer 5G runtime option
6589 *
6590 * hHal - HAL handle for device
6591 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6592 * Return Success or failure
6593 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006594
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306595QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6596 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006597{
6598 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306599 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306601 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006602 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6603 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306604 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306605 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606 "%s: gRoamPrefer5GHz is changed from %d to %d",
6607 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6608 nRoamPrefer5GHz);
6609 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6610 sme_release_global_lock(&pMac->sme);
6611 }
6612
6613 return status;
6614}
6615
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306616/*
6617 * sme_set_roam_intra_band() -
6618 * enable/disable Intra band roaming
6619 * This function is called through dynamic setConfig callback function
6620 * to configure the intra band roaming
6621 * hHal - HAL handle for device
6622 * nRoamIntraBand Enable/Disable Intra band roaming
6623 * Return Success or failure
6624 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306625QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006626{
6627 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306628 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006629
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306630 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006631 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6632 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306633 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 "%s: gRoamIntraBand is changed from %d to %d",
6636 __func__, pMac->roam.configParam.nRoamIntraBand,
6637 nRoamIntraBand);
6638 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6639 sme_release_global_lock(&pMac->sme);
6640 }
6641
6642 return status;
6643}
6644
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306645/*
6646 * sme_update_roam_scan_n_probes() -
6647 * Function to update roam scan N probes
6648 * This function is called through dynamic setConfig callback function
6649 * to update roam scan N probes
6650 * hHal - HAL handle for device
6651 * sessionId - Session Identifier
6652 * nProbes number of probe requests to be sent out
6653 * Return Success or failure
6654 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306655QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 const uint8_t nProbes)
6657{
6658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306659 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306661 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006662 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6663 NO_SESSION, 0));
6664 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306665 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306666 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006667 "%s: gRoamScanNProbes is changed from %d to %d",
6668 __func__, pMac->roam.configParam.nProbes, nProbes);
6669 pMac->roam.configParam.nProbes = nProbes;
6670 sme_release_global_lock(&pMac->sme);
6671 }
6672 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6673 csr_roam_offload_scan(pMac, sessionId,
6674 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6675 REASON_NPROBES_CHANGED);
6676 }
6677 return status;
6678}
6679
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306680/*
6681 * sme_update_roam_scan_home_away_time() -
6682 * Function to update roam scan Home away time
6683 * This function is called through dynamic setConfig callback function
6684 * to update roam scan home away time
6685 *
6686 * hHal - HAL handle for device
6687 * sessionId - Session Identifier
6688 * nRoamScanAwayTime Scan home away time
6689 * bSendOffloadCmd If true then send offload command to firmware
6690 * If false then command is not sent to firmware
6691 * Return Success or failure
6692 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306693QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306695 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006696 const bool bSendOffloadCmd)
6697{
6698 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306699 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306701 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006702 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6703 NO_SESSION, 0));
6704 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306705 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306706 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006707 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6708 __func__,
6709 pMac->roam.configParam.nRoamScanHomeAwayTime,
6710 nRoamScanHomeAwayTime);
6711 pMac->roam.configParam.nRoamScanHomeAwayTime =
6712 nRoamScanHomeAwayTime;
6713 sme_release_global_lock(&pMac->sme);
6714 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306715 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6716 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717 csr_roam_offload_scan(pMac, sessionId,
6718 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6719 REASON_HOME_AWAY_TIME_CHANGED);
6720 }
6721 return status;
6722}
6723
Abhishek Singh518323d2015-10-19 17:42:01 +05306724/**
6725 * sme_ext_change_channel()- function to post send ECSA
6726 * action frame to csr.
6727 * @hHal: Hal context
6728 * @channel: new channel to switch
6729 * @session_id: senssion it should be sent on.
6730 *
6731 * This function is called to post ECSA frame to csr.
6732 *
6733 * Return: success if msg is sent else return failure
6734 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306735QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306736 uint8_t session_id)
6737{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306738 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306739 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6740 uint8_t channel_state;
6741
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006742 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306743 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006744 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306745
6746 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006747 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306748 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306749 }
6750
6751 status = sme_acquire_global_lock(&mac_ctx->sme);
6752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306753 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306754 /* update the channel list to the firmware */
6755 status = csr_send_ext_change_channel(mac_ctx,
6756 channel, session_id);
6757 sme_release_global_lock(&mac_ctx->sme);
6758 }
6759
6760 return status;
6761}
6762
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306763/*
6764 * sme_get_roam_intra_band() -
6765 * get Intra band roaming
6766 *
6767 * hHal - HAL handle for device
6768 * Return Success or failure
6769 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006770bool sme_get_roam_intra_band(tHalHandle hHal)
6771{
6772 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306773
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306774 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006775 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6776 return pMac->roam.configParam.nRoamIntraBand;
6777}
6778
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306779/*
6780 * sme_get_roam_scan_n_probes() -
6781 * get N Probes
6782 *
6783 * hHal - HAL handle for device
6784 * Return Success or failure
6785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6787{
6788 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306789
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006790 return pMac->roam.configParam.nProbes;
6791}
6792
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306793/*
6794 * sme_get_roam_scan_home_away_time() -
6795 * get Roam scan home away time
6796 *
6797 * hHal - HAL handle for device
6798 * Return Success or failure
6799 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6801{
6802 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006804 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6805}
6806
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306807/*
6808 * sme_update_roam_rssi_diff() -
6809 * Update RoamRssiDiff
6810 * This function is called through dynamic setConfig callback function
6811 * to configure RoamRssiDiff
6812 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6813 *
6814 * hHal - HAL handle for device
6815 * sessionId - Session Identifier
6816 * RoamRssiDiff - minimum rssi difference between potential
6817 * candidate and current AP.
6818 * Return Success or failure
6819 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306821QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 uint8_t RoamRssiDiff)
6823{
6824 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306825 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006826
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006827 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6828 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6829 FL("Invalid sme session id: %d"), sessionId);
6830 return QDF_STATUS_E_INVAL;
6831 }
6832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306834 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306835 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6837 RoamRssiDiff,
6838 pMac->roam.configParam.RoamRssiDiff,
6839 mac_trace_get_neighbour_roam_state(pMac->roam.
6840 neighborRoamInfo
6841 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306842 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006843 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6844 sme_release_global_lock(&pMac->sme);
6845 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006846
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306847 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848 csr_roam_offload_scan(pMac, sessionId,
6849 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6850 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006851 return status;
6852}
6853
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306854#ifdef WLAN_FEATURE_FILS_SK
6855QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6856 tCsrRoamProfile *src_profile)
6857{
6858 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6859 QDF_STATUS status = QDF_STATUS_SUCCESS;
6860 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6861 &mac->roam.neighborRoamInfo[session_id];
6862
6863 if (session_id >= CSR_ROAM_SESSION_MAX) {
6864 sme_err("Invalid sme session id: %d", session_id);
6865 return QDF_STATUS_E_INVAL;
6866 }
6867
6868 if (!src_profile) {
6869 sme_err("src roam profile NULL");
6870 return QDF_STATUS_E_INVAL;
6871 }
6872
6873 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6874 (neighbor_roam_info->neighborRoamState !=
6875 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6876 sme_info("Fast roam is disabled or not connected(%d)",
6877 neighbor_roam_info->neighborRoamState);
6878 return QDF_STATUS_E_PERM;
6879 }
6880
6881 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306882 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306883 sme_debug("Updating fils config to fw");
6884 csr_roam_offload_scan(mac, session_id,
6885 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6886 REASON_FILS_PARAMS_CHANGED);
6887 } else {
6888 sme_info("LFR3 not enabled");
6889 return QDF_STATUS_E_INVAL;
6890 }
6891
6892 return status;
6893}
6894
6895void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6896 tCsrRoamProfile *profile, uint32_t if_addr)
6897{
6898 int i;
6899 struct scheduler_msg msg;
6900 QDF_STATUS status;
6901 struct hlp_params *params;
6902 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6903 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6904 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6905 &mac->roam.neighborRoamInfo[session_id];
6906
6907 if (!session) {
6908 sme_err("session NULL");
6909 return;
6910 }
6911
6912 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6913 (neighbor_roam_info->neighborRoamState !=
6914 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6915 sme_debug("Fast roam is disabled or not connected(%d)",
6916 neighbor_roam_info->neighborRoamState);
6917 return;
6918 }
6919
6920 params = qdf_mem_malloc(sizeof(*params));
6921 if (!params) {
6922 sme_err("Mem alloc for HLP IE fails");
6923 return;
6924 }
6925 if ((profile->hlp_ie_len +
6926 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6927 sme_err("HLP IE len exceeds %d",
6928 profile->hlp_ie_len);
6929 qdf_mem_free(params);
6930 return;
6931 }
6932
6933 params->vdev_id = session_id;
6934 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6935
6936 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6937 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6938
6939 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6940 profile->hlp_ie, profile->hlp_ie_len);
6941
6942 msg.type = SIR_HAL_HLP_IE_INFO;
6943 msg.reserved = 0;
6944 msg.bodyptr = params;
6945 status = sme_acquire_global_lock(&mac->sme);
6946 if (status != QDF_STATUS_SUCCESS) {
6947 sme_err("sme lock acquire fails");
6948 qdf_mem_free(params);
6949 return;
6950 }
6951
6952 if (!QDF_IS_STATUS_SUCCESS
6953 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6954 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6955 sme_release_global_lock(&mac->sme);
6956 qdf_mem_free(params);
6957 return;
6958 }
6959
6960 sme_release_global_lock(&mac->sme);
6961}
6962
Jeff Johnson172237b2017-11-07 15:32:59 -08006963void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306964{
6965 struct fils_join_rsp_params *roam_fils_params;
6966
6967 if (!roam_info) {
6968 sme_err("FILS Roam Info NULL");
6969 return;
6970 }
6971
6972 roam_fils_params = roam_info->fils_join_rsp;
6973 if (!roam_fils_params) {
6974 sme_err("FILS Roam Param NULL");
6975 return;
6976 }
6977
6978 if (roam_fils_params->fils_pmk)
6979 qdf_mem_free(roam_fils_params->fils_pmk);
6980
6981 qdf_mem_free(roam_fils_params);
6982
6983 roam_info->fils_join_rsp = NULL;
6984}
6985
6986#else
6987inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6988 tCsrRoamProfile *profile, uint32_t if_addr)
6989{}
6990#endif
6991
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306992/*
6993 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6994 * support at runtime
6995 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6996 * isFastTransitionEnabled.
6997 * This is a synchronous call
6998 *
6999 * hHal - The handle returned by mac_open.
7000 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7001 * successfully.
7002 * Other status means SME is failed to update isFastTransitionEnabled.
7003 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307004QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007005 bool isFastTransitionEnabled)
7006{
7007 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307008 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007009
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307010 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7012 0));
7013 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307014 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016 "%s: FastTransitionEnabled is changed from %d to %d",
7017 __func__,
7018 pMac->roam.configParam.isFastTransitionEnabled,
7019 isFastTransitionEnabled);
7020 pMac->roam.configParam.isFastTransitionEnabled =
7021 isFastTransitionEnabled;
7022 sme_release_global_lock(&pMac->sme);
7023 }
7024
7025 return status;
7026}
7027
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307028/*
7029 * sme_update_wes_mode() -
7030 * Update WES Mode
7031 * This function is called through dynamic setConfig callback function
7032 * to configure isWESModeEnabled
7033 *
7034 * hHal - HAL handle for device
7035 * isWESModeEnabled - WES mode
7036 * sessionId - Session Identifier
7037 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7038 * Other status means SME is failed to update isWESModeEnabled.
7039 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007040
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307041QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007042 uint8_t sessionId)
7043{
7044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307045 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007046
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007047 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7049 FL("Invalid sme session id: %d"), sessionId);
7050 return QDF_STATUS_E_INVAL;
7051 }
7052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307054 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307055 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7057 isWESModeEnabled,
7058 pMac->roam.configParam.isWESModeEnabled,
7059 mac_trace_get_neighbour_roam_state(pMac->roam.
7060 neighborRoamInfo
7061 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307062 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007063 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7064 sme_release_global_lock(&pMac->sme);
7065 }
7066
7067 return status;
7068}
7069
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307070/*
7071 * sme_set_roam_scan_control() -
7072 * Set roam scan control
7073 * This function is called to set roam scan control
7074 * if roam scan control is set to 0, roaming scan cache is cleared
7075 * any value other than 0 is treated as invalid value
7076 * hHal - HAL handle for device
7077 * sessionId - Session Identifier
7078 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7079 * Other status means SME failure to update
7080 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307081QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007082 bool roamScanControl)
7083{
7084 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307085 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307087 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007088 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007089
7090 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7092 FL("Invalid sme session id: %d"), sessionId);
7093 return QDF_STATUS_E_INVAL;
7094 }
7095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307097 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007099 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7100 roamScanControl,
7101 pMac->roam.configParam.nRoamScanControl,
7102 mac_trace_get_neighbour_roam_state(pMac->roam.
7103 neighborRoamInfo
7104 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307105 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007106 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7107 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307108 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307110 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7111 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007112 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7113 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307114 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7115 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007116 }
7117 }
7118 sme_release_global_lock(&pMac->sme);
7119 }
7120 return status;
7121}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307123/*
7124 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7125 * support at runtime
7126 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7127 * isFastRoamIniFeatureEnabled.
7128 * This is a synchronous call
7129 *
7130 * hHal - The handle returned by mac_open.
7131 * sessionId - Session Identifier
7132 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7133 * successfully.
7134 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7135 */
7136QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7137 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7138{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7140
7141 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7142 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307143 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007144 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7145 __func__,
7146 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7147 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307148 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007149 }
7150
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307151 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007152 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7153 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7154 isFastRoamIniFeatureEnabled);
7155 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7156 isFastRoamIniFeatureEnabled;
7157 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307158 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007159
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307160 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161}
7162
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307163/**
7164 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7165 * @hal - The handle returned by macOpen.
7166 * @session_id - Session Identifier
7167 * @is_fast_roam_enabled - flag to enable/disable roaming
7168 *
7169 * When Supplicant issues enabled/disable fast roaming on the basis
7170 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7171 *
7172 * Return: QDF_STATUS
7173 */
7174
7175QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7176 const bool is_fast_roam_enabled)
7177{
7178 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307179 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307180 QDF_STATUS status;
7181
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007182 /*
7183 * supplicant_disabled_roaming flag is set to true in
7184 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7185 * request with BSSID. This flag is reset when supplicant sends
7186 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007187 *
7188 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007189 * if roaming is disabled using driver command or INI and
7190 * supplicant_disabled_roaming flag remains set. So make sure to set
7191 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7192 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007193 */
7194 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007195 session->pCurRoamProfile->supplicant_disabled_roaming =
7196 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007197
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307198 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007199 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307200 if (!is_fast_roam_enabled)
7201 return QDF_STATUS_SUCCESS;
7202 return QDF_STATUS_E_FAILURE;
7203 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307204
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307205 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7206 session_id, is_fast_roam_enabled);
7207 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007208 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307209 return QDF_STATUS_E_FAILURE;
7210 }
7211
7212 return QDF_STATUS_SUCCESS;
7213}
7214
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307215/*
7216 * sme_update_is_mawc_ini_feature_enabled() -
7217 * Enable/disable LFR MAWC support at runtime
7218 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7219 * isMAWCIniFeatureEnabled.
7220 * This is a synchronous call
7221 *
7222 * hHal - The handle returned by mac_open.
7223 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7224 * Other status means SME is failed to update MAWCEnabled.
7225 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307226QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007227 const bool MAWCEnabled)
7228{
7229 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307230 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007231
7232 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307233 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307234 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007235 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007236 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7237 MAWCEnabled);
7238 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7239 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007240 sme_release_global_lock(&pMac->sme);
7241 }
7242
7243 return status;
7244
7245}
7246
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007247/**
7248 * sme_stop_roaming() - Stop roaming for a given sessionId
7249 * This is a synchronous call
7250 *
7251 * @hHal - The handle returned by mac_open
7252 * @sessionId - Session Identifier
7253 *
7254 * Return QDF_STATUS_SUCCESS on success
7255 * Other status on failure
7256 */
7257QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007258{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007259 struct scheduler_msg wma_msg = {0};
7260 tSirRetStatus status;
7261 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007262 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7263 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007264 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007265
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007266 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007267 sme_err("incorrect session/vdev ID");
7268 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007269 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007270
7271 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05307272
7273 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
7274 if (!roam_info->b_roam_scan_offload_started) {
7275 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007276 return QDF_STATUS_SUCCESS;
7277 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007278 req = qdf_mem_malloc(sizeof(*req));
7279 if (!req) {
7280 sme_err("failed to allocated memory");
7281 return QDF_STATUS_E_NOMEM;
7282 }
7283
7284 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307285 if (reason == eCsrForcedDisassoc)
7286 req->reason = REASON_ROAM_STOP_ALL;
7287 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08007288 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007289 req->sessionId = session_id;
7290 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007291 req->middle_of_roaming = 1;
7292 else
7293 csr_roam_reset_roam_params(mac_ctx);
7294
7295 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7296 wma_msg.bodyptr = req;
7297
7298 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7299 if (eSIR_SUCCESS != status) {
7300 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007301 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007302 qdf_mem_free(req);
7303 return QDF_STATUS_E_FAULT;
7304 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007305 roam_info->b_roam_scan_offload_started = false;
7306 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007307
7308 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007309}
7310
Abhishek Singhd5686472017-09-20 15:18:50 +05307311void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7312{
7313 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7314 QDF_STATUS status = QDF_STATUS_SUCCESS;
7315 struct csr_roam_session *session;
7316
7317 status = sme_acquire_global_lock(&mac_ctx->sme);
7318 if (QDF_IS_STATUS_SUCCESS(status)) {
7319 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7320 session = CSR_GET_SESSION(mac_ctx, session_id);
7321 if (session)
7322 session->discon_in_progress = true;
7323 }
7324 sme_release_global_lock(&mac_ctx->sme);
7325 }
7326}
7327
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307328/*
7329 * sme_start_roaming() - Start roaming for a given sessionId
7330 * This is a synchronous call
7331 *
7332 * hHal - The handle returned by mac_open
7333 * sessionId - Session Identifier
7334 * Return QDF_STATUS_SUCCESS on success
7335 * Other status on failure
7336 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307337QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007338{
7339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307340 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341
7342 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307343 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007344 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7345 reason);
7346 sme_release_global_lock(&pMac->sme);
7347 }
7348
7349 return status;
7350}
7351
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307352/*
7353 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7354 * Concurrent session exists
7355 * This is a synchronuous call
7356 *
7357 * hHal - The handle returned by mac_open.
7358 * Return QDF_STATUS_SUCCESS
7359 * Other status means SME is failed
7360 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307361QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007362 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307363 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007364{
7365
7366 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307367 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007368
7369 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307370 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7372 bFastRoamInConIniFeatureEnabled;
7373 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7374 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7375 0;
7376 }
7377 sme_release_global_lock(&pMac->sme);
7378 }
7379
7380 return status;
7381}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007382
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307383/*
7384 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7385 * Monitoring at runtime
7386 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7387 * fEnableFwRssiMonitoring.
7388 * This is a synchronous call
7389 *
7390 * hHal - The handle returned by mac_open.
7391 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7392 * config successfully.
7393 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307395QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007396 bool fEnableFwRssiMonitoring)
7397{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307398 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007399
7400 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307401 fEnableFwRssiMonitoring) ==
7402 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307403 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307404 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007405 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7406 }
7407
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307408 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007409}
7410
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307411/*
7412 * sme_set_roam_opportunistic_scan_threshold_diff() -
7413 * Update Opportunistic Scan threshold diff
7414 * This function is called through dynamic setConfig callback function
7415 * to configure nOpportunisticThresholdDiff
7416 *
7417 * hHal - HAL handle for device
7418 * sessionId - Session Identifier
7419 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7420 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7421 * successfully.
7422 * else SME is failed to update nOpportunisticThresholdDiff.
7423 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307424QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007425 uint8_t sessionId,
7426 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307427 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007428{
7429 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307430 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007431
7432 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307433 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007434 status = csr_neighbor_roam_update_config(pMac, sessionId,
7435 nOpportunisticThresholdDiff,
7436 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307437 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438 pMac->roam.configParam.neighborRoamConfig.
7439 nOpportunisticThresholdDiff =
7440 nOpportunisticThresholdDiff;
7441 }
7442 sme_release_global_lock(&pMac->sme);
7443 }
7444 return status;
7445}
7446
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307447/*
7448 * sme_get_roam_opportunistic_scan_threshold_diff()
7449 * gets Opportunistic Scan threshold diff
7450 * This is a synchronous call
7451 *
7452 * hHal - The handle returned by mac_open
7453 * Return uint8_t - nOpportunisticThresholdDiff
7454 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7456{
7457 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 return pMac->roam.configParam.neighborRoamConfig.
7460 nOpportunisticThresholdDiff;
7461}
7462
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307463/*
7464 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7465 * This function is called through dynamic setConfig callback function
7466 * to configure nRoamRescanRssiDiff
7467 *
7468 * hHal - HAL handle for device
7469 * sessionId - Session Identifier
7470 * nRoamRescanRssiDiff - roam rescan rssi diff
7471 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7472 * successfully.
7473 * else SME is failed to update nRoamRescanRssiDiff.
7474 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307475QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007476 uint8_t sessionId,
7477 const uint8_t nRoamRescanRssiDiff)
7478{
7479 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307480 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007481
7482 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307483 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007484 status = csr_neighbor_roam_update_config(pMac, sessionId,
7485 nRoamRescanRssiDiff,
7486 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307487 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 pMac->roam.configParam.neighborRoamConfig.
7489 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7490 }
7491 sme_release_global_lock(&pMac->sme);
7492 }
7493 return status;
7494}
7495
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307496/*
7497 * sme_get_roam_rescan_rssi_diff()
7498 * gets roam rescan rssi diff
7499 * This is a synchronous call
7500 *
7501 * hHal - The handle returned by mac_open
7502 * Return int8_t - nRoamRescanRssiDiff
7503 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007504uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7505{
7506 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007508 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7509}
7510
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307511/*
7512 * sme_set_roam_bmiss_first_bcnt() -
7513 * Update Roam count for first beacon miss
7514 * This function is called through dynamic setConfig callback function
7515 * to configure nRoamBmissFirstBcnt
7516 * hHal - HAL handle for device
7517 * sessionId - Session Identifier
7518 * nRoamBmissFirstBcnt - Roam first bmiss count
7519 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7520 * successfully.
7521 * else SME is failed to update nRoamBmissFirstBcnt
7522 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307523QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007524 uint8_t sessionId,
7525 const uint8_t nRoamBmissFirstBcnt)
7526{
7527 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307528 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007529
7530 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307531 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007532 status = csr_neighbor_roam_update_config(pMac, sessionId,
7533 nRoamBmissFirstBcnt,
7534 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307535 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007536 pMac->roam.configParam.neighborRoamConfig.
7537 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7538 }
7539 sme_release_global_lock(&pMac->sme);
7540 }
7541 return status;
7542}
7543
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307544/*
7545 * sme_get_roam_bmiss_first_bcnt() -
7546 * get neighbor roam beacon miss first count
7547 *
7548 * hHal - The handle returned by mac_open.
7549 * Return uint8_t - neighbor roam beacon miss first count
7550 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7552{
7553 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007555 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7556}
7557
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307558/*
7559 * sme_set_roam_bmiss_final_bcnt() -
7560 * Update Roam count for final beacon miss
7561 * This function is called through dynamic setConfig callback function
7562 * to configure nRoamBmissFinalBcnt
7563 * hHal - HAL handle for device
7564 * sessionId - Session Identifier
7565 * nRoamBmissFinalBcnt - Roam final bmiss count
7566 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7567 * successfully.
7568 * else SME is failed to update nRoamBmissFinalBcnt
7569 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307570QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007571 uint8_t sessionId,
7572 const uint8_t nRoamBmissFinalBcnt)
7573{
7574 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307575 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007576
7577 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307578 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007579 status = csr_neighbor_roam_update_config(pMac, sessionId,
7580 nRoamBmissFinalBcnt,
7581 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307582 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007583 pMac->roam.configParam.neighborRoamConfig.
7584 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7585 }
7586 sme_release_global_lock(&pMac->sme);
7587 }
7588 return status;
7589}
7590
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307591/*
7592 * sme_get_roam_bmiss_final_bcnt() -
7593 * gets Roam count for final beacon miss
7594 * This is a synchronous call
7595 *
7596 * hHal - The handle returned by mac_open
7597 * Return uint8_t - nRoamBmissFinalBcnt
7598 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7600{
7601 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007603 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7604}
7605
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307606/*
7607 * sme_set_roam_beacon_rssi_weight() -
7608 * Update Roam beacon rssi weight
7609 * This function is called through dynamic setConfig callback function
7610 * to configure nRoamBeaconRssiWeight
7611 *
7612 * hHal - HAL handle for device
7613 * sessionId - Session Identifier
7614 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7615 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7616 * successfully.
7617 * else SME is failed to update nRoamBeaconRssiWeight
7618 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307619QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007620 uint8_t sessionId,
7621 const uint8_t nRoamBeaconRssiWeight)
7622{
7623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307624 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625
7626 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307627 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007628 status = csr_neighbor_roam_update_config(pMac, sessionId,
7629 nRoamBeaconRssiWeight,
7630 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307631 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007632 pMac->roam.configParam.neighborRoamConfig.
7633 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7634 }
7635 sme_release_global_lock(&pMac->sme);
7636 }
7637 return status;
7638}
7639
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307640/*
7641 * sme_get_roam_beacon_rssi_weight() -
7642 * gets Roam beacon rssi weight
7643 * This is a synchronous call
7644 *
7645 * hHal - The handle returned by mac_open
7646 * Return uint8_t - nRoamBeaconRssiWeight
7647 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7649{
7650 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7653}
7654
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307655/*
7656 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7657 * rssi threshold
7658 * This is a synchronous call
7659 *
7660 * hHal - The handle returned by mac_open.
7661 * sessionId - Session Identifier
7662 * Return QDF_STATUS_SUCCESS - SME update config successful.
7663 * Other status means SME is failed to update
7664 */
7665QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7666 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7667{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007668 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307669 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670
7671 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307672 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007673 status = csr_neighbor_roam_update_config(pMac,
7674 sessionId, neighborLookupRssiThreshold,
7675 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307676 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677 pMac->roam.configParam.neighborRoamConfig.
7678 nNeighborLookupRssiThreshold =
7679 neighborLookupRssiThreshold;
7680 }
7681 sme_release_global_lock(&pMac->sme);
7682 }
7683 return status;
7684}
7685
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307686/*
7687 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7688 * This is a synchronous call
7689 *
7690 * hal - The handle returned by macOpen.
7691 * session_id - Session Identifier
7692 * delay_before_vdev_stop - value to be set
7693 * Return QDF_STATUS_SUCCESS - SME update config successful.
7694 * Other status means SME is failed to update
7695 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307696QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007697 uint8_t session_id,
7698 uint8_t delay_before_vdev_stop)
7699{
7700 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307701 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007702
7703 if (session_id >= CSR_ROAM_SESSION_MAX) {
7704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7705 FL("Invalid sme session id: %d"), session_id);
7706 return QDF_STATUS_E_INVAL;
7707 }
7708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307710 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307711 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7712 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007713 pMac->roam.configParam.neighborRoamConfig.
7714 delay_before_vdev_stop,
7715 delay_before_vdev_stop);
7716 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7717 delay_before_vdev_stop = delay_before_vdev_stop;
7718 pMac->roam.configParam.neighborRoamConfig.
7719 delay_before_vdev_stop = delay_before_vdev_stop;
7720 sme_release_global_lock(&pMac->sme);
7721 }
7722 return status;
7723}
7724
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307725/*
7726 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7727 * rssi threshold
7728 * This is a synchronous call
7729 *
7730 * hHal - The handle returned by mac_open.
7731 * Return QDF_STATUS_SUCCESS - SME update config successful.
7732 * Other status means SME is failed to update
7733 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007734uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7735{
7736 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007738 return pMac->roam.configParam.neighborRoamConfig.
7739 nNeighborLookupRssiThreshold;
7740}
7741
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307742/*
7743 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7744 * refresh period
7745 * This is a synchronous call
7746 *
7747 * hHal - The handle returned by mac_open.
7748 * sessionId - Session Identifier
7749 * Return QDF_STATUS_SUCCESS - SME update config successful.
7750 * Other status means SME is failed to update
7751 */
7752QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7753 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7754{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007755 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307756 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307757 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007758 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7759
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007760 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7762 FL("Invalid sme session id: %d"), sessionId);
7763 return QDF_STATUS_E_INVAL;
7764 }
7765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307767 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768 pNeighborRoamConfig =
7769 &pMac->roam.configParam.neighborRoamConfig;
7770 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7773 neighborScanResultsRefreshPeriod,
7774 pMac->roam.configParam.neighborRoamConfig.
7775 nNeighborResultsRefreshPeriod,
7776 mac_trace_get_neighbour_roam_state(pMac->roam.
7777 neighborRoamInfo
7778 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307779 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7781 neighborScanResultsRefreshPeriod;
7782 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7783 neighborScanResultsRefreshPeriod;
7784
7785 sme_release_global_lock(&pMac->sme);
7786 }
7787 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7788 csr_roam_offload_scan(pMac, sessionId,
7789 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307790 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007791 }
7792 return status;
7793}
7794
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307795/*
7796 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7797 * offload feaure
7798 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7799 * gRoamScanOffloadEnabled.
7800 * This is a synchronous call
7801 *
7802 * hHal - The handle returned by mac_open.
7803 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7804 * Other status means SME is failed to update.
7805 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307806QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007807 bool nRoamScanOffloadEnabled)
7808{
7809 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307810 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007811
7812 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307813 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307814 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307815 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 pMac->roam.configParam.isRoamOffloadScanEnabled,
7817 nRoamScanOffloadEnabled);
7818 pMac->roam.configParam.isRoamOffloadScanEnabled =
7819 nRoamScanOffloadEnabled;
7820 sme_release_global_lock(&pMac->sme);
7821 }
7822
7823 return status;
7824}
7825
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307826/*
7827 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7828 * refresh period
7829 * This is a synchronous call
7830 *
7831 * \param hHal - The handle returned by mac_open.
7832 * \return uint16_t - Neighbor scan results refresh period value
7833 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7835{
7836 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007838 return pMac->roam.configParam.neighborRoamConfig.
7839 nNeighborResultsRefreshPeriod;
7840}
7841
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307842/*
7843 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7844 * This is a synchronuous call
7845 *
7846 * hHal - The handle returned by mac_open.
7847 * Return QDF_STATUS_SUCCESS - SME update config successful.
7848 * Other status means SME is failed to update
7849 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7851{
7852 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854 return pMac->roam.configParam.neighborRoamConfig.
7855 nEmptyScanRefreshPeriod;
7856}
7857
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307858/*
7859 * sme_update_empty_scan_refresh_period
7860 * Update nEmptyScanRefreshPeriod
7861 * This function is called through dynamic setConfig callback function
7862 * to configure nEmptyScanRefreshPeriod
7863 * Usage: adb shell iwpriv wlan0 setConfig
7864 * nEmptyScanRefreshPeriod=[0 .. 60]
7865 *
7866 * hHal - HAL handle for device
7867 * sessionId - Session Identifier
7868 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7869 * Return Success or failure
7870 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007871
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307872QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7873 sessionId, uint16_t
7874 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875{
7876 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307877 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307878 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007879 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7880
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007881 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7882 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7883 FL("Invalid sme session id: %d"), sessionId);
7884 return QDF_STATUS_E_INVAL;
7885 }
7886
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007887 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307888 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007889 pNeighborRoamConfig =
7890 &pMac->roam.configParam.neighborRoamConfig;
7891 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307892 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007893 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7894 nEmptyScanRefreshPeriod,
7895 pMac->roam.configParam.neighborRoamConfig.
7896 nEmptyScanRefreshPeriod,
7897 mac_trace_get_neighbour_roam_state(pMac->roam.
7898 neighborRoamInfo
7899 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307900 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7902 nEmptyScanRefreshPeriod;
7903 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7904 nEmptyScanRefreshPeriod;
7905 sme_release_global_lock(&pMac->sme);
7906 }
7907 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7908 csr_roam_offload_scan(pMac, sessionId,
7909 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7910 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7911 }
7912 return status;
7913}
7914
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307915/*
7916 * sme_set_neighbor_scan_min_chan_time() -
7917 * Update nNeighborScanMinChanTime
7918 * This function is called through dynamic setConfig callback function
7919 * to configure gNeighborScanChannelMinTime
7920 * Usage: adb shell iwpriv wlan0 setConfig
7921 * gNeighborScanChannelMinTime=[0 .. 60]
7922 *
7923 * hHal - HAL handle for device
7924 * nNeighborScanMinChanTime - Channel minimum dwell time
7925 * sessionId - Session Identifier
7926 * Return Success or failure
7927 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307928QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007929 const uint16_t
7930 nNeighborScanMinChanTime,
7931 uint8_t sessionId)
7932{
7933 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307934 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007935
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007936 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7938 FL("Invalid sme session id: %d"), sessionId);
7939 return QDF_STATUS_E_INVAL;
7940 }
7941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007942 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307943 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007945 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7946 nNeighborScanMinChanTime,
7947 pMac->roam.configParam.neighborRoamConfig.
7948 nNeighborScanMinChanTime,
7949 mac_trace_get_neighbour_roam_state(pMac->roam.
7950 neighborRoamInfo
7951 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307952 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953
7954 pMac->roam.configParam.neighborRoamConfig.
7955 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7956 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7957 minChannelScanTime = nNeighborScanMinChanTime;
7958 sme_release_global_lock(&pMac->sme);
7959 }
7960
7961 return status;
7962}
7963
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307964/*
7965 * sme_set_neighbor_scan_max_chan_time() -
7966 * Update nNeighborScanMaxChanTime
7967 * This function is called through dynamic setConfig callback function
7968 * to configure gNeighborScanChannelMaxTime
7969 * Usage: adb shell iwpriv wlan0 setConfig
7970 * gNeighborScanChannelMaxTime=[0 .. 60]
7971 *
7972 * hHal - HAL handle for device
7973 * sessionId - Session Identifier
7974 * nNeighborScanMinChanTime - Channel maximum dwell time
7975 * Return Success or failure
7976 */
7977QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7978 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 const uint16_t
7980 nNeighborScanMaxChanTime)
7981{
7982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307983 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307984 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007985 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7986
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007987 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7989 FL("Invalid sme session id: %d"), sessionId);
7990 return QDF_STATUS_E_INVAL;
7991 }
7992
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307994 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007995 pNeighborRoamConfig =
7996 &pMac->roam.configParam.neighborRoamConfig;
7997 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007999 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8000 nNeighborScanMaxChanTime,
8001 pMac->roam.configParam.neighborRoamConfig.
8002 nNeighborScanMaxChanTime,
8003 mac_trace_get_neighbour_roam_state(pMac->roam.
8004 neighborRoamInfo
8005 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308006 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008007 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8008 nNeighborScanMaxChanTime;
8009 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8010 nNeighborScanMaxChanTime;
8011 sme_release_global_lock(&pMac->sme);
8012 }
8013 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8014 csr_roam_offload_scan(pMac, sessionId,
8015 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8016 REASON_SCAN_CH_TIME_CHANGED);
8017 }
8018
8019 return status;
8020}
8021
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308022/*
8023 * sme_get_neighbor_scan_min_chan_time() -
8024 * get neighbor scan min channel time
8025 *
8026 * hHal - The handle returned by mac_open.
8027 * sessionId - Session Identifier
8028 * Return uint16_t - channel min time value
8029 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008030uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8031{
8032 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008033
8034 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8035 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8036 FL("Invalid sme session id: %d"), sessionId);
8037 return 0;
8038 }
8039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8041 minChannelScanTime;
8042}
8043
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308044/*
8045 * sme_get_neighbor_roam_state() -
8046 * get neighbor roam state
8047 *
8048 * hHal - The handle returned by mac_open.
8049 * sessionId - Session Identifier
8050 * Return uint32_t - neighbor roam state
8051 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8053{
8054 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008055
8056 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8058 FL("Invalid sme session id: %d"), sessionId);
8059 return 0;
8060 }
8061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008062 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8063}
8064
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308065/*
8066 * sme_get_current_roam_state() -
8067 * get current roam state
8068 *
8069 * hHal - The handle returned by mac_open.
8070 * sessionId - Session Identifier
8071 * Return uint32_t - current roam state
8072 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008073uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8074{
8075 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308076
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 return pMac->roam.curState[sessionId];
8078}
8079
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308080/*
8081 * sme_get_current_roam_sub_state() -
8082 * \brief get neighbor roam sub state
8083 *
8084 * hHal - The handle returned by mac_open.
8085 * sessionId - Session Identifier
8086 * Return uint32_t - current roam sub state
8087 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8089{
8090 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008092 return pMac->roam.curSubState[sessionId];
8093}
8094
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308095/*
8096 * sme_get_lim_sme_state() -
8097 * get Lim Sme state
8098 *
8099 * hHal - The handle returned by mac_open.
8100 * Return uint32_t - Lim Sme state
8101 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008102uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8103{
8104 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 return pMac->lim.gLimSmeState;
8107}
8108
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308109/*
8110 * sme_get_lim_mlm_state() -
8111 * get Lim Mlm state
8112 *
8113 * hHal - The handle returned by mac_open.
8114 * Return uint32_t - Lim Mlm state
8115 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8117{
8118 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008120 return pMac->lim.gLimMlmState;
8121}
8122
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308123/*
8124 * sme_is_lim_session_valid() -
8125 * is Lim session valid
8126 *
8127 * hHal - The handle returned by mac_open.
8128 * sessionId - Session Identifier
8129 * Return bool - true or false
8130 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8132{
8133 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308134
8135 if (sessionId > pMac->lim.maxBssId)
8136 return false;
8137
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008138 return pMac->lim.gpSession[sessionId].valid;
8139}
8140
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308141/*
8142 * sme_get_lim_sme_session_state() -
8143 * get Lim Sme session state
8144 *
8145 * hHal - The handle returned by mac_open.
8146 * sessionId - Session Identifier
8147 * Return uint32_t - Lim Sme session state
8148 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8150{
8151 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008153 return pMac->lim.gpSession[sessionId].limSmeState;
8154}
8155
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308156/*
8157 * sme_get_lim_mlm_session_state() -
8158 * \brief get Lim Mlm session state
8159 *
8160 * hHal - The handle returned by mac_open.
8161 * sessionId - Session Identifier
8162 * Return uint32_t - Lim Mlm session state
8163 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008164uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8165{
8166 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308167
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008168 return pMac->lim.gpSession[sessionId].limMlmState;
8169}
8170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308171/*
8172 * sme_get_neighbor_scan_max_chan_time() -
8173 * get neighbor scan max channel time
8174 *
8175 * hHal - The handle returned by mac_open.
8176 * sessionId - Session Identifier
8177 * Return uint16_t - channel max time value
8178 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008179uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8180{
8181 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008182
8183 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8184 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8185 FL("Invalid sme session id: %d"), sessionId);
8186 return 0;
8187 }
8188
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008189 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8190 maxChannelScanTime;
8191}
8192
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308193/*
8194 * sme_set_neighbor_scan_period() -
8195 * Update nNeighborScanPeriod
8196 * This function is called through dynamic setConfig callback function
8197 * to configure nNeighborScanPeriod
8198 * Usage: adb shell iwpriv wlan0 setConfig
8199 * nNeighborScanPeriod=[0 .. 1000]
8200 *
8201 * hHal - HAL handle for device
8202 * sessionId - Session Identifier
8203 * nNeighborScanPeriod - neighbor scan period
8204 * Return Success or failure
8205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308206QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008207 const uint16_t nNeighborScanPeriod)
8208{
8209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308210 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308211 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008212 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8213
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008214 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8215 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8216 FL("Invalid sme session id: %d"), sessionId);
8217 return QDF_STATUS_E_INVAL;
8218 }
8219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008220 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308221 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008222 pNeighborRoamConfig =
8223 &pMac->roam.configParam.neighborRoamConfig;
8224 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308226 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008227 nNeighborScanPeriod,
8228 pMac->roam.configParam.neighborRoamConfig.
8229 nNeighborScanTimerPeriod,
8230 mac_trace_get_neighbour_roam_state(pMac->roam.
8231 neighborRoamInfo
8232 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308233 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008234 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8235 nNeighborScanPeriod;
8236 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8237 nNeighborScanPeriod;
8238 sme_release_global_lock(&pMac->sme);
8239 }
8240 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8241 csr_roam_offload_scan(pMac, sessionId,
8242 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8243 REASON_SCAN_HOME_TIME_CHANGED);
8244 }
8245
8246 return status;
8247}
8248
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308249/*
8250 * sme_get_neighbor_scan_period() -
8251 * get neighbor scan period
8252 *
8253 * hHal - The handle returned by mac_open.
8254 * sessionId - Session Identifier
8255 * Return uint16_t - neighbor scan period
8256 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008257uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8258{
8259 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008260
8261 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8262 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8263 FL("Invalid sme session id: %d"), sessionId);
8264 return 0;
8265 }
8266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8268 neighborScanPeriod;
8269}
8270
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308271/**
8272 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8273 * This function is called through dynamic setConfig callback function
8274 * to configure neighbor_scan_min_period
8275 *
8276 * @hal - HAL handle for device
8277 * @session_id - Session Identifier
8278 * @neighbor_scan_min_period - neighbor scan min period
8279 *
8280 * Return - QDF_STATUS
8281 */
8282QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8283 uint8_t session_id,
8284 const uint16_t
8285 neighbor_scan_min_period)
8286{
8287 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8288 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308289 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308290 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008291
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308292 if (session_id >= CSR_ROAM_SESSION_MAX) {
8293 sme_err("Invalid sme session id: %d", session_id);
8294 return QDF_STATUS_E_INVAL;
8295 }
8296
8297 status = sme_acquire_global_lock(&pmac->sme);
8298 if (QDF_IS_STATUS_SUCCESS(status)) {
8299 p_neighbor_roam_config =
8300 &pmac->roam.configParam.neighborRoamConfig;
8301 p_neighbor_roam_info = &pmac->
8302 roam.neighborRoamInfo[session_id];
8303 sme_debug("LFR:set neighbor scan min period, old:%d, "
8304 "new: %d, state: %s",
8305 pmac->roam.configParam.neighborRoamConfig.
8306 neighbor_scan_min_timer_period,
8307 neighbor_scan_min_period,
8308 mac_trace_get_neighbour_roam_state(pmac->roam.
8309 neighborRoamInfo[session_id].
8310 neighborRoamState));
8311 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8312 neighbor_scan_min_period;
8313 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8314 neighbor_scan_min_period;
8315 sme_release_global_lock(&pmac->sme);
8316 }
8317
8318 return status;
8319}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308321/*
8322 * sme_get_roam_rssi_diff() - get Roam rssi diff
8323 * This is a synchronous call
8324 *
8325 * hHal - The handle returned by mac_open.
8326 * Return uint16_t - Rssi diff value
8327 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8329{
8330 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008332 return pMac->roam.configParam.RoamRssiDiff;
8333}
8334
8335/**
8336 * sme_change_roam_scan_channel_list() - to change scan channel list
8337 * @hHal: pointer HAL handle returned by mac_open
8338 * @sessionId: sme session id
8339 * @pChannelList: Output channel list
8340 * @numChannels: Output number of channels
8341 *
8342 * This routine is called to Change roam scan channel list.
8343 * This is a synchronous call
8344 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308345 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308347QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008348 uint8_t *pChannelList,
8349 uint8_t numChannels)
8350{
8351 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308352 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008353 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8355 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8356 uint8_t i = 0, j = 0;
8357 tCsrChannelInfo *chan_info;
8358
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008359 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8360 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8361 FL("Invalid sme session id: %d"), sessionId);
8362 return QDF_STATUS_E_INVAL;
8363 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008365 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308367 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008368 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8369 csr_roam_offload_scan(pMac, sessionId,
8370 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8371 REASON_CHANNEL_LIST_CHANGED);
8372 return status;
8373 }
8374 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8375
8376 if (NULL != chan_info->ChannelList) {
8377 for (i = 0; i < chan_info->numOfChannels; i++) {
8378 if (j < sizeof(oldChannelList))
8379 j += snprintf(oldChannelList + j,
8380 sizeof(oldChannelList) -
8381 j, "%d",
8382 chan_info->ChannelList[i]);
8383 else
8384 break;
8385 }
8386 }
8387 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8388 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8389 numChannels);
8390 sme_set_roam_scan_control(hHal, sessionId, 1);
8391 if (NULL != chan_info->ChannelList) {
8392 j = 0;
8393 for (i = 0; i < chan_info->numOfChannels; i++) {
8394 if (j < sizeof(newChannelList))
8395 j += snprintf(newChannelList + j,
8396 sizeof(newChannelList) -
8397 j, " %d",
8398 chan_info->ChannelList[i]);
8399 else
8400 break;
8401 }
8402 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308404 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008405 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308406 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008407 sme_release_global_lock(&pMac->sme);
8408
8409 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8410 csr_roam_offload_scan(pMac, sessionId,
8411 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8412 REASON_CHANNEL_LIST_CHANGED);
8413 return status;
8414}
8415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008416/**
8417 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8418 * @hHal: HAL pointer
8419 * @pChannelList: Output channel list
8420 * @pNumChannels: Output number of channels
8421 * @sessionId: Session Identifier
8422 *
8423 * To get roam scan channel list This is a synchronous call
8424 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308425 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008426 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308427QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428 uint8_t *pChannelList, uint8_t *pNumChannels,
8429 uint8_t sessionId)
8430{
8431 int i = 0;
8432 uint8_t *pOutPtr = pChannelList;
8433 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008434 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308435 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008437 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8438 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8439 FL("Invalid sme session id: %d"), sessionId);
8440 return QDF_STATUS_E_INVAL;
8441 }
8442
8443 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008444 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308445 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 return status;
8447 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008449 FL("Roam Scan channel list is NOT yet initialized"));
8450 *pNumChannels = 0;
8451 sme_release_global_lock(&pMac->sme);
8452 return status;
8453 }
8454
8455 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308456 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008457 pOutPtr[i] =
8458 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 pOutPtr[i] = '\0';
8461 sme_release_global_lock(&pMac->sme);
8462 return status;
8463}
8464
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308465/*
8466 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8467 * This is a synchronuous call
8468 *
8469 * hHal - The handle returned by mac_open.
8470 * Return true (1) - if the ESE feature is enabled
8471 * false (0) - if feature is disabled (compile or runtime)
8472 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008473bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8474{
8475#ifdef FEATURE_WLAN_ESE
8476 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478 return csr_roam_is_ese_ini_feature_enabled(pMac);
8479#else
8480 return false;
8481#endif
8482}
8483
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308484/*
8485 * sme_get_wes_mode() - get WES Mode
8486 * This is a synchronous call
8487 *
8488 * hHal - The handle returned by mac_open
8489 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8490 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008491bool sme_get_wes_mode(tHalHandle hHal)
8492{
8493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008495 return pMac->roam.configParam.isWESModeEnabled;
8496}
8497
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308498/*
8499 * sme_get_roam_scan_control() - get scan control
8500 * This is a synchronous call
8501 *
8502 * hHal - The handle returned by mac_open.
8503 * Return bool - Enabled(1)/Disabled(0)
8504 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008505bool sme_get_roam_scan_control(tHalHandle hHal)
8506{
8507 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008509 return pMac->roam.configParam.nRoamScanControl;
8510}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008511
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308512/*
8513 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8514 * This is a synchronuous call
8515 * hHal - The handle returned by mac_open.
8516 * Return true (1) - if the feature is enabled
8517 * false (0) - if feature is disabled (compile or runtime)
8518 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8520{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008524}
8525
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308526/*
8527 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8528 * This is a synchronuous call
8529 *
8530 * hHal - The handle returned by mac_open.
8531 * Return true (1) - if the feature is enabled
8532 * false (0) - if feature is disabled (compile or runtime)
8533 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8535{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008538 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539}
8540
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008541/**
8542 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8543 * @feature: enum value of requested feature.
8544 *
8545 * Retrun: 1 if supported; 0 otherwise
8546 */
8547bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008549 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008550}
8551
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308552QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008553 void *plsContext,
8554 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8555 void *pContext))
8556{
8557
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308558 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008559 tpAniSirGlobal pMac;
8560 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308561 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562
Jeff Johnsona5317a62017-01-26 08:51:25 -08008563 if (!hHal || !pCallbackfn || !lsReq) {
8564 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8565 FL("Invalid parameter"));
8566 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008567 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008568
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308569 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8570 if (!wma_handle) {
8571 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8572 "wma handle is NULL");
8573 return QDF_STATUS_E_FAILURE;
8574 }
8575
Jeff Johnsona5317a62017-01-26 08:51:25 -08008576 pMac = PMAC_STRUCT(hHal);
8577 req = qdf_mem_malloc(sizeof(*req));
8578 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008579 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008580 return QDF_STATUS_E_NOMEM;
8581 }
8582 *req = *lsReq;
8583
8584 status = sme_acquire_global_lock(&pMac->sme);
8585 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008586 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008587 qdf_mem_free(req);
8588 return QDF_STATUS_E_FAILURE;
8589 }
8590
8591 pMac->sme.pLinkSpeedCbContext = plsContext;
8592 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308593 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008594 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008596 return status;
8597}
8598
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308599QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8600 struct sir_peer_info_req req)
8601{
8602 QDF_STATUS qdf_status;
8603 struct scheduler_msg message = {0};
8604
8605 qdf_status = sme_acquire_global_lock(&mac->sme);
8606 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8607 sme_debug("Failed to get Lock");
8608 return qdf_status;
8609 }
8610 /* serialize the req through MC thread */
8611 message.bodyptr = qdf_mem_malloc(sizeof(req));
8612 if (NULL == message.bodyptr) {
8613 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8614 "%s: Memory allocation failed.", __func__);
8615 sme_release_global_lock(&mac->sme);
8616 return QDF_STATUS_E_NOMEM;
8617 }
8618 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8619 message.type = WMA_GET_PEER_INFO;
8620 message.reserved = 0;
8621 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8622 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8623 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8624 "%s: Post get peer info msg fail", __func__);
8625 qdf_mem_free(message.bodyptr);
8626 qdf_status = QDF_STATUS_E_FAILURE;
8627 }
8628 sme_release_global_lock(&mac->sme);
8629 return qdf_status;
8630}
8631
Will Huang558f8082017-05-31 16:22:24 +08008632QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8633 void *context,
8634 void (*callbackfn)(struct sir_peer_info_resp *param,
8635 void *pcontext))
8636{
8637
8638 QDF_STATUS status;
8639 QDF_STATUS qdf_status;
8640 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008641 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008642
8643 status = sme_acquire_global_lock(&mac->sme);
8644 if (QDF_STATUS_SUCCESS == status) {
8645 if (NULL == callbackfn) {
8646 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8647 "%s: Indication Call back is NULL",
8648 __func__);
8649 sme_release_global_lock(&mac->sme);
8650 return QDF_STATUS_E_FAILURE;
8651 }
8652
8653 mac->sme.pget_peer_info_ind_cb = callbackfn;
8654 mac->sme.pget_peer_info_cb_context = context;
8655
8656 /* serialize the req through MC thread */
8657 message.bodyptr = qdf_mem_malloc(sizeof(req));
8658 if (NULL == message.bodyptr) {
8659 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8660 "%s: Memory allocation failed.", __func__);
8661 sme_release_global_lock(&mac->sme);
8662 return QDF_STATUS_E_NOMEM;
8663 }
8664 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8665 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308666 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008667 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8668 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8669 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8670 "%s: Post get peer info msg fail", __func__);
8671 qdf_mem_free(message.bodyptr);
8672 status = QDF_STATUS_E_FAILURE;
8673 }
8674 sme_release_global_lock(&mac->sme);
8675 }
8676 return status;
8677}
8678
8679QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8680 struct sir_peer_info_ext_req *req,
8681 void *context,
8682 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8683 void *pcontext))
8684{
8685 QDF_STATUS status;
8686 QDF_STATUS qdf_status;
8687 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008688 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008689
8690 status = sme_acquire_global_lock(&mac->sme);
8691 if (QDF_STATUS_SUCCESS == status) {
8692 if (NULL == callbackfn) {
8693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8694 "%s: Indication Call back is NULL",
8695 __func__);
8696 sme_release_global_lock(&mac->sme);
8697 return QDF_STATUS_E_FAILURE;
8698 }
8699
8700 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8701 mac->sme.pget_peer_info_ext_cb_context = context;
8702
8703 /* serialize the req through MC thread */
8704 message.bodyptr =
8705 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8706 if (NULL == message.bodyptr) {
8707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8708 "%s: Memory allocation failed.", __func__);
8709 sme_release_global_lock(&mac->sme);
8710 return QDF_STATUS_E_NOMEM;
8711 }
8712 qdf_mem_copy(message.bodyptr,
8713 req,
8714 sizeof(struct sir_peer_info_ext_req));
8715 message.type = WMA_GET_PEER_INFO_EXT;
8716 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8717 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8718 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8719 "%s: Post get rssi msg fail", __func__);
8720 qdf_mem_free(message.bodyptr);
8721 status = QDF_STATUS_E_FAILURE;
8722 }
8723 sme_release_global_lock(&mac->sme);
8724 }
8725 return status;
8726}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008727
8728/*
8729 * SME API to enable/disable WLAN driver initiated SSR
8730 */
8731void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8732{
8733 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308734 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735
8736 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308737 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008738 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008739 /* not serializing this messsage, as this is only going
8740 * to set a variable in WMA/WDI
8741 */
8742 WMA_SetEnableSSR(enableSSR);
8743 sme_release_global_lock(&pMac->sme);
8744 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745}
8746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008747/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8748ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8749{
8750 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8751}
8752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308753/*
8754 * sme_set_curr_device_mode() - Sets the current operating device mode.
8755 *
8756 * hHal - The handle returned by mac_open.
8757 * currDeviceMode - Current operating device mode.
8758 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008759void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008760 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761{
8762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765}
8766
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308767/*
8768 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8769 * This is a synchronous call
8770 *
8771 * hHal - The handle returned by mac_open
8772 * sessionId - Session Identifier
8773 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8774 * BSSID, channel etc.)
8775 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8776 * Other status means SME is failed to send the request.
8777 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308779QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 uint8_t sessionId,
8781 tCsrHandoffRequest *pHandoffInfo)
8782{
8783 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308784 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008785
8786 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308787 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308788 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008789 "%s: invoked", __func__);
8790 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8791 sme_release_global_lock(&pMac->sme);
8792 }
8793
8794 return status;
8795}
8796
8797#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308798/*
8799 * sme_ipa_offload_enable_disable() -
8800 * API to enable/disable IPA offload
8801 *
8802 * hal - The handle returned by macOpen.
8803 * session_id - Session Identifier
8804 * request - Pointer to the offload request.
8805 * Return QDF_STATUS
8806 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308807QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008808 struct sir_ipa_offload_enable_disable *request)
8809{
8810 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308811 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008813 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008814
8815 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308816 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308817 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308819 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308820 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308822 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 }
8824
8825 request_buf->offload_type = request->offload_type;
8826 request_buf->vdev_id = request->vdev_id;
8827 request_buf->enable = request->enable;
8828
8829 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8830 msg.reserved = 0;
8831 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308832 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008833 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308835 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308836 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008839 }
8840
8841 sme_release_global_lock(&pMac->sme);
8842 }
8843
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308844 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008845}
8846#endif /* IPA_OFFLOAD */
8847
8848/*
8849 * SME API to check if there is any infra station or
8850 * P2P client is connected
8851 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308852QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853{
8854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308855
8856 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308857 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308858
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008860}
8861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862/**
8863 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8864 * @hal: global hal handle
8865 * @addPeriodicTxPtrnParams: request message
8866 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308869QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870sme_add_periodic_tx_ptrn(tHalHandle hal,
8871 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8872{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308873 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8875 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008876 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008877
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008878 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308880 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008882 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308883 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 }
8885
8886 *req_msg = *addPeriodicTxPtrnParams;
8887
8888 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308889 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008890 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308892 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 return status;
8894 }
8895
8896 /* Serialize the req through MC thread */
8897 msg.bodyptr = req_msg;
8898 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308899 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8900 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008901 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308902 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008903 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308905 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 }
8907 sme_release_global_lock(&mac->sme);
8908 return status;
8909}
8910
8911/**
8912 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8913 * @hal: global hal handle
8914 * @delPeriodicTxPtrnParams: request message
8915 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308916 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308918QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008919sme_del_periodic_tx_ptrn(tHalHandle hal,
8920 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8921{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308922 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008923 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8924 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008925 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008927 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308929 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008930 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008931 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308932 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 }
8934
8935 *req_msg = *delPeriodicTxPtrnParams;
8936
8937 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308938 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008939 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308941 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008942 return status;
8943 }
8944
8945 /* Serialize the req through MC thread */
8946 msg.bodyptr = req_msg;
8947 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308948 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8949 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008950 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308951 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008952 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008953 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308954 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008955 }
8956 sme_release_global_lock(&mac->sme);
8957 return status;
8958}
8959
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308960/*
8961 * sme_enable_rmc() - enables RMC
8962 * @hHal : Pointer to global HAL handle
8963 * @sessionId : Session ID
8964 *
8965 * Return: QDF_STATUS
8966 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008967QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8968{
8969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008971 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008972 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8973
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008974 SME_ENTER();
8975
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008976 status = sme_acquire_global_lock(&pMac->sme);
8977 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008978 message.bodyptr = NULL;
8979 message.type = WMA_RMC_ENABLE_IND;
8980 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8981 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008982 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8983 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8984 "%s: failed to post message to WMA",
8985 __func__);
8986 status = QDF_STATUS_E_FAILURE;
8987 }
8988 sme_release_global_lock(&pMac->sme);
8989 }
8990 return status;
8991}
8992
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308993/*
8994 * sme_disable_rmc() - disables RMC
8995 * @hHal : Pointer to global HAL handle
8996 * @sessionId : Session ID
8997 *
8998 * Return: QDF_STATUS
8999 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009000QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9001{
9002 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9003 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009004 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009005 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9006
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009007 SME_ENTER();
9008
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009009 status = sme_acquire_global_lock(&pMac->sme);
9010 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009011 message.bodyptr = NULL;
9012 message.type = WMA_RMC_DISABLE_IND;
9013 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9014 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9017 "%s: failed to post message to WMA",
9018 __func__);
9019 status = QDF_STATUS_E_FAILURE;
9020 }
9021 sme_release_global_lock(&pMac->sme);
9022 }
9023 return status;
9024}
9025
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309026/*
9027 * sme_send_rmc_action_period() - sends RMC action period param to target
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_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9034{
9035 QDF_STATUS status = QDF_STATUS_SUCCESS;
9036 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9037 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009038 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009039
9040 status = sme_acquire_global_lock(&pMac->sme);
9041 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009042 message.bodyptr = NULL;
9043 message.type = WMA_RMC_ACTION_PERIOD_IND;
9044 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9045 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009046 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9047 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9048 "%s: failed to post message to WMA",
9049 __func__);
9050 status = QDF_STATUS_E_FAILURE;
9051 }
9052 sme_release_global_lock(&pMac->sme);
9053 }
9054
9055 return status;
9056}
9057
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309058/*
9059 * sme_request_ibss_peer_info() - request ibss peer info
9060 * @hHal : Pointer to global HAL handle
9061 * @pUserData : Pointer to user data
9062 * @peerInfoCbk : Peer info callback
9063 * @allPeerInfoReqd : All peer info required or not
9064 * @staIdx : sta index
9065 *
9066 * Return: QDF_STATUS
9067 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009068QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9069 pIbssPeerInfoCb peerInfoCbk,
9070 bool allPeerInfoReqd, uint8_t staIdx)
9071{
9072 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9073 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9074 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009075 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009076 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9077
9078 status = sme_acquire_global_lock(&pMac->sme);
9079 if (QDF_STATUS_SUCCESS == status) {
9080 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9081 pMac->sme.peerInfoParams.pUserData = pUserData;
9082
9083 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309084 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009085 if (NULL == pIbssInfoReqParams) {
9086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9087 "%s: Not able to allocate memory for dhcp start",
9088 __func__);
9089 sme_release_global_lock(&pMac->sme);
9090 return QDF_STATUS_E_NOMEM;
9091 }
9092 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9093 pIbssInfoReqParams->staIdx = staIdx;
9094
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009095 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9096 message.bodyptr = pIbssInfoReqParams;
9097 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009098
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009099 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9100 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009101 if (QDF_STATUS_SUCCESS != qdf_status) {
9102 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9103 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9104 __func__);
9105 qdf_mem_free(pIbssInfoReqParams);
9106 qdf_status = QDF_STATUS_E_FAILURE;
9107 }
9108 sme_release_global_lock(&pMac->sme);
9109 }
9110
9111 return qdf_status;
9112}
9113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309114/*
9115 * sme_send_cesium_enable_ind() -
9116 * Used to send proprietary cesium enable indication to fw
9117 *
9118 * hHal
9119 * sessionId
9120 * Return QDF_STATUS
9121 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009122QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9123{
9124 QDF_STATUS status = QDF_STATUS_SUCCESS;
9125 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9126 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009127 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009128
9129 status = sme_acquire_global_lock(&pMac->sme);
9130 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009131 message.bodyptr = NULL;
9132 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9133 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9134 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009135 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9136 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9137 "%s: failed to post message to WMA",
9138 __func__);
9139 status = QDF_STATUS_E_FAILURE;
9140 }
9141 sme_release_global_lock(&pMac->sme);
9142 }
9143
9144 return status;
9145}
9146
Paul Zhang99fe8842017-12-08 14:43:46 +08009147QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
9148 uint16_t latency_level)
9149{
9150 QDF_STATUS status;
9151 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9152 struct wlm_latency_level_param params;
9153 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
9154
9155 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
9156 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9157 "%s: WLM latency level setting is disabled",
9158 __func__);
9159 return QDF_STATUS_E_FAILURE;
9160 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08009161 if (!wma) {
9162 sme_err("wma is NULL");
9163 return QDF_STATUS_E_FAILURE;
9164 }
Paul Zhang99fe8842017-12-08 14:43:46 +08009165
9166 params.wlm_latency_level = latency_level;
9167 params.wlm_latency_flags =
9168 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
9169 params.vdev_id = session_id;
9170
9171 status = wma_set_wlm_latency_level(wma, &params);
9172 if (!QDF_IS_STATUS_SUCCESS(status))
9173 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9174 "%s: failed to set latency level",
9175 __func__);
9176
9177 return status;
9178}
9179
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009180void sme_get_command_q_status(tHalHandle hHal)
9181{
9182 tSmeCmd *pTempCmd = NULL;
9183 tListElem *pEntry;
9184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9185
9186 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309187 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009188 "%s: pMac is NULL", __func__);
9189 return;
9190 }
9191
Krunal Sonia8270f52017-02-23 19:51:25 -08009192 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309193 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009194 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309195
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009196 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009197 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9198 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309199 if (eSmeCsrCommandMask & pTempCmd->command)
9200 /* CSR command is stuck. See what the reason code is
9201 * for that command
9202 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009203 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 } /* if(pTempCmd) */
9205
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009206 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009207 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009209}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009210/**
9211 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9212 * @hal: The handle returned by macOpen
9213 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9214 */
9215void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9216 bool sta_prefer_80MHz_over_160MHz)
9217{
9218 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309219
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009220 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9221}
9222
Agrawal Ashishb141b092016-09-02 19:59:26 +05309223#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009224/**
9225 * sme_set_dot11p_config() - API to set the 802.11p config
9226 * @hHal: The handle returned by macOpen
9227 * @enable_dot11p: 802.11p config param
9228 */
9229void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9230{
9231 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009233 pMac->enable_dot11p = enable_dot11p;
9234}
9235
9236/**
9237 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9238 * @src: the source configuration
9239 *
9240 * Return: pointer to the copied OCB configuration
9241 */
9242static struct sir_ocb_config *sme_copy_sir_ocb_config(
9243 struct sir_ocb_config *src)
9244{
9245 struct sir_ocb_config *dst;
9246 uint32_t length;
9247 void *cursor;
9248
9249 length = sizeof(*src) +
9250 src->channel_count * sizeof(*src->channels) +
9251 src->schedule_size * sizeof(*src->schedule) +
9252 src->dcc_ndl_chan_list_len +
9253 src->dcc_ndl_active_state_list_len;
9254
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309255 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009256 if (!dst)
9257 return NULL;
9258
9259 *dst = *src;
9260
9261 cursor = dst;
9262 cursor += sizeof(*dst);
9263 dst->channels = cursor;
9264 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309265 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 src->channel_count * sizeof(*src->channels));
9267 dst->schedule = cursor;
9268 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309269 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 src->schedule_size * sizeof(*src->schedule));
9271 dst->dcc_ndl_chan_list = cursor;
9272 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309273 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274 src->dcc_ndl_chan_list_len);
9275 dst->dcc_ndl_active_state_list = cursor;
9276 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309277 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009278 src->dcc_ndl_active_state_list,
9279 src->dcc_ndl_active_state_list_len);
9280 return dst;
9281}
9282
9283/**
9284 * sme_ocb_set_config() - Set the OCB configuration
9285 * @hHal: reference to the HAL
9286 * @context: the context of the call
9287 * @callback: the callback to hdd
9288 * @config: the OCB configuration
9289 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309290 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009291 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309292QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009293 ocb_callback callback,
9294 struct sir_ocb_config *config)
9295{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309296 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009298 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 struct sir_ocb_config *msg_body;
9300
9301 /* Lock the SME structure */
9302 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309303 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009304 return status;
9305
9306 /*
9307 * Check if there is a pending request and return an error if one
9308 * exists
9309 */
9310 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309311 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009312 goto end;
9313 }
9314
9315 msg_body = sme_copy_sir_ocb_config(config);
9316
9317 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309318 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009319 goto end;
9320 }
9321
9322 msg.type = WMA_OCB_SET_CONFIG_CMD;
9323 msg.bodyptr = msg_body;
9324
9325 /* Set the request callback and context */
9326 pMac->sme.ocb_set_config_callback = callback;
9327 pMac->sme.ocb_set_config_context = context;
9328
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009329 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309330 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309331 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 FL("Error posting message to WDA: %d"), status);
9333 pMac->sme.ocb_set_config_callback = callback;
9334 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309335 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 goto end;
9337 }
9338
9339end:
9340 sme_release_global_lock(&pMac->sme);
9341
9342 return status;
9343}
9344
9345/**
9346 * sme_ocb_set_utc_time() - Set the OCB UTC time
9347 * @hHal: reference to the HAL
9348 * @utc: the UTC time struct
9349 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309350 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009351 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309352QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009353{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309354 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009355 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009356 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 struct sir_ocb_utc *sme_utc;
9358
9359 /* Lock the SME structure */
9360 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309361 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009362 return status;
9363
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309364 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309366 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009367 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309368 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369 goto end;
9370 }
9371 *sme_utc = *utc;
9372
9373 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9374 msg.reserved = 0;
9375 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009376 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309377 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309378 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309380 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009381 goto end;
9382 }
9383
9384end:
9385 sme_release_global_lock(&pMac->sme);
9386
9387 return status;
9388}
9389
9390/**
9391 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9392 * @hHal: reference to the HAL
9393 * @timing_advert: the timing advertisement struct
9394 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309395 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009396 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309397QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009398 struct sir_ocb_timing_advert *timing_advert)
9399{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309400 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009401 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009402 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009403 void *buf;
9404 struct sir_ocb_timing_advert *sme_timing_advert;
9405
9406 /* Lock the SME structure */
9407 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309408 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009409 return status;
9410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309411 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009412 timing_advert->template_length);
9413 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309414 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009415 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309416 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009417 goto end;
9418 }
9419
9420 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9421 *sme_timing_advert = *timing_advert;
9422 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309423 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009424 timing_advert->template_value, timing_advert->template_length);
9425
9426 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9427 msg.reserved = 0;
9428 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009429 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309430 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309431 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009432 FL("Not able to post msg to WDA"));
9433 goto end;
9434 }
9435
9436end:
9437 sme_release_global_lock(&pMac->sme);
9438
9439 return status;
9440}
9441
9442/**
9443 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9444 * @hHal: reference to the HAL
9445 * @timing_advert: the timing advertisement struct
9446 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309447 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009448 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309449QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009450 struct sir_ocb_timing_advert *timing_advert)
9451{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309452 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009453 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009454 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009455 struct sir_ocb_timing_advert *sme_timing_advert;
9456
9457 /* Lock the SME structure */
9458 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309459 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 return status;
9461
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309462 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009465 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309466 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009467 goto end;
9468 }
9469 *sme_timing_advert = *timing_advert;
9470
9471 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9472 msg.reserved = 0;
9473 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009474 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309475 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309476 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 FL("Not able to post msg to WDA"));
9478 goto end;
9479 }
9480
9481end:
9482 sme_release_global_lock(&pMac->sme);
9483
9484 return status;
9485}
9486
9487/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009488 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9489 * @hal_handle: reference to the HAL
9490 * @self_addr: the self MAC address
9491 * @buf: the buffer that will contain the frame
9492 * @timestamp_offset: return for the offset of the timestamp field
9493 * @time_value_offset: return for the time_value field in the TA IE
9494 *
9495 * Return: the length of the buffer.
9496 */
9497int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9498 tSirMacAddr self_addr, uint8_t **buf,
9499 uint32_t *timestamp_offset,
9500 uint32_t *time_value_offset)
9501{
9502 int template_length;
9503 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9504
9505 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9506 timestamp_offset,
9507 time_value_offset);
9508 return template_length;
9509}
9510/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9512 * @hHal: reference to the HAL
9513 * @context: the context of the call
9514 * @callback: the callback to hdd
9515 * @request: the TSF timer request
9516 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309517 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309519QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009520 ocb_callback callback,
9521 struct sir_ocb_get_tsf_timer *request)
9522{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309523 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009524 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009525 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009526 struct sir_ocb_get_tsf_timer *msg_body;
9527
9528 /* Lock the SME structure */
9529 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309530 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 return status;
9532
9533 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309534 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009535 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309536 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009537 goto end;
9538 }
9539 *msg_body = *request;
9540
9541 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9542 msg.bodyptr = msg_body;
9543
9544 /* Set the request callback and the context */
9545 pMac->sme.ocb_get_tsf_timer_callback = callback;
9546 pMac->sme.ocb_get_tsf_timer_context = context;
9547
9548 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009549 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309550 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 FL("Error posting message to WDA: %d"), status);
9553 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9554 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309555 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009556 goto end;
9557 }
9558
9559end:
9560 sme_release_global_lock(&pMac->sme);
9561
9562 return status;
9563}
9564
9565/**
9566 * sme_dcc_get_stats() - Get the DCC stats
9567 * @hHal: reference to the HAL
9568 * @context: the context of the call
9569 * @callback: the callback to hdd
9570 * @request: the get DCC stats request
9571 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309572 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009573 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309574QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009575 ocb_callback callback,
9576 struct sir_dcc_get_stats *request)
9577{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309578 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009579 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009580 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 struct sir_dcc_get_stats *msg_body;
9582
9583 /* Lock the SME structure */
9584 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309585 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009586 return status;
9587
9588 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309589 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 request->request_array_len);
9591 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309592 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009593 goto end;
9594 }
9595 *msg_body = *request;
9596 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309597 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009598 request->request_array_len);
9599
9600 msg.type = WMA_DCC_GET_STATS_CMD;
9601 msg.bodyptr = msg_body;
9602
9603 /* Set the request callback and context */
9604 pMac->sme.dcc_get_stats_callback = callback;
9605 pMac->sme.dcc_get_stats_context = context;
9606
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009607 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309608 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 FL("Error posting message to WDA: %d"), status);
9611 pMac->sme.dcc_get_stats_callback = callback;
9612 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309613 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009614 goto end;
9615 }
9616
9617end:
9618 sme_release_global_lock(&pMac->sme);
9619
9620 return status;
9621}
9622
9623/**
9624 * sme_dcc_clear_stats() - Clear the DCC stats
9625 * @hHal: reference to the HAL
9626 * @vdev_id: vdev id for OCB interface
9627 * @dcc_stats_bitmap: the entries in the stats to clear
9628 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309629 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309631QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009632 uint32_t dcc_stats_bitmap)
9633{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309634 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009636 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009637 struct sir_dcc_clear_stats *request;
9638
9639 /* Lock the SME structure */
9640 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309641 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009642 return status;
9643
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309644 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309646 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309648 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649 goto end;
9650 }
9651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 request->vdev_id = vdev_id;
9653 request->dcc_stats_bitmap = dcc_stats_bitmap;
9654
9655 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9656 msg.bodyptr = request;
9657
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009658 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309659 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009661 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309662 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009663 goto end;
9664 }
9665
9666end:
9667 sme_release_global_lock(&pMac->sme);
9668
9669 return status;
9670}
9671
9672/**
9673 * sme_dcc_update_ndl() - Update the DCC settings
9674 * @hHal: reference to the HAL
9675 * @context: the context of the call
9676 * @callback: the callback to hdd
9677 * @request: the update DCC request
9678 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309679 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009680 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309681QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009682 ocb_callback callback,
9683 struct sir_dcc_update_ndl *request)
9684{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309685 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009687 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 struct sir_dcc_update_ndl *msg_body;
9689
9690 /* Lock the SME structure */
9691 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309692 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009693 return status;
9694
9695 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309696 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009697 request->dcc_ndl_chan_list_len +
9698 request->dcc_ndl_active_state_list_len);
9699 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309702 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009703 goto end;
9704 }
9705
9706 *msg_body = *request;
9707
9708 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9709 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9710 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309711 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009712 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309713 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009714 request->dcc_ndl_active_state_list,
9715 request->dcc_ndl_active_state_list_len);
9716
9717 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9718 msg.bodyptr = msg_body;
9719
9720 /* Set the request callback and the context */
9721 pMac->sme.dcc_update_ndl_callback = callback;
9722 pMac->sme.dcc_update_ndl_context = context;
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("Error posting message to WDA: %d"), status);
9728 pMac->sme.dcc_update_ndl_callback = NULL;
9729 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309730 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 goto end;
9732 }
9733
9734end:
9735 sme_release_global_lock(&pMac->sme);
9736
9737 return status;
9738}
9739
9740/**
9741 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9742 * event
9743 * @hHal: reference to the HAL
9744 * @context: the context of the call
9745 * @callback: the callback to hdd
9746 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309747 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009748 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309749QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009750 ocb_callback callback)
9751{
9752 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309753 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754
9755 status = sme_acquire_global_lock(&pMac->sme);
9756 pMac->sme.dcc_stats_event_callback = callback;
9757 pMac->sme.dcc_stats_event_context = context;
9758 sme_release_global_lock(&pMac->sme);
9759
9760 return 0;
9761}
9762
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309763/**
9764 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9765 * event
9766 * @h_hal: Hal Handle
9767 *
9768 * This function de-registers the DCC perioc stats callback
9769 *
9770 * Return: QDF_STATUS Enumeration
9771 */
9772QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9773{
9774 tpAniSirGlobal mac;
9775 QDF_STATUS status;
9776
9777 if (!h_hal) {
9778 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9779 FL("h_hal is not valid"));
9780 return QDF_STATUS_E_INVAL;
9781 }
9782 mac = PMAC_STRUCT(h_hal);
9783
9784 status = sme_acquire_global_lock(&mac->sme);
9785 if (!QDF_IS_STATUS_SUCCESS(status)) {
9786 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9787 FL("Failed to acquire global lock"));
9788 return status;
9789 }
9790 mac->sme.dcc_stats_event_callback = NULL;
9791 mac->sme.dcc_stats_event_context = NULL;
9792 sme_release_global_lock(&mac->sme);
9793
9794 return status;
9795}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309796#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798void sme_get_recovery_stats(tHalHandle hHal)
9799{
9800 uint8_t i;
9801
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803 "Self Recovery Stats");
9804 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9805 if (eSmeNoCommand !=
9806 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009808 "timestamp %llu: command 0x%0X: reason %d: session %d",
9809 g_self_recovery_stats.activeCmdStats[i].
9810 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309811 g_self_recovery_stats.activeCmdStats[i].command,
9812 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813 g_self_recovery_stats.activeCmdStats[i].
9814 sessionId);
9815 }
9816 }
9817}
9818
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309819QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009820{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009821 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009822 tpSirModemPowerStateInd request_buf;
9823 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9824
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309825 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309826 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009827
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309828 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009829 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309830 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9832 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309833 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 }
9835
9836 request_buf->param = value;
9837
9838 msg.type = WMA_MODEM_POWER_STATE_IND;
9839 msg.reserved = 0;
9840 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309841 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009842 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309843 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309844 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9845 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309846 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009848 }
9849
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309850 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009851}
9852
9853#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309854QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309855 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009856 uint8_t sessionId,
9857 uint8_t channel_type)
9858{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009859 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009860 tUpdateVHTOpMode *pHtOpMode = NULL;
9861 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9862
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309863 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309864 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009865
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309866 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009867 if (NULL == pHtOpMode) {
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 "%s: Not able to allocate memory for setting OP mode",
9870 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309871 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 }
9873
9874 switch (channel_type) {
9875 case eHT_CHAN_HT20:
9876 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9877 break;
9878
9879 case eHT_CHAN_HT40MINUS:
9880 case eHT_CHAN_HT40PLUS:
9881 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9882 break;
9883
9884 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309885 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009886 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309887 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888 }
9889
9890 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309891 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009892 sizeof(tSirMacAddr));
9893 pHtOpMode->smesessionId = sessionId;
9894
9895 msg.type = WMA_UPDATE_OP_MODE;
9896 msg.reserved = 0;
9897 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309898 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009899 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309901 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9902 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309903 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309904 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009905 }
9906
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309907 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908 "%s: Notifed FW about OP mode: %d for staId=%d",
9909 __func__, pHtOpMode->opMode, staId);
9910
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309911 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009912}
9913
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309914/*
9915 * sme_set_ht2040_mode() -
9916 * To update HT Operation beacon IE.
9917 *
9918 * Return QDF_STATUS SUCCESS
9919 * FAILURE or RESOURCES
9920 * The API finished and failed.
9921 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309922QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009923 uint8_t channel_type, bool obssEnabled)
9924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309925 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9927 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309928 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009929
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309930 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9931 sme_err("Session not valid for session id %d", sessionId);
9932 return QDF_STATUS_E_INVAL;
9933 }
9934 session = CSR_GET_SESSION(pMac, sessionId);
9935 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9936 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009937
9938 switch (channel_type) {
9939 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309940 if (!session->bssParams.cbMode)
9941 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009942 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9943 break;
9944 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309945 if (session->bssParams.cbMode)
9946 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009947 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9948 break;
9949 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309950 if (session->bssParams.cbMode)
9951 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009952 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9953 break;
9954 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309955 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309956 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009957 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309958 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009959 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309960 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009961 status = csr_set_ht2040_mode(pMac, sessionId,
9962 cbMode, obssEnabled);
9963 sme_release_global_lock(&pMac->sme);
9964 }
9965 return status;
9966}
9967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009968#endif
9969
9970/*
9971 * SME API to enable/disable idle mode powersave
9972 * This should be called only if powersave offload
9973 * is enabled
9974 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309975QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009976{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309977 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978
9979 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309980 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009981 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309982 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009983 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309984 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985 " Idle Ps Set Value %d", value);
9986
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309987 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009989 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009991 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309992
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309993 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009994}
9995
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309996int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9997 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009998{
9999 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010000 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010001
10002 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010003 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004 "%s: pSession is NULL", __func__);
10005 return -EIO;
10006 }
10007 switch (ht_capab) {
10008 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10009 return pSession->htConfig.ht_rx_ldpc;
10010 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10011 return pSession->htConfig.ht_tx_stbc;
10012 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10013 return pSession->htConfig.ht_rx_stbc;
10014 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010015 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010016 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010017 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010019 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010020 "invalid ht capability");
10021 return -EIO;
10022 }
10023}
10024
10025int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
10026 int value)
10027{
10028 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010029 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010030
10031 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010033 "%s: pSession is NULL", __func__);
10034 return -EIO;
10035 }
10036
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010037 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010038 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010039 "Failed to set ht capability in target");
10040 return -EIO;
10041 }
10042
10043 switch (htCapab) {
10044 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10045 pSession->htConfig.ht_rx_ldpc = value;
10046 break;
10047 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10048 pSession->htConfig.ht_tx_stbc = value;
10049 break;
10050 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10051 pSession->htConfig.ht_rx_stbc = value;
10052 break;
10053 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010054 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010055 pSession->htConfig.ht_sgi20 = value;
10056 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010057 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010058 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010059 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010060 break;
10061 }
10062
Naveen Rawat8029a402017-06-01 10:54:19 -070010063 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010064 return 0;
10065}
10066
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -080010067int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
10068{
10069 struct sme_addba_accept *addba_accept;
10070 struct scheduler_msg msg = {0};
10071 QDF_STATUS status;
10072
10073 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
10074 if (!addba_accept) {
10075 sme_err("mem alloc failed for addba_accept");
10076 return -EIO;
10077 }
10078 addba_accept->session_id = session_id;
10079 addba_accept->addba_accept = value;
10080 qdf_mem_zero(&msg, sizeof(msg));
10081 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
10082 msg.reserved = 0;
10083 msg.bodyptr = addba_accept;
10084 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
10085 if (status != QDF_STATUS_SUCCESS) {
10086 sme_err("Not able to post addba reject");
10087 qdf_mem_free(addba_accept);
10088 return -EIO;
10089 }
10090 return 0;
10091}
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -080010092
10093int sme_set_ba_buff_size(tHalHandle hal, uint8_t session_id,
10094 uint16_t buff_size)
10095{
10096 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
10097 if (!buff_size) {
10098 sme_err("invalid buff size %d", buff_size);
10099 return -EINVAL;
10100 }
10101 mac_ctx->usr_cfg_ba_buff_size = buff_size;
10102 sme_debug("addba buff size is set to %d",
10103 mac_ctx->usr_cfg_ba_buff_size);
10104
10105 return 0;
10106}
10107
10108#define DEFAULT_BA_BUFF_SIZE 64
10109int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid,
10110 uint16_t buff_size)
10111{
10112 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
10113 uint16_t ba_buff = 0;
10114 QDF_STATUS status;
10115 struct scheduler_msg msg = {0};
10116 struct send_add_ba_req *send_ba_req;
10117 struct csr_roam_session *csr_session = NULL;
10118
10119 if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
10120 sme_err("STA not infra/connected state session_id: %d",
10121 session_id);
10122 return -EINVAL;
10123 }
10124 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
10125 if (!csr_session) {
10126 sme_err("CSR session is NULL");
10127 return -EINVAL;
10128 }
10129 send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req));
10130 if (!send_ba_req) {
10131 sme_err("mem alloc failed");
10132 return -EIO;
10133 }
10134 qdf_mem_copy(send_ba_req->mac_addr,
10135 csr_session->connectedProfile.bssid.bytes,
10136 QDF_MAC_ADDR_SIZE);
10137 ba_buff = buff_size;
10138 if (!buff_size) {
10139 if (mac_ctx->usr_cfg_ba_buff_size)
10140 ba_buff = mac_ctx->usr_cfg_ba_buff_size;
10141 else
10142 ba_buff = DEFAULT_BA_BUFF_SIZE;
10143 }
10144 send_ba_req->param.vdev_id = session_id;
10145 send_ba_req->param.tidno = tid;
10146 send_ba_req->param.buffersize = ba_buff;
10147 msg.type = WMA_SEND_ADDBA_REQ;
10148 msg.bodyptr = send_ba_req;
10149 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
10150 if (QDF_STATUS_SUCCESS != status) {
10151 sme_err("Failed to post WMA_SEND_ADDBA_REQ");
10152 qdf_mem_free(send_ba_req);
10153 return -EIO;
10154 }
10155 sme_debug("ADDBA_REQ sent to FW: tid %d buff_size %d", tid, ba_buff);
10156
10157 return 0;
10158}
10159
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -080010160int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id,
10161 uint8_t val, uint8_t ac)
10162{
10163 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
10164 uint8_t i, set_val;
10165
10166 if (ac > MAX_NUM_AC) {
10167 sme_err("invalid ac val %d", ac);
10168 return -EINVAL;
10169 }
10170 if (val)
10171 set_val = 1;
10172 else
10173 set_val = 0;
10174 if (ac == MAX_NUM_AC) {
10175 for (i = 0; i < ac; i++)
10176 mac_ctx->no_ack_policy_cfg[i] = set_val;
10177 } else {
10178 mac_ctx->no_ack_policy_cfg[ac] = set_val;
10179 }
10180 sme_debug("no ack is set to %d for ac %d", set_val, ac);
10181
10182 return 0;
10183}
10184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010185#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010186/*
10187 * sme_send_rate_update_ind() -
10188 * API to Update rate
10189 *
10190 * hHal - The handle returned by mac_open
10191 * rateUpdateParams - Pointer to rate update params
10192 * Return QDF_STATUS
10193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010194QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010195 tSirRateUpdateInd *rateUpdateParams)
10196{
10197 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010198 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010199 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010200 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201
10202 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010203 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010204 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010205 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010206 }
10207 *rate_upd = *rateUpdateParams;
10208
10209 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10210 rate_upd->mcastDataRate24GHzTxFlag =
10211 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10212 else if (rate_upd->reliableMcastDataRate ==
10213 HT20_SHORT_GI_MCS7_RATE)
10214 rate_upd->reliableMcastDataRateTxFlag =
10215 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10216
10217 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010218 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010219 msg.type = WMA_RATE_UPDATE_IND;
10220 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010221 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10222 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010223 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010224 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010226 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010227 __func__);
10228
10229 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010230 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010231 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 }
10233
10234 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010235 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010236 }
10237
10238 return status;
10239}
10240
10241/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010242 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10243 * @hal: Pointer to the mac context
10244 * @session_id: sme session id
10245 * @vendor_ie: vendor ie
10246 * @access_policy: vendor ie access policy
10247 *
10248 * This function updates the vendor ie and access policy to lim.
10249 *
10250 * Return: success or failure.
10251 */
10252QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10253 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10254{
10255 struct sme_update_access_policy_vendor_ie *msg;
10256 uint16_t msg_len;
10257 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010258
10259 msg_len = sizeof(*msg);
10260
10261 msg = qdf_mem_malloc(msg_len);
10262 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010263 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010264 return QDF_STATUS_E_FAILURE;
10265 }
10266
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010267 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10268 msg->length = (uint16_t)msg_len;
10269
10270 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10271
10272 msg->sme_session_id = session_id;
10273 msg->access_policy = access_policy;
10274
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010275 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10276 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010277
Rajeev Kumard138ac52017-01-30 18:38:37 -080010278 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010279
10280 return status;
10281}
10282
10283/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010284 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10285 * @hal: Handle returned by mac_open
10286 * @session_id: Session ID on which short frame retry limit needs to be
10287 * updated to FW
10288 * @short_limit_count_th: Retry count TH to retry short frame.
10289 *
10290 * This function is used to configure count to retry short frame.
10291 *
10292 * Return: QDF_STATUS
10293 */
10294QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10295 struct sme_short_retry_limit *short_retry_limit_th)
10296{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010297 QDF_STATUS status = QDF_STATUS_SUCCESS;
10298 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010299 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010300
10301 srl = qdf_mem_malloc(sizeof(*srl));
10302 if (NULL == srl) {
10303 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10304 "%s: fail to alloc short retry limit", __func__);
10305 return QDF_STATUS_E_FAILURE;
10306 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010307 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010308 short_retry_limit_th->session_id,
10309 short_retry_limit_th->short_retry_limit);
10310
10311 srl->session_id = short_retry_limit_th->session_id;
10312 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10313
10314 qdf_mem_zero(&msg, sizeof(msg));
10315 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10316 msg.reserved = 0;
10317 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010318 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010319 if (status != QDF_STATUS_SUCCESS) {
10320 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10321 FL("Not able to post short retry limit count to WDA"));
10322 qdf_mem_free(srl);
10323 return QDF_STATUS_E_FAILURE;
10324 }
10325
10326 return status;
10327}
10328
10329/**
10330 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10331 * @hal: Handle returned by mac_open
10332 * @session_id: Session ID on which long frames retry TH needs to be updated
10333 * to FW
10334 * @long_limit_count_th: Retry count to retry long frame.
10335 *
10336 * This function is used to configure TH to retry long frame.
10337 *
10338 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010339 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010340QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10341 struct sme_long_retry_limit *long_retry_limit_th)
10342{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010343 QDF_STATUS status = QDF_STATUS_SUCCESS;
10344 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010345 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010346
10347 lrl = qdf_mem_malloc(sizeof(*lrl));
10348 if (NULL == lrl) {
10349 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10350 "%s: fail to alloc long retry limit", __func__);
10351 return QDF_STATUS_E_FAILURE;
10352 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010353 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010354 long_retry_limit_th->session_id,
10355 long_retry_limit_th->long_retry_limit);
10356
10357 lrl->session_id = long_retry_limit_th->session_id;
10358 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10359
10360 qdf_mem_zero(&msg, sizeof(msg));
10361 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10362 msg.reserved = 0;
10363 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010364 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010365
10366 if (status != QDF_STATUS_SUCCESS) {
10367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10368 FL("Not able to post long retry limit count to WDA"));
10369 qdf_mem_free(lrl);
10370 return QDF_STATUS_E_FAILURE;
10371 }
10372
10373 return status;
10374}
10375
10376/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010377 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10378 * @hal: Handle returned by mac_open
10379 * @session_id: Session ID on which sta_inactivity_timeout needs
10380 * to be updated to FW
10381 * @sta_inactivity_timeout: sta inactivity timeout.
10382 *
10383 * If a station does not send anything in sta_inactivity_timeout seconds, an
10384 * empty data frame is sent to it in order to verify whether it is
10385 * still in range. If this frame is not ACKed, the station will be
10386 * disassociated and then deauthenticated.
10387 *
10388 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010389 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010390QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10391 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10392{
10393 struct sme_sta_inactivity_timeout *inactivity_time;
10394 void *wma_handle;
10395
10396 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10397 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10398 if (NULL == inactivity_time) {
10399 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10400 "%s: fail to alloc inactivity_time", __func__);
10401 return QDF_STATUS_E_FAILURE;
10402 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010404 FL("sta_inactivity_timeout: %d"),
10405 sta_inactivity_timer->sta_inactivity_timeout);
10406 inactivity_time->session_id = sta_inactivity_timer->session_id;
10407 inactivity_time->sta_inactivity_timeout =
10408 sta_inactivity_timer->sta_inactivity_timeout;
10409
10410 wma_update_sta_inactivity_timeout(wma_handle,
10411 inactivity_time);
10412 return QDF_STATUS_SUCCESS;
10413}
10414
10415/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 * sme_get_reg_info() - To get registration info
10417 * @hHal: HAL context
10418 * @chanId: channel id
10419 * @regInfo1: first reg info to fill
10420 * @regInfo2: second reg info to fill
10421 *
10422 * This routine will give you reg info
10423 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010424 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010425 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010426QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 uint32_t *regInfo1, uint32_t *regInfo2)
10428{
10429 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010430 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 uint8_t i;
10432 bool found = false;
10433
10434 status = sme_acquire_global_lock(&pMac->sme);
10435 *regInfo1 = 0;
10436 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010437 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010438 return status;
10439
10440 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010441 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010442 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010443 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444
10445 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010446 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010447 found = true;
10448 break;
10449 }
10450 }
10451 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010452 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453
10454 sme_release_global_lock(&pMac->sme);
10455 return status;
10456}
10457
10458#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010459/*
10460 * sme_auto_shutdown_cb() -
10461 * Used to plug in callback function for receiving auto shutdown evt
10462 *
10463 * hHal
10464 * pCallbackfn : callback function pointer should be plugged in
10465 * Return QDF_STATUS
10466 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010467QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010469 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10471
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010472 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010473 "%s: Plug in Auto shutdown event callback", __func__);
10474
10475 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010476 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010477 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010478 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010479 sme_release_global_lock(&pMac->sme);
10480 }
10481
10482 return status;
10483}
10484
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010485/*
10486 * sme_set_auto_shutdown_timer() -
10487 * API to set auto shutdown timer value in FW.
10488 *
10489 * hHal - The handle returned by mac_open
10490 * timer_val - The auto shutdown timer value to be set
10491 * Return Configuration message posting status, SUCCESS or Fail
10492 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010493QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010495 QDF_STATUS status = QDF_STATUS_SUCCESS;
10496 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10498 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010499 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010500
10501 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010502 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010503 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010504 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010505 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010506 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010507 "%s Request Buffer Alloc Fail", __func__);
10508 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010509 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010510 }
10511
10512 auto_sh_cmd->timer_val = timer_val;
10513
10514 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010515 message.bodyptr = auto_sh_cmd;
10516 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10517 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10518 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010519 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010520 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010521 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010522 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010523 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010524 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010525 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527 "%s: Posted Auto shutdown MSG", __func__);
10528 sme_release_global_lock(&pMac->sme);
10529 }
10530
10531 return status;
10532}
10533#endif
10534
Nirav Shaheb017be2018-02-15 11:20:58 +053010535#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010536/*
10537 * sme_ch_avoid_update_req() -
10538 * API to request channel avoidance update from FW.
10539 *
10540 * hHal - The handle returned by mac_open
10541 * update_type - The udpate_type parameter of this request call
10542 * Return Configuration message posting status, SUCCESS or Fail
10543 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010544QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010545{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010546 QDF_STATUS status = QDF_STATUS_SUCCESS;
10547 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010548 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10549 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010550 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010551
10552 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010553 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010554 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010555 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010557 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010558 "%s Request Buffer Alloc Fail", __func__);
10559 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010560 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010561 }
10562
10563 cauReq->reserved_param = 0;
10564
10565 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010566 message.bodyptr = cauReq;
10567 message.type = WMA_CH_AVOID_UPDATE_REQ;
10568 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10569 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010570 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010571 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010572 "%s: Post Ch Avoid Update MSG fail",
10573 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010574 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010576 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010577 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010578 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010579 "%s: Posted Ch Avoid Update MSG", __func__);
10580 sme_release_global_lock(&pMac->sme);
10581 }
10582
10583 return status;
10584}
Nirav Shaheb017be2018-02-15 11:20:58 +053010585#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010586
10587/**
10588 * sme_set_miracast() - Function to set miracast value to UMAC
10589 * @hal: Handle returned by macOpen
10590 * @filter_type: 0-Disabled, 1-Source, 2-sink
10591 *
10592 * This function passes down the value of miracast set by
10593 * framework to UMAC
10594 *
10595 * Return: Configuration message posting status, SUCCESS or Fail
10596 *
10597 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010598QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010599{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010600 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601 uint32_t *val;
10602 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10603
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010604 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010605 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010606 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010607 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010608 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 }
10610
10611 *val = filter_type;
10612
10613 msg.type = SIR_HAL_SET_MIRACAST;
10614 msg.reserved = 0;
10615 msg.bodyptr = val;
10616
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010617 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010618 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010620 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10621 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010622 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010623 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010624 }
10625
10626 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010627 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010628}
10629
10630/**
10631 * sme_set_mas() - Function to set MAS value to UMAC
10632 * @val: 1-Enable, 0-Disable
10633 *
10634 * This function passes down the value of MAS to the UMAC. A
10635 * value of 1 will enable MAS and a value of 0 will disable MAS
10636 *
10637 * Return: Configuration message posting status, SUCCESS or Fail
10638 *
10639 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010640QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010641{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010642 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010643 uint32_t *ptr_val;
10644
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010645 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010648 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010649 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010650 }
10651
10652 *ptr_val = val;
10653
10654 msg.type = SIR_HAL_SET_MAS;
10655 msg.reserved = 0;
10656 msg.bodyptr = ptr_val;
10657
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010658 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010659 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010661 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10662 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010663 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010664 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010666 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010667}
10668
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010669/**
10670 * sme_roam_channel_change_req() - Channel change to new target channel
10671 * @hHal: handle returned by mac_open
10672 * @bssid: mac address of BSS
10673 * @ch_params: target channel information
10674 * @profile: CSR profile
10675 *
10676 * API to Indicate Channel change to new target channel
10677 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010678 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010679 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010680QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010681 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010682 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010683 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010684{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010685 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687
10688 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010689 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010690
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010691 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010692 profile);
10693 sme_release_global_lock(&pMac->sme);
10694 }
10695 return status;
10696}
10697
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010698/*
10699 * sme_process_channel_change_resp() -
10700 * API to Indicate Channel change response message to SAP.
10701 *
10702 * Return QDF_STATUS
10703 */
10704static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010705 uint16_t msg_type, void *pMsgBuf)
10706{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010707 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010708 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 eCsrRoamResult roamResult;
10710 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10711 uint32_t SessionId = pChnlParams->peSessionId;
10712
10713 proam_info.channelChangeRespEvent =
10714 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010715 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010717 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010718 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010719 return status;
10720 }
10721 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10722 proam_info.channelChangeRespEvent->sessionId = SessionId;
10723 proam_info.channelChangeRespEvent->newChannelNumber =
10724 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010725
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010726 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010728 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10729 SessionId);
10730 proam_info.channelChangeRespEvent->channelChangeStatus =
10731 1;
10732 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10733 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010735 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10736 SessionId);
10737 proam_info.channelChangeRespEvent->channelChangeStatus =
10738 0;
10739 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10740 }
10741
10742 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10743 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10744
10745 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010746 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010747 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010748 status);
10749 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010750 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010751
10752 return status;
10753}
10754
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010755/*
10756 * sme_roam_start_beacon_req() -
10757 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10758 *
10759 * hHal - The handle returned by mac_open
10760 * sessionId - session ID
10761 * dfsCacWaitStatus - CAC WAIT status flag
10762 * Return QDF_STATUS
10763 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010764QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 uint8_t dfsCacWaitStatus)
10766{
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);
10771
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010772 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010773 status = csr_roam_start_beacon_req(pMac, bssid,
10774 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010775 sme_release_global_lock(&pMac->sme);
10776 }
10777 return status;
10778}
10779
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010780/**
10781 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10782 * @hHal: handle returned by mac_open
10783 * @bssid: SAP bssid
10784 * @targetChannel: target channel information
10785 * @csaIeReqd: CSA IE Request
10786 * @ch_params: channel information
10787 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010788 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010789 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010790QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010791 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010792 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010794 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010795 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010797 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010798 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010799 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10800 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010801 sme_release_global_lock(&pMac->sme);
10802 }
10803 return status;
10804}
10805
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010806/*
10807 * sme_init_thermal_info() -
10808 * SME API to initialize the thermal mitigation parameters
10809 *
10810 * hHal
10811 * thermalParam : thermal mitigation parameters
10812 * Return QDF_STATUS
10813 */
10814QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10815 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010816{
10817 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010818 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010819 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10820
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010821 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010822 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010824 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010825 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010826 }
10827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010828 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10829 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010830
10831 pWmaParam->throttle_duty_cycle_tbl[0] =
10832 thermalParam.sme_throttle_duty_cycle_tbl[0];
10833 pWmaParam->throttle_duty_cycle_tbl[1] =
10834 thermalParam.sme_throttle_duty_cycle_tbl[1];
10835 pWmaParam->throttle_duty_cycle_tbl[2] =
10836 thermalParam.sme_throttle_duty_cycle_tbl[2];
10837 pWmaParam->throttle_duty_cycle_tbl[3] =
10838 thermalParam.sme_throttle_duty_cycle_tbl[3];
10839
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010840 pWmaParam->thermalLevels[0].minTempThreshold =
10841 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10842 pWmaParam->thermalLevels[0].maxTempThreshold =
10843 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10844 pWmaParam->thermalLevels[1].minTempThreshold =
10845 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10846 pWmaParam->thermalLevels[1].maxTempThreshold =
10847 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10848 pWmaParam->thermalLevels[2].minTempThreshold =
10849 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10850 pWmaParam->thermalLevels[2].maxTempThreshold =
10851 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10852 pWmaParam->thermalLevels[3].minTempThreshold =
10853 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10854 pWmaParam->thermalLevels[3].maxTempThreshold =
10855 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10856
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010857 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010858 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10859 msg.bodyptr = pWmaParam;
10860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010861 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010862 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010864 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10865 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010866 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010868 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010869 }
10870 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010871 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010873 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875}
10876
10877/**
10878 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10879 * @hal: Handle returned by macOpen
10880 * @callback: sme_set_thermal_level_callback
10881 *
10882 * Plug in set thermal level callback
10883 *
10884 * Return: none
10885 */
10886void sme_add_set_thermal_level_callback(tHalHandle hal,
10887 sme_set_thermal_level_callback callback)
10888{
10889 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10890
10891 pMac->sme.set_thermal_level_cb = callback;
10892}
10893
10894/**
10895 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10896 * @hal: Handler to HAL
10897 * @level: Thermal mitigation level
10898 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010899 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010900 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010901QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010902{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010903 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010904 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010905 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010907 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010908 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010909 msg.type = WMA_SET_THERMAL_LEVEL;
10910 msg.bodyval = level;
10911
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010912 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010913 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010914 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010915 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10916 __func__);
10917 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010919 }
10920 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010921 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010922 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010923 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924}
10925
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010926/*
10927 * sme_txpower_limit() -
10928 * SME API to set txpower limits
10929 *
10930 * hHal
10931 * psmetx : power limits for 2g/5g
10932 * Return QDF_STATUS
10933 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010934QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010935{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010936 QDF_STATUS status = QDF_STATUS_SUCCESS;
10937 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010938 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010939 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010940 tSirTxPowerLimit *tx_power_limit;
10941
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010942 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010943 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010945 "%s: Memory allocation for TxPowerLimit failed!",
10946 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010947 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010948 }
10949
10950 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010951
10952 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010953 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010954 message.type = WMA_TX_POWER_LIMIT;
10955 message.reserved = 0;
10956 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010957
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010958 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10959 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010960 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010961 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010962 "%s: not able to post WMA_TX_POWER_LIMIT",
10963 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010964 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010965 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010966 }
10967 sme_release_global_lock(&pMac->sme);
10968 }
10969 return status;
10970}
10971
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010972QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010973{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010974 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010977 pMac->fEnableDebugLog = set_value;
10978 return status;
10979}
10980
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010981/*
10982 * sme_ap_disable_intra_bss_fwd() -
10983 * SME will send message to WMA to set Intra BSS in txrx
10984 *
10985 * hHal - The handle returned by mac_open
10986 * sessionId - session id ( vdev id)
10987 * disablefwd - bool value that indicate disable intrabss fwd disable
10988 * Return QDF_STATUS
10989 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010990QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010991 bool disablefwd)
10992{
10993 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010994 int status = QDF_STATUS_SUCCESS;
10995 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010996 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010997 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10998
10999 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011000 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011001 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011002 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011003 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011004 }
11005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011006 pSapDisableIntraFwd->sessionId = sessionId;
11007 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
11008
11009 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011010 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011011 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011012 message.bodyptr = pSapDisableIntraFwd;
11013 message.type = WMA_SET_SAP_INTRABSS_DIS;
11014 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11015 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011016 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
11017 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011018 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011019 }
11020 sme_release_global_lock(&pMac->sme);
11021 }
11022 return status;
11023}
11024
11025#ifdef WLAN_FEATURE_STATS_EXT
11026
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011027/*
11028 * sme_stats_ext_register_callback() -
11029 * This function called to register the callback that send vendor event for
11030 * stats ext
11031 *
11032 * callback - callback to be registered
11033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011034void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
11035{
11036 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11037
11038 pMac->sme.StatsExtCallback = callback;
11039}
11040
lifeng66831662017-05-19 16:01:35 +080011041void sme_stats_ext2_register_callback(tHalHandle hal_handle,
11042 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
11043{
11044 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
11045
11046 pmac->sme.stats_ext2_cb = stats_ext2_cb;
11047}
11048
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011049/**
11050 * sme_stats_ext_deregister_callback() - De-register ext stats callback
11051 * @h_hal: Hal Handle
11052 *
11053 * This function is called to de initialize the HDD NAN feature. Currently
11054 * the only operation required is to de-register a callback with SME.
11055 *
11056 * Return: None
11057 */
11058void sme_stats_ext_deregister_callback(tHalHandle h_hal)
11059{
11060 tpAniSirGlobal pmac;
11061
11062 if (!h_hal) {
11063 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11064 FL("hHal is not valid"));
11065 return;
11066 }
11067
11068 pmac = PMAC_STRUCT(h_hal);
11069 pmac->sme.StatsExtCallback = NULL;
11070}
11071
11072
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011073/*
11074 * sme_stats_ext_request() -
11075 * Function called when HDD receives STATS EXT vendor command from userspace
11076 *
11077 * sessionID - vdevID for the stats ext request
11078 * input - Stats Ext Request structure ptr
11079 * Return QDF_STATUS
11080 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011081QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011082{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011083 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011084 tpStatsExtRequest data;
11085 size_t data_len;
11086
11087 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011088 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011089
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011090 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011091 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011093 data->vdev_id = session_id;
11094 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011095 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011096 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011097 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011098
11099 msg.type = WMA_STATS_EXT_REQUEST;
11100 msg.reserved = 0;
11101 msg.bodyptr = data;
11102
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011103 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080011104 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011105 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011106 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
11107 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011108 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011109 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011110 }
11111
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011112 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113}
11114
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011115/*
11116 * sme_stats_ext_event() -
11117 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
11118 * response from WMA
11119 *
11120 * hHal - HAL handle for device
11121 * pMsg - Message body passed from WMA; includes NAN header
11122 * Return QDF_STATUS
11123 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011124QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011125{
11126 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011127 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011128
11129 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011130 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011131 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011132 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011133 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 pMac->sme.StatsExtCallback(pMac->hHdd,
11135 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011136 }
11137
11138 return status;
11139}
11140
11141#endif
11142
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011143/*
11144 * sme_update_dfs_scan_mode() -
11145 * Update DFS roam scan mode
11146 * This function is called through dynamic setConfig callback function
11147 * to configure allowDFSChannelRoam.
11148 * hHal - HAL handle for device
11149 * sessionId - Session Identifier
11150 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
11151 * 1 (passive), 2 (active)
11152 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11153 * successfully.
11154 * Other status means SME failed to update DFS roaming scan config.
11155 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011156QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 uint8_t allowDFSChannelRoam)
11158{
11159 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011160 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011162 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11163 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11164 FL("Invalid sme session id: %d"), sessionId);
11165 return QDF_STATUS_E_INVAL;
11166 }
11167
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011168 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011169 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011170 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011171 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011172 allowDFSChannelRoam,
11173 pMac->roam.configParam.allowDFSChannelRoam,
11174 mac_trace_get_neighbour_roam_state(pMac->roam.
11175 neighborRoamInfo
11176 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011177 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011178 pMac->roam.configParam.allowDFSChannelRoam =
11179 allowDFSChannelRoam;
11180 sme_release_global_lock(&pMac->sme);
11181 }
11182 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11183 csr_roam_offload_scan(pMac, sessionId,
11184 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11185 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11186 }
11187
11188 return status;
11189}
11190
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011191/*
11192 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11193 * This is a synchronous call
11194 *
11195 * hHal - The handle returned by mac_open.
11196 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11197 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011198uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11199{
11200 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011202 return pMac->roam.configParam.allowDFSChannelRoam;
11203}
11204
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011205/*
11206 * sme_modify_add_ie() -
11207 * This function sends msg to updates the additional IE buffers in PE
11208 *
11209 * hHal - global structure
11210 * pModifyIE - pointer to tModifyIE structure
11211 * updateType - type of buffer
11212 * Return Success or failure
11213 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011214QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011215 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220 status = sme_acquire_global_lock(&pMac->sme);
11221
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011222 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011223 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11224 sme_release_global_lock(&pMac->sme);
11225 }
11226 return status;
11227}
11228
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011229/*
11230 * sme_update_add_ie() -
11231 * This function sends msg to updates the additional IE buffers in PE
11232 *
11233 * hHal - global structure
11234 * pUpdateIE - pointer to structure tUpdateIE
11235 * updateType - type of buffer
11236 * Return Success or failure
11237 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011238QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011239 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11240{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011241 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244 status = sme_acquire_global_lock(&pMac->sme);
11245
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011246 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011247 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11248 sme_release_global_lock(&pMac->sme);
11249 }
11250 return status;
11251}
11252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253/**
11254 * sme_update_dsc_pto_up_mapping()
11255 * @hHal: HAL context
11256 * @dscpmapping: pointer to DSCP mapping structure
11257 * @sessionId: SME session id
11258 *
11259 * This routine is called to update dscp mapping
11260 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011261 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011262 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011263QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011264 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011265 uint8_t sessionId)
11266{
11267 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011268 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011269 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011270 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011271 tpPESession pSession = NULL;
11272
11273 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011274 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275 return status;
11276 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11277 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011279 FL("Session lookup fails for CSR session"));
11280 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011281 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282 }
11283 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011284 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 FL("Invalid session Id %u"), sessionId);
11286 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011287 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 }
11289
11290 pSession = pe_find_session_by_bssid(pMac,
11291 pCsrSession->connectedProfile.bssid.bytes,
11292 &peSessionId);
11293
11294 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011295 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011296 FL(" Session lookup fails for BSSID"));
11297 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011298 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011299 }
11300
11301 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011302 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011304 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011305 }
11306 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11307 for (j = pSession->QosMapSet.dscp_range[i][0];
11308 j <= pSession->QosMapSet.dscp_range[i][1];
11309 j++) {
11310 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11311 && (pSession->QosMapSet.dscp_range[i][1] ==
11312 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011313 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011314 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011315 FL("User Priority %d isn't used"), i);
11316 break;
11317 } else {
11318 dscpmapping[j] = i;
11319 }
11320 }
11321 }
11322 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11323 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11324 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11325 pSession->QosMapSet.dscp_exceptions[i][1];
11326
11327 sme_release_global_lock(&pMac->sme);
11328 return status;
11329}
11330
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011331/*
11332 * sme_abort_roam_scan() -
11333 * API to abort current roam scan cycle by roam scan offload module.
11334 *
11335 * hHal - The handle returned by mac_open.
11336 * sessionId - Session Identifier
11337 * Return QDF_STATUS
11338 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011339
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011340QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011341{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011342 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011343 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11344
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011345 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11346 /* acquire the lock for the sme object */
11347 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011348 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011349 csr_roam_offload_scan(pMac, sessionId,
11350 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11351 REASON_ROAM_ABORT_ROAM_SCAN);
11352 /* release the lock for the sme object */
11353 sme_release_global_lock(&pMac->sme);
11354 }
11355 }
11356
11357 return status;
11358}
11359
11360#ifdef FEATURE_WLAN_EXTSCAN
11361/**
11362 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11363 * @hHal: HAL context
11364 * @wifiBand: RF band information
11365 * @aValidChannels: output array to store channel info
11366 * @pNumChannels: output number of channels
11367 *
11368 * SME API to fetch all valid channels filtered by band
11369 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011370 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011372QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011373 uint8_t wifiBand,
11374 uint32_t *aValidChannels,
11375 uint8_t *pNumChannels)
11376{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011377 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011378 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011379 uint8_t numChannels = 0;
11380 uint8_t i = 0;
11381 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011382 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011383
11384 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011385 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011386 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 }
11388
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011389 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011390 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011391 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011392 }
11393
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011394 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011395 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011396 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011397 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011398 return status;
11399 }
11400
11401 switch (wifiBand) {
11402 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011403 sme_debug("Unspec Band, return all %d valid channels",
11404 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011405 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011406 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011407 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 break;
11409
11410 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011411 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011412 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011413 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011414 aValidChannels[numChannels++] =
11415 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011416 }
11417 break;
11418
11419 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011420 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011421 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011422 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011423 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011424 aValidChannels[numChannels++] =
11425 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011426 }
11427 break;
11428
11429 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011430 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011431 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011432 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11433 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011434 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 aValidChannels[numChannels++] =
11436 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011437 }
11438 break;
11439
11440 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011441 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011442 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011443 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011444 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011445 aValidChannels[numChannels++] =
11446 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011447 }
11448 break;
11449
11450 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011451 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011453 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011454 aValidChannels[numChannels++] =
11455 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011456 }
11457 break;
11458
11459 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011460 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011461 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011462 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011463 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011464 aValidChannels[numChannels++] =
11465 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011466 }
11467 break;
11468
11469 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011470 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011471 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011472 }
11473 *pNumChannels = numChannels;
11474
11475 return status;
11476}
11477
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011478/*
11479 * sme_ext_scan_get_capabilities() -
11480 * SME API to fetch extscan capabilities
11481 *
11482 * hHal
11483 * pReq: extscan capabilities structure
11484 * Return QDF_STATUS
11485 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011486QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011487 tSirGetExtScanCapabilitiesReqParams *
11488 pReq)
11489{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011490 QDF_STATUS status = QDF_STATUS_SUCCESS;
11491 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011492 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011493 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494
11495 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011496 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011497 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011498 message.bodyptr = pReq;
11499 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011500 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011501 NO_SESSION, message.type));
11502 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11503 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011504 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11505 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011506
11507 sme_release_global_lock(&pMac->sme);
11508 }
11509 return status;
11510}
11511
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011512/*
11513 * sme_ext_scan_start() -
11514 * SME API to issue extscan start
11515 *
11516 * hHal
11517 * pStartCmd: extscan start structure
11518 * Return QDF_STATUS
11519 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011520QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011521 tSirWifiScanCmdReqParams *pStartCmd)
11522{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011523 QDF_STATUS status = QDF_STATUS_SUCCESS;
11524 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011525 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011526 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011527
11528 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011529 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011530 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011531 message.bodyptr = pStartCmd;
11532 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011533 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011534 NO_SESSION, message.type));
11535 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11536 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011537 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11538 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011539
11540 sme_release_global_lock(&pMac->sme);
11541 }
11542 return status;
11543}
11544
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011545/*
11546 * sme_ext_scan_stop() -
11547 * SME API to issue extscan stop
11548 *
11549 * hHal
11550 * pStopReq: extscan stop structure
11551 * Return QDF_STATUS
11552 */
11553QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11554 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011555{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011556 QDF_STATUS status = QDF_STATUS_SUCCESS;
11557 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011559 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560
11561 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011562 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011564 message.bodyptr = pStopReq;
11565 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011566 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011567 NO_SESSION, message.type));
11568 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11569 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011570 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11571 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 sme_release_global_lock(&pMac->sme);
11573 }
11574 return status;
11575}
11576
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011577/*
11578 * sme_set_bss_hotlist() -
11579 * SME API to set BSSID hotlist
11580 *
11581 * hHal
11582 * pSetHotListReq: extscan set hotlist structure
11583 * Return QDF_STATUS
11584 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011585QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011586 tSirExtScanSetBssidHotListReqParams *
11587 pSetHotListReq)
11588{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011589 QDF_STATUS status = QDF_STATUS_SUCCESS;
11590 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011591 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011592 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011593
11594 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011595 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011597 message.bodyptr = pSetHotListReq;
11598 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011599 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011600 NO_SESSION, message.type));
11601 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11602 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011603 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11604 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011605
11606 sme_release_global_lock(&pMac->sme);
11607 }
11608 return status;
11609}
11610
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011611/*
11612 * sme_reset_bss_hotlist() -
11613 * SME API to reset BSSID hotlist
11614 *
11615 * hHal
11616 * pSetHotListReq: extscan set hotlist structure
11617 * Return QDF_STATUS
11618 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011619QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011620 tSirExtScanResetBssidHotlistReqParams *
11621 pResetReq)
11622{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011623 QDF_STATUS status = QDF_STATUS_SUCCESS;
11624 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011625 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011626 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011627
11628 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011629 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011630 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011631 message.bodyptr = pResetReq;
11632 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011633 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011634 NO_SESSION, message.type));
11635 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11636 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011637 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11638 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011639
11640 sme_release_global_lock(&pMac->sme);
11641 }
11642 return status;
11643}
11644
Manikandan Mohan80dea792016-04-28 16:36:48 -070011645/**
11646 * sme_send_wisa_params(): Pass WISA mode to WMA
11647 * @hal: HAL context
11648 * @wisa_params: pointer to WISA params struct
11649 * @sessionId: SME session id
11650 *
11651 * Pass WISA params to WMA
11652 *
11653 * Return: QDF_STATUS
11654 */
11655QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11656 struct sir_wisa_params *wisa_params)
11657{
11658 QDF_STATUS status = QDF_STATUS_SUCCESS;
11659 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011660 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011661 struct sir_wisa_params *cds_msg_wisa_params;
11662
11663 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11664 if (!cds_msg_wisa_params)
11665 return QDF_STATUS_E_NOMEM;
11666
11667 *cds_msg_wisa_params = *wisa_params;
11668 status = sme_acquire_global_lock(&mac->sme);
11669 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011670 message.bodyptr = cds_msg_wisa_params;
11671 message.type = WMA_SET_WISA_PARAMS;
11672 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011673 sme_release_global_lock(&mac->sme);
11674 }
11675 return status;
11676}
11677
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011678/*
11679 * sme_set_significant_change() -
11680 * SME API to set significant change
11681 *
11682 * hHal
11683 * pSetSignificantChangeReq: extscan set significant change structure
11684 * Return QDF_STATUS
11685 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011686QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 tSirExtScanSetSigChangeReqParams *
11688 pSetSignificantChangeReq)
11689{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011690 QDF_STATUS status = QDF_STATUS_SUCCESS;
11691 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011693 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694
11695 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011696 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011697 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011698 message.bodyptr = pSetSignificantChangeReq;
11699 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011700 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011701 NO_SESSION, message.type));
11702 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11703 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011704 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11705 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011706
11707 sme_release_global_lock(&pMac->sme);
11708 }
11709 return status;
11710}
11711
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011712/*
11713 * sme_reset_significant_change
11714 * SME API to reset significant change
11715 *
11716 * hHal
11717 * pResetReq: extscan reset significant change structure
11718 * Return QDF_STATUS
11719 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011720QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011721 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011722 *pResetReq)
11723{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011724 QDF_STATUS status = QDF_STATUS_SUCCESS;
11725 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011727 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728
11729 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011730 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011732 message.bodyptr = pResetReq;
11733 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011734 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011735 NO_SESSION, message.type));
11736 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11737 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011738 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11739 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740
11741 sme_release_global_lock(&pMac->sme);
11742 }
11743 return status;
11744}
11745
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011746/*
11747 * sme_get_cached_results() -
11748 * SME API to get cached results
11749 *
11750 * hHal
11751 * pCachedResultsReq: extscan get cached results structure
11752 * Return QDF_STATUS
11753 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011754QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 tSirExtScanGetCachedResultsReqParams *
11756 pCachedResultsReq)
11757{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011758 QDF_STATUS status = QDF_STATUS_SUCCESS;
11759 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011760 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011761 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762
11763 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011764 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011765 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011766 message.bodyptr = pCachedResultsReq;
11767 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011768 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011769 NO_SESSION, message.type));
11770 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11771 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011772 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11773 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011774
11775 sme_release_global_lock(&pMac->sme);
11776 }
11777 return status;
11778}
11779
11780/**
11781 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011782 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011783 * @input: request message
11784 *
11785 * This function constructs the cds message and fill in message type,
11786 * bodyptr with %input and posts it to WDA queue.
11787 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011788 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011789 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011790QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011791 struct wifi_epno_params *input)
11792{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011793 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011795 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796 struct wifi_epno_params *req_msg;
11797 int len, i;
11798
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011799 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 len = sizeof(*req_msg) +
11801 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011802
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011803 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011804 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011805 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011806 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 }
11808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809 req_msg->num_networks = input->num_networks;
11810 req_msg->request_id = input->request_id;
11811 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011812
11813 /* Fill only when num_networks are non zero */
11814 if (req_msg->num_networks) {
11815 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11816 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11817 req_msg->initial_score_max = input->initial_score_max;
11818 req_msg->same_network_bonus = input->same_network_bonus;
11819 req_msg->secure_bonus = input->secure_bonus;
11820 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11821 req_msg->current_connection_bonus =
11822 input->current_connection_bonus;
11823
11824 for (i = 0; i < req_msg->num_networks; i++) {
11825 req_msg->networks[i].flags = input->networks[i].flags;
11826 req_msg->networks[i].auth_bit_field =
11827 input->networks[i].auth_bit_field;
11828 req_msg->networks[i].ssid.length =
11829 input->networks[i].ssid.length;
11830 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11831 input->networks[i].ssid.ssId,
11832 req_msg->networks[i].ssid.length);
11833 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011834 }
11835
11836 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011837 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011838 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011839 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011840 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011841 return status;
11842 }
11843
11844 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011845 message.bodyptr = req_msg;
11846 message.type = WMA_SET_EPNO_LIST_REQ;
11847 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011848 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011849 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011850 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011851 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011852 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853 }
11854 sme_release_global_lock(&mac->sme);
11855 return status;
11856}
11857
11858/**
11859 * sme_set_passpoint_list() - set passpoint network list
11860 * @hal: global hal handle
11861 * @input: request message
11862 *
11863 * This function constructs the cds message and fill in message type,
11864 * bodyptr with @input and posts it to WDA queue.
11865 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011866 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011867 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011868QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011869 struct wifi_passpoint_req *input)
11870{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011871 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011872 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011873 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011874 struct wifi_passpoint_req *req_msg;
11875 int len, i;
11876
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011877 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011878 len = sizeof(*req_msg) +
11879 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011880 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011882 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011883 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011884 }
11885
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011886 req_msg->num_networks = input->num_networks;
11887 req_msg->request_id = input->request_id;
11888 req_msg->session_id = input->session_id;
11889 for (i = 0; i < req_msg->num_networks; i++) {
11890 req_msg->networks[i].id =
11891 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011892 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011893 input->networks[i].realm,
11894 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011895 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896 input->networks[i].plmn,
11897 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011898 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011899 input->networks[i].roaming_consortium_ids,
11900 sizeof(req_msg->networks[i].roaming_consortium_ids));
11901 }
11902
11903 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011904 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011905 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011906 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011907 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011908 return status;
11909 }
11910
11911 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011912 message.bodyptr = req_msg;
11913 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11914 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011915 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011916 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011917 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011918 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011919 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011920 }
11921 sme_release_global_lock(&mac->sme);
11922 return status;
11923}
11924
11925/**
11926 * sme_reset_passpoint_list() - reset passpoint network list
11927 * @hHal: global hal handle
11928 * @input: request message
11929 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011930 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011931 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011932QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011933 struct wifi_passpoint_req *input)
11934{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011935 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011936 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011937 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011938 struct wifi_passpoint_req *req_msg;
11939
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011940 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011941 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011942 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011943 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011944 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011945 }
11946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011947 req_msg->request_id = input->request_id;
11948 req_msg->session_id = input->session_id;
11949
11950 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011951 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011952 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011953 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011954 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011955 return status;
11956 }
11957
11958 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011959 message.bodyptr = req_msg;
11960 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11961 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011962 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011963 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011964 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011965 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011966 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011967 }
11968 sme_release_global_lock(&mac->sme);
11969 return status;
11970}
11971
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011972QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011973 void (*pExtScanIndCb)(void *,
11974 const uint16_t,
11975 void *))
11976{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011977 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11979
11980 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011981 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011982 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11983 sme_release_global_lock(&pMac->sme);
11984 }
11985 return status;
11986}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011987#endif /* FEATURE_WLAN_EXTSCAN */
11988
11989#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11990
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011991/*
11992 * sme_ll_stats_clear_req() -
11993 * SME API to clear Link Layer Statistics
11994 *
11995 * hHal
11996 * pclearStatsReq: Link Layer clear stats request params structure
11997 * Return QDF_STATUS
11998 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011999QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012000 tSirLLStatsClearReq *pclearStatsReq)
12001{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012002 QDF_STATUS status = QDF_STATUS_SUCCESS;
12003 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012004 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012005 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012006 tSirLLStatsClearReq *clear_stats_req;
12007
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012008 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012009 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012011 "statsClearReqMask = 0x%X",
12012 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012013 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012014 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070012015 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
12016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12017 "%s: invalid staId %d",
12018 __func__, pclearStatsReq->staId);
12019 return QDF_STATUS_E_INVAL;
12020 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012021
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012022 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012023
12024 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012025 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012026 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
12027 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012028 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012029 }
12030
12031 *clear_stats_req = *pclearStatsReq;
12032
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012033 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012034 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012035 message.bodyptr = clear_stats_req;
12036 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012037 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012038 NO_SESSION, message.type));
12039 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12040 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012041 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012042 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012043 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
12044 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012045 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012046 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012047 }
12048 sme_release_global_lock(&pMac->sme);
12049 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012050 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12051 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012052 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012053 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012054 }
12055
12056 return status;
12057}
12058
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012059/*
12060 * sme_ll_stats_set_req() -
12061 * SME API to set the Link Layer Statistics
12062 *
12063 * hHal
12064 * psetStatsReq: Link Layer set stats request params structure
12065 * Return QDF_STATUS
12066 */
12067QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
12068 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012069{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012070 QDF_STATUS status = QDF_STATUS_SUCCESS;
12071 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012072 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012073 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012074 tSirLLStatsSetReq *set_stats_req;
12075
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012077 "%s: MPDU Size = %u", __func__,
12078 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012079 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080 " Aggressive Stats Collections = %u",
12081 psetStatsReq->aggressiveStatisticsGathering);
12082
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012083 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012084
12085 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
12088 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012089 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012090 }
12091
12092 *set_stats_req = *psetStatsReq;
12093
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012094 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012095 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012096 message.bodyptr = set_stats_req;
12097 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012098 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012099 NO_SESSION, message.type));
12100 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12101 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012102 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012103 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012104 "%s: not able to post WMA_LL_STATS_SET_REQ",
12105 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012106 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012107 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012108 }
12109 sme_release_global_lock(&pMac->sme);
12110 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12112 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012113 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012114 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012115 }
12116
12117 return status;
12118}
12119
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012120/*
12121 * sme_ll_stats_get_req() -
12122 * SME API to get the Link Layer Statistics
12123 *
12124 * hHal
12125 * pgetStatsReq: Link Layer get stats request params structure
12126 * Return QDF_STATUS
12127 */
12128QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
12129 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012130{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012131 QDF_STATUS status = QDF_STATUS_SUCCESS;
12132 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012133 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012134 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012135 tSirLLStatsGetReq *get_stats_req;
12136
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012137 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012138
12139 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012140 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012141 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
12142 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012143 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012144 }
12145
12146 *get_stats_req = *pgetStatsReq;
12147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012148 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012149 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012150 message.bodyptr = get_stats_req;
12151 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012152 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012153 NO_SESSION, message.type));
12154 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12155 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012156 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012157 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 "%s: not able to post WMA_LL_STATS_GET_REQ",
12159 __func__);
12160
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012161 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012162 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163
12164 }
12165 sme_release_global_lock(&pMac->sme);
12166 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012167 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12168 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012169 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012170 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012171 }
12172
12173 return status;
12174}
12175
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012176/*
12177 * sme_set_link_layer_stats_ind_cb() -
12178 * SME API to trigger the stats are available after get request
12179 *
12180 * hHal
12181 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012182 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012183 * Return QDF_STATUS
12184 */
12185QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12186 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12187{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012188 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012189 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12190
12191 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012192 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012193 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12194 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012195 } else
12196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12197 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012198
12199 return status;
12200}
12201
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012202/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012203 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12204 * @hal: Mac global handle
12205 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12206 * status notification from FW
12207 *
12208 * Return: eHalStatus
12209 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012210QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12211 (tHddHandle callback_ctx, tSirLLStatsResults
12212 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012213{
12214 QDF_STATUS status;
12215 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12216
12217 status = sme_acquire_global_lock(&mac->sme);
12218 if (status == QDF_STATUS_SUCCESS) {
12219 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12220 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012221 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012222 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12223 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012224 return status;
12225}
12226
12227/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012228 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12229 * indication
12230 * @h_hal: Hal Handle
12231 *
12232 * This function reset's the link layer stats indication
12233 *
12234 * Return: QDF_STATUS Enumeration
12235 */
12236
12237QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12238{
12239 QDF_STATUS status;
12240 tpAniSirGlobal pmac;
12241
12242 if (!h_hal) {
12243 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12244 FL("hHal is not valid"));
12245 return QDF_STATUS_E_INVAL;
12246 }
12247 pmac = PMAC_STRUCT(h_hal);
12248
12249 status = sme_acquire_global_lock(&pmac->sme);
12250 if (QDF_IS_STATUS_SUCCESS(status)) {
12251 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12252 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012253 } else
12254 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12255 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012256
12257 return status;
12258}
12259
Zhang Qian73c348a2017-03-13 16:15:55 +080012260/**
12261 * sme_ll_stats_set_thresh - set threshold for mac counters
12262 * @hal, hal layer handle
12263 * @threshold, threshold for mac counters
12264 *
12265 * Return: QDF_STATUS Enumeration
12266 */
12267QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12268 struct sir_ll_ext_stats_threshold *threshold)
12269{
12270 QDF_STATUS status;
12271 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080012272 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080012273 struct sir_ll_ext_stats_threshold *thresh;
12274
12275 if (!threshold) {
12276 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12277 FL("threshold is not valid"));
12278 return QDF_STATUS_E_INVAL;
12279 }
12280
12281 if (!hal) {
12282 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12283 FL("hal is not valid"));
12284 return QDF_STATUS_E_INVAL;
12285 }
12286 mac = PMAC_STRUCT(hal);
12287
12288 thresh = qdf_mem_malloc(sizeof(*thresh));
12289 if (!thresh) {
12290 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12291 "%s: Fail to alloc mem", __func__);
12292 return QDF_STATUS_E_NOMEM;
12293 }
12294 *thresh = *threshold;
12295
12296 status = sme_acquire_global_lock(&mac->sme);
12297 if (QDF_IS_STATUS_SUCCESS(status)) {
12298 /* Serialize the req through MC thread */
12299 message.bodyptr = thresh;
12300 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12301 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12302 NO_SESSION, message.type));
12303 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12304 if (!QDF_IS_STATUS_SUCCESS(status)) {
12305 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12306 "%s: not able to post WDA_LL_STATS_GET_REQ",
12307 __func__);
12308 qdf_mem_free(thresh);
12309 }
12310 sme_release_global_lock(&mac->sme);
12311 } else {
12312 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12313 FL("sme_acquire_global_lock error"));
12314 qdf_mem_free(thresh);
12315 }
12316 return status;
12317}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012318
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012319#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12320
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012321#ifdef WLAN_POWER_DEBUGFS
12322/**
12323 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12324 * @callback_fn: Pointer to the callback function for Power stats event
12325 * @power_stats_context: Pointer to context
12326 *
12327 * Return: QDF_STATUS
12328 */
12329QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12330 (struct power_stats_response *response,
12331 void *context), void *power_stats_context)
12332{
12333 QDF_STATUS status = QDF_STATUS_SUCCESS;
12334 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012335 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012336
12337 status = sme_acquire_global_lock(&mac_ctx->sme);
12338 if (QDF_IS_STATUS_SUCCESS(status)) {
12339 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012340 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012341 sme_release_global_lock(&mac_ctx->sme);
12342 return QDF_STATUS_E_FAILURE;
12343 }
12344
12345 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12346 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12347 msg.bodyptr = NULL;
12348 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012349 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012350 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012351 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012352 sme_release_global_lock(&mac_ctx->sme);
12353 }
12354 return status;
12355}
12356#endif
12357
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012358#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012359/*
12360 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12361 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12362 *
12363 * hHal - The handle returned by mac_open.
12364 * nRoamOffloadEnabled - The bool to update with
12365 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12366 * Other status means SME is failed to update.
12367 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012368
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012369QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012370 bool nRoamOffloadEnabled)
12371{
12372 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012373 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012374
12375 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012376 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012377 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012378 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12379 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12380 nRoamOffloadEnabled);
12381 pMac->roam.configParam.isRoamOffloadEnabled =
12382 nRoamOffloadEnabled;
12383 sme_release_global_lock(&pMac->sme);
12384 }
12385
12386 return status;
12387}
12388
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012389/**
12390 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12391 * This is a synchronous call
12392 * @hal_ctx: The handle returned by mac_open.
12393 * @session_id: Session Identifier
12394 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012395 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012396 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12397 * Other status means SME is failed to update.
12398 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012399
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012400QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012401 uint8_t session_id,
12402 bool key_mgmt_offload_enabled,
12403 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012404{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012405 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012406 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012407
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012408 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012409 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012410 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012411 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012412 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12413 __func__, key_mgmt_offload_enabled);
12414 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12415 session_id,
12416 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012417 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012418 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012419 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012420 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421 }
12422
12423 return status;
12424}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012425#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012427/*
12428 * sme_get_temperature() -
12429 * SME API to get the pdev temperature
12430 *
12431 * hHal
12432 * temperature context
12433 * pCallbackfn: callback fn with response (temperature)
12434 * Return QDF_STATUS
12435 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012436QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012437 void *tempContext,
12438 void (*pCallbackfn)(int temperature,
12439 void *pContext))
12440{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012441 QDF_STATUS status = QDF_STATUS_SUCCESS;
12442 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012444 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012445
12446 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012447 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012448 if ((NULL == pCallbackfn) &&
12449 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012450 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012451 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012452 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012453 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012454 } else if (NULL != pCallbackfn) {
12455 pMac->sme.pTemperatureCbContext = tempContext;
12456 pMac->sme.pGetTemperatureCb = pCallbackfn;
12457 }
12458 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012459 message.bodyptr = NULL;
12460 message.type = WMA_GET_TEMPERATURE_REQ;
12461 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12462 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012463 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012465 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012466 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012467 }
12468 sme_release_global_lock(&pMac->sme);
12469 }
12470 return status;
12471}
12472
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012473/*
12474 * sme_set_scanning_mac_oui() -
12475 * SME API to set scanning mac oui
12476 *
12477 * hHal
12478 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12479 * Return QDF_STATUS
12480 */
12481QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12482 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012483{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012484 QDF_STATUS status = QDF_STATUS_SUCCESS;
12485 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012486 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012487 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012488
12489 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012490 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012491 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012492 message.bodyptr = pScanMacOui;
12493 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12494 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12495 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012496 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012498 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012499 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012500 }
12501 sme_release_global_lock(&pMac->sme);
12502 }
12503 return status;
12504}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012505
12506#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012507/*
12508 * sme_set_dhcp_srv_offload() -
12509 * SME API to set DHCP server offload info
12510 *
12511 * hHal
12512 * pDhcpSrvInfo : DHCP server offload info struct
12513 * Return QDF_STATUS
12514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012515QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012516 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12517{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012518 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012519 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012520 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12522
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012523 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012524
12525 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012527 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12528 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012529 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012530 }
12531
12532 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12533
12534 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012535 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012537 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12538 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012539
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012540 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012541 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12542 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012544 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012545 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012546 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012547 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012548 }
12549 sme_release_global_lock(&pMac->sme);
12550 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012553 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012554 }
12555
12556 return status;
12557}
12558#endif /* DHCP_SERVER_OFFLOAD */
12559
Krunal Soniaadaa272017-10-04 16:42:55 -070012560QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12561 uint32_t arg_count, uint32_t *arg)
12562{
12563 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12564 arg_count, arg);
12565}
12566
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012567#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012568/*
12569 * sme_set_led_flashing() -
12570 * API to set the Led flashing parameters.
12571 *
12572 * hHal - The handle returned by mac_open.
12573 * x0, x1 - led flashing parameters
12574 * Return QDF_STATUS
12575 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012576QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012577 uint32_t x0, uint32_t x1)
12578{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012579 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012580 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012581 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012582 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012583
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012584 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012585 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012586 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012587 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012588 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589 }
12590
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012591 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592 ledflashing->pattern_id = type;
12593 ledflashing->led_x0 = x0;
12594 ledflashing->led_x1 = x1;
12595
12596 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012597 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012598 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012599 message.bodyptr = ledflashing;
12600 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012601 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012602 sme_release_global_lock(&pMac->sme);
12603 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012604 if (!QDF_IS_STATUS_SUCCESS(status))
12605 qdf_mem_free(ledflashing);
12606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012607 return status;
12608}
12609#endif
12610
12611/**
12612 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12613 * @h_hal: corestack handler
12614 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012615 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012616 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012617QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012618{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012619 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012620 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12621
12622 status = sme_acquire_global_lock(&mac->sme);
12623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012624 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012625
12626 mac->scan.fEnableDFSChnlScan = dfs_flag;
12627
12628 /* update the channel list to the firmware */
12629 status = csr_update_channel_list(mac);
12630
12631 sme_release_global_lock(&mac->sme);
12632 }
12633
12634 return status;
12635}
12636
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012637#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12638/**
12639 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12640 * concurreny rules set to avoid channel interference.
12641 * @hal - Hal context
12642 * @sap_ch - channel to switch
12643 * @sap_phy_mode - phy mode of SAP
12644 * @cc_switch_mode - concurreny switch mode
12645 * @session_id - sme session id.
12646 *
12647 * Return: true if there is no channel interference else return false
12648 */
12649bool sme_validate_sap_channel_switch(tHalHandle hal,
12650 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12651 uint8_t session_id)
12652{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012653 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012654 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012655 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012656 uint16_t intf_channel = 0;
12657
12658 if (!session)
12659 return false;
12660
12661 session->ch_switch_in_progress = true;
12662 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012663 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012664 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12665 sap_phy_mode,
12666 cc_switch_mode);
12667 sme_release_global_lock(&mac->sme);
12668 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012669 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012670 FL("sme_acquire_global_lock error!"));
12671 session->ch_switch_in_progress = false;
12672 return false;
12673 }
12674
12675 session->ch_switch_in_progress = false;
12676 return (intf_channel == 0) ? true : false;
12677}
12678#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012679
12680/**
12681 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12682 * @hal: hal
12683 * @session_id: session ID
12684 * @stats_avg_factor: average stats factor
12685 *
12686 * This function configures the stats avg factor in firmware
12687 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012688 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012689 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012690QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012691 uint16_t stats_avg_factor)
12692{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012693 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012694 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012695 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12696 struct sir_stats_avg_factor *stats_factor;
12697
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012698 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012699
12700 if (!stats_factor) {
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: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12703 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012704 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012705 }
12706
12707 status = sme_acquire_global_lock(&mac->sme);
12708
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012709 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012710
12711 stats_factor->vdev_id = session_id;
12712 stats_factor->stats_avg_factor = stats_avg_factor;
12713
12714 /* serialize the req through MC thread */
12715 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12716 msg.bodyptr = stats_factor;
12717
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012718 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012719 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012720 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012721 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12722 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012723 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012724 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012725 }
12726 sme_release_global_lock(&mac->sme);
12727 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729 "%s: sme_acquire_global_lock error!",
12730 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012731 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012732 }
12733
12734 return status;
12735}
12736
12737/**
12738 * sme_configure_guard_time() - function to configure guard time
12739 * @hal: hal
12740 * @session_id: session id
12741 * @guard_time: guard time
12742 *
12743 * This function configures the guard time in firmware
12744 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012745 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012746 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012747QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012748 uint32_t guard_time)
12749{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012750 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012751 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012752 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12753 struct sir_guard_time_request *g_time;
12754
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012755 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012756
12757 if (!g_time) {
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: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12760 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012761 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012762 }
12763
12764 status = sme_acquire_global_lock(&mac->sme);
12765
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012766 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012767
12768 g_time->vdev_id = session_id;
12769 g_time->guard_time = guard_time;
12770
12771 /* serialize the req through MC thread */
12772 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12773 msg.bodyptr = g_time;
12774
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012775 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012776 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012777 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012778 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12779 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012780 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012781 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012782 }
12783 sme_release_global_lock(&mac->sme);
12784 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786 "%s: sme_acquire_global_lock error!",
12787 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012788 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012789 }
12790
12791 return status;
12792}
12793
12794/**
12795 * sme_configure_modulated_dtim() - function to configure modulated dtim
12796 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12797 * @session_id: session ID
12798 * @modulated_dtim: modulated dtim value
12799 *
12800 * This function configures the modulated dtim in firmware
12801 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012802 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012803 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012804QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012805 uint32_t modulated_dtim)
12806{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012807 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012808 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12810 wma_cli_set_cmd_t *iwcmd;
12811
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012812 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012813 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012814 QDF_TRACE(QDF_MODULE_ID_SME,
12815 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012816 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012817 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818 }
12819
12820 status = sme_acquire_global_lock(&mac->sme);
12821
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012822 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012824 iwcmd->param_value = modulated_dtim;
12825 iwcmd->param_vdev_id = session_id;
12826 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12827 iwcmd->param_vp_dev = GEN_CMD;
12828 msg.type = WMA_CLI_SET_CMD;
12829 msg.reserved = 0;
12830 msg.bodyptr = (void *)iwcmd;
12831
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012832 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012833 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012835 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12836 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012837 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012838 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012839 }
12840 sme_release_global_lock(&mac->sme);
12841 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012842 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012843 "%s: sme_acquire_global_lock error!",
12844 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012845 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012846 }
12847
12848 return status;
12849}
12850
Mukul Sharma6398b252017-05-01 17:58:12 +053012851/**
12852 * sme_override_listen_interval() - function to override static LI
12853 * @h_hal: SME API to override listen interval
12854 * @session_id: session ID
12855 * @override_li: new LI value passed by user
12856 *
12857 * This function override (enable/disable) static a.k.a ini based LI
12858 *
12859 * Return: QDF_STATUS
12860 */
12861QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12862 uint32_t override_li)
12863{
12864 struct scheduler_msg msg = {0};
12865 QDF_STATUS status = QDF_STATUS_SUCCESS;
12866 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12867 wma_cli_set_cmd_t *iwcmd;
12868
12869 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12870 if (!iwcmd) {
12871 QDF_TRACE(QDF_MODULE_ID_SME,
12872 QDF_TRACE_LEVEL_FATAL,
12873 "%s: qdf_mem_malloc failed", __func__);
12874 return QDF_STATUS_E_NOMEM;
12875 }
12876
12877 status = sme_acquire_global_lock(&mac->sme);
12878
12879 if (status == QDF_STATUS_SUCCESS) {
12880
12881 iwcmd->param_value = override_li;
12882 iwcmd->param_vdev_id = session_id;
12883 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12884 iwcmd->param_vp_dev = GEN_CMD;
12885 msg.type = WMA_CLI_SET_CMD;
12886 msg.reserved = 0;
12887 msg.bodyptr = (void *)iwcmd;
12888
12889 if (!QDF_IS_STATUS_SUCCESS(
12890 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12891 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12892 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12893 __func__);
12894 qdf_mem_free(iwcmd);
12895 status = QDF_STATUS_E_FAILURE;
12896 }
12897 sme_release_global_lock(&mac->sme);
12898 } else {
12899 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12900 "%s: sme_acquire_global_lock error!",
12901 __func__);
12902 qdf_mem_free(iwcmd);
12903 }
12904
12905 return status;
12906}
12907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012908/*
12909 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12910 * to either start/stop logging
12911 * @hal: HAL context
12912 * @start_log: Structure containing the wifi start logger params
12913 *
12914 * This function sends the start/stop logging command to WMA
12915 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012916 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012918QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012919 struct sir_wifi_start_log start_log)
12920{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012921 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012922 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012923 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012924 struct sir_wifi_start_log *req_msg;
12925 uint32_t len;
12926
12927 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012928 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012929 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012930 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012931 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012932 }
12933
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012934 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012935 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012936 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012937 req_msg->ini_triggered = start_log.ini_triggered;
12938 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012939 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012940 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012941
12942 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012943 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012944 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012945 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012946 return status;
12947 }
12948
12949 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012950 message.bodyptr = req_msg;
12951 message.type = SIR_HAL_START_STOP_LOGGING;
12952 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012953 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012954 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012955 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012956 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012957 }
12958 sme_release_global_lock(&mac->sme);
12959
12960 return status;
12961}
12962
12963/**
12964 * sme_neighbor_middle_of_roaming() - Function to know if
12965 * STA is in the middle of roaming states
12966 * @hal: Handle returned by macOpen
12967 * @sessionId: sessionId of the STA session
12968 *
12969 * This function is a wrapper to call
12970 * csr_neighbor_middle_of_roaming to know STA is in the
12971 * middle of roaming states
12972 *
12973 * Return: True or False
12974 *
12975 */
12976bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12977{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012978 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12979 bool val = false;
12980
12981 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12982 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12983 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012984 sme_err("Invalid Session: %d", sessionId);
12985
Sandeep Puligillaca631612016-11-08 11:53:52 -080012986 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012987}
12988
12989/*
12990 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12991 * @mac: MAC handle
12992 *
12993 * This function is used to send the command that will
12994 * be used to flush the logs in the firmware
12995 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012996 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012997 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012998QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012999{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013000 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013001 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013003 /* Serialize the req through MC thread */
13004 message.bodyptr = NULL;
13005 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013006 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013007 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013008 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013009 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013011 return status;
13012}
13013
Jeff Johnsona1e92612017-09-24 15:33:44 -070013014QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013015 sme_ac_enum_type ac, uint8_t tid,
13016 uint8_t pri, uint32_t srvc_int,
13017 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053013018 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019 uint8_t psb, uint32_t sessionId,
13020 uint32_t delay_interval)
13021{
13022 void *wma_handle;
13023 t_wma_trigger_uapsd_params uapsd_params;
13024 enum uapsd_ac access_category;
13025
13026 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013027 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013028 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013029 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013030 }
13031
Anurag Chouhan6d760662016-02-20 16:05:43 +053013032 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013033 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013034 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013035 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013036 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013037 }
13038
13039 switch (ac) {
13040 case SME_AC_BK:
13041 access_category = UAPSD_BK;
13042 break;
13043 case SME_AC_BE:
13044 access_category = UAPSD_BE;
13045 break;
13046 case SME_AC_VI:
13047 access_category = UAPSD_VI;
13048 break;
13049 case SME_AC_VO:
13050 access_category = UAPSD_VO;
13051 break;
13052 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013053 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013054 }
13055
13056 uapsd_params.wmm_ac = access_category;
13057 uapsd_params.user_priority = pri;
13058 uapsd_params.service_interval = srvc_int;
13059 uapsd_params.delay_interval = delay_interval;
13060 uapsd_params.suspend_interval = sus_int;
13061
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013062 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013063 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013065 "Failed to Trigger Uapsd params for sessionId %d",
13066 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013067 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013068 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013069 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013070}
13071
Jeff Johnsona1e92612017-09-24 15:33:44 -070013072QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013073 sme_ac_enum_type ac,
13074 uint32_t sessionId)
13075{
13076 void *wma_handle;
13077 enum uapsd_ac access_category;
13078
13079 switch (ac) {
13080 case SME_AC_BK:
13081 access_category = UAPSD_BK;
13082 break;
13083 case SME_AC_BE:
13084 access_category = UAPSD_BE;
13085 break;
13086 case SME_AC_VI:
13087 access_category = UAPSD_VI;
13088 break;
13089 case SME_AC_VO:
13090 access_category = UAPSD_VO;
13091 break;
13092 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013093 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013094 }
13095
Anurag Chouhan6d760662016-02-20 16:05:43 +053013096 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013097 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013099 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013100 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013101 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013102 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013103 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013105 "Failed to disable uapsd for ac %d for sessionId %d",
13106 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013107 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013108 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013109 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013110}
13111
13112/**
13113 * sme_update_nss() - SME API to change the number for spatial streams
13114 * (1 or 2)
13115 * @hal: Handle returned by mac open
13116 * @nss: Number of spatial streams
13117 *
13118 * This function is used to update the number of spatial streams supported.
13119 *
13120 * Return: Success upon successfully changing nss else failure
13121 *
13122 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013123QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013124{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013125 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013126 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13127 uint32_t i, value = 0;
13128 union {
13129 uint16_t cfg_value16;
13130 tSirMacHTCapabilityInfo ht_cap_info;
13131 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013132 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013133
13134 status = sme_acquire_global_lock(&mac_ctx->sme);
13135
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013136 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013137 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13138
13139 /* get the HT capability info*/
13140 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13141 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13142
13143 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13144 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13145 csr_session = &mac_ctx->roam.roamSession[i];
13146 csr_session->htConfig.ht_tx_stbc =
13147 uHTCapabilityInfo.ht_cap_info.txSTBC;
13148 }
13149 }
13150
13151 sme_release_global_lock(&mac_ctx->sme);
13152 }
13153 return status;
13154}
13155
13156/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013157 * sme_update_user_configured_nss() - sets the nss based on user request
13158 * @hal: Pointer to HAL
13159 * @nss: number of streams
13160 *
13161 * Return: None
13162 */
13163void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13164{
13165 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13166
13167 mac_ctx->user_configured_nss = nss;
13168}
13169
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013170#ifdef WLAN_FEATURE_11AX
13171void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
13172 uint8_t nss)
13173{
13174 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13175 struct csr_roam_session *csr_session;
13176 uint32_t tx_mcs_map = 0;
13177 uint32_t rx_mcs_map = 0;
13178
13179 if (!nss || (nss > 2)) {
13180 sme_err("invalid Nss value %d", nss);
13181 }
13182 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13183 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
13184 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
13185 if (nss == 1) {
13186 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
13187 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
13188 } else {
13189 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_0_11, 2);
13190 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_0_11, 2);
13191 }
13192 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
13193 rx_mcs_map, tx_mcs_map);
13194 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
13195 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
13196 csr_update_session_he_cap(mac_ctx, csr_session);
13197
13198}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080013199
13200int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
13201{
13202 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13203 struct csr_roam_session *csr_session;
13204 uint16_t mcs_val = 0;
13205 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
13206 uint32_t wni_cfg_tx_param = 0;
13207 uint32_t wni_cfg_rx_param = 0;
13208
13209 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13210 if (!csr_session) {
13211 sme_err("No session for id %d", session_id);
13212 return -EINVAL;
13213 }
13214 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
13215 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
13216 he_mcs);
13217 return -EINVAL;
13218 }
13219 mcs_val = he_mcs & 0x3;
13220 switch (he_mcs) {
13221 case HE_80_MCS0_7:
13222 case HE_80_MCS0_9:
13223 case HE_80_MCS0_11:
13224 if (mac_ctx->roam.configParam.enable2x2) {
13225 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13226 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
13227 } else {
13228 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13229 }
13230 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
13231 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
13232 break;
13233
13234 case HE_160_MCS0_7:
13235 case HE_160_MCS0_9:
13236 case HE_160_MCS0_11:
13237 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13238 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
13239 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
13240 break;
13241
13242 case HE_80p80_MCS0_7:
13243 case HE_80p80_MCS0_9:
13244 case HE_80p80_MCS0_11:
13245 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13246 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
13247 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
13248 break;
13249
13250 default:
13251 sme_err("Invalid HE MCS 0x%0x", he_mcs);
13252 return -EINVAL;
13253 }
13254 sme_info("new HE MCS 0x%0x", mcs_map);
13255 sme_cfg_set_int(mac_ctx, wni_cfg_tx_param, mcs_map);
13256 sme_cfg_set_int(mac_ctx, wni_cfg_rx_param, mcs_map);
13257 csr_update_session_he_cap(mac_ctx, csr_session);
13258
13259 return 0;
13260}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013261
13262static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
13263 uint16_t he_cap, int value)
13264{
13265 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13266 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013267
13268 session = CSR_GET_SESSION(mac_ctx, session_id);
13269 if (!session) {
13270 sme_err("No session for id %d", session_id);
13271 return -EINVAL;
13272 }
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013273 sme_cfg_set_int(mac_ctx, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013274 csr_update_session_he_cap(mac_ctx, session);
13275
13276 return 0;
13277}
13278
13279int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13280{
13281 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013282 uint32_t he_cap_val = 0;
13283
13284 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013285
13286 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013287 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013288 if (ret)
13289 return ret;
13290
13291 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013292 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013293}
13294
13295int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13296{
13297 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013298 uint32_t he_cap_val = 0;
13299
13300 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013301
13302 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013303 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013304 if (ret)
13305 return ret;
13306
13307 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013308 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
13309}
13310
13311int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
13312 uint16_t he_frag)
13313{
13314 return sme_update_he_cap(hal, session_id,
13315 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013316}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013317#endif
13318
Archana Ramachandran5041b252016-04-25 14:29:25 -070013319/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013320 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13321 * @hal: global hal handle
13322 * @cb: callback function pointer
13323 *
13324 * This function stores nud debug stats callback function.
13325 *
13326 * Return: QDF_STATUS enumeration.
13327 */
13328QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13329 void (*cb)(void *, struct rsp_stats *))
13330{
13331 QDF_STATUS status = QDF_STATUS_SUCCESS;
13332 tpAniSirGlobal mac;
13333
13334 if (!hal) {
13335 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13336 FL("hal is not valid"));
13337 return QDF_STATUS_E_INVAL;
13338 }
13339 mac = PMAC_STRUCT(hal);
13340
13341 status = sme_acquire_global_lock(&mac->sme);
13342 if (!QDF_IS_STATUS_SUCCESS(status)) {
13343 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13344 FL("sme_acquire_global_lock failed!(status=%d)"),
13345 status);
13346 return status;
13347 }
13348
13349 mac->sme.get_arp_stats_cb = cb;
13350 sme_release_global_lock(&mac->sme);
13351 return status;
13352}
13353
13354/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013355 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013356 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013357 * @cb: callback function pointer
13358 *
13359 * This function stores the rssi threshold breached callback function.
13360 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013361 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013362 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013363QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013364 void (*cb)(void *, struct rssi_breach_event *))
13365{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013366 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013367 tpAniSirGlobal mac;
13368
13369 if (!h_hal) {
13370 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13371 FL("hHal is not valid"));
13372 return QDF_STATUS_E_INVAL;
13373 }
13374 mac = PMAC_STRUCT(h_hal);
13375
13376 status = sme_acquire_global_lock(&mac->sme);
13377 if (!QDF_IS_STATUS_SUCCESS(status)) {
13378 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13379 FL("sme_acquire_global_lock failed!(status=%d)"),
13380 status);
13381 return status;
13382 }
13383
13384 mac->sme.rssi_threshold_breached_cb = cb;
13385 sme_release_global_lock(&mac->sme);
13386 return status;
13387}
13388
13389/**
13390 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13391 * @hal: global hal handle
13392 *
13393 * This function de-registers the rssi threshold breached callback function.
13394 *
13395 * Return: QDF_STATUS enumeration.
13396 */
13397QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13398{
13399 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013400 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13401
13402 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013403 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013404 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013405 return status;
13406 }
13407
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013408 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013409 sme_release_global_lock(&mac->sme);
13410 return status;
13411}
13412
13413/**
13414 * sme_is_any_session_in_connected_state() - SME wrapper API to
13415 * check if any session is in connected state or not.
13416 *
13417 * @hal: Handle returned by mac open
13418 *
13419 * This function is used to check if any valid sme session is in
13420 * connected state or not.
13421 *
13422 * Return: true if any session is connected, else false.
13423 *
13424 */
13425bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13426{
13427 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013428 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429 bool ret = false;
13430
13431 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013432 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013433 ret = csr_is_any_session_in_connect_state(mac_ctx);
13434 sme_release_global_lock(&mac_ctx->sme);
13435 }
13436 return ret;
13437}
13438
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013439QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13440 void (*cb)(void *,
13441 struct chip_pwr_save_fail_detected_params *)) {
13442
13443 QDF_STATUS status = QDF_STATUS_SUCCESS;
13444 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13445
13446 status = sme_acquire_global_lock(&mac->sme);
13447 if (status != QDF_STATUS_SUCCESS) {
13448 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13449 return status;
13450 }
13451 mac->sme.chip_power_save_fail_cb = cb;
13452 sme_release_global_lock(&mac->sme);
13453 return status;
13454}
13455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013456/**
13457 * sme_set_rssi_monitoring() - set rssi monitoring
13458 * @hal: global hal handle
13459 * @input: request message
13460 *
13461 * This function constructs the vos message and fill in message type,
13462 * bodyptr with @input and posts it to WDA queue.
13463 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013464 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013465 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013466QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013467 struct rssi_monitor_req *input)
13468{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013469 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013470 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013471 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013472 struct rssi_monitor_req *req_msg;
13473
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013474 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013475 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013476 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013477 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013478 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013479 }
13480
13481 *req_msg = *input;
13482
13483 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013484 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013485 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013486 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013487 return status;
13488 }
13489
13490 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013491 message.bodyptr = req_msg;
13492 message.type = WMA_SET_RSSI_MONITOR_REQ;
13493 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013494 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013495 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013496 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013497 }
13498 sme_release_global_lock(&mac->sme);
13499
13500 return status;
13501}
13502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013503/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013504 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013505 * @hal: Handle returned by macOpen
13506 * @msg: PCL channel list and length structure
13507 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013508 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013509 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013510 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013511QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013512{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013513 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013514 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013515 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013516 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013517 uint32_t len, i;
13518
Krunal Soni3fa80e22018-01-09 14:16:02 -080013519 if (!mac) {
13520 sme_err("mac is NULL");
13521 return QDF_STATUS_E_FAILURE;
13522 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013523 len = sizeof(*req_msg);
13524
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013525 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013526 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013527 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013528 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013529 }
13530
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013531 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013532 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013533 req_msg->weight_list[i] = msg.weight_list[i];
13534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013535
13536 req_msg->pcl_len = msg.pcl_len;
13537
13538 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013539 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013540 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013541 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013542 return status;
13543 }
13544
13545 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013546 message.bodyptr = req_msg;
13547 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13548 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013549 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013550 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013551 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013552 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013553 }
13554 sme_release_global_lock(&mac->sme);
13555
13556 return status;
13557}
13558
13559/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013560 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013561 * @hal: Handle returned by macOpen
13562 * @msg: HW mode structure containing hw mode and callback details
13563 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013564 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013565 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013566 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013567QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013568{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013569 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013570 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013571 tSmeCmd *cmd = NULL;
13572
Krunal Soni3fa80e22018-01-09 14:16:02 -080013573 if (!mac) {
13574 sme_err("mac is NULL");
13575 return QDF_STATUS_E_FAILURE;
13576 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013577 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013578 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013579 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013580 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013581 }
13582
Krunal Soni78618d92017-02-14 21:46:31 -080013583 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013584 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013585 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013586 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013587 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013588 }
13589
13590 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013591 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013592 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13593 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013594 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13595 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013596 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013597 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013598
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013599 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013600 cmd->u.set_hw_mode_cmd.session_id,
13601 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013602 csr_queue_sme_command(mac, cmd, false);
13603
13604 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013605 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013606}
13607
13608/**
13609 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13610 * @hal: Handle returned by macOpen
13611 * @callback: HDD callback to be registered
13612 *
13613 * Registers the HDD callback with SME. This callback will be invoked when
13614 * HW mode transition event is received from the FW
13615 *
13616 * Return: None
13617 */
13618void sme_register_hw_mode_trans_cb(tHalHandle hal,
13619 hw_mode_transition_cb callback)
13620{
13621 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13622
13623 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013624}
13625
13626/**
13627 * sme_nss_update_request() - Send beacon templete update to FW with new
13628 * nss value
13629 * @hal: Handle returned by macOpen
13630 * @vdev_id: the session id
13631 * @new_nss: the new nss value
13632 * @cback: hdd callback
13633 * @next_action: next action to happen at policy mgr after beacon update
13634 *
13635 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013636 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013637 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013638QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13639 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13640 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13641 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013642{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013643 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013644 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013645 tSmeCmd *cmd = NULL;
13646
Krunal Soni3fa80e22018-01-09 14:16:02 -080013647 if (!mac) {
13648 sme_err("mac is null");
13649 return status;
13650 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013651 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013652 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013653 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013654 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013655 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013656 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013657 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013658 }
13659 cmd->command = e_sme_command_nss_update;
13660 /* Sessionized modules may require this info */
13661 cmd->sessionId = vdev_id;
13662 cmd->u.nss_update_cmd.new_nss = new_nss;
13663 cmd->u.nss_update_cmd.session_id = vdev_id;
13664 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013665 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013666 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013667 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013668
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013669 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013670 csr_queue_sme_command(mac, cmd, false);
13671 sme_release_global_lock(&mac->sme);
13672 }
13673 return status;
13674}
13675
13676/**
13677 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13678 * @hal: Handle returned by macOpen
13679 * @msg: Structure containing the dual mac config parameters
13680 *
13681 * Queues configuration information to CSR to configure
13682 * WLAN firmware for the dual MAC features
13683 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013684 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013685 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013686QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013687{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013688 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013689 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013690 tSmeCmd *cmd;
13691
Krunal Soni3fa80e22018-01-09 14:16:02 -080013692 if (!mac) {
13693 sme_err("mac is null");
13694 return QDF_STATUS_E_FAILURE;
13695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013696 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013697 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013698 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013699 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013700 }
13701
Krunal Soni78618d92017-02-14 21:46:31 -080013702 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013703 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013704 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013705 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013706 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013707 }
13708
13709 cmd->command = e_sme_command_set_dual_mac_config;
13710 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13711 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13712 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13713
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013714 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013715 cmd->u.set_dual_mac_cmd.scan_config,
13716 cmd->u.set_dual_mac_cmd.fw_mode_config);
13717 csr_queue_sme_command(mac, cmd, false);
13718
13719 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013720 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013721}
13722
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013723#ifdef FEATURE_LFR_SUBNET_DETECTION
13724/**
13725 * sme_gateway_param_update() - to update gateway parameters with WMA
13726 * @Hal: hal handle
13727 * @gw_params: request parameters from HDD
13728 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013729 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013730 *
13731 * This routine will update gateway parameters to WMA
13732 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013733QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013734 struct gateway_param_update_req *gw_params)
13735{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013736 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013737 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013738 struct gateway_param_update_req *request_buf;
13739
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013740 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013741 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013743 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013744 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013745 }
13746
13747 *request_buf = *gw_params;
13748
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013749 message.type = WMA_GW_PARAM_UPDATE_REQ;
13750 message.reserved = 0;
13751 message.bodyptr = request_buf;
13752 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013753 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013755 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013756 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013757 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013758 }
13759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013760 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013761}
13762#endif /* FEATURE_LFR_SUBNET_DETECTION */
13763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013764/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013765 * sme_soc_set_antenna_mode() - set antenna mode
13766 * @hal: Handle returned by macOpen
13767 * @msg: Structure containing the antenna mode parameters
13768 *
13769 * Send the command to CSR to send
13770 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13771 *
13772 * Return: QDF_STATUS
13773 */
13774QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13775 struct sir_antenna_mode_param *msg)
13776{
13777 QDF_STATUS status = QDF_STATUS_SUCCESS;
13778 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13779 tSmeCmd *cmd;
13780
13781 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013782 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013783 return QDF_STATUS_E_FAILURE;
13784 }
13785
13786 status = sme_acquire_global_lock(&mac->sme);
13787 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013788 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013789 return QDF_STATUS_E_RESOURCES;
13790 }
13791
Krunal Soni78618d92017-02-14 21:46:31 -080013792 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013793 if (!cmd) {
13794 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013795 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013796 return QDF_STATUS_E_NULL_VALUE;
13797 }
13798
13799 cmd->command = e_sme_command_set_antenna_mode;
13800 cmd->u.set_antenna_mode_cmd = *msg;
13801
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013802 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013803 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13804 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13805
13806 csr_queue_sme_command(mac, cmd, false);
13807 sme_release_global_lock(&mac->sme);
13808
13809 return QDF_STATUS_SUCCESS;
13810}
13811
13812/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013813 * sme_set_peer_authorized() - call peer authorized callback
13814 * @peer_addr: peer mac address
13815 * @auth_cb: auth callback
13816 * @vdev_id: vdev id
13817 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013818 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013819 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013820QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013821 sme_peer_authorized_fp auth_cb,
13822 uint32_t vdev_id)
13823{
13824 void *wma_handle;
13825
Anurag Chouhan6d760662016-02-20 16:05:43 +053013826 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013827 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013828 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013829 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013830 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013831 }
13832
13833 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13834 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13835 1, vdev_id);
13836}
13837
13838/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013839 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013840 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013841 * @fcc_constraint: flag to enable/disable the constraint
13842 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013843 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013844 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013845 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013846QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13847 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013848{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013849 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013850 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13851
13852 status = sme_acquire_global_lock(&mac_ptr->sme);
13853
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013854 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013855
13856 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13857 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013858 if (scan_pending)
13859 mac_ptr->scan.defer_update_channel_list = true;
13860 else
13861 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013862 }
13863
13864 sme_release_global_lock(&mac_ptr->sme);
13865 }
13866
13867 return status;
13868}
13869/**
13870 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13871 * @hal: Global MAC pointer
13872 *
13873 * Return: NULL.
13874 */
13875void sme_setdef_dot11mode(tHalHandle hal)
13876{
13877 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013879 csr_set_default_dot11_mode(mac_ctx);
13880}
13881
13882/**
13883 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13884 * params
13885 * @hal_handle - The handle returned by macOpen.
13886 * @session_id - Session Identifier
13887 * @notify_id - Identifies 1 of the 4 parameters to be modified
13888 * @val New value of the parameter
13889 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013890 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013891 * Other status means SME failed to update
13892 */
13893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013894QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013895 uint8_t session_id,
13896 uint32_t notify_id,
13897 int32_t val)
13898{
13899 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013900 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013901 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013902 tpCsrNeighborRoamControlInfo nr_info = NULL;
13903 uint32_t reason = 0;
13904
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013905 if (session_id >= CSR_ROAM_SESSION_MAX) {
13906 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13907 FL("Invalid sme session id: %d"), session_id);
13908 return QDF_STATUS_E_INVAL;
13909 }
13910
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013911 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013912 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013913 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13914 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13915 switch (notify_id) {
13916 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013918 "%s: gRoamScanHirssiMaxCount %d => %d",
13919 __func__, nr_config->nhi_rssi_scan_max_count,
13920 val);
13921 nr_config->nhi_rssi_scan_max_count = val;
13922 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13923 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13924 break;
13925
13926 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013927 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013928 FL("gRoamScanHiRssiDelta %d => %d"),
13929 nr_config->nhi_rssi_scan_rssi_delta,
13930 val);
13931 nr_config->nhi_rssi_scan_rssi_delta = val;
13932 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13933 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13934 break;
13935
13936 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013938 FL("gRoamScanHiRssiDelay %d => %d"),
13939 nr_config->nhi_rssi_scan_delay,
13940 val);
13941 nr_config->nhi_rssi_scan_delay = val;
13942 nr_info->cfgParams.hi_rssi_scan_delay = val;
13943 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13944 break;
13945
13946 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013948 FL("gRoamScanHiRssiUpperBound %d => %d"),
13949 nr_config->nhi_rssi_scan_rssi_ub,
13950 val);
13951 nr_config->nhi_rssi_scan_rssi_ub = val;
13952 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13953 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13954 break;
13955
13956 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013957 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013958 FL("invalid parameter notify_id %d"),
13959 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013960 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013961 break;
13962 }
13963 sme_release_global_lock(&mac_ctx->sme);
13964 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013965 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013966 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013967 csr_roam_offload_scan(mac_ctx, session_id,
13968 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13969 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013970
13971 return status;
13972}
13973
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013974/**
13975 * sme_update_tgt_services() - update the target services config.
13976 * @hal: HAL pointer.
13977 * @cfg: wma_tgt_services parameters.
13978 *
13979 * update the target services config.
13980 *
13981 * Return: None.
13982 */
13983void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13984{
13985 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13986
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013987 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013988 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013989 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013990 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013991 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013992 mac_ctx->is_fils_roaming_supported =
13993 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013994 mac_ctx->is_11k_offload_supported =
13995 cfg->is_11k_offload_supported;
13996 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13997 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13998 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013999}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014000
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014001/**
14002 * sme_is_session_id_valid() - Check if the session id is valid
14003 * @hal: Pointer to HAL
14004 * @session_id: Session id
14005 *
14006 * Checks if the session id is valid or not
14007 *
14008 * Return: True is the session id is valid, false otherwise
14009 */
14010bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
14011{
14012 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014013
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014014 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053014015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14016 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014017 return false;
14018 }
14019
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014020 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014021 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014022
14023 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014024}
14025
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014026#ifdef FEATURE_WLAN_TDLS
14027
14028/**
14029 * sme_get_opclass() - determine operating class
14030 * @hal: Pointer to HAL
14031 * @channel: channel id
14032 * @bw_offset: bandwidth offset
14033 * @opclass: pointer to operating class
14034 *
14035 * Function will determine operating class from regdm_get_opclass_from_channel
14036 *
14037 * Return: none
14038 */
14039void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
14040 uint8_t *opclass)
14041{
14042 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14043
14044 /* redgm opclass table contains opclass for 40MHz low primary,
14045 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
14046 * first we will check if bit for 40MHz is set and if so find
14047 * matching opclass either with low primary or high primary
14048 * (a channel would never be in both) and then search for opclass
14049 * matching 20MHz, else for any BW.
14050 */
14051 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014052 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014053 mac_ctx->scan.countryCodeCurrent,
14054 channel, BW40_LOW_PRIMARY);
14055 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014056 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014057 mac_ctx->scan.countryCodeCurrent,
14058 channel, BW40_HIGH_PRIMARY);
14059 }
14060 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014061 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014062 mac_ctx->scan.countryCodeCurrent,
14063 channel, BW20);
14064 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014065 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014066 mac_ctx->scan.countryCodeCurrent,
14067 channel, BWALL);
14068 }
14069}
14070#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014071
Sandeep Puligillae0875662016-02-12 16:09:21 -080014072/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053014073 * sme_set_fw_test() - set fw test
14074 * @fw_test: fw test param
14075 *
14076 * Return: Return QDF_STATUS, otherwise appropriate failure code
14077 */
14078QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
14079{
14080 void *wma_handle;
14081
14082 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14083 if (!wma_handle) {
14084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14085 "wma handle is NULL");
14086 return QDF_STATUS_E_FAILURE;
14087 }
14088 wma_process_fw_test_cmd(wma_handle, fw_test);
14089 return QDF_STATUS_SUCCESS;
14090}
14091
14092/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080014093 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
14094 * @hal: mac handel
14095 * @vdev_id: vdev identifier
14096 *
14097 * Return: Return QDF_STATUS, otherwise appropriate failure code
14098 */
14099QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
14100{
14101 void *wma_handle;
14102
14103 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14104 if (!wma_handle) {
14105 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14106 "wma handle is NULL");
14107 return QDF_STATUS_E_FAILURE;
14108 }
14109 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
14110 return QDF_STATUS_SUCCESS;
14111}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014112
14113/**
14114 * sme_update_mimo_power_save() - Update MIMO power save
14115 * configuration
14116 * @hal: The handle returned by macOpen
14117 * @is_ht_smps_enabled: enable/disable ht smps
14118 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080014119 * @send_smps_action: flag to send smps force mode command
14120 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014121 *
14122 * Return: QDF_STATUS if SME update mimo power save
14123 * configuration sucsess else failue status
14124 */
14125QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
14126 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080014127 uint8_t ht_smps_mode,
14128 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014129{
14130 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080014131
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014132 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080014133 is_ht_smps_enabled, ht_smps_mode,
14134 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014135 mac_ctx->roam.configParam.enableHtSmps =
14136 is_ht_smps_enabled;
14137 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080014138 mac_ctx->roam.configParam.send_smps_action =
14139 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014140
14141 return QDF_STATUS_SUCCESS;
14142}
14143
14144/**
14145 * sme_is_sta_smps_allowed() - check if the supported nss for
14146 * the session is greater than 1x1 to enable sta SMPS
14147 * @hal: The handle returned by macOpen
14148 * @session_id: session id
14149 *
14150 * Return: bool returns true if supported nss is greater than
14151 * 1x1 else false
14152 */
14153bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
14154{
14155 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014156 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014157
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014158 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
14159 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014160 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053014161 return false;
14162 }
14163
14164 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014165 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014166 return false;
14167 }
14168
14169 return (csr_session->supported_nss_1x1 == true) ? false : true;
14170}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014171
14172/**
14173 * sme_add_beacon_filter() - set the beacon filter configuration
14174 * @hal: The handle returned by macOpen
14175 * @session_id: session id
14176 * @ie_map: bitwise array of IEs
14177 *
14178 * Return: Return QDF_STATUS, otherwise appropriate failure code
14179 */
14180QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
14181 uint32_t session_id,
14182 uint32_t *ie_map)
14183{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014184 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014185 QDF_STATUS qdf_status;
14186 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14187 struct beacon_filter_param *filter_param;
14188
14189 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014190 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014191 return QDF_STATUS_E_FAILURE;
14192 }
14193
14194 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14195 if (NULL == filter_param) {
14196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14197 "%s: fail to alloc filter_param", __func__);
14198 return QDF_STATUS_E_FAILURE;
14199 }
14200
14201 filter_param->vdev_id = session_id;
14202
14203 qdf_mem_copy(filter_param->ie_map, ie_map,
14204 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14205
14206 message.type = WMA_ADD_BCN_FILTER_CMDID;
14207 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014208 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014209 &message);
14210 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14211 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14212 "%s: Not able to post msg to WDA!",
14213 __func__);
14214
14215 qdf_mem_free(filter_param);
14216 }
14217 return qdf_status;
14218}
14219
14220/**
14221 * sme_remove_beacon_filter() - set the beacon filter configuration
14222 * @hal: The handle returned by macOpen
14223 * @session_id: session id
14224 *
14225 * Return: Return QDF_STATUS, otherwise appropriate failure code
14226 */
14227QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14228{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014229 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014230 QDF_STATUS qdf_status;
14231 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14232 struct beacon_filter_param *filter_param;
14233
14234 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014235 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014236 return QDF_STATUS_E_FAILURE;
14237 }
14238
14239 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14240 if (NULL == filter_param) {
14241 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14242 "%s: fail to alloc filter_param", __func__);
14243 return QDF_STATUS_E_FAILURE;
14244 }
14245
14246 filter_param->vdev_id = session_id;
14247
14248 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14249 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014250 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014251 &message);
14252 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14253 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14254 "%s: Not able to post msg to WDA!",
14255 __func__);
14256
14257 qdf_mem_free(filter_param);
14258 }
14259 return qdf_status;
14260}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014261
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014262/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014263 * sme_send_disassoc_req_frame - send disassoc req
14264 * @hal: handler to hal
14265 * @session_id: session id
14266 * @peer_mac: peer mac address
14267 * @reason: reason for disassociation
14268 * wait_for_ack: wait for acknowledgment
14269 *
14270 * function to send disassoc request to lim
14271 *
14272 * return: none
14273 */
14274void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14275 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14276{
14277 struct sme_send_disassoc_frm_req *msg;
14278 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14279 A_UINT8 *buf;
14280 A_UINT16 tmp;
14281
14282 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14283
14284 if (NULL == msg)
14285 qdf_status = QDF_STATUS_E_FAILURE;
14286 else
14287 qdf_status = QDF_STATUS_SUCCESS;
14288
14289 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14290 return;
14291
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014292 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14293
14294 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14295
14296 buf = &msg->session_id;
14297
14298 /* session id */
14299 *buf = (A_UINT8) session_id;
14300 buf += sizeof(A_UINT8);
14301
14302 /* transaction id */
14303 *buf = 0;
14304 *(buf + 1) = 0;
14305 buf += sizeof(A_UINT16);
14306
14307 /* Set the peer MAC address before sending the message to LIM */
14308 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14309
14310 buf += QDF_MAC_ADDR_SIZE;
14311
14312 /* reasoncode */
14313 tmp = (uint16_t) reason;
14314 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14315 buf += sizeof(uint16_t);
14316
14317 *buf = wait_for_ack;
14318 buf += sizeof(uint8_t);
14319
Rajeev Kumard138ac52017-01-30 18:38:37 -080014320 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014321
14322 if (qdf_status != QDF_STATUS_SUCCESS)
14323 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14324 FL("cds_send_mb_message Failed"));
14325}
14326
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014327QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14328 bpf_get_offload_cb callback,
14329 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014330{
14331 QDF_STATUS status = QDF_STATUS_SUCCESS;
14332 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014333 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014334
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014335 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014336
14337 status = sme_acquire_global_lock(&mac_ctx->sme);
14338 if (QDF_STATUS_SUCCESS == status) {
14339 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014340 mac_ctx->sme.bpf_get_offload_cb = callback;
14341 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014342 cds_msg.bodyptr = NULL;
14343 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014344 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014345 if (!QDF_IS_STATUS_SUCCESS(status)) {
14346 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14347 FL("Post bpf get offload msg fail"));
14348 status = QDF_STATUS_E_FAILURE;
14349 }
14350 sme_release_global_lock(&mac_ctx->sme);
14351 } else {
14352 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14353 FL("sme_acquire_global_lock error"));
14354 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014355 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014356 return status;
14357}
14358
14359
14360/**
14361 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14362 * @hal: HAL handle
14363 * @bpf_set_offload: struct to set bpf filter instructions.
14364 *
14365 * Return: QDF_STATUS enumeration.
14366 */
14367QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14368 struct sir_bpf_set_offload *req)
14369{
14370 QDF_STATUS status = QDF_STATUS_SUCCESS;
14371 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014372 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014373 struct sir_bpf_set_offload *set_offload;
14374
Arun Khandavallica198b52016-04-26 20:53:35 +053014375 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14376 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014377
14378 if (NULL == set_offload) {
14379 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14380 FL("Failed to alloc set_offload"));
14381 return QDF_STATUS_E_NOMEM;
14382 }
14383
14384 set_offload->session_id = req->session_id;
14385 set_offload->filter_id = req->filter_id;
14386 set_offload->current_offset = req->current_offset;
14387 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014388 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014389 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014390 set_offload->program = ((uint8_t *)set_offload) +
14391 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014392 qdf_mem_copy(set_offload->program, req->program,
14393 set_offload->current_length);
14394 }
14395 status = sme_acquire_global_lock(&mac_ctx->sme);
14396 if (QDF_STATUS_SUCCESS == status) {
14397 /* Serialize the req through MC thread */
14398 cds_msg.bodyptr = set_offload;
14399 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014400 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014401
14402 if (!QDF_IS_STATUS_SUCCESS(status)) {
14403 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14404 FL("Post BPF set offload msg fail"));
14405 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014406 qdf_mem_free(set_offload);
14407 }
14408 sme_release_global_lock(&mac_ctx->sme);
14409 } else {
14410 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14411 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014412 qdf_mem_free(set_offload);
14413 }
14414 return status;
14415}
14416
14417/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014418 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14419 * @hal: hal pointer
14420 *
14421 * Return: wni dot11 mode.
14422 */
14423uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14424{
14425 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14426
14427 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14428 mac_ctx->roam.configParam.uCfgDot11Mode);
14429}
14430
14431/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014432 * sme_create_mon_session() - post message to create PE session for monitormode
14433 * operation
14434 * @hal_handle: Handle to the HAL
14435 * @bssid: pointer to bssid
14436 *
14437 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14438 */
14439QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14440{
14441 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14442 struct sir_create_session *msg;
14443
14444 msg = qdf_mem_malloc(sizeof(*msg));
14445 if (NULL != msg) {
14446 msg->type = eWNI_SME_MON_INIT_SESSION;
14447 msg->msg_len = sizeof(*msg);
14448 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014449 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014450 }
14451 return status;
14452}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014453
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014454void sme_set_chan_info_callback(tHalHandle hal_handle,
14455 void (*callback)(struct scan_chan_info *chan_info))
14456{
14457 tpAniSirGlobal mac;
14458
14459 if (hal_handle == NULL) {
14460 QDF_ASSERT(0);
14461 return;
14462 }
14463 mac = PMAC_STRUCT(hal_handle);
14464 mac->chan_info_cb = callback;
14465}
14466
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014467/**
14468 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14469 * @hal: The handle returned by macOpen
14470 * @params: adaptive_dwelltime_params config
14471 *
14472 * Return: QDF_STATUS if adaptive dwell time update
14473 * configuration sucsess else failure status
14474 */
14475QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14476 struct adaptive_dwelltime_params *params)
14477{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014478 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014479 QDF_STATUS status;
14480 struct adaptive_dwelltime_params *dwelltime_params;
14481
14482 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14483 if (NULL == dwelltime_params) {
14484 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14485 "%s: fail to alloc dwelltime_params", __func__);
14486 return QDF_STATUS_E_NOMEM;
14487 }
14488
14489 dwelltime_params->is_enabled = params->is_enabled;
14490 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14491 dwelltime_params->lpf_weight = params->lpf_weight;
14492 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14493 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14494
14495 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14496 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014497 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014498 if (!QDF_IS_STATUS_SUCCESS(status)) {
14499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14500 "%s: Not able to post msg to WMA!", __func__);
14501
14502 qdf_mem_free(dwelltime_params);
14503 }
14504 return status;
14505}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014506
14507/**
14508 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14509 * @hal: Pointer to HAL
14510 * @vdev_id: vdev_id for which IE is targeted
14511 *
14512 * Return: None
14513 */
14514void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14515{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014516 struct sir_set_vdev_ies_per_band *p_msg;
14517 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14518
14519 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14520 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014521 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014522 return;
14523 }
14524
14525 p_msg->vdev_id = vdev_id;
14526 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14527 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014528 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014529 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014530 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014531 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014532 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014533}
14534
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014535/**
14536 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14537 * @hal: Pointer to HAL
14538 * @enable2x2: 1x1 or 2x2 mode.
14539 *
14540 * Sends the set pdev IE req with Nss value.
14541 *
14542 * Return: None
14543 */
14544void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14545{
14546 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14547 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14548 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14549
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014550 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14551 eCSR_CFG_DOT11_MODE_AUTO) ||
14552 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14553 eCSR_CFG_DOT11_MODE_11N) ||
14554 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14555 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14556 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14557 eCSR_CFG_DOT11_MODE_11AC) ||
14558 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14559 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14560 return;
14561
14562 status = sme_acquire_global_lock(&mac_ctx->sme);
14563 if (QDF_STATUS_SUCCESS == status) {
14564 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14565 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014566 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014567 sme_release_global_lock(&mac_ctx->sme);
14568 return;
14569 }
14570
14571 ht_vht_cfg->pdev_id = 0;
14572 if (enable2x2)
14573 ht_vht_cfg->nss = 2;
14574 else
14575 ht_vht_cfg->nss = 1;
14576 ht_vht_cfg->dot11mode =
14577 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14578 mac_ctx->roam.configParam.uCfgDot11Mode);
14579
14580 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14581 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014582 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14583 ht_vht_cfg->nss,
14584 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014585 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014586 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014587 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014588
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014589 sme_release_global_lock(&mac_ctx->sme);
14590 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014591}
14592
14593/**
14594 * sme_update_vdev_type_nss() - sets the nss per vdev type
14595 * @hal: Pointer to HAL
14596 * @max_supp_nss: max_supported Nss
14597 * @band: 5G or 2.4G band
14598 *
14599 * Sets the per band Nss for each vdev type based on INI and configured
14600 * chain mask value.
14601 *
14602 * Return: None
14603 */
14604void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014605 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014606{
14607 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14608 struct vdev_type_nss *vdev_nss;
14609
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014610 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014611 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14612 else
14613 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14614
14615 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14616 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14617 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14618 CFG_P2P_GO_NSS(vdev_type_nss));
14619 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14620 CFG_P2P_CLI_NSS(vdev_type_nss));
14621 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14622 CFG_P2P_DEV_NSS(vdev_type_nss));
14623 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14624 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14625 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14626
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014627 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 -070014628 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14629 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14630 vdev_nss->tdls, vdev_nss->ocb);
14631}
Peng Xu8fdaa492016-06-22 10:20:47 -070014632
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014633#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14634#define MAX_BSS_COLOR_VAL 63
14635#define MIN_BSS_COLOR_VAL 1
14636
14637QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14638 uint8_t bss_color)
14639
14640{
14641 struct sir_set_he_bss_color *bss_color_msg;
14642 uint8_t len;
14643
14644 if (!hal) {
14645 sme_err("Invalid hal pointer");
14646 return QDF_STATUS_E_FAULT;
14647 }
14648
14649 sme_debug("Set HE bss_color %d", bss_color);
14650
14651 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14652 sme_debug("Invalid HE bss_color %d", bss_color);
14653 return QDF_STATUS_E_INVAL;
14654 }
14655 len = sizeof(*bss_color_msg);
14656 bss_color_msg = qdf_mem_malloc(len);
14657 if (!bss_color_msg) {
14658 sme_err("mem alloc failed");
14659 return QDF_STATUS_E_NOMEM;
14660 }
14661 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14662 bss_color_msg->length = len;
14663 bss_color_msg->session_id = session_id;
14664 bss_color_msg->bss_color = bss_color;
14665 return umac_send_mb_message_to_mac(bss_color_msg);
14666}
14667#endif
14668
Peng Xu8fdaa492016-06-22 10:20:47 -070014669/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014670 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14671 * @hal: Pointer to HAL
14672 * @hw_dbs_capable: HW DBS capability
14673 *
14674 * Sets HW DBS capability based on INI and fw capability.
14675 *
14676 * Return: None
14677 */
14678void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14679{
14680 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014681
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014682 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14683}
14684
14685/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014686 * sme_register_p2p_lo_event() - Register for the p2p lo event
14687 * @hHal: reference to the HAL
14688 * @context: the context of the call
14689 * @callback: the callback to hdd
14690 *
14691 * This function registers the callback function for P2P listen
14692 * offload stop event.
14693 *
14694 * Return: none
14695 */
14696void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14697 p2p_lo_callback callback)
14698{
14699 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14700 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14701
14702 status = sme_acquire_global_lock(&pMac->sme);
14703 pMac->sme.p2p_lo_event_callback = callback;
14704 pMac->sme.p2p_lo_event_context = context;
14705 sme_release_global_lock(&pMac->sme);
14706}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014707
14708/**
14709 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14710 * @hal: The handle returned by macOpen
14711 * @session_id: session id
14712 * @dbg_args: args for mac pwr debug command
14713 * Return: Return QDF_STATUS, otherwise appropriate failure code
14714 */
14715QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14716 struct sir_mac_pwr_dbg_cmd*
14717 dbg_args)
14718{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014719 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014720 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14721 struct sir_mac_pwr_dbg_cmd *req;
14722 int i;
14723
14724 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014725 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014726 return QDF_STATUS_E_FAILURE;
14727 }
14728
14729 req = qdf_mem_malloc(sizeof(*req));
14730 if (NULL == req) {
14731 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14732 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14733 return QDF_STATUS_E_FAILURE;
14734 }
14735 req->module_id = dbg_args->module_id;
14736 req->pdev_id = dbg_args->pdev_id;
14737 req->num_args = dbg_args->num_args;
14738 for (i = 0; i < req->num_args; i++)
14739 req->args[i] = dbg_args->args[i];
14740
14741 message.type = SIR_HAL_POWER_DBG_CMD;
14742 message.bodyptr = req;
14743
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014744 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014745 (QDF_MODULE_ID_WMA, &message))) {
14746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14747 "%s: Not able to post msg to WDA!",
14748 __func__);
14749 qdf_mem_free(req);
14750 }
14751 return QDF_STATUS_SUCCESS;
14752}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014753/**
14754 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014755 * @dev_mode: connection type.
14756 * @nss2g: Pointer to the 2G Nss parameter.
14757 * @nss5g: Pointer to the 5G Nss parameter.
14758 *
14759 * Fills the 2G and 5G Nss values based on connection type.
14760 *
14761 * Return: None
14762 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014763void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14764 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014765{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014766 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14767
14768 if (NULL == mac_ctx) {
14769 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14770 FL("Invalid MAC context"));
14771 return;
14772 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014773 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14774}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014775
14776/**
14777 * sme_update_sta_roam_policy() - update sta roam policy for
14778 * unsafe and DFS channels.
14779 * @hal_handle: hal handle for getting global mac struct
14780 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14781 * skipped or not
14782 * @skip_unsafe_channels: Param to tell if driver needs to
14783 * skip unsafe channels or not.
14784 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014785 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014786 *
14787 * sme_update_sta_roam_policy update sta rome policies to csr
14788 * this function will call csrUpdateChannelList as well
14789 * to include/exclude DFS channels and unsafe channels.
14790 *
14791 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14792 */
14793QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14794 enum sta_roam_policy_dfs_mode dfs_mode,
14795 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014796 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014797{
14798 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14799 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014800 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014801
14802 if (!mac_ctx) {
14803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14804 "%s: mac_ctx is null", __func__);
14805 return QDF_STATUS_E_FAILURE;
14806 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014807
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014808 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14809 if (!sme_config) {
14810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14811 FL("failed to allocate memory for sme_config"));
14812 return QDF_STATUS_E_FAILURE;
14813 }
14814 qdf_mem_zero(sme_config, sizeof(*sme_config));
14815 sme_get_config_param(hal_handle, sme_config);
14816
14817 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014818 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014819 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014820 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014821 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014822 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014823
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014824 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014825
14826 status = csr_update_channel_list(mac_ctx);
14827 if (QDF_STATUS_SUCCESS != status) {
14828 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14829 FL("failed to update the supported channel list"));
14830 }
14831 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14832 csr_roam_offload_scan(mac_ctx, session_id,
14833 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14834 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014835
14836 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014837 return status;
14838}
14839
14840/**
14841 * sme_enable_disable_chanavoidind_event - configure ca event ind
14842 * @hal: handler to hal
14843 * @set_value: enable/disable
14844 *
14845 * function to enable/disable chan avoidance indication
14846 *
14847 * Return: QDF_STATUS
14848 */
14849QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14850 uint8_t set_value)
14851{
14852 QDF_STATUS status;
14853 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014854 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014855
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014856 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014857 status = sme_acquire_global_lock(&mac_ctx->sme);
14858 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014859 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014860 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14861 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014862 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014863 sme_release_global_lock(&mac_ctx->sme);
14864 return status;
14865 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014866 return status;
14867}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014868
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014869/*
14870 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14871 * @hal: reference to the HAL
14872 * @session_id: current session ID
14873 * @ie_data: Pointer to Scan IE data
14874 * @ie_len: Length of @ie_data
14875 *
14876 * Return: QDF_STATUS
14877 */
14878QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14879 uint8_t *ie_data, uint16_t ie_len)
14880{
14881 QDF_STATUS status;
14882 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14883 struct hdd_default_scan_ie *set_ie_params;
14884
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014885 if (!ie_data)
14886 return QDF_STATUS_E_INVAL;
14887
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014888 status = sme_acquire_global_lock(&mac_ctx->sme);
14889 if (QDF_IS_STATUS_SUCCESS(status)) {
14890 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14891 if (!set_ie_params)
14892 status = QDF_STATUS_E_NOMEM;
14893 else {
14894 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14895 set_ie_params->length = sizeof(*set_ie_params);
14896 set_ie_params->session_id = session_id;
14897 set_ie_params->ie_len = ie_len;
14898 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014899 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014900 }
14901 sme_release_global_lock(&mac_ctx->sme);
14902 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014903 return status;
14904}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014905
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014906QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14907 wma_sar_cb callback, void *context)
14908{
14909 void *wma_handle;
14910
14911 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14912 if (!wma_handle) {
14913 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14914 "wma handle is NULL");
14915 return QDF_STATUS_E_FAILURE;
14916 }
14917
14918 return wma_get_sar_limit(wma_handle, callback, context);
14919}
14920
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014921QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14922 struct sar_limit_cmd_params *sar_limit_cmd)
14923{
14924 void *wma_handle;
14925
14926 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14927 if (!wma_handle) {
14928 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14929 "wma handle is NULL");
14930 return QDF_STATUS_E_FAILURE;
14931 }
14932
14933 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14934}
14935
Jeff Johnson6136fb92017-03-30 15:21:49 -070014936#ifdef WLAN_FEATURE_FIPS
14937QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14938 wma_fips_cb callback, void *context)
14939{
14940 void *wma_handle;
14941
14942 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14943 if (!wma_handle) {
14944 sme_err("wma handle is NULL");
14945 return QDF_STATUS_E_FAILURE;
14946 }
14947
14948 return wma_fips_request(wma_handle, param, callback, context);
14949}
14950#endif
14951
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014952QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14953{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014954 void *wma_handle;
14955
14956 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14957 if (!wma_handle) {
14958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14959 "wma_handle is NULL");
14960 return QDF_STATUS_E_FAILURE;
14961 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014962 if (QDF_STATUS_SUCCESS !=
14963 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14964 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14965 "%s: Failed to set cts2self for p2p GO to firmware",
14966 __func__);
14967 return QDF_STATUS_E_FAILURE;
14968 }
14969 return QDF_STATUS_SUCCESS;
14970}
Yingying Tang95409972016-10-20 15:16:15 +080014971
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014972/**
14973 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14974 * @hal: Handle returned by mac_open
14975 * @session_id: Session ID on which tx fail count needs to be updated to FW
14976 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14977 *
14978 * This function is used to set tx fail count threshold to firmware.
14979 * firmware will issue disocnnect with peer device once this threshold is
14980 * reached.
14981 *
14982 * Return: Return QDF_STATUS, otherwise appropriate failure code
14983 */
14984QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14985 uint8_t session_id, uint32_t tx_fail_count)
14986{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014987 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14988 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014989 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014990
14991 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14992 if (NULL == tx_fail_cnt) {
14993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14994 "%s: fail to alloc filter_param", __func__);
14995 return QDF_STATUS_E_FAILURE;
14996 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014997 sme_debug("session_id: %d tx_fail_count: %d",
14998 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014999 tx_fail_cnt->session_id = session_id;
15000 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
15001
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015002 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015003 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
15004 msg.reserved = 0;
15005 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015006 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015007
15008 if (!QDF_IS_STATUS_SUCCESS(status)) {
15009 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015010 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015011 qdf_mem_free(tx_fail_cnt);
15012 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015013 return status;
15014}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015015
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015016QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
15017 void (*cb)(void *, struct sir_lost_link_info *))
15018{
15019 QDF_STATUS status = QDF_STATUS_SUCCESS;
15020 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15021
15022 status = sme_acquire_global_lock(&mac->sme);
15023 if (QDF_IS_STATUS_SUCCESS(status)) {
15024 mac->sme.lost_link_info_cb = cb;
15025 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015026 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015027 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015028 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015029
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015030 return status;
15031}
Yingying Tang95409972016-10-20 15:16:15 +080015032
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015033#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080015034bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015035{
15036 return roam_info->isESEAssoc;
15037}
Manjeet Singh2f785062017-03-08 18:14:18 +053015038#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053015039/**
Manjeet Singh2f785062017-03-08 18:14:18 +053015040 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053015041 * params from ini.
15042 * @hal_handle: Handle returned by mac_open
15043 * @5g_pref_params: pref params from ini.
15044 *
15045 * Returns: None
15046 */
15047void sme_set_5g_band_pref(tHalHandle hal_handle,
15048 struct sme_5g_band_pref_params *pref_params)
15049{
15050
15051 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
15052 struct roam_ext_params *roam_params;
15053 QDF_STATUS status = QDF_STATUS_SUCCESS;
15054
15055 if (!pref_params) {
15056 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15057 "Invalid 5G pref params!");
15058 return;
15059 }
15060 status = sme_acquire_global_lock(&mac_ctx->sme);
15061 if (QDF_STATUS_SUCCESS == status) {
15062 roam_params = &mac_ctx->roam.configParam.roam_params;
15063 roam_params->raise_rssi_thresh_5g =
15064 pref_params->rssi_boost_threshold_5g;
15065 roam_params->raise_factor_5g =
15066 pref_params->rssi_boost_factor_5g;
15067 roam_params->max_raise_rssi_5g =
15068 pref_params->max_rssi_boost_5g;
15069 roam_params->drop_rssi_thresh_5g =
15070 pref_params->rssi_penalize_threshold_5g;
15071 roam_params->drop_factor_5g =
15072 pref_params->rssi_penalize_factor_5g;
15073 roam_params->max_drop_rssi_5g =
15074 pref_params->max_rssi_penalize_5g;
15075
15076 sme_release_global_lock(&mac_ctx->sme);
15077 } else
15078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15079 "Unable to acquire global sme lock");
15080}
15081
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015082
15083bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
15084{
15085 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015086
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015087 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
15088}
Yingying Tang95409972016-10-20 15:16:15 +080015089
15090#ifdef WLAN_FEATURE_WOW_PULSE
15091/**
15092 * sme_set_wow_pulse() - set wow pulse info
15093 * @wow_pulse_set_info: wow_pulse_mode structure pointer
15094 *
15095 * Return: QDF_STATUS
15096 */
15097QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
15098{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015099 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080015100 QDF_STATUS status;
15101 struct wow_pulse_mode *wow_pulse_set_cmd;
15102
15103 if (!wow_pulse_set_info) {
15104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15105 "%s: invalid wow_pulse_set_info pointer", __func__);
15106 return QDF_STATUS_E_FAILURE;
15107 }
15108
15109 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
15110 if (NULL == wow_pulse_set_cmd) {
15111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15112 "%s: fail to alloc wow_pulse_set_cmd", __func__);
15113 return QDF_STATUS_E_NOMEM;
15114 }
15115
15116 *wow_pulse_set_cmd = *wow_pulse_set_info;
15117
15118 message.type = WMA_SET_WOW_PULSE_CMD;
15119 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015120 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080015121 &message);
15122 if (!QDF_IS_STATUS_SUCCESS(status)) {
15123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15124 "%s: Not able to post msg to WDA!",
15125 __func__);
15126 qdf_mem_free(wow_pulse_set_cmd);
15127 status = QDF_STATUS_E_FAILURE;
15128 }
15129
15130 return status;
15131}
15132#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015133
15134/**
15135 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
15136 * different fields and IEs from bss descriptor.
15137 * @frame_buf: frame buffer to populate
15138 * @bss_descp: bss descriptor
15139 * @bssid: bssid of the beacon frame to populate
15140 * @ie_len: length of IE fields
15141 *
15142 * Return: None
15143 */
15144static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
15145 tSirBssDescription *bss_descp,
15146 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080015147 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015148{
15149 tDot11fBeacon1 *bcn_fixed;
15150 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
15151
15152 /* populate mac header first to indicate beacon */
15153 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15154 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
15155 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
15156 qdf_mem_copy((uint8_t *) mac_hdr->da,
15157 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
15158 sizeof(struct qdf_mac_addr));
15159 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15160 sizeof(struct qdf_mac_addr));
15161 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15162 sizeof(struct qdf_mac_addr));
15163
15164 /* now populate fixed params */
15165 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15166 /* populate timestamp */
15167 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15168 sizeof(bss_descp->timeStamp));
15169 /* populate beacon interval */
15170 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15171 /* populate capability */
15172 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15173 sizeof(bss_descp->capabilityInfo));
15174
15175 /* copy IEs now */
15176 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15177 + SIR_MAC_B_PR_SSID_OFFSET,
15178 &bss_descp->ieFields, ie_len);
15179}
15180
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015181QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
15182 tCsrRoamProfile *profile,
15183 const uint8_t *bssid,
15184 int8_t *rssi, int8_t *snr)
15185{
15186 tSirBssDescription *bss_descp;
15187 tCsrScanResultFilter *scan_filter;
15188 struct scan_result_list *bss_list;
15189 tScanResultHandle result_handle = NULL;
15190 QDF_STATUS status = QDF_STATUS_SUCCESS;
15191 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15192
15193 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15194 if (NULL == scan_filter) {
15195 sme_err("memory allocation failed");
15196 status = QDF_STATUS_E_NOMEM;
15197 goto free_scan_flter;
15198 }
15199
15200 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15201 profile, scan_filter);
15202 if (QDF_STATUS_SUCCESS != status) {
15203 sme_err("prepare_filter failed");
15204 goto free_scan_flter;
15205 }
15206
15207 /* update filter to get scan result with just target BSSID */
15208 if (NULL == scan_filter->BSSIDs.bssid) {
15209 scan_filter->BSSIDs.bssid =
15210 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15211 if (scan_filter->BSSIDs.bssid == NULL) {
15212 sme_err("malloc failed");
15213 status = QDF_STATUS_E_NOMEM;
15214 goto free_scan_flter;
15215 }
15216 }
15217
15218 scan_filter->BSSIDs.numOfBSSIDs = 1;
15219 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15220 bssid, sizeof(struct qdf_mac_addr));
15221
15222 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15223 if (QDF_STATUS_SUCCESS != status) {
15224 sme_err("parse_scan_result failed");
15225 goto free_scan_flter;
15226 }
15227
15228 bss_list = (struct scan_result_list *)result_handle;
15229 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15230 if (!bss_descp) {
15231 sme_err("unable to fetch bss descriptor");
15232 status = QDF_STATUS_E_FAULT;
15233 goto free_scan_flter;
15234 }
15235
15236 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15237 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15238
15239 if (rssi)
15240 *rssi = bss_descp->rssi;
15241 if (snr)
15242 *snr = bss_descp->sinr;
15243
15244free_scan_flter:
15245 /* free scan filter and exit */
15246 if (scan_filter) {
15247 csr_free_scan_filter(mac_ctx, scan_filter);
15248 qdf_mem_free(scan_filter);
15249 }
15250
15251 if (result_handle)
15252 csr_scan_result_purge(mac_ctx, result_handle);
15253
15254 return status;
15255}
15256
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015257QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15258 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015259 uint8_t **frame_buf, uint32_t *frame_len,
15260 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015261{
15262 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015263 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015264 tCsrScanResultFilter *scan_filter;
15265 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15266 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015267 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015268 uint32_t ie_len;
15269
15270 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15271 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015272 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015273 status = QDF_STATUS_E_NOMEM;
15274 goto free_scan_flter;
15275 }
15276 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15277 profile, scan_filter);
15278 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015279 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015280 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015281 goto free_scan_flter;
15282 }
15283
15284 /* update filter to get scan result with just target BSSID */
15285 if (NULL == scan_filter->BSSIDs.bssid) {
15286 scan_filter->BSSIDs.bssid =
15287 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15288 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015289 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015290 status = QDF_STATUS_E_NOMEM;
15291 goto free_scan_flter;
15292 }
15293 }
15294 scan_filter->BSSIDs.numOfBSSIDs = 1;
15295 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15296 bssid, sizeof(struct qdf_mac_addr));
15297
15298 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15299 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015300 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015301 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015302 goto free_scan_flter;
15303 }
15304
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015305 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015306 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015307 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015308 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015309 status = QDF_STATUS_E_FAULT;
15310 goto free_scan_flter;
15311 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015312
Naveen Rawat81f058c2017-06-02 16:02:39 -070015313 /**
15314 * Length of BSS descriptor is without length of
15315 * length itself and length of pointer that holds ieFields.
15316 *
15317 * tSirBssDescription
15318 * +--------+---------------------------------+---------------+
15319 * | length | other fields | pointer to IEs|
15320 * +--------+---------------------------------+---------------+
15321 * ^
15322 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015323 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015324 ie_len = bss_descp->length + sizeof(bss_descp->length)
15325 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015326 sme_debug("found bss_descriptor ie_len: %d channel %d",
15327 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015328
15329 /* include mac header and fixed params along with IEs in frame */
15330 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15331 *frame_buf = qdf_mem_malloc(*frame_len);
15332 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015333 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015334 status = QDF_STATUS_E_NOMEM;
15335 goto free_scan_flter;
15336 }
15337
15338 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15339
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015340 if (!*channel)
15341 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015342free_scan_flter:
15343 /* free scan filter and exit */
15344 if (scan_filter) {
15345 csr_free_scan_filter(mac_ctx, scan_filter);
15346 qdf_mem_free(scan_filter);
15347 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015348 if (result_handle)
15349 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015350
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015351 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015352}
15353
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015354#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015355QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15356 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015357 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015358{
15359 QDF_STATUS status;
15360 struct wma_roam_invoke_cmd *fastreassoc;
15361 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015362 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015363
15364 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15365 if (NULL == fastreassoc) {
15366 sme_err("qdf_mem_malloc failed for fastreassoc");
15367 return QDF_STATUS_E_NOMEM;
15368 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015369 /* if both are same then set the flag */
15370 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15371 fastreassoc->is_same_bssid = true;
15372 sme_debug("bssid same, bssid[%pM]", bssid);
15373 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015374 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015375 fastreassoc->bssid[0] = bssid[0];
15376 fastreassoc->bssid[1] = bssid[1];
15377 fastreassoc->bssid[2] = bssid[2];
15378 fastreassoc->bssid[3] = bssid[3];
15379 fastreassoc->bssid[4] = bssid[4];
15380 fastreassoc->bssid[5] = bssid[5];
15381
15382 status = sme_get_beacon_frm(hal, profile, bssid,
15383 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015384 &fastreassoc->frame_len,
15385 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015386
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015387 if (!channel) {
15388 sme_err("channel retrieval from BSS desc fails!");
15389 qdf_mem_free(fastreassoc);
15390 return QDF_STATUS_E_FAULT;
15391 }
15392
15393 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015394 if (QDF_STATUS_SUCCESS != status) {
15395 sme_warn("sme_get_beacon_frm failed");
15396 fastreassoc->frame_buf = NULL;
15397 fastreassoc->frame_len = 0;
15398 }
15399
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015400 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15401 connectedProfile.AuthType)) {
15402 sme_debug("Beacon is not required for ESE");
15403 if (fastreassoc->frame_len) {
15404 qdf_mem_free(fastreassoc->frame_buf);
15405 fastreassoc->frame_buf = NULL;
15406 fastreassoc->frame_len = 0;
15407 }
15408 }
15409
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015410 msg.type = SIR_HAL_ROAM_INVOKE;
15411 msg.reserved = 0;
15412 msg.bodyptr = fastreassoc;
15413 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15414 if (QDF_STATUS_SUCCESS != status) {
15415 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15416 qdf_mem_free(fastreassoc);
15417 }
15418
15419 return status;
15420}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015421#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015422
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015423QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15424 tPmkidCacheInfo *pmk_cache_info,
15425 bool is_add)
15426{
15427 struct wmi_unified_pmk_cache *pmk_cache;
15428 struct scheduler_msg msg;
15429
15430 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15431 if (!pmk_cache) {
15432 sme_err("Memory allocation failure");
15433 return QDF_STATUS_E_NOMEM;
15434 }
15435
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015436 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15437
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015438 pmk_cache->session_id = session_id;
15439
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015440 if (!pmk_cache_info)
15441 goto send_flush_cmd;
15442
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015443 if (!pmk_cache_info->ssid_len) {
15444 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15445 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15446 &pmk_cache->bssid);
15447 } else {
15448 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15449 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15450 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15451 pmk_cache_info->ssid,
15452 pmk_cache->ssid.length);
15453 }
15454 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15455 pmk_cache_info->cache_id[1]);
15456
15457 if (is_add)
15458 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15459 else
15460 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15461
15462 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15463 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15464 CSR_RSN_PMKID_SIZE);
15465
15466 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15467 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15468 pmk_cache->pmk_len);
15469
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015470send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015471 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15472 msg.reserved = 0;
15473 msg.bodyptr = pmk_cache;
15474 if (QDF_STATUS_SUCCESS !=
15475 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15476 sme_err("Not able to post message to WDA");
15477 qdf_mem_free(pmk_cache);
15478 return QDF_STATUS_E_FAILURE;
15479 }
15480
15481 return QDF_STATUS_SUCCESS;
15482}
15483
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015484/* ARP DEBUG STATS */
15485
15486/**
15487 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15488 * @hal: handle to hal
15489 * @set_stats_param: pointer to set stats param
15490 *
15491 * Return: Return QDF_STATUS.
15492 */
15493QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15494 struct set_arp_stats_params
15495 *set_stats_param)
15496{
15497 struct set_arp_stats_params *arp_set_param;
15498 struct scheduler_msg msg;
15499
15500 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15501 if (arp_set_param == NULL) {
15502 sme_err("Memory allocation failure");
15503 return QDF_STATUS_E_NOMEM;
15504 }
15505
15506 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15507
15508 msg.type = WMA_SET_ARP_STATS_REQ;
15509 msg.reserved = 0;
15510 msg.bodyptr = arp_set_param;
15511
15512 if (QDF_STATUS_SUCCESS !=
15513 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15514 sme_err("Not able to post message to WDA");
15515 qdf_mem_free(arp_set_param);
15516 return QDF_STATUS_E_FAILURE;
15517 }
15518
15519 return QDF_STATUS_SUCCESS;
15520}
15521
15522/**
15523 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15524 * @hal: handle to hal
15525 * @get_stats_param: pointer to set stats param
15526 *
15527 * Return: Return QDF_STATUS.
15528 */
15529QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15530 struct get_arp_stats_params
15531 *get_stats_param)
15532{
15533 struct get_arp_stats_params *arp_get_param;
15534 struct scheduler_msg msg;
15535
15536 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15537 if (arp_get_param == NULL) {
15538 sme_err("Memory allocation failure");
15539 return QDF_STATUS_E_NOMEM;
15540 }
15541
15542 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15543
15544 msg.type = WMA_GET_ARP_STATS_REQ;
15545 msg.reserved = 0;
15546 msg.bodyptr = arp_get_param;
15547
15548 if (QDF_STATUS_SUCCESS !=
15549 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15550 sme_err("Not able to post message to WDA");
15551 qdf_mem_free(arp_get_param);
15552 return QDF_STATUS_E_FAILURE;
15553 }
15554
15555 return QDF_STATUS_SUCCESS;
15556}
15557
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015558QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15559 uint32_t param_value, uint32_t vdev_id)
15560{
15561 void *wma_handle;
15562
15563 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15564 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015565 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015566 return QDF_STATUS_E_FAILURE;
15567 }
15568
15569 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15570 param_value, vdev_id);
15571}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015572
15573QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015574 bool (*set_connection_info_cb)(bool),
15575 bool (*get_connection_info_cb)(uint8_t *session_id,
15576 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015577{
15578 QDF_STATUS status = QDF_STATUS_SUCCESS;
15579 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15580
15581 status = sme_acquire_global_lock(&pMac->sme);
15582 if (QDF_IS_STATUS_SUCCESS(status)) {
15583 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015584 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015585 sme_release_global_lock(&pMac->sme);
15586 }
15587 return status;
15588}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015589
15590QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15591 void (*cb)(void *, struct rso_cmd_status *))
15592{
15593 QDF_STATUS status = QDF_STATUS_SUCCESS;
15594 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15595
15596 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015597 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015598 return status;
15599}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015600
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015601QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15602 struct wmi_dbs_scan_sel_params *params)
15603{
15604 struct scheduler_msg message = {0};
15605 QDF_STATUS status;
15606 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15607 uint32_t i;
15608
15609 if (0 == params->num_clients) {
15610 sme_err("Num of clients is 0");
15611 return QDF_STATUS_E_FAILURE;
15612 }
15613
15614 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15615 if (!dbs_scan_params) {
15616 sme_err("fail to alloc dbs_scan_params");
15617 return QDF_STATUS_E_NOMEM;
15618 }
15619
15620 dbs_scan_params->num_clients = params->num_clients;
15621 dbs_scan_params->pdev_id = params->pdev_id;
15622 for (i = 0; i < params->num_clients; i++) {
15623 dbs_scan_params->module_id[i] = params->module_id[i];
15624 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15625 dbs_scan_params->num_non_dbs_scans[i] =
15626 params->num_non_dbs_scans[i];
15627 }
15628 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15629 message.bodyptr = dbs_scan_params;
15630 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15631 if (!QDF_IS_STATUS_SUCCESS(status)) {
15632 sme_err("Not able to post msg to WMA!");
15633 qdf_mem_free(dbs_scan_params);
15634 }
15635
15636 return status;
15637}
15638
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015639QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15640{
15641 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15642 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015643 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015644 struct sme_rcpi_req *rcpi_req;
15645
15646 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15647 if (rcpi_req == NULL) {
15648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15649 "%s: Not able to allocate memory for rcpi req",
15650 __func__);
15651 return QDF_STATUS_E_NOMEM;
15652 }
15653 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15654
15655 status = sme_acquire_global_lock(&pMac->sme);
15656 if (QDF_IS_STATUS_SUCCESS(status)) {
15657 msg.bodyptr = rcpi_req;
15658 msg.type = WMA_GET_RCPI_REQ;
15659 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15660 sme_release_global_lock(&pMac->sme);
15661 if (!QDF_IS_STATUS_SUCCESS(status)) {
15662 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15663 FL("post get rcpi req failed"));
15664 status = QDF_STATUS_E_FAILURE;
15665 qdf_mem_free(rcpi_req);
15666 }
15667 } else {
15668 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15669 FL("sme_acquire_global_lock failed"));
15670 qdf_mem_free(rcpi_req);
15671 }
15672
15673 return status;
15674}
15675
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015676void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15677{
15678 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15679 void *wma_handle;
15680 QDF_STATUS status;
15681
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015682 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015683 if (QDF_STATUS_SUCCESS != status) {
15684 mac_ctx->pdev = NULL;
15685 return;
15686 }
15687 mac_ctx->pdev = pdev;
15688 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15689 if (!wma_handle) {
15690 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015691 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015692 return;
15693 }
15694 wma_store_pdev(wma_handle, pdev);
15695}
15696
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015697QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15698 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15699{
15700 QDF_STATUS status;
15701 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15702
15703 status = sme_acquire_global_lock(&mac->sme);
15704 if (QDF_IS_STATUS_SUCCESS(status)) {
15705 mac->sme.congestion_cb = congestion_cb;
15706 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015707 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015708 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015709 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015710 }
15711
15712 return status;
15713}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015714
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015715QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
15716 void (*tx_queue_cb)(void *,
15717 uint32_t vdev_id,
15718 enum netif_action_type action,
15719 enum netif_reason_type reason))
15720{
15721 QDF_STATUS status;
15722 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15723
15724 status = sme_acquire_global_lock(&mac->sme);
15725 if (QDF_IS_STATUS_SUCCESS(status)) {
15726 mac->sme.tx_queue_cb = tx_queue_cb;
15727 sme_release_global_lock(&mac->sme);
15728 sme_debug("Tx queue callback set");
15729 } else {
15730 sme_err("Aquiring lock failed %d", status);
15731 }
15732
15733 return status;
15734}
15735
15736QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
15737{
15738 return sme_register_tx_queue_cb(hal, NULL);
15739}
15740
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015741QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15742 uint32_t param_val)
15743{
15744 return wma_configure_smps_params(vdev_id, param_id, param_val);
15745}
15746
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015747QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15748 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15749{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015750 wma_cli_set_cmd_t *iwcmd;
15751 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015752
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015753 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15754 if (!iwcmd) {
15755 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015756 return QDF_STATUS_E_NOMEM;
15757 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015758
15759 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15760 iwcmd->param_sec_value = 0;
15761 iwcmd->param_vdev_id = vdev_id;
15762 iwcmd->param_id = param_id;
15763 iwcmd->param_vp_dev = req_cat;
15764 iwcmd->param_value = param_val;
15765 wma_ipa_uc_stat_request(iwcmd);
15766 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015767
15768 return status;
15769}
lifeng66831662017-05-19 16:01:35 +080015770
15771QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15772 struct sir_set_rx_reorder_timeout_val *req)
15773{
15774 QDF_STATUS status;
15775
15776 status = wma_set_rx_reorder_timeout_val(hal, req);
15777
15778 return status;
15779}
15780
15781QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15782 struct sir_peer_set_rx_blocksize *req)
15783{
15784 QDF_STATUS status;
15785
15786 status = wma_set_rx_blocksize(hal, req);
15787
15788 return status;
15789}
Naveen Rawat247a8682017-06-05 15:00:31 -070015790
15791int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15792{
15793 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15794}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015795
15796QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15797 void (*cb)(void *, uint32_t bt_activity))
15798{
15799 QDF_STATUS status;
15800 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15801
15802 status = sme_acquire_global_lock(&mac->sme);
15803 if (QDF_IS_STATUS_SUCCESS(status)) {
15804 mac->sme.bt_activity_info_cb = cb;
15805 sme_release_global_lock(&mac->sme);
15806 sme_debug("bt activity info callback set");
15807 } else {
15808 sme_debug("sme_acquire_global_lock failed %d", status);
15809 }
15810
15811 return status;
15812}
lifengd217d192017-05-09 19:44:16 +080015813
15814QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15815 struct get_chain_rssi_req_params *input,
15816 get_chain_rssi_callback callback,
15817 void *context)
15818{
15819 QDF_STATUS status = QDF_STATUS_SUCCESS;
15820 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15821
15822 SME_ENTER();
15823
15824 if (NULL == input) {
15825 sme_err("Invalid req params");
15826 return QDF_STATUS_E_INVAL;
15827 }
15828
15829 mac_ctx->sme.get_chain_rssi_cb = callback;
15830 mac_ctx->sme.get_chain_rssi_context = context;
15831 wma_get_chain_rssi(hal, input);
15832
15833 SME_EXIT();
15834 return status;
15835}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015836
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015837QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15838 struct scheduler_msg *msg)
15839{
15840 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15841
15842 if (msg == NULL) {
15843 sme_err("Empty message for SME Msg callback");
15844 return status;
15845 }
15846 status = sme_process_msg(hal, msg);
15847 return status;
15848}
15849
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015850void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15851{
15852 struct csr_roam_session *session;
15853 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15854
15855 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15856 sme_err("%s Invalid session id: %d", __func__, session_id);
15857 return;
15858 }
15859
15860 session = CSR_GET_SESSION(mac_ctx, session_id);
15861 if (!session) {
15862 sme_err("%s Failed to get session for id: %d",
15863 __func__, session_id);
15864 return;
15865 }
15866
15867 sme_debug("Total No. of Disconnections: %d",
15868 session->disconnect_stats.disconnection_cnt);
15869
15870 sme_debug("No. of Diconnects Triggered by Application: %d",
15871 session->disconnect_stats.disconnection_by_app);
15872
15873 sme_debug("No. of Disassoc Sent by Peer: %d",
15874 session->disconnect_stats.disassoc_by_peer);
15875
15876 sme_debug("No. of Deauth Sent by Peer: %d",
15877 session->disconnect_stats.deauth_by_peer);
15878
15879 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15880 session->disconnect_stats.bmiss);
15881
15882 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15883 session->disconnect_stats.peer_kickout);
15884}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015885
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015886 /**
15887 * sme_set_vc_mode_config() - Set voltage corner config to FW
15888 * @bitmap: Bitmap that referes to voltage corner config with
15889 * different phymode and bw configuration
15890 *
15891 * Return: QDF_STATUS
15892 */
15893QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15894{
15895 void *wma_handle;
15896
15897 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15898 if (!wma_handle) {
15899 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15900 "wma_handle is NULL");
15901 return QDF_STATUS_E_FAILURE;
15902 }
15903 if (QDF_STATUS_SUCCESS !=
15904 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15905 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15906 "%s: Failed to set Voltage Control config to FW",
15907 __func__);
15908 return QDF_STATUS_E_FAILURE;
15909 }
15910 return QDF_STATUS_SUCCESS;
15911}
15912
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015913/**
15914 * sme_set_bmiss_bcnt() - set bmiss config parameters
15915 * @vdev_id: virtual device for the command
15916 * @first_cnt: bmiss first value
15917 * @final_cnt: bmiss final value
15918 *
15919 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15920 */
15921QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15922 uint32_t final_cnt)
15923{
15924 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15925}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015926
15927QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15928 bool is_tos_active, uint32_t max_off_chan_time,
15929 uint32_t rest_time, bool skip_dfs_chan)
15930{
15931 struct sir_limit_off_chan *cmd;
15932 struct scheduler_msg msg = {0};
15933
15934 cmd = qdf_mem_malloc(sizeof(*cmd));
15935 if (!cmd) {
15936 sme_err("qdf_mem_malloc failed for limit off channel");
15937 return QDF_STATUS_E_NOMEM;
15938 }
15939
15940 cmd->vdev_id = vdev_id;
15941 cmd->is_tos_active = is_tos_active;
15942 cmd->max_off_chan_time = max_off_chan_time;
15943 cmd->rest_time = rest_time;
15944 cmd->skip_dfs_chans = skip_dfs_chan;
15945
15946 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15947 msg.reserved = 0;
15948 msg.bodyptr = cmd;
15949
15950 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15951 &msg))) {
15952 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15953 qdf_mem_free(cmd);
15954 return QDF_STATUS_E_FAILURE;
15955 }
15956
15957 return QDF_STATUS_SUCCESS;
15958}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015959
15960/**
15961 * sme_get_status_for_candidate() - Get bss transition status for candidate
15962 * @hal: Handle for HAL
15963 * @conn_bss_desc: connected bss descriptor
15964 * @bss_desc: candidate bss descriptor
15965 * @info: candiadate bss information
15966 * @trans_reason: transition reason code
15967 * @is_bt_in_progress: bt activity indicator
15968 *
15969 * Return : true if candidate is rejected and reject reason is filled
15970 * @info->status. Otherwise returns false.
15971 */
15972static bool sme_get_status_for_candidate(tHalHandle *hal,
15973 tSirBssDescription *conn_bss_desc,
15974 tSirBssDescription *bss_desc,
15975 struct bss_candidate_info *info,
15976 uint8_t trans_reason,
15977 bool is_bt_in_progress)
15978{
15979 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15980
15981 /*
15982 * Low RSSI based rejection
15983 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15984 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15985 * candidate with MBO reason code 4.
15986 */
15987 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15988 mbo_candidate_rssi_thres) &&
15989 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15990 mbo_current_rssi_thres)) {
15991 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15992 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15993 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15994 return true;
15995 }
15996
15997 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15998 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15999 /*
16000 * MCC rejection
16001 * If moving to candidate's channel will result in MCC scenario
16002 * and the rssi of connected bss is greater than
16003 * mbo_current_rssi_mss_thres, then reject the candidate with
16004 * MBO reason code 3.
16005 */
16006 if ((conn_bss_desc->rssi >
16007 mac_ctx->roam.configParam.mbo_thresholds.
16008 mbo_current_rssi_mcc_thres) &&
16009 csr_is_mcc_channel(hal, bss_desc->channelId)) {
16010 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
16011 MAC_ADDR_ARRAY(bss_desc->bssId));
16012 info->status =
16013 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
16014 return true;
16015 }
16016
16017 /*
16018 * BT coex rejection
16019 * If AP is trying to move the client from 5G to 2.4G and moving
16020 * to 2.4G will result in BT coex and candidate channel rssi is
16021 * less than mbo_candidate_rssi_btc_thres, then reject the
16022 * candidate with MBO reason code 2.
16023 */
16024 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
16025 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
16026 is_bt_in_progress &&
16027 (bss_desc->rssi <
16028 mac_ctx->roam.configParam.mbo_thresholds.
16029 mbo_candidate_rssi_btc_thres)) {
16030 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
16031 MAC_ADDR_ARRAY(bss_desc->bssId));
16032 info->status =
16033 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
16034 return true;
16035 }
16036
16037 /*
16038 * LTE coex rejection
16039 * If moving to candidate's channel can cause LTE coex, then
16040 * reject the candidate with MBO reason code 5.
16041 */
16042 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
16043 conn_bss_desc->channelId) &&
16044 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
16045 bss_desc->channelId))) {
16046 sme_err("High interference expected if transitioned to BSS "
16047 MAC_ADDRESS_STR" hence reject",
16048 MAC_ADDR_ARRAY(bss_desc->bssId));
16049 info->status =
16050 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
16051 return true;
16052 }
16053 }
16054
16055 return false;
16056}
16057
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053016058uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
16059 uint8_t buf_len, tDot11fIERSN *rsn_ie,
16060 bool append_ie)
16061{
16062 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16063
Abhishek Singh3f13a812018-01-16 14:24:44 +053016064 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053016065}
16066
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053016067/**
16068 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
16069 * @adapter : Pointer to adapter
16070 * @transition_reason : Transition reason
16071 * @info : bss candidate information
16072 * @n_candidates : number of candidates
16073 *
16074 * Return : 0 on success otherwise errno
16075 */
16076int sme_get_bss_transition_status(tHalHandle hal,
16077 uint8_t transition_reason,
16078 struct qdf_mac_addr *bssid,
16079 struct bss_candidate_info *info,
16080 uint16_t n_candidates,
16081 bool is_bt_in_progress)
16082{
16083 QDF_STATUS status = QDF_STATUS_SUCCESS;
16084 tSirBssDescription *bss_desc, *conn_bss_desc;
16085 tCsrScanResultInfo *res, *conn_res;
16086 uint16_t i;
16087
16088 if (!n_candidates || !info) {
16089 sme_err("No candidate info available");
16090 return QDF_STATUS_E_INVAL;
16091 }
16092
16093 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16094 if (!conn_res) {
16095 sme_err("Failed to allocate memory for conn_res");
16096 return QDF_STATUS_E_NOMEM;
16097 }
16098
16099 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16100 if (!res) {
16101 sme_err("Failed to allocate memory for conn_res");
16102 status = QDF_STATUS_E_NOMEM;
16103 goto free;
16104 }
16105
16106 /* Get the connected BSS descriptor */
16107 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
16108 if (!QDF_IS_STATUS_SUCCESS(status)) {
16109 sme_err("Failed to find connected BSS in scan list");
16110 goto free;
16111 }
16112 conn_bss_desc = &conn_res->BssDescriptor;
16113
16114 for (i = 0; i < n_candidates; i++) {
16115 /* Get candidate BSS descriptors */
16116 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
16117 res);
16118 if (!QDF_IS_STATUS_SUCCESS(status)) {
16119 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
16120 MAC_ADDR_ARRAY(info[i].bssid.bytes));
16121 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
16122 continue;
16123 }
16124
16125 bss_desc = &res->BssDescriptor;
16126 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
16127 &info[i], transition_reason, is_bt_in_progress)) {
16128 /*
16129 * If status is not over written, it means it is a
16130 * candidate for accept.
16131 */
16132 info[i].status = QCA_STATUS_ACCEPT;
16133 }
16134 }
16135
16136 /* success */
16137 status = QDF_STATUS_SUCCESS;
16138
16139free:
16140 /* free allocated memory */
16141 if (conn_res)
16142 qdf_mem_free(conn_res);
16143 if (res)
16144 qdf_mem_free(res);
16145
16146 return status;
16147}
16148
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016149void sme_enable_roaming_on_connected_sta(tHalHandle hal)
16150{
16151 uint8_t session_id;
16152 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16153 QDF_STATUS status;
16154
16155 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
16156 if (session_id != CSR_SESSION_ID_INVALID)
16157 return;
16158
16159 session_id = csr_get_connected_infra(mac_ctx);
16160 if (session_id == CSR_SESSION_ID_INVALID) {
16161 sme_debug("No STA in conencted state");
16162 return;
16163 }
16164
16165 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
16166 session_id);
16167 status = sme_acquire_global_lock(&mac_ctx->sme);
16168 if (QDF_IS_STATUS_SUCCESS(status)) {
16169 csr_roam_offload_scan(mac_ctx, session_id,
16170 ROAM_SCAN_OFFLOAD_START,
16171 REASON_CTX_INIT);
16172 sme_release_global_lock(&mac_ctx->sme);
16173 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016174}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016175
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016176int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
16177{
16178 uint8_t vdev_id, chan;
16179 struct csr_roam_session *session;
16180 tpAniSirGlobal mac_ctx;
16181 tHalHandle h_hal;
16182 int16_t freq = 0;
16183
16184 if (vdev == NULL) {
16185 sme_err("Invalid vdev id is passed");
16186 return 0;
16187 }
16188
16189 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016190 if (!h_hal) {
16191 sme_err("h_hal is null");
16192 return 0;
16193 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016194 mac_ctx = PMAC_STRUCT(h_hal);
16195 vdev_id = wlan_vdev_get_id(vdev);
16196 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16197 sme_err("Invalid vdev id is passed");
16198 return 0;
16199 }
16200
16201 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16202 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
16203 if (chan)
16204 freq = cds_chan_to_freq(chan);
16205
16206 return freq;
16207}
16208
16209enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
16210{
16211 uint8_t vdev_id;
16212 struct csr_roam_session *session;
16213 tpAniSirGlobal mac_ctx;
16214 tHalHandle h_hal;
16215 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
16216
16217 if (vdev == NULL) {
16218 sme_err("Invalid vdev id is passed");
16219 return CH_WIDTH_INVALID;
16220 }
16221
16222 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016223 if (!h_hal) {
16224 sme_err("h_hal is null");
16225 return CH_WIDTH_INVALID;
16226 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016227 mac_ctx = PMAC_STRUCT(h_hal);
16228 vdev_id = wlan_vdev_get_id(vdev);
16229 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16230 sme_err("Invalid vdev id is passed");
16231 return CH_WIDTH_INVALID;
16232 }
16233
16234 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16235
16236 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16237 ch_width = session->connectedProfile.vht_channel_width;
16238
16239 return ch_width;
16240}
16241
16242int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16243 uint16_t *sec20chan_freq)
16244{
16245 uint8_t vdev_id;
16246
16247 vdev_id = wlan_vdev_get_id(vdev);
16248 /* Need to extend */
16249 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016250}
16251
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016252#ifdef WLAN_FEATURE_SAE
16253QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16254 uint8_t sae_status)
16255{
16256 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16257 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16258 struct sir_sae_msg *sae_msg;
16259 struct scheduler_msg sch_msg = {0};
16260
16261 qdf_status = sme_acquire_global_lock(&mac->sme);
16262 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16263 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16264 if (!sae_msg) {
16265 qdf_status = QDF_STATUS_E_NOMEM;
16266 sme_err("SAE: memory allocation failed");
16267 } else {
16268 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16269 sae_msg->length = sizeof(*sae_msg);
16270 sae_msg->session_id = session_id;
16271 sae_msg->sae_status = sae_status;
16272 sme_debug("SAE: sae_status %d session_id %d",
16273 sae_msg->sae_status,
16274 sae_msg->session_id);
16275
16276 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16277 sch_msg.bodyptr = sae_msg;
16278
16279 qdf_status =
16280 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16281 }
16282 sme_release_global_lock(&mac->sme);
16283 }
16284
16285 return qdf_status;
16286}
16287#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016288
16289bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16290{
16291 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16292
16293 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16294 sme_err("Invalid session id: %d", session_id);
16295 return false;
16296 }
16297
16298 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16299}