blob: b90d3ad1dfde951f3b360149663d0229ae50a4a5 [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) {
383 case eSmeCommandScan:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700384 sme_debug("scan command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 pCmd->u.scanCmd.reason);
386 break;
387
388 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700389 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 pCmd->u.roamCmd.roamReason);
391 break;
392
393 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700394 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 pCmd->u.wmStatusChangeCmd.Type);
396 break;
397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700399 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800400 pCmd->command);
401 break;
402 }
403}
404
405tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
406{
407 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
408 tListElem *pEntry;
409 static int sme_command_queue_full;
410
411 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
412
413 /* If we can get another MS Msg buffer, then we are ok. Just link */
414 /* the entry onto the linked list. (We are using the linked list */
415 /* to keep track of tfhe message buffers). */
416 if (pEntry) {
417 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
418 /* reset when free list is available */
419 sme_command_queue_full = 0;
420 } else {
421 int idx = 1;
422
423 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800424 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530425 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530427
428 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
430 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530431 if (eSmeCsrCommandMask & pTempCmd->command)
432 /* CSR command is stuck. See what the reason
433 * code is for that command
434 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 } /* if(pTempCmd) */
437
438 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800439 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800441 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442 LL_ACCESS_NOLOCK);
443 while (pEntry && !sme_command_queue_full) {
444 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
445 /* Print only 1st five commands from pending queue. */
446 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530447 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 idx, pTempCmd->command);
449 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530450 if (eSmeCsrCommandMask & pTempCmd->command)
451 /* CSR command is stuck. See what the reason
452 * code is for that command
453 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800455 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 LL_ACCESS_NOLOCK);
457 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800458 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459
Abhishek Singh5ea86532016-04-27 14:10:53 +0530460 if (pMac->roam.configParam.enable_fatal_event)
461 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
462 WLAN_LOG_INDICATOR_HOST_DRIVER,
463 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
464 false,
465 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530466 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530467 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 }
469
470 /* memset to zero */
471 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530472 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530474 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530476 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 }
478
479 return pRetCmd;
480}
481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800483 * sme_ser_handle_active_cmd() - handle command activation callback from
484 * new serialization module
485 * @cmd: pointer to new serialization command
486 *
487 * This API is to handle command activation callback from new serialization
488 * callback
489 *
490 * Return: QDF_STATUS_SUCCESS
491 */
492static
493QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
494{
495 tSmeCmd *sme_cmd;
496 tHalHandle hal;
497 tpAniSirGlobal mac_ctx;
498 QDF_STATUS status = QDF_STATUS_SUCCESS;
499 bool do_continue;
500
501 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700502 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800503 return QDF_STATUS_E_FAILURE;
504 }
505
506 hal = cds_get_context(QDF_MODULE_ID_SME);
507 mac_ctx = PMAC_STRUCT(hal);
508 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700509 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800510 return QDF_STATUS_E_FAILURE;
511 }
512 sme_cmd = cmd->umac_cmd;
513 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700514 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800515 return QDF_STATUS_E_FAILURE;
516 }
517
518 switch (sme_cmd->command) {
519 case eSmeCommandRoam:
520 status = csr_roam_process_command(mac_ctx, sme_cmd);
521 break;
522 case eSmeCommandWmStatusChange:
523 csr_roam_process_wm_status_change_command(mac_ctx,
524 sme_cmd);
525 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800526 case eSmeCommandNdpInitiatorRequest:
527 status = csr_process_ndp_initiator_request(mac_ctx, sme_cmd);
528 break;
529 case eSmeCommandNdpResponderRequest:
530 status = csr_process_ndp_responder_request(mac_ctx, sme_cmd);
531 break;
532 case eSmeCommandNdpDataEndInitiatorRequest:
533 status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
534 break;
Krunal Soni81f068c2017-02-23 19:51:55 -0800535 case eSmeCommandScan:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700536 sme_debug("Processing scan offload cmd");
Krunal Soni81f068c2017-02-23 19:51:55 -0800537 qdf_mc_timer_start(&sme_cmd->u.scanCmd.csr_scan_timer,
538 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
539 status = csr_process_scan_command(mac_ctx, sme_cmd);
540 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800541 /*
542 * Treat standby differently here because caller may not be able
543 * to handle the failure so we do our best here
544 */
545 case eSmeCommandEnterStandby:
546 break;
547 case eSmeCommandAddTs:
548 case eSmeCommandDelTs:
549#ifndef WLAN_MDM_CODE_REDUCTION_OPT
550 do_continue = qos_process_command(mac_ctx, sme_cmd);
551 if (do_continue)
552 status = QDF_STATUS_E_FAILURE;
553#endif
554 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800555 case e_sme_command_set_hw_mode:
556 csr_process_set_hw_mode(mac_ctx, sme_cmd);
557 break;
558 case e_sme_command_nss_update:
559 csr_process_nss_update_req(mac_ctx, sme_cmd);
560 break;
561 case e_sme_command_set_dual_mac_config:
562 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
563 break;
564 case e_sme_command_set_antenna_mode:
565 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
566 break;
567 default:
568 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700569 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800570 status = QDF_STATUS_E_FAILURE;
571 break;
572 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800573 return status;
574}
575
576QDF_STATUS sme_ser_cmd_callback(void *buf,
577 enum wlan_serialization_cb_reason reason)
578{
579 struct wlan_serialization_command *cmd = buf;
580 tHalHandle hal;
581 tpAniSirGlobal mac_ctx;
582 QDF_STATUS status = QDF_STATUS_SUCCESS;
583 tSmeCmd *sme_cmd;
584
585 hal = cds_get_context(QDF_MODULE_ID_SME);
586 mac_ctx = PMAC_STRUCT(hal);
587 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700588 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800589 return QDF_STATUS_E_FAILURE;
590 }
591 /*
592 * Do not acquire lock here as sme global lock is already acquired in
593 * caller or MC thread context
594 */
595 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700596 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800597 return QDF_STATUS_E_FAILURE;
598 }
599
600 switch (reason) {
601 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700602 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800603 status = sme_ser_handle_active_cmd(cmd);
604 break;
605 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700606 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800607 sme_cmd = cmd->umac_cmd;
608 csr_cancel_command(mac_ctx, sme_cmd);
Krunal Sonia8270f52017-02-23 19:51:25 -0800609 break;
610 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700611 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800612 sme_cmd = cmd->umac_cmd;
613 csr_release_command_buffer(mac_ctx, sme_cmd);
614 break;
615 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700616 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800617 break;
618 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700619 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800620 return QDF_STATUS_E_FAILURE;
621 }
622 return status;
623}
624
625/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530626 * sme_get_sessionid_from_activelist() - gets session id
627 * @mac: mac context
628 *
629 * This function is used to get session id from sme command
630 * active list
631 *
632 * Return: returns session id
633 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700634static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530635{
636 tListElem *entry;
637 tSmeCmd *command;
638 uint32_t session_id = CSR_SESSION_ID_INVALID;
639
Krunal Sonia8270f52017-02-23 19:51:25 -0800640 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530641 if (entry) {
642 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
643 session_id = command->sessionId;
644 }
645
646 return session_id;
647}
648
649/**
650 * sme_state_info_dump() - prints state information of sme layer
651 * @buf: buffer pointer
652 * @size: size of buffer to be filled
653 *
654 * This function is used to dump state information of sme layer
655 *
656 * Return: None
657 */
658static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
659{
660 uint32_t session_id, active_session_id;
661 tHalHandle hal;
662 tpAniSirGlobal mac;
663 uint16_t len = 0;
664 char *buf = *buf_ptr;
665 eCsrConnectState connect_state;
666
667 hal = cds_get_context(QDF_MODULE_ID_SME);
668 if (hal == NULL) {
669 QDF_ASSERT(0);
670 return;
671 }
672
673 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530674
675 active_session_id = sme_get_sessionid_from_activelist(mac);
676 if (active_session_id != CSR_SESSION_ID_INVALID) {
677 len += qdf_scnprintf(buf + len, *size - len,
678 "\n active command sessionid %d", active_session_id);
679 }
680
681 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
682 if (CSR_IS_SESSION_VALID(mac, session_id)) {
683 connect_state =
684 mac->roam.roamSession[session_id].connectState;
685 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
686 connect_state)
687 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
688 connect_state)) {
689 len += qdf_scnprintf(buf + len, *size - len,
690 "\n NeighborRoamState: %d",
691 mac->roam.neighborRoamInfo[session_id].
692 neighborRoamState);
693 len += qdf_scnprintf(buf + len, *size - len,
694 "\n RoamState: %d", mac->roam.
695 curState[session_id]);
696 len += qdf_scnprintf(buf + len, *size - len,
697 "\n RoamSubState: %d", mac->roam.
698 curSubState[session_id]);
699 len += qdf_scnprintf(buf + len, *size - len,
700 "\n ConnectState: %d",
701 connect_state);
702 }
703 }
704 }
705
706 *size -= len;
707 *buf_ptr += len;
708}
709
710/**
711 * sme_register_debug_callback() - registration function sme layer
712 * to print sme state information
713 *
714 * Return: None
715 */
716static void sme_register_debug_callback(void)
717{
718 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
719}
720
721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722/* Global APIs */
723
724/**
725 * sme_open() - Initialze all SME modules and put them at idle state
726 * @hHal: The handle returned by mac_open
727 *
728 * The function initializes each module inside SME, PMC, CSR, etc. Upon
729 * successfully return, all modules are at idle state ready to start.
730 * smeOpen must be called before any other SME APIs can be involved.
731 * smeOpen must be called after mac_open.
732 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530733 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 * Other status means SME is failed to be initialized
735 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530736QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530738 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740
741 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530742 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530743 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700745 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530746 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 }
748 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530749 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700750 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 return status;
752 }
753
754 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530755 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700756 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 return status;
758 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760#ifndef WLAN_MDM_CODE_REDUCTION_OPT
761 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700763 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 return status;
765 }
766#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530768 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530772 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700773 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 return status;
775 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530777 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700778 wlan_serialization_legacy_init_callback();
779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 return status;
781}
782
783/*
784 * sme_init_chan_list, triggers channel setup based on country code.
785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530786QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700787 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788{
789 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
790
Amar Singhala297bfa2015-10-15 15:07:29 -0700791 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
793 pmac->roam.configParam.Is11dSupportEnabled = false;
794 }
795
796 return csr_init_chan_list(pmac, alpha2);
797}
798
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530799/*
800 * sme_set11dinfo() - Set the 11d information about valid channels
801 * and there power using information from nvRAM
802 * This function is called only for AP.
803 *
804 * This is a synchronous call
805 *
806 * hHal - The handle returned by mac_open.
807 * pSmeConfigParams - a pointer to a caller allocated object of
808 * typedef struct _smeConfigParams.
809 *
810 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
811 *
812 * Other status means SME is failed to update the config parameters.
813 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530815QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530817 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530819 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
821 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700822 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 return status;
824 }
825
826 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700827 if (!QDF_IS_STATUS_SUCCESS(status))
828 sme_err("csr_set_channels failed with status: %d", status);
829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 return status;
831}
832
833/**
834 * sme_set_scan_disable() - Dynamically enable/disable scan
835 * @h_hal: Handle to HAL
836 *
837 * This command gives the user an option to dynamically
838 * enable or disable scans.
839 *
840 * Return: None
841 */
842void sme_set_scan_disable(tHalHandle h_hal, int value)
843{
844 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530845
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700846 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530847 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530849/*
850 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
851 * This is a synchronous call
852 *
853 * hHal - The handle returned by HostapdAdapter.
854 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
855 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
856 * Other status means, failed to get the current regulatory domain.
857 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530859QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
860 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530862 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
864
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530865 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
867 NO_SESSION, 0));
868 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700869 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 return status;
871 }
872
873 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530874 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
876 return status;
877}
878
Krunal Sonie3531942016-04-12 17:43:53 -0700879/**
880 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
881 * incoming val
882 * @hal: Handle for Hal layer
883 * @val: New FTM capability value
884 *
885 * Return: None
886 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530887void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
888 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700889{
890 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530891
Naveen Rawatd2657be2017-10-10 14:31:23 -0700892 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700893
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530894 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700895 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
896 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
897 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
898 } else {
899 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
900 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
901 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
902 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530903
904 /* Inform this RRM IE change to FW */
905 csr_roam_offload_scan(mac_ctx, session_id,
906 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
907 REASON_CONNECT_IES_CHANGED);
Krunal Sonie3531942016-04-12 17:43:53 -0700908}
909
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530910/*
911 * sme_update_config() - Change configurations for all SME moduels
912 * The function updates some configuration for modules in SME, CSR, etc
913 * during SMEs close open sequence.
914 * Modules inside SME apply the new configuration at the next transaction.
915 * This is a synchronous call
916 *
917 * hHal - The handle returned by mac_open.
918 * pSmeConfigParams - a pointer to a caller allocated object of
919 * typedef struct _smeConfigParams.
920 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
921 * Other status means SME is failed to update the config parameters.
922 */
923QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
924 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530926 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
928
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530929 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
931 0));
932 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700933 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 return status;
935 }
936
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530937 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
938 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530940 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700941 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530944 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
945 rrmConfig);
946
947 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700948 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530950
951 /* For SOC, CFG is set before start We don't want to apply global CFG
952 * in connect state because that may cause some side affect
953 */
954 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956
957 /*
958 * If scan offload is enabled then lim has allow the sending of
959 * scan request to firmware even in powersave mode. The firmware has
960 * to take care of exiting from power save mode
961 */
962 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
963
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530964 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530965 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530967
968 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 return status;
971}
972
973/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530974 * sme_update_scan_roam_params() - Update the scan roaming params
975 * @mac_ctx: mac ctx
976 *
977 * Return: void.
978 */
979static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
980{
981 struct roam_filter_params scan_params = {0};
982 struct roam_ext_params *roam_params_src;
983 uint8_t i;
984 QDF_STATUS status;
985
986 roam_params_src = &mac_ctx->roam.configParam.roam_params;
987
988 scan_params.num_bssid_avoid_list =
989 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530990
991 if (scan_params.num_bssid_avoid_list >
992 MAX_AVOID_LIST_BSSID)
993 scan_params.num_bssid_avoid_list =
994 MAX_AVOID_LIST_BSSID;
995
996 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
997 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
998 &roam_params_src->bssid_avoid_list[i]);
999 }
1000
1001 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
1002 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001003 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +05301004 status);
1005}
1006
1007/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 * sme_update_roam_params() - Store/Update the roaming params
1009 * @hal: Handle for Hal layer
1010 * @session_id: SME Session ID
1011 * @roam_params_src: The source buffer to copy
1012 * @update_param: Type of parameter to be updated
1013 *
1014 * Return: Return the status of the updation.
1015 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301016QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001017 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 int update_param)
1019{
1020 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1021 struct roam_ext_params *roam_params_dst;
1022 uint8_t i;
1023
1024 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1025 switch (update_param) {
1026 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1027 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001028 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001030 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001032 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001034 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001036 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001038 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001040 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 roam_params_dst->is_5g_pref_enabled = true;
1042 break;
1043 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301044 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1046 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001047 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1049 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001050 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001052 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 roam_params_dst->ssid_allowed_list[i].length);
1054 }
1055 break;
1056 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301057 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1059 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001060 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301062 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001063 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 sizeof(tSirMacAddr));
1065 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001066 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 }
1068 break;
1069 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301070 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301071 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001073 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301075 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001076 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 }
1078 break;
1079 case REASON_ROAM_GOOD_RSSI_CHANGED:
1080 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001081 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 break;
1083 default:
1084 break;
1085 }
1086 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1087 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301088
1089 sme_update_scan_roam_params(mac_ctx);
1090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 return 0;
1092}
1093
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301094/*
1095 * sme_process_ready_to_suspend() -
1096 * On getting ready to suspend indication, this function calls
1097 * callback registered (HDD callbacks) with SME to inform ready
1098 * to suspend indication.
1099 *
1100 * hHal - Handle returned by mac_open.
1101 * pReadyToSuspend - Parameter received along with ready to suspend
1102 * indication from WMA.
1103 * Return: None
1104 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001105static void sme_process_ready_to_suspend(tHalHandle hHal,
1106 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107{
1108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1109
1110 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 "%s: pMac is null", __func__);
1113 return;
1114 }
1115
1116 if (NULL != pMac->readyToSuspendCallback) {
1117 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1118 pReadyToSuspend->suspended);
1119 pMac->readyToSuspendCallback = NULL;
1120 }
1121}
1122
1123#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001125/**
1126 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1127 * @hHal - Handle returned by mac_open.
1128 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1129 * indication from WMA.
1130 *
1131 * On getting ready to Ext WoW indication, this function calls callback
1132 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1133 *
1134 * Return: None
1135 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001136static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1137 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138{
1139 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1140
1141 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143 "%s: pMac is null", __func__);
1144 return;
1145 }
1146
1147 if (NULL != pMac->readyToExtWoWCallback) {
1148 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1149 pReadyToExtWoW->status);
1150 pMac->readyToExtWoWCallback = NULL;
1151 pMac->readyToExtWoWContext = NULL;
1152 }
1153
1154}
1155#endif
1156
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301157/*
1158 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1159 * that the NIC is ready tio run.
1160 * The function is called by HDD at the end of initialization stage so PE/HAL
1161 * can enable the NIC to running state.
1162 * This is a synchronous call
1163 *
1164 * @hHal - The handle returned by mac_open.
1165 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1166 * successfully.
1167 * Other status means SME failed to send the message to PE.
1168 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301169QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170{
Abhishek Singhde410b72017-05-22 15:25:39 +05301171 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301172 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1174
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301175 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1177 do {
1178
Abhishek Singhde410b72017-05-22 15:25:39 +05301179 msg = qdf_mem_malloc(sizeof(*msg));
1180 if (!msg) {
1181 sme_err("Memory allocation failed! for msg");
1182 return QDF_STATUS_E_NOMEM;
1183 }
1184 msg->messageType = eWNI_SME_SYS_READY_IND;
1185 msg->length = sizeof(*msg);
1186 msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
1187 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001188 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301190 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1191 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301192 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001194 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 break;
1196 }
1197
1198 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301199 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001200 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201 break;
1202 }
1203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 pMac->sme.state = SME_STATE_READY;
1205 } while (0);
1206
1207 return status;
1208}
1209
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001210QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1211{
1212 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1213 QDF_STATUS status = QDF_STATUS_SUCCESS;
1214
1215 if (NULL == mac_ctx) {
1216 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1217 FL("Invalid MAC context"));
1218 return QDF_STATUS_E_FAILURE;
1219 }
1220
1221 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1222 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1223 status = QDF_STATUS_E_INVAL;
1224
1225 return status;
1226}
1227
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301228/*
1229 * sme_start() - Put all SME modules at ready state.
1230 * The function starts each module in SME, PMC, CSR, etc. . Upon
1231 * successfully return, all modules are ready to run.
1232 * This is a synchronous call
1233 *
1234 * hHal - The handle returned by mac_open.
1235 * Return QDF_STATUS_SUCCESS - SME is ready.
1236 * Other status means SME is failed to start
1237 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301238QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301240 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001242 struct policy_mgr_sme_cbacks sme_cbacks;
Sandeep Puligilla063a4342018-01-10 02:50:14 -08001243 struct spectral_legacy_cbacks spectral_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244
1245 do {
1246 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001248 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 break;
1250 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001251 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001252 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001253 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1254 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1255 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1256 sme_cbacks.sme_soc_set_dual_mac_config =
1257 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001258 sme_cbacks.sme_change_mcc_beacon_interval =
1259 sme_change_mcc_beacon_interval;
1260 sme_cbacks.sme_get_ap_channel_from_scan =
1261 sme_get_ap_channel_from_scan;
1262 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001263 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1264 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001265 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001266 status);
1267 break;
1268 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -08001269 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1270 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1271 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1272 spectral_register_legacy_cb(pMac->psoc, &spectral_cb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001275 /* START RRM */
1276 status = rrm_start(pMac);
1277 if (!QDF_IS_STATUS_SUCCESS(status)) {
1278 sme_err("Failed to start RRM");
1279 break;
1280 }
1281 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 return status;
1283}
1284
Arif Hussaincd151632017-02-11 16:57:19 -08001285static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1286 struct scheduler_msg *msg)
1287{
1288 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001289 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001290 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1291 uint32_t session_id = 0;
1292 eRoamCmdStatus roam_status;
1293 eCsrRoamResult roam_result;
1294
1295 switch (msg->type) {
1296 case eWNI_SME_DFS_RADAR_FOUND:
1297 {
1298 session_id = msg->bodyval;
1299 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1300 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301301 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001302 "sapdfs: Radar indication event occurred");
1303 break;
1304 }
1305 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1306 {
1307 csa_ie_tx_complete_rsp =
1308 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1309 if (!csa_ie_tx_complete_rsp) {
1310 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1311 return QDF_STATUS_E_FAILURE;
1312 }
1313 session_id = csa_ie_tx_complete_rsp->sessionId;
1314 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1315 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001317 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1318 session_id);
1319 break;
1320 }
1321 case eWNI_SME_DFS_CAC_COMPLETE:
1322 {
1323 session_id = msg->bodyval;
1324 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1325 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001327 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1328 session_id);
1329 break;
1330 }
1331 default:
1332 {
1333 sme_err("Invalid DFS message: 0x%x", msg->type);
1334 status = QDF_STATUS_E_FAILURE;
1335 return status;
1336 }
1337 }
1338
1339 /* Indicate Radar Event to SAP */
1340 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1341 roam_status, roam_result);
1342 return status;
1343}
1344
1345
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301347/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 * Handle the unprotected management frame indication from LIM and
1349 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301350 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301351QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1353{
1354 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301355 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001356 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1358
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001359 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1360 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1361 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362
1363 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001364 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1366
1367 return status;
1368}
1369#endif
1370
Kapil Gupta8878ad92017-02-13 11:56:04 +05301371QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1372{
1373 QDF_STATUS status = QDF_STATUS_SUCCESS;
1374 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001375 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301376 eRoamCmdStatus roamStatus;
1377 eCsrRoamResult roamResult;
1378
1379 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001380 if (!roamInfo) {
1381 sme_err("mem alloc failed for roam info");
1382 return QDF_STATUS_E_FAILURE;
1383 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301384 roamInfo->dfs_event.sessionId = session_id;
1385
1386 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1387 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301389 "sapdfs: Updated new channel event");
1390
1391 /* Indicate channel Event to SAP */
1392 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1393 roamStatus, roamResult);
1394
1395 qdf_mem_free(roamInfo);
1396 return status;
1397}
1398
1399
Abhishek Singh518323d2015-10-19 17:42:01 +05301400/**
1401 * sme_extended_change_channel_ind()- function to indicate ECSA
1402 * action frame is received in lim to SAP
1403 * @mac_ctx: pointer to global mac structure
1404 * @msg_buf: contain new channel and session id.
1405 *
1406 * This function is called to post ECSA action frame
1407 * receive event to SAP.
1408 *
1409 * Return: success if msg indicated to SAP else return failure
1410 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301411static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301412 void *msg_buf)
1413{
1414 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301415 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301416 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001417 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301418 eRoamCmdStatus roam_status;
1419 eCsrRoamResult roam_result;
1420
Abhishek Singh518323d2015-10-19 17:42:01 +05301421 ext_chan_ind = msg_buf;
1422 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001423 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301424 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301425 }
1426 session_id = ext_chan_ind->session_id;
1427 roamInfo.target_channel = ext_chan_ind->new_channel;
1428 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1429 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001430 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1431 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301432
1433 /* Indicate Ext Channel Change event to SAP */
1434 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1435 roam_status, roam_result);
1436 return status;
1437}
1438
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001439#ifdef FEATURE_WLAN_ESE
1440/**
1441 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1442 * @hHal: HAL handle
1443 * @sessionId: session id
1444 * @isEseIniFeatureEnabled: ese ini enabled
1445 *
1446 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1447 * isEseIniFeatureEnabled. This is a synchronous call
1448 *
1449 * Return: QDF_STATUS enumeration
1450 */
1451QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1452 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1453{
1454 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1455
1456 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1457 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301458 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001459 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1460 __func__,
1461 pMac->roam.configParam.isEseIniFeatureEnabled,
1462 isEseIniFeatureEnabled);
1463 return QDF_STATUS_SUCCESS;
1464 }
1465
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301466 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001467 "%s: EseEnabled is changed from %d to %d", __func__,
1468 pMac->roam.configParam.isEseIniFeatureEnabled,
1469 isEseIniFeatureEnabled);
1470 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001471 csr_neighbor_roam_update_fast_roaming_enabled(
1472 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001473
1474 if (true == isEseIniFeatureEnabled)
1475 sme_update_fast_transition_enabled(hHal, true);
1476
1477 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1478 csr_roam_offload_scan(pMac, sessionId,
1479 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1480 REASON_ESE_INI_CFG_CHANGED);
1481
1482 return QDF_STATUS_SUCCESS;
1483}
1484
1485/**
1486 * sme_set_plm_request() - set plm request
1487 * @hHal: HAL handle
1488 * @pPlmReq: Pointer to input plm request
1489 *
1490 * Return: QDF_STATUS enumeration
1491 */
1492QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1493{
1494 QDF_STATUS status;
1495 bool ret = false;
1496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001497 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001498 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001499 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301500 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1501 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001502
1503 status = sme_acquire_global_lock(&pMac->sme);
1504 if (!QDF_IS_STATUS_SUCCESS(status))
1505 return status;
1506
1507 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001508 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001509 sme_release_global_lock(&pMac->sme);
1510 return QDF_STATUS_E_FAILURE;
1511 }
1512
1513 if (!pSession->sessionActive) {
1514 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1515 FL("Invalid Sessionid"));
1516 sme_release_global_lock(&pMac->sme);
1517 return QDF_STATUS_E_FAILURE;
1518 }
1519
1520 if (!pPlmReq->enable)
1521 goto send_plm_start;
1522 /* validating channel numbers */
1523 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1524 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1525 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001526 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1527 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001528 pPlmReq->plmChList[count])) {
1529 /* DFS channel is provided, no PLM bursts can be
1530 * transmitted. Ignoring these channels.
1531 */
1532 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301533 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001534 FL("DFS channel %d ignored for PLM"),
1535 pPlmReq->plmChList[count]);
1536 continue;
1537 }
1538 } else if (!ret) {
1539 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001541 FL("Unsupported channel %d ignored for PLM"),
1542 pPlmReq->plmChList[count]);
1543 continue;
1544 }
1545 ch_list[valid_count] = pPlmReq->plmChList[count];
1546 valid_count++;
1547 } /* End of for () */
1548
1549 /* Copying back the valid channel list to plm struct */
1550 qdf_mem_set((void *)pPlmReq->plmChList,
1551 pPlmReq->plmNumCh, 0);
1552 if (valid_count)
1553 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1554 valid_count);
1555 /* All are invalid channels, FW need to send the PLM
1556 * report with "incapable" bit set.
1557 */
1558 pPlmReq->plmNumCh = valid_count;
1559
1560send_plm_start:
1561 /* PLM START */
1562 msg.type = WMA_SET_PLM_REQ;
1563 msg.reserved = 0;
1564 msg.bodyptr = pPlmReq;
1565
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001566 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001567 &msg))) {
1568 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1569 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1570 sme_release_global_lock(&pMac->sme);
1571 return QDF_STATUS_E_FAILURE;
1572 }
1573
1574 sme_release_global_lock(&pMac->sme);
1575 return status;
1576}
1577
1578/**
1579 * sme_tsm_ie_ind() - sme tsm ie indication
1580 * @hHal: HAL handle
1581 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 *
1583 * Handle the tsm ie indication from LIM and forward it to HDD.
1584 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001585 * Return: QDF_STATUS enumeration
1586 */
1587static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588{
1589 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301590 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001591 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301593
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001594 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1595 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1596 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001598 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301599 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 return status;
1601}
1602
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001603/**
1604 * sme_set_cckm_ie() - set cckm ie
1605 * @hHal: HAL handle
1606 * @sessionId: session id
1607 * @pCckmIe: Pointer to CCKM Ie
1608 * @cckmIeLen: Length of @pCckmIe
1609 *
1610 * Function to store the CCKM IE passed from supplicant and use
1611 * it while packing reassociation request.
1612 *
1613 * Return: QDF_STATUS enumeration
1614 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301615QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 uint8_t *pCckmIe, uint8_t cckmIeLen)
1617{
1618 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301619 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301622 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1624 sme_release_global_lock(&pMac->sme);
1625 }
1626 return status;
1627}
1628
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001629/**
1630 * sme_set_ese_beacon_request() - set ese beacon request
1631 * @hHal: HAL handle
1632 * @sessionId: session id
1633 * @pEseBcnReq: Ese beacon report
1634 *
1635 * function to set ESE beacon request parameters
1636 *
1637 * Return: QDF_STATUS enumeration
1638 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301639QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 const tCsrEseBeaconReq *pEseBcnReq)
1641{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001642 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1644 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1645 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1646 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301647 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1649
1650 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001651 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301652 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 }
1654
1655 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301656 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 sizeof(tCsrEseBeaconReq));
1658
1659 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301660 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001662 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301663 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 }
1665
1666 pSmeRrmContext->eseBcnReqInProgress = true;
1667
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001668 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669
1670 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1671 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301672 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 pSession->connectedProfile.bssid.bytes,
1674 sizeof(tSirMacAddr));
1675 pSmeBcnReportReq->channelInfo.channelNum = 255;
1676 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1677 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1678
1679 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1680 pBeaconReq =
1681 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1682 pSmeBcnReportReq->fMeasurementtype[counter] =
1683 pBeaconReq->scanMode;
1684 pSmeBcnReportReq->measurementDuration[counter] =
1685 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1686 pSmeBcnReportReq->channelList.channelNumber[counter] =
1687 pBeaconReq->channel;
1688 }
1689
1690 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1691
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301692 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 pSmeRrmContext->eseBcnReqInProgress = false;
1694
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301695 qdf_mem_free(pSmeBcnReportReq);
1696
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 return status;
1698}
1699
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001700/**
1701 * sme_get_tsm_stats() - SME get tsm stats
1702 * @hHal: HAL handle
1703 * @callback: SME sends back the requested stats using the callback
1704 * @staId: The station ID for which the stats is requested for
1705 * @bssId: bssid
1706 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001707 * @tid: Traffic id
1708 *
1709 * API register a callback to get TSM Stats.
1710 *
1711 * Return: QDF_STATUS enumeration
1712 */
1713QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1714 tCsrTsmStatsCallback callback,
1715 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001716 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001717{
1718 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1720
1721 status = sme_acquire_global_lock(&pMac->sme);
1722 if (QDF_IS_STATUS_SUCCESS(status)) {
1723 status = csr_get_tsm_stats(pMac, callback,
1724 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001725 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001726 sme_release_global_lock(&pMac->sme);
1727 }
1728 return status;
1729}
1730
1731/**
1732 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1733 * @hHal: pointer HAL handle returned by mac_open
1734 * @sessionId: sme session id
1735 * @pChannelList: Output channel list
1736 * @numChannels: Output number of channels
1737 *
1738 * This routine is called to set ese roam scan channel list.
1739 * This is a synchronous call
1740 *
1741 * Return: QDF_STATUS
1742 */
1743QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1744 uint8_t sessionId,
1745 uint8_t *pChannelList,
1746 uint8_t numChannels)
1747{
1748 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1749 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001750 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1751 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001752 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1753 uint8_t newChannelList[128] = { 0 };
1754 uint8_t i = 0, j = 0;
1755
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001756 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1757 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1758 FL("Invalid sme session id: %d"), sessionId);
1759 return QDF_STATUS_E_INVAL;
1760 }
1761
1762 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1763 curchnl_list_info =
1764 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1765
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001766 status = sme_acquire_global_lock(&pMac->sme);
1767 if (!QDF_IS_STATUS_SUCCESS(status)) {
1768 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1769 csr_roam_offload_scan(pMac, sessionId,
1770 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1771 REASON_CHANNEL_LIST_CHANGED);
1772 return status;
1773 }
1774 if (NULL != curchnl_list_info->ChannelList) {
1775 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1776 j += snprintf(oldChannelList + j,
1777 sizeof(oldChannelList) - j, "%d",
1778 curchnl_list_info->ChannelList[i]);
1779 }
1780 }
1781 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1782 pChannelList, numChannels,
1783 csr_get_current_band(hHal));
1784 if (QDF_IS_STATUS_SUCCESS(status)) {
1785 if (NULL != curchnl_list_info->ChannelList) {
1786 j = 0;
1787 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1788 j += snprintf(newChannelList + j,
1789 sizeof(newChannelList) - j, "%d",
1790 curchnl_list_info->ChannelList[i]);
1791 }
1792 }
1793 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1794 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1795 newChannelList, oldChannelList,
1796 pNeighborRoamInfo->neighborRoamState);
1797 }
1798 sme_release_global_lock(&pMac->sme);
1799 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1800 csr_roam_offload_scan(pMac, sessionId,
1801 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1802 REASON_CHANNEL_LIST_CHANGED);
1803 return status;
1804}
1805
1806#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807
Jeff Johnson49c02f92016-10-07 10:29:09 -07001808static
1809QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1810 tpSirIbssGetPeerInfoRspParams
1811 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001812{
1813 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1814
1815 if (NULL == pMac) {
1816 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1817 "%s: pMac is null", __func__);
1818 return QDF_STATUS_E_FAILURE;
1819 }
1820 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1821 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1822 "%s: HDD callback is null", __func__);
1823 return QDF_STATUS_E_FAILURE;
1824 }
1825 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1826 &pIbssPeerInfoParams->
1827 ibssPeerInfoRspParams);
1828 return QDF_STATUS_SUCCESS;
1829}
1830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1833 * @mac: Global MAC pointer
1834 * @msg: Dual mac config response
1835 *
1836 * Processes the dual mac configuration response and invokes the HDD callback
1837 * to process further
1838 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 uint8_t *msg)
1841{
1842 tListElem *entry = NULL;
1843 tSmeCmd *command = NULL;
1844 bool found;
1845 dual_mac_cb callback = NULL;
1846 struct sir_dual_mac_config_resp *param;
1847
1848 param = (struct sir_dual_mac_config_resp *)msg;
1849 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001850 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 /* Not returning. Need to check if active command list
1852 * needs to be freed
1853 */
1854 }
1855
Krunal Sonia8270f52017-02-23 19:51:25 -08001856 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001858 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
1861
1862 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1863 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001864 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301865 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 }
1867
1868 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001869 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301870 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 }
1872
1873 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1874 if (callback) {
1875 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001876 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001878 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 callback(param->status,
1880 command->u.set_dual_mac_cmd.scan_config,
1881 command->u.set_dual_mac_cmd.fw_mode_config);
1882 }
1883 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001884 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 }
1886
Krunal Soni72dba662017-02-15 20:13:17 -08001887 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 if (found)
1889 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001890 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301892 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893}
1894
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001895/**
1896 * sme_process_antenna_mode_resp() - Process set antenna mode
1897 * response
1898 * @mac: Global MAC pointer
1899 * @msg: antenna mode response
1900 *
1901 * Processes the antenna mode response and invokes the HDD
1902 * callback to process further
1903 */
1904static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1905 uint8_t *msg)
1906{
1907 tListElem *entry;
1908 tSmeCmd *command;
1909 bool found;
1910 antenna_mode_cb callback;
1911 struct sir_antenna_mode_resp *param;
1912
1913 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301914 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001915 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001916 /* Not returning. Need to check if active command list
1917 * needs to be freed
1918 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001919
Krunal Sonia8270f52017-02-23 19:51:25 -08001920 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001921 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001922 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 return QDF_STATUS_E_FAILURE;
1924 }
1925
1926 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1927 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001928 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001929 return QDF_STATUS_E_FAILURE;
1930 }
1931
1932 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001933 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001934 return QDF_STATUS_E_FAILURE;
1935 }
1936
1937 callback =
1938 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1939 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301940 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001941 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301942 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001943 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001944 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001945 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001946 }
1947
Krunal Soni72dba662017-02-15 20:13:17 -08001948 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001949 if (found)
1950 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001951 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001952
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001953 return QDF_STATUS_SUCCESS;
1954}
1955
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301956/*
1957 * sme_process_msg() - The main message processor for SME.
1958 * The function is called by a message dispatcher when to process a message
1959 * targeted for SME.
1960 * This is a synchronous call
1961 *
1962 * hHal - The handle returned by mac_open.
1963 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1964 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1965 * Other status means SME failed to process the message to HAL.
1966 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001967QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301971 struct sir_peer_info *peer_stats;
1972 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973
1974 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001975 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 return status;
1977 }
1978 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301979 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001980 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301982 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 return status;
1984 }
1985 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001986 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301988 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 goto release_lock;
1990 }
1991 switch (pMsg->type) {
1992#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1996 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301997 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 break;
1999#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 case WNI_CFG_SET_CNF:
2001 case WNI_CFG_DNLD_CNF:
2002 case WNI_CFG_GET_RSP:
2003 case WNI_CFG_ADD_GRP_ADDR_CNF:
2004 case WNI_CFG_DEL_GRP_ADDR_CNF:
2005 break;
2006 case eWNI_SME_ADDTS_RSP:
2007 case eWNI_SME_DELTS_RSP:
2008 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 /* QoS */
2011 if (pMsg->bodyptr) {
2012#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2013 status = sme_qos_msg_processor(pMac, pMsg->type,
2014 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302015 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016#endif
2017 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002018 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 }
2020 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 case eWNI_SME_NEIGHBOR_REPORT_IND:
2022 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 if (pMsg->bodyptr) {
2024 status = sme_rrm_msg_processor(pMac, pMsg->type,
2025 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302026 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302028 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 }
2030 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 case eWNI_SME_ADD_STA_SELF_RSP:
2032 if (pMsg->bodyptr) {
2033 status = csr_process_add_sta_session_rsp(pMac,
2034 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302035 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002037 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 }
2039 break;
2040 case eWNI_SME_DEL_STA_SELF_RSP:
2041 if (pMsg->bodyptr) {
2042 status = csr_process_del_sta_session_rsp(pMac,
2043 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302044 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002046 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 }
2048 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 case eWNI_SME_CHANGE_COUNTRY_CODE:
2050 if (pMsg->bodyptr) {
2051 status = sme_handle_change_country_code((void *)pMac,
2052 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002055 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 }
2057 break;
2058 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2059 if (pMsg->bodyptr) {
2060 status = sme_handle_generic_change_country_code(
2061 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302062 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002064 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 }
2066 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068#ifdef WLAN_FEATURE_11W
2069 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2070 if (pMsg->bodyptr) {
2071 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302072 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002074 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 }
2076 break;
2077#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002078#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 case eWNI_SME_TSM_IE_IND:
2080 if (pMsg->bodyptr) {
2081 sme_tsm_ie_ind(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;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002087#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2089 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2090 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302091 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002093 case eWNI_SME_IBSS_PEER_INFO_RSP:
2094 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002095 sme_ibss_peer_info_response_handler(pMac,
2096 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002097 qdf_mem_free(pMsg->bodyptr);
2098 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002099 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002100 }
2101 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 case eWNI_SME_READY_TO_SUSPEND_IND:
2103 if (pMsg->bodyptr) {
2104 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302105 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002107 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 }
2109 break;
2110#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2111 case eWNI_SME_READY_TO_EXTWOW_IND:
2112 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002113 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302114 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002116 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 }
2118 break;
2119#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2121 case eWNI_SME_AUTO_SHUTDOWN_IND:
2122 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 FL("Auto shutdown notification"));
2125 pMac->sme.pAutoShutdownNotificationCb();
2126 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 break;
2129#endif
2130 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002131 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002133 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302134 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 break;
2136 case eWNI_SME_CHANNEL_CHANGE_RSP:
2137 if (pMsg->bodyptr) {
2138 status = sme_process_channel_change_resp(pMac,
2139 pMsg->type,
2140 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302141 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002143 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 }
2145 break;
2146#ifdef WLAN_FEATURE_STATS_EXT
2147 case eWNI_SME_STATS_EXT_EVENT:
2148 if (pMsg->bodyptr) {
2149 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302150 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002152 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 }
2154 break;
2155#endif
Will Huang558f8082017-05-31 16:22:24 +08002156 case eWNI_SME_GET_PEER_INFO_IND:
2157 if (pMac->sme.pget_peer_info_ind_cb)
2158 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2159 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302160 if (pMsg->bodyptr) {
2161 peer_info_rsp = (struct sir_peer_info_resp *)
2162 (pMsg->bodyptr);
2163 peer_stats = (struct sir_peer_info *)
2164 (peer_info_rsp->info);
2165 if (peer_stats) {
2166 pMac->peer_rssi = peer_stats[0].rssi;
2167 pMac->peer_txrate = peer_stats[0].tx_rate;
2168 pMac->peer_rxrate = peer_stats[0].rx_rate;
2169 }
2170 }
Will Huang558f8082017-05-31 16:22:24 +08002171 qdf_mem_free(pMsg->bodyptr);
2172 break;
2173 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2174 if (pMac->sme.pget_peer_info_ext_ind_cb)
2175 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2176 pMac->sme.pget_peer_info_ext_cb_context);
2177 qdf_mem_free(pMsg->bodyptr);
2178 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 case eWNI_SME_CSA_OFFLOAD_EVENT:
2180 if (pMsg->bodyptr) {
2181 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302182 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 }
2184 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002185 case eWNI_SME_TSF_EVENT:
2186 if (pMac->sme.get_tsf_cb) {
2187 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2188 (struct stsf *)pMsg->bodyptr);
2189 }
2190 if (pMsg->bodyptr)
2191 qdf_mem_free(pMsg->bodyptr);
2192 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193#ifdef WLAN_FEATURE_NAN
2194 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302195 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2196 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 if (pMsg->bodyptr) {
2198 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 }
2201 break;
2202#endif /* WLAN_FEATURE_NAN */
2203 case eWNI_SME_LINK_STATUS_IND:
2204 {
2205 tAniGetLinkStatus *pLinkStatus =
2206 (tAniGetLinkStatus *) pMsg->bodyptr;
2207 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302208 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 pMac->sme.linkStatusCallback(
2210 pLinkStatus->linkStatus,
2211 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 pMac->sme.linkStatusCallback = NULL;
2214 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302215 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 }
2217 break;
2218 }
2219 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302220 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2222 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 break;
2224 case eWNI_SME_SNR_IND:
2225 {
2226 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 if (pSnrReq) {
2229 if (pSnrReq->snrCallback) {
2230 ((tCsrSnrCallback)
2231 (pSnrReq->snrCallback))
2232 (pSnrReq->snr, pSnrReq->staId,
2233 pSnrReq->pDevContext);
2234 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 }
2237 break;
2238 }
2239#ifdef FEATURE_WLAN_EXTSCAN
2240 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2241 if (pMac->sme.pExtScanIndCb)
2242 pMac->sme.pExtScanIndCb(pMac->hHdd,
2243 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2244 pMsg->bodyptr);
2245 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002246 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 pMsg->type);
2248
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302249 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 break;
2251 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2252 if (pMac->sme.pExtScanIndCb)
2253 pMac->sme.pExtScanIndCb(pMac->hHdd,
2254 eSIR_EPNO_NETWORK_FOUND_IND,
2255 pMsg->bodyptr);
2256 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002257 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 pMsg->type);
2259
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302260 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 break;
2262#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 case eWNI_SME_SET_HW_MODE_RESP:
2264 if (pMsg->bodyptr) {
2265 status = sme_process_set_hw_mode_resp(pMac,
2266 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302267 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002269 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 }
2271 break;
2272 case eWNI_SME_HW_MODE_TRANS_IND:
2273 if (pMsg->bodyptr) {
2274 status = sme_process_hw_mode_trans_ind(pMac,
2275 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302276 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002278 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 }
2280 break;
2281 case eWNI_SME_NSS_UPDATE_RSP:
2282 if (pMsg->bodyptr) {
2283 status = sme_process_nss_update_resp(pMac,
2284 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302285 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002287 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 }
2289 break;
2290 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302291 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 pMac->sme.ocb_set_config_callback(
2293 pMac->sme.ocb_set_config_context,
2294 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302295 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002296 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 pMac->sme.ocb_set_config_callback = NULL;
2298 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302299 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 break;
2301 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302302 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 pMac->sme.ocb_get_tsf_timer_callback(
2304 pMac->sme.ocb_get_tsf_timer_context,
2305 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302306 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002307 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2309 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302310 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 break;
2312 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302313 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 pMac->sme.dcc_get_stats_callback(
2315 pMac->sme.dcc_get_stats_context,
2316 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302317 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002318 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 pMac->sme.dcc_get_stats_callback = NULL;
2320 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302321 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 break;
2323 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302324 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 pMac->sme.dcc_update_ndl_callback(
2326 pMac->sme.dcc_update_ndl_context,
2327 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302328 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002329 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 pMac->sme.dcc_update_ndl_callback = NULL;
2331 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302332 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 break;
2334 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302335 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 pMac->sme.dcc_stats_event_callback(
2337 pMac->sme.dcc_stats_event_context,
2338 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302339 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002340 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302341 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 break;
2343 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2344 if (pMsg->bodyptr) {
2345 status = sme_process_dual_mac_config_resp(pMac,
2346 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302347 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002349 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 }
2351 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2352 if (pMac->sme.set_thermal_level_cb)
2353 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2354 pMsg->bodyval);
2355 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302356 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2357 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302358 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302359 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002360 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2361 if (pMsg->bodyptr) {
2362 status = sme_process_antenna_mode_resp(pMac,
2363 pMsg->bodyptr);
2364 qdf_mem_free(pMsg->bodyptr);
2365 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002366 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002367 }
2368 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002369 case eWNI_SME_NDP_CONFIRM_IND:
2370 case eWNI_SME_NDP_NEW_PEER_IND:
2371 case eWNI_SME_NDP_INITIATOR_RSP:
Abhishek Singh4fef7472016-06-06 11:36:03 -07002372 case eWNI_SME_NDP_INDICATION:
2373 case eWNI_SME_NDP_RESPONDER_RSP:
Naveen Rawatf28315c2016-06-29 18:06:02 -07002374 case eWNI_SME_NDP_END_RSP:
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07002375 case eWNI_SME_NDP_END_IND:
2376 case eWNI_SME_NDP_PEER_DEPARTED_IND:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002377 sme_ndp_msg_processor(pMac, pMsg);
2378 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302379 case eWNI_SME_LOST_LINK_INFO_IND:
2380 if (pMac->sme.lost_link_info_cb)
2381 pMac->sme.lost_link_info_cb(pMac->hHdd,
2382 (struct sir_lost_link_info *)pMsg->bodyptr);
2383 qdf_mem_free(pMsg->bodyptr);
2384 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302385 case eWNI_SME_RSO_CMD_STATUS_IND:
2386 if (pMac->sme.rso_cmd_status_cb)
2387 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002388 qdf_mem_free(pMsg->bodyptr);
2389 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002390 case eWMI_SME_LL_STATS_IND:
2391 if (pMac->sme.link_layer_stats_ext_cb)
2392 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2393 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302394 qdf_mem_free(pMsg->bodyptr);
2395 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302396 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2397 if (pMac->sme.bt_activity_info_cb)
2398 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2399 pMsg->bodyval);
2400 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 default:
2402
2403 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2404 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2405 /* CSR */
2406 if (pMsg->bodyptr) {
2407 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302408 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302409 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002410 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002412 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302414 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 }
2416 } /* switch */
2417release_lock:
2418 sme_release_global_lock(&pMac->sme);
2419 return status;
2420}
2421
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002422QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2423{
2424 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2425
2426 if (mac_ctx == NULL) {
2427 QDF_ASSERT(0);
2428 return QDF_STATUS_E_FAILURE;
2429 }
2430
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002431 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002432}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434/**
2435 * sme_process_nss_update_resp() - Process nss update response
2436 * @mac: Global MAC pointer
2437 * @msg: nss update response
2438 *
2439 * Processes the nss update response and invokes the HDD
2440 * callback to process further
2441 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302442static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443{
2444 tListElem *entry = NULL;
2445 tSmeCmd *command = NULL;
2446 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002447 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 struct sir_beacon_tx_complete_rsp *param;
2449
2450 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302451 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002452 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 /* Not returning. Need to check if active command list
2454 * needs to be freed
2455 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456
Krunal Sonia8270f52017-02-23 19:51:25 -08002457 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002459 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302460 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 }
2462
2463 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2464 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002465 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302466 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 }
2468
2469 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002470 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302471 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 }
2473
2474 callback = command->u.nss_update_cmd.nss_update_cb;
2475 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302476 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002477 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302478 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479 callback(command->u.nss_update_cmd.context,
2480 param->tx_status,
2481 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302482 command->u.nss_update_cmd.next_action,
2483 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002485 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 }
2487
Krunal Soni72dba662017-02-15 20:13:17 -08002488 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 if (found) {
2490 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002491 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002493
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302494 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495}
2496
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302497/* No need to hold the global lock here because this function can only be
2498 * called after sme_stop.
2499 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002500void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501{
2502 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302503 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302504 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 }
2506
2507}
2508
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302509/*
2510 * sme_stop() - Stop all SME modules and put them at idle state
2511 *
2512 * The function stops each module in SME, PMC, CSR, etc. . Upon
2513 * return, all modules are at idle state ready to start.
2514 * This is a synchronous call
2515 *
2516 * hHal - The handle returned by mac_open
2517 * tHalStopType - reason for stopping
2518 * Return QDF_STATUS_SUCCESS - SME is stopped.
2519 * Other status means SME is failed to stop but caller should still
2520 * consider SME is stopped.
2521 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302522QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302524 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2525 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2527
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002528 status = rrm_stop(pMac);
2529 if (!QDF_IS_STATUS_SUCCESS(status)) {
2530 sme_err("rrm_stop failed with status: %d", status);
2531 }
2532
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302534 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002535 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 fail_status = status;
2537 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302539 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
2542 pMac->sme.state = SME_STATE_STOP;
2543
2544 return status;
2545}
2546
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302547/*
2548 * sme_close() - Release all SME modules and their resources.
2549 * The function release each module in SME, PMC, CSR, etc. . Upon
2550 * return, all modules are at closed state.
2551 *
2552 * No SME APIs can be involved after smeClose except smeOpen.
2553 * smeClose must be called before mac_close.
2554 * This is a synchronous call
2555 *
2556 * hHal - The handle returned by mac_open
2557 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2558 *
2559 * Other status means SME is failed to be closed but caller still cannot
2560 * call any other SME functions except smeOpen.
2561 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302562QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302564 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2565 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2567
2568 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302569 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570
2571 /* Note: pSession will be invalid from here on, do not access */
2572 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302573 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002574 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 fail_status = status;
2576 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2578 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002580 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 fail_status = status;
2582 }
2583#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302585 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002586 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 fail_status = status;
2588 }
2589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302591 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002592 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 fail_status = status;
2594 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 free_sme_cmd_list(pMac);
2597
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302598 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302599 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302600 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302602 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
2605 pMac->sme.state = SME_STATE_STOP;
2606
2607 return status;
2608}
2609
2610/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302611 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2612 * scan list
2613 * @hal: hal context.
2614 * @bssid: bssid to be removed
2615 *
2616 * This function remove the given bssid from scan list.
2617 *
2618 * Return: QDF status.
2619 */
2620QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2621 tSirMacAddr bssid)
2622{
2623 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2624 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2625
2626 status = sme_acquire_global_lock(&mac_ctx->sme);
2627 if (QDF_IS_STATUS_SUCCESS(status)) {
2628 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2629 sme_release_global_lock(&mac_ctx->sme);
2630 }
2631
2632 return status;
2633}
2634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302636/*
2637 * sme_scan_get_result
2638 * A wrapper function to request scan results from CSR.
2639 * This is a synchronous call
2640 *
2641 * pFilter - If pFilter is NULL, all cached results are returned
2642 * phResult - an object for the result.
2643 * Return QDF_STATUS
2644 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302645QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 tCsrScanResultFilter *pFilter,
2647 tScanResultHandle *phResult)
2648{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302649 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2651
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302652 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2654 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 status = csr_scan_get_result(hHal, pFilter, phResult);
2658 sme_release_global_lock(&pMac->sme);
2659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660
2661 return status;
2662}
2663
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302664QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2665 struct qdf_mac_addr *bssid,
2666 tCsrScanResultInfo *res)
2667{
2668 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2669 QDF_STATUS status;
2670
2671 status = sme_acquire_global_lock(&mac_ctx->sme);
2672 if (QDF_IS_STATUS_SUCCESS(status)) {
2673 status = csr_scan_get_result_for_bssid(hal_handle, bssid, res);
2674 sme_release_global_lock(&mac_ctx->sme);
2675 }
2676
2677 return status;
2678}
2679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002681 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002682 * AP's channel id from
2683 * CSR by filtering the
2684 * result which matches
2685 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002686 * @profile: SAP profile
2687 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2688 * best ap from scan cache.
2689 *
2690 * This function is written to get AP's channel id from CSR by filtering
2691 * the result which matches our roam profile. This is a synchronous call.
2692 *
2693 * Return: QDF_STATUS.
2694 */
2695QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2696 tScanResultHandle *scan_cache,
2697 uint8_t *ap_chnl_id)
2698{
2699 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2700 profile,
2701 scan_cache,
2702 ap_chnl_id);
2703}
2704
2705/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2707 * channel id from CSR by filtering the
2708 * result which matches our roam profile.
2709 * @profile: SAP adapter
2710 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2711 * best ap from scan cache.
2712 *
2713 * This function is written to get AP's channel id from CSR by filtering
2714 * the result which matches our roam profile. This is a synchronous call.
2715 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302716 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002718QDF_STATUS sme_get_ap_channel_from_scan_cache(
2719 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2720 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302722 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002723 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 tCsrScanResultFilter *scan_filter = NULL;
2725 tScanResultHandle filtered_scan_result = NULL;
2726 tSirBssDescription first_ap_profile;
2727
2728 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302729 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302731 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302733 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302735 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302737 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302738 }
2739 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2740 if (NULL == profile) {
2741 scan_filter->EncryptionType.numEntries = 1;
2742 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302744 } else {
2745 /* Here is the profile we need to connect to */
2746 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 profile,
2748 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302749 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302751 if (QDF_STATUS_SUCCESS == status) {
2752 /* Save the WPS info */
2753 if (NULL != profile) {
2754 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302756 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302759 scan_filter->bWPSAssociation = 0;
2760 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302762 } else {
2763 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2764 FL("Preparing the profile filter failed"));
2765 qdf_mem_free(scan_filter);
2766 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 }
2768 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302769 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002770 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302772 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2774 &first_ap_profile);
2775 *scan_cache = filtered_scan_result;
2776 if (0 != first_ap_profile.channelId) {
2777 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302778 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302779 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 FL("Found best AP & its on chnl[%d]"),
2781 first_ap_profile.channelId);
2782 } else {
2783 /*
2784 * This means scan result is empty
2785 * so set the channel to zero, caller should
2786 * take of zero channel id case.
2787 */
2788 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302789 QDF_TRACE(QDF_MODULE_ID_SME,
2790 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302792 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 }
2794 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302797 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 }
2799 csr_free_scan_filter(mac_ctx, scan_filter);
2800 sme_release_global_lock(&mac_ctx->sme);
2801 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002804 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302805 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 return status;
2809}
2810
2811/**
2812 * sme_store_joinreq_param() - This function will pass station's join
2813 * request to store to csr.
2814 * @hal_handle: pointer to hal context.
2815 * @profile: pointer to station's roam profile.
2816 * @scan_cache: pointer to station's scan cache.
2817 * @roam_id: reference to roam_id variable being passed.
2818 * @session_id: station's session id.
2819 *
2820 * This function will pass station's join request further down to csr
2821 * to store it. this stored parameter will be used later.
2822 *
2823 * Return: true or false based on function's overall success.
2824 **/
2825bool sme_store_joinreq_param(tHalHandle hal_handle,
2826 tCsrRoamProfile *profile,
2827 tScanResultHandle scan_cache,
2828 uint32_t *roam_id,
2829 uint32_t session_id)
2830{
2831 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302832 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 bool ret_status = true;
2834
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302835 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2837 session_id, 0));
2838 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302839 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302841 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 sme_release_global_lock(&mac_ctx->sme);
2844 } else {
2845 ret_status = false;
2846 }
2847
2848 return ret_status;
2849}
2850
2851/**
2852 * sme_clear_joinreq_param() - This function will pass station's clear
2853 * the join request to csr.
2854 * @hal_handle: pointer to hal context.
2855 * @session_id: station's session id.
2856 *
2857 * This function will pass station's clear join request further down to csr
2858 * to cleanup.
2859 *
2860 * Return: true or false based on function's overall success.
2861 **/
2862bool sme_clear_joinreq_param(tHalHandle hal_handle,
2863 uint32_t session_id)
2864{
2865 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302866 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 bool ret_status = true;
2868
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302869 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2871 session_id, 0));
2872 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302873 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302875 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 sme_release_global_lock(&mac_ctx->sme);
2878 } else {
2879 ret_status = false;
2880 }
2881
2882 return ret_status;
2883}
2884
2885/**
2886 * sme_issue_stored_joinreq() - This function will issues station's stored
2887 * the join request to csr.
2888 * @hal_handle: pointer to hal context.
2889 * @roam_id: reference to roam_id variable being passed.
2890 * @session_id: station's session id.
2891 *
2892 * This function will issue station's stored join request further down to csr
2893 * to proceed forward.
2894 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302895 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302897QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 uint32_t *roam_id,
2899 uint32_t session_id)
2900{
2901 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302902 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2903 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302905 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2907 session_id, 0));
2908 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302909 if (QDF_STATUS_SUCCESS == status) {
2910 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 roam_id,
2912 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302913 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 }
2915 sme_release_global_lock(&mac_ctx->sme);
2916 } else {
2917 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302918 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 }
2920 return ret_status;
2921}
2922
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302923/*
2924 * sme_scan_flush_result() -
2925 * A wrapper function to request CSR to clear scan results.
2926 * This is a synchronous call
2927 *
2928 * Return QDF_STATUS
2929 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302930QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302932 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2934
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302935 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2937 0, 0));
2938 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302939 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 status = csr_scan_flush_result(hHal);
2941 sme_release_global_lock(&pMac->sme);
2942 }
2943
2944 return status;
2945}
2946
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302947/*
2948 * sme_filter_scan_results() -
2949 * A wrapper function to request CSR to clear scan results.
2950 * This is a synchronous call
2951 *
2952 * tHalHandle - HAL context handle
2953 * sessionId - session id
2954 * Return QDF_STATUS
2955 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302956QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302958 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2960
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302961 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2963 sessionId, 0));
2964 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302965 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 csr_scan_filter_results(pMac);
2967 sme_release_global_lock(&pMac->sme);
2968 }
2969
2970 return status;
2971}
2972
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302973QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302975 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2977
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302978 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2980 sessionId, 0));
2981 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 status = csr_scan_flush_selective_result(hHal, true);
2984 sme_release_global_lock(&pMac->sme);
2985 }
2986
2987 return status;
2988}
2989
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302990/*
2991 * sme_scan_result_get_first() -
2992 * A wrapper function to request CSR to returns the first element of
2993 * scan result.
2994 * This is a synchronous call
2995 *
2996 * hScanResult - returned from csr_scan_get_result
2997 * Return tCsrScanResultInfo * - NULL if no result
2998 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
3000 tScanResultHandle hScanResult)
3001{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303002 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3004 tCsrScanResultInfo *pRet = NULL;
3005
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303006 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3008 NO_SESSION, 0));
3009 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303010 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 pRet = csr_scan_result_get_first(pMac, hScanResult);
3012 sme_release_global_lock(&pMac->sme);
3013 }
3014
3015 return pRet;
3016}
3017
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303018/*
3019 * sme_scan_result_get_next() -
3020 * A wrapper function to request CSR to returns the next element of
3021 * scan result. It can be called without calling csr_scan_result_get_first first
3022 * This is a synchronous call
3023 *
3024 * hScanResult - returned from csr_scan_get_result
3025 * Return Null if no result or reach the end
3026 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3028 tScanResultHandle hScanResult)
3029{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303030 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3032 tCsrScanResultInfo *pRet = NULL;
3033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303035 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 pRet = csr_scan_result_get_next(pMac, hScanResult);
3037 sme_release_global_lock(&pMac->sme);
3038 }
3039
3040 return pRet;
3041}
3042
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303043/*
3044 * sme_scan_result_purge() -
3045 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3046 * in the list and free memory for each item
3047 * This is a synchronous call
3048 *
3049 * hScanResult - returned from csr_scan_get_result. hScanResult is
3050 * considered gone by
3051 * calling this function and even before this function reutrns.
3052 * Return QDF_STATUS
3053 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003054QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303056 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003057 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303059 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3061 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003062 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303063 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003064 status = csr_scan_result_purge(mac_ctx, hScanResult);
3065 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 }
3067
3068 return status;
3069}
3070
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303071/*
3072 * sme_scan_get_pmkid_candidate_list() -
3073 * A wrapper function to return the PMKID candidate list
3074 * This is a synchronous call
3075 *
3076 * pPmkidList - caller allocated buffer point to an array of
3077 * tPmkidCandidateInfo
3078 * pNumItems - pointer to a variable that has the number of
3079 * tPmkidCandidateInfo allocated when retruning, this is
3080 * either the number needed or number of items put into
3081 * pPmkidList
3082 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3083 * big enough and pNumItems
3084 * has the number of tPmkidCandidateInfo.
3085 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3086 * not sizeof(tPmkidCandidateInfo) * something
3087 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303088QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 tPmkidCandidateInfo *pPmkidList,
3090 uint32_t *pNumItems)
3091{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303092 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3094
3095 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303096 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 status =
3098 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3099 pPmkidList,
3100 pNumItems);
3101 sme_release_global_lock(&pMac->sme);
3102 }
3103
3104 return status;
3105}
3106
3107eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3108{
3109 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 return pMac->roam.configParam.phyMode;
3112}
3113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303114/*
jiadbdefb252018-01-03 14:27:06 +08003115 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303116 *
3117 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003118 * mode - channel bonding mode
3119 *
3120 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303121 */
jiadbdefb252018-01-03 14:27:06 +08003122QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123{
3124 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003125 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126
jiadbdefb252018-01-03 14:27:06 +08003127 if (!mode) {
3128 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3129 "%s: invalid mode", __func__);
3130 return QDF_STATUS_E_FAILURE;
3131 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132
jiadbdefb252018-01-03 14:27:06 +08003133 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3134 if (!smeConfig) {
3135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3136 "%s: failed to alloc smeConfig", __func__);
3137 return QDF_STATUS_E_NOMEM;
3138 }
3139
3140 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3142 "%s: sme_get_config_param failed", __func__);
3143 qdf_mem_free(smeConfig);
3144 return QDF_STATUS_E_FAILURE;
3145 }
3146
3147 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3148 qdf_mem_free(smeConfig);
3149
3150 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151}
3152
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303153/*
jiadbdefb252018-01-03 14:27:06 +08003154 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3155 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303156 *
3157 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003158 * mode - channel bonding mode
3159 *
3160 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303161 */
jiadbdefb252018-01-03 14:27:06 +08003162QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163{
3164 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003165 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166
jiadbdefb252018-01-03 14:27:06 +08003167 if (!mode) {
3168 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3169 "%s: invalid mode", __func__);
3170 return QDF_STATUS_E_FAILURE;
3171 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172
jiadbdefb252018-01-03 14:27:06 +08003173 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3174 if (!smeConfig) {
3175 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3176 "%s: failed to alloc smeConfig", __func__);
3177 return QDF_STATUS_E_NOMEM;
3178 }
3179
3180 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3181 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3182 "%s: sme_get_config_param failed", __func__);
3183 qdf_mem_free(smeConfig);
3184 return QDF_STATUS_E_FAILURE;
3185 }
3186
3187 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3188 qdf_mem_free(smeConfig);
3189
3190 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191}
3192
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303193/*
3194 * sme_roam_connect() -
3195 * A wrapper function to request CSR to inititiate an association
3196 * This is an asynchronous call.
3197 *
3198 * sessionId - the sessionId returned by sme_open_session.
3199 * pProfile - description of the network to which to connect
3200 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3201 * from csr_scan_get_result
3202 * pRoamId - to get back the request ID
3203 * Return QDF_STATUS
3204 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303205QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303208 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3210
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303211 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303212 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303214 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3219 status =
3220 csr_roam_connect(pMac, sessionId, pProfile,
3221 pRoamId);
3222 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003223 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303224 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 }
3226 sme_release_global_lock(&pMac->sme);
3227 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003228 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 }
3230
3231 return status;
3232}
3233
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303234/*
3235 * sme_set_phy_mode() -
3236 * Changes the PhyMode.
3237 *
3238 * hHal - The handle returned by mac_open.
3239 * phyMode new phyMode which is to set
3240 * Return QDF_STATUS SUCCESS.
3241 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303242QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243{
3244 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3245
3246 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303247 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 }
3251
3252 pMac->roam.configParam.phyMode = phyMode;
3253 pMac->roam.configParam.uCfgDot11Mode =
3254 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303255 pMac->roam.configParam.phyMode,
3256 pMac->roam.configParam.
3257 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303259 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260}
3261
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303262/*
3263 * sme_roam_reassoc() -
3264 * A wrapper function to request CSR to inititiate a re-association
3265 *
3266 * pProfile - can be NULL to join the currently connected AP. In that
3267 * case modProfileFields should carry the modified field(s) which could trigger
3268 * reassoc
3269 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3270 * that might need modification dynamically once STA is up & running and this
3271 * could trigger a reassoc
3272 * pRoamId - to get back the request ID
3273 * Return QDF_STATUS
3274 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 tCsrRoamProfile *pProfile,
3277 tCsrRoamModifyProfileFields modProfileFields,
3278 uint32_t *pRoamId, bool fForce)
3279{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3282
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303283 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303286 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303288 if ((NULL == pProfile) && (fForce == 1))
3289 status = csr_reassoc(pMac, sessionId,
3290 &modProfileFields, pRoamId,
3291 fForce);
3292 else
3293 status = csr_roam_reassoc(pMac, sessionId,
3294 pProfile,
3295 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 }
3299 sme_release_global_lock(&pMac->sme);
3300 }
3301
3302 return status;
3303}
3304
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303305/*
3306 * sme_roam_connect_to_last_profile() -
3307 * A wrapper function to request CSR to disconnect and reconnect with
3308 * the same profile
3309 * This is an asynchronous call.
3310 *
3311 * Return QDF_STATUS. It returns fail if currently connected
3312 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303313QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303315 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3317
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303318 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3320 sessionId, 0));
3321 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303322 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303323 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3324 status = csr_roam_connect_to_last_profile(pMac,
3325 sessionId);
3326 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303327 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 sme_release_global_lock(&pMac->sme);
3329 }
3330
3331 return status;
3332}
3333
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303334/*
3335 * sme_roam_disconnect() -
3336 * A wrapper function to request CSR to disconnect from a network
3337 * This is an asynchronous call.
3338 *
3339 * reason -- To indicate the reason for disconnecting. Currently, only
3340 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3341 * Return QDF_STATUS
3342 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 eCsrRoamDisconnectReason reason)
3345{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303346 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3348
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303349 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3351 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303353 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303354 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303356 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303357 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 sme_release_global_lock(&pMac->sme);
3359 }
3360
3361 return status;
3362}
3363
Abhishek Singhca408032016-09-13 15:26:12 +05303364/* sme_dhcp_done_ind() - send dhcp done ind
3365 * @hal: hal context
3366 * @session_id: session id
3367 *
3368 * Return: void.
3369 */
3370void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3371{
3372 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303373 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303374
3375 if (!mac_ctx)
3376 return;
3377
3378 session = CSR_GET_SESSION(mac_ctx, session_id);
3379 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003380 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303381 return;
3382 }
3383 session->dhcp_done = true;
3384}
3385
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303386/*
3387 * sme_roam_stop_bss() -
3388 * To stop BSS for Soft AP. This is an asynchronous API.
3389 *
3390 * hHal - Global structure
3391 * sessionId - sessionId of SoftAP
3392 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3393 * actual results
3394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303397 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3399
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303401 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303402 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3403 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303404 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303405 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303406 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 sme_release_global_lock(&pMac->sme);
3408 }
3409
3410 return status;
3411}
3412
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303413/**
3414 * sme_roam_disconnect_sta() - disassociate a station
3415 * @hHal: Global structure
3416 * @sessionId: SessionId of SoftAP
3417 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3418 *
3419 * To disassociate a station. This is an asynchronous API.
3420 *
3421 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3422 * be called to indicate actual result.
3423 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303424QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003425 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303427 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3429
3430 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303431 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 return status;
3433 }
3434
3435 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303436 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303437 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303439 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303440 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 sme_release_global_lock(&pMac->sme);
3443 }
3444
3445 return status;
3446}
3447
3448/**
3449 * sme_roam_deauth_sta() - deauthenticate a station
3450 * @hHal: Global structure
3451 * @sessionId: SessionId of SoftAP
3452 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3453 *
3454 * To disassociate a station. This is an asynchronous API.
3455 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303456 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 * code on error. Roam callback will be called to indicate actual
3458 * result
3459 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303460QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003461 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3465
3466 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303467 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 return status;
3469 }
3470
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303471 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303472 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3473 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303476 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 status =
3478 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3479 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303480 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303481 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 sme_release_global_lock(&pMac->sme);
3483 }
3484
3485 return status;
3486}
3487
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303488/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303489 * sme_roam_get_associated_stas() -
3490 * To probe the list of associated stations from various modules
3491 * of CORE stack.
3492 * This is an asynchronous API.
3493 *
3494 * sessionId - sessionId of SoftAP
3495 * modId - Module from whom list of associtated stations is
3496 * to be probed. If an invalid module is passed then
3497 * by default QDF_MODULE_ID_PE will be probed.
3498 * pUsrContext - Opaque HDD context
3499 * pfnSapEventCallback - Sap event callback in HDD
3500 * pAssocBuf - Caller allocated memory to be filled with associatd
3501 * stations info
3502 * Return QDF_STATUS
3503 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303504QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303505 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 void *pfnSapEventCallback,
3507 uint8_t *pAssocStasBuf)
3508{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3511
3512 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303513 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 return status;
3515 }
3516
3517 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303519 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303521 csr_roam_get_associated_stas(pMac, sessionId,
3522 modId,
3523 pUsrContext,
3524 pfnSapEventCallback,
3525 pAssocStasBuf);
3526 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303527 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 sme_release_global_lock(&pMac->sme);
3529 }
3530
3531 return status;
3532}
3533
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303534/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303535 * sme_roam_get_connect_state() -
3536 * A wrapper function to request CSR to return the current connect state
3537 * of Roaming
3538 * This is a synchronous call.
3539 *
3540 * Return QDF_STATUS
3541 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 eCsrConnectState *pState)
3544{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303545 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3547
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_state(pMac, sessionId,
3552 pState);
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
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303561/*
3562 * sme_roam_get_connect_profile() -
3563 * A wrapper function to request CSR to return the current connect
3564 * profile. Caller must call csr_roam_free_connect_profile after it is done
3565 * and before reuse for another csr_roam_get_connect_profile call.
3566 * This is a synchronous call.
3567 *
3568 * pProfile - pointer to a caller allocated structure
3569 * tCsrRoamConnectedProfile
3570 * eturn QDF_STATUS. Failure if not connected
3571 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303572QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 tCsrRoamConnectedProfile *pProfile)
3574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303575 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3577
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303578 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3580 sessionId, 0));
3581 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303583 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3584 status = csr_roam_get_connect_profile(pMac, sessionId,
3585 pProfile);
3586 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303587 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 sme_release_global_lock(&pMac->sme);
3589 }
3590
3591 return status;
3592}
3593
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003594/**
3595 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3596 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3597 *
3598 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3599 *
3600 * Return: none
3601 */
3602void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303604 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3606 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003607 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608}
3609
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303610/*
3611 * sme_roam_set_pmkid_cache() -
3612 * A wrapper function to request CSR to return the PMKID candidate list
3613 * This is a synchronous call.
3614
3615 * pPMKIDCache - caller allocated buffer point to an array of
3616 * tPmkidCacheInfo
3617 * numItems - a variable that has the number of tPmkidCacheInfo
3618 * allocated when retruning, this is either the number needed
3619 * or number of items put into pPMKIDCache
3620 * update_entire_cache - this bool value specifies if the entire pmkid
3621 * cache should be overwritten or should it be
3622 * updated entry by entry.
3623 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3624 * big enough and pNumItems has the number of
3625 * tPmkidCacheInfo.
3626 * \Note: pNumItems is a number of tPmkidCacheInfo,
3627 * not sizeof(tPmkidCacheInfo) * something
3628 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303629QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 tPmkidCacheInfo *pPMKIDCache,
3631 uint32_t numItems, bool update_entire_cache)
3632{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303633 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3635
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303636 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3638 numItems));
3639 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303641 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3642 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3643 pPMKIDCache,
3644 numItems, update_entire_cache);
3645 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303646 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 sme_release_global_lock(&pMac->sme);
3648 }
3649
3650 return status;
3651}
3652
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303653QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303654 tPmkidCacheInfo *pmksa,
3655 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303657 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303659
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303660 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303661 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3662 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303665 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303667 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303668 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303669 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 sme_release_global_lock(&pMac->sme);
3671 }
3672 return status;
3673}
3674
3675#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303676/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 * \fn sme_roam_set_psk_pmk
3678 * \brief a wrapper function to request CSR to save PSK/PMK
3679 * This is a synchronous call.
3680 * \param hHal - Global structure
3681 * \param sessionId - SME sessionId
3682 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3683 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3684 * connections. Need to pass this information to
3685 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303686 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 uint8_t *pPSK_PMK, size_t pmk_len)
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);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 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_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303699 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 return status;
3704}
3705#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303706/*
3707 * sme_roam_get_security_req_ie() -
3708 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3709 * passes to PE to JOIN request or START_BSS request
3710 * This is a synchronous call.
3711 *
3712 * pLen - caller allocated memory that has the length of pBuf as input.
3713 * Upon returned, *pLen has the needed or IE length in pBuf.
3714 * pBuf - Caller allocated memory that contain the IE field, if any,
3715 * upon return
3716 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3717 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3718 * big enough
3719 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 uint32_t *pLen, uint8_t *pBuf,
3722 eCsrSecurityType secType)
3723{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303724 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3726
3727 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303728 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303729 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3730 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3731 pLen, pBuf);
3732 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303733 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 sme_release_global_lock(&pMac->sme);
3735 }
3736
3737 return status;
3738}
3739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303740/*
3741 * sme_roam_get_security_rsp_ie() -
3742 * A wrapper function to request CSR to return the WPA or RSN or
3743 * WAPI IE from the beacon or probe rsp if connected
3744 * This is a synchronous call.
3745 *
3746 * pLen - caller allocated memory that has the length of pBuf as input.
3747 * Upon returned, *pLen has the needed or IE length in pBuf.
3748 * pBuf - Caller allocated memory that contain the IE field, if any,
3749 * upon return
3750 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3751 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3752 * big enough
3753 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303754QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 uint32_t *pLen, uint8_t *pBuf,
3756 eCsrSecurityType secType)
3757{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303758 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3760
3761 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303762 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303763 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3764 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3765 pLen, pBuf);
3766 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303767 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 sme_release_global_lock(&pMac->sme);
3769 }
3770
3771 return status;
3772
3773}
3774
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303775/*
3776 * sme_roam_get_num_pmkid_cache() -
3777 * A wrapper function to request CSR to return number of PMKID cache
3778 * entries
3779 * This is a synchronous call.
3780 *
3781 * Return uint32_t - the number of PMKID cache entries
3782 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3784{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303785 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3787 uint32_t numPmkidCache = 0;
3788
3789 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303790 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3792 numPmkidCache =
3793 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303795 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303796 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 sme_release_global_lock(&pMac->sme);
3798 }
3799
3800 return numPmkidCache;
3801}
3802
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303803/*
3804 * sme_roam_get_pmkid_cache() -
3805 * A wrapper function to request CSR to return PMKID cache from CSR
3806 * This is a synchronous call.
3807 *
3808 * pNum - caller allocated memory that has the space of the number of
3809 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3810 * needed or actually number in tPmkidCacheInfo.
3811 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3812 * any, upon return
3813 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3814 * big enough
3815 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303817 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303819 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3821
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303822 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3824 0));
3825 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303826 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303827 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3828 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303830 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303831 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832 sme_release_global_lock(&pMac->sme);
3833 }
3834
3835 return status;
3836}
3837
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303838/*
3839 * sme_get_config_param() -
3840 * A wrapper function that HDD calls to get the global settings
3841 * currently maintained by CSR.
3842 * This is a synchronous call.
3843 *
3844 * pParam - caller allocated memory
3845 * Return QDF_STATUS
3846 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303847QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303849 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3851
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303852 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3854 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003858 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 sme_release_global_lock(&pMac->sme);
3860 return status;
3861 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303862 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003863 &pMac->rrm.rrmSmeContext.rrmConfig,
3864 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303865 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 sme_release_global_lock(&pMac->sme);
3867 }
3868
3869 return status;
3870}
3871
3872/**
3873 * sme_cfg_set_int() - Sets the cfg parameter value.
3874 * @hal: Handle to hal.
3875 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003876 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 *
3878 * This function sets the string value in cfg parameter.
3879 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303880 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303882QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883{
3884 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303885 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003886
3887 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303888 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889
3890 return status;
3891}
3892
3893/**
3894 * sme_cfg_set_str() - Sets the cfg parameter string.
3895 * @hal: Handle to hal.
3896 * @cfg_id: Configuration parameter ID.
3897 * @str: Pointer to the string buffer.
3898 * @length: Length of the string.
3899 *
3900 * This function sets the string value in cfg parameter.
3901 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303902 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303904QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 uint32_t length)
3906{
3907 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303908 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909
3910 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303911 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912
3913 return status;
3914}
3915
3916/**
3917 * sme_cfg_get_int() - Gets the cfg parameter value.
3918 * @hal: Handle to hal.
3919 * @cfg_id: Configuration parameter ID.
3920 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003921 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 *
3923 * This function gets the value of the cfg parameter.
3924 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303925 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303927QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928{
3929 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303930 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931
3932 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303933 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934
3935 return status;
3936}
3937
3938/**
3939 * sme_cfg_get_str() - Gets the cfg parameter string.
3940 * @hal: Handle to hal.
3941 * @cfg_id: Configuration parameter ID.
3942 * @str: Pointer to the string buffer.
3943 * @length: Pointer to length of the string.
3944 *
3945 * This function gets the string value of the cfg parameter.
3946 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303947 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303949QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 uint32_t *length)
3951{
3952 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954
3955 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303956 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957
3958 return status;
3959}
3960
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303961/*
3962 * sme_get_modify_profile_fields() -
3963 * HDD or SME - QOS calls this function to get the current values of
3964 * connected profile fields, changing which can cause reassoc.
3965 * This function must be called after CFG is downloaded and STA is in connected
3966 * state. Also, make sure to call this function to get the current profile
3967 * fields before calling the reassoc. So that pModifyProfileFields will have
3968 * all the latest values plus the one(s) has been updated as part of reassoc
3969 * request.
3970 *
3971 * pModifyProfileFields - pointer to the connected profile fields
3972 * changing which can cause reassoc
3973 * Return QDF_STATUS
3974 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303975QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976 tCsrRoamModifyProfileFields *
3977 pModifyProfileFields)
3978{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303979 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3981
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303982 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3984 0));
3985 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303986 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303987 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3988 status = csr_get_modify_profile_fields(pMac, sessionId,
3989 pModifyProfileFields);
3990 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 sme_release_global_lock(&pMac->sme);
3993 }
3994
3995 return status;
3996}
3997
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303998/*
3999 * sme_set_dhcp_till_power_active_flag() -
4000 * Sets/Clears DHCP related flag to disable/enable auto PS
4001 *
4002 * hal - The handle returned by mac_open.
4003 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
4005{
4006 tpAniSirGlobal mac = PMAC_STRUCT(hal);
4007 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
4008
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304009 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
4011 flag));
4012 /* Set/Clear the DHCP flag which will disable/enable auto PS */
4013 ps_global_info->remain_in_power_active_till_dhcp = flag;
4014}
4015
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304016/*
4017 * sme_register11d_scan_done_callback() -
4018 * Register a routine of type csr_scan_completeCallback which is
4019 * called whenever an 11d scan is done
4020 *
4021 * hHal - The handle returned by mac_open.
4022 * callback - 11d scan complete routine to be registered
4023 * Return QDF_STATUS
4024 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304025QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304026 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304028 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4030
4031 pMac->scan.callback11dScanDone = callback;
4032
4033 return status;
4034}
4035
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304036/**
4037 * sme_deregister11d_scan_done_callback() - De-register scandone callback
4038 * @h_hal: Handler return by mac_open
4039 *
4040 * This function De-registers the scandone callback to SME
4041 *
4042 * Return: None
4043 */
4044void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
4045{
4046 tpAniSirGlobal pmac;
4047
4048 if (!h_hal) {
4049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4050 FL("hHal is not valid"));
4051 return;
4052 }
4053
4054 pmac = PMAC_STRUCT(h_hal);
4055 pmac->scan.callback11dScanDone = NULL;
4056}
4057
4058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059#ifdef FEATURE_OEM_DATA_SUPPORT
4060/**
4061 * sme_register_oem_data_rsp_callback() - Register a routine of
4062 * type send_oem_data_rsp_msg
4063 * @h_hal: Handle returned by mac_open.
4064 * @callback: Callback to send response
4065 * to oem application.
4066 *
4067 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4068 * callback function.
4069 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304070 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304072QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 sme_send_oem_data_rsp_msg callback)
4074{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304075 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4077
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004078 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079
4080 return status;
4081
4082}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304083
4084/**
4085 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4086 * @h_hal: Handler return by mac_open
4087 * This function De-registers the OEM data response callback to SME
4088 *
4089 * Return: None
4090 */
4091void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4092{
4093 tpAniSirGlobal pmac;
4094
4095 if (!h_hal) {
4096 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4097 FL("hHal is not valid"));
4098 return;
4099 }
4100 pmac = PMAC_STRUCT(h_hal);
4101
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004102 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304103}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104
4105/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004106 * sme_oem_update_capability() - update UMAC's oem related capability.
4107 * @hal: Handle returned by mac_open
4108 * @oem_cap: pointer to oem_capability
4109 *
4110 * This function updates OEM capability to UMAC. Currently RTT
4111 * related capabilities are updated. More capabilities can be
4112 * added in future.
4113 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304114 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004115 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304116QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004117 struct sme_oem_capability *cap)
4118{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304119 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004120 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4121 uint8_t *bytes;
4122
4123 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4124
4125 if (cap->ftm_rr)
4126 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4127 if (cap->lci_capability)
4128 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4129
4130 return status;
4131}
4132
4133/**
4134 * sme_oem_get_capability() - get oem capability
4135 * @hal: Handle returned by mac_open
4136 * @oem_cap: pointer to oem_capability
4137 *
4138 * This function is used to get the OEM capability from UMAC.
4139 * Currently RTT related capabilities are received. More
4140 * capabilities can be added in future.
4141 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304142 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004143 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304144QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004145 struct sme_oem_capability *cap)
4146{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304147 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004148 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4149 uint8_t *bytes;
4150
4151 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4152
4153 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4154 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4155
4156 return status;
4157}
Naveen Rawat910726a2017-03-06 11:42:51 -08004158#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004159
4160/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4162 * @hal_ctx - The handle returned by mac_open.
4163 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4164 * Used for success/failure notification by SME
4165 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4166 * back to HDD at the time of callback.
4167 * @wake_reason_ind_cb - Callback routine provided by HDD.
4168 * Used for Wake Reason Indication by SME
4169 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4170 * back to HDD at the time of callback.
4171 *
4172 * WoWLAN works on top of BMPS mode.
4173 * If the device is not in BMPS mode,
4174 * SME will will cache the information that
4175 * WOWL has been enabled and attempt to put the device
4176 * in BMPS. On entry into BMPS, SME will enable the
4177 * WOWL mode.
4178 * Note 1: If we exit BMPS mode (someone requests full power),
4179 * we will NOT resume WOWL when we go back to BMPS again.
4180 * Request for full power (while in WOWL mode) means disable
4181 * WOWL and go to full power.
4182 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4183 * On entry into BMPS, SME will give priority to UAPSD and
4184 * enable only UAPSD if both UAPSD and WOWL are required.
4185 * Currently there is no requirement or use case to support
4186 * UAPSD and WOWL at the same time.
4187 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304188 * Return: QDF_STATUS
4189 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4190 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4191 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 * WOWL after BMPS mode is entered.
4193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304194QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 void (*enter_wowl_callback_routine)(void
4196 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304197 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 void *enter_wowl_callback_context,
4199#ifdef WLAN_WAKEUP_EVENTS
4200 void (*wakeIndicationCB)(void *callback_context,
4201 tpSirWakeReasonInd
4202 wake_reason_ind),
4203 void *wakeIndicationCBContext,
4204#endif /* WLAN_WAKEUP_EVENTS */
4205 tpSirSmeWowlEnterParams wowl_enter_params,
4206 uint8_t session_id)
4207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304208 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4210 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304211
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304212 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4214
4215 /* cache the WOWL information */
4216 ps_global_info->ps_params[session_id].wowl_enter_params =
4217 *wowl_enter_params;
4218 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4219 enter_wowl_callback_routine;
4220 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4221 enter_wowl_callback_context;
4222#ifdef WLAN_WAKEUP_EVENTS
4223 /* Cache the Wake Reason Indication callback information */
4224 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4225 wakeIndicationCB;
4226 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4227 wakeIndicationCBContext;
4228#endif /* WLAN_WAKEUP_EVENTS */
4229
4230 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4231 return status;
4232}
4233/**
4234 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4235 * @hal_ctx - The handle returned by mac_open.
4236 * @wowl_exit_params - Carries info on which smesession
4237 * wowl exit is requested.
4238 *
4239 * SME will initiate exit from WoWLAN mode and device will be
4240 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304241 * Return QDF_STATUS
4242 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4243 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304245QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246 tpSirSmeWowlExitParams wowl_exit_params)
4247{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304248 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4250 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304251
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304252 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4254 session_id = wowl_exit_params->sessionId;
4255 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4256 return status;
4257}
4258
4259/**
4260 * sme_roam_set_key() - To set encryption key.
4261 * @hal: hal global context
4262 * @session_id: session id
4263 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4264 * @ptr_roam_id: Upon success return, this is the id caller can use to
4265 * identify the request in roamcallback
4266 *
4267 * This function should be called only when connected. This is an asynchronous
4268 * API.
4269 *
4270 * Return: Status of operation
4271 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304272QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4274{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304275 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4277 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304278 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4280
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304281 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 session_id, 0));
4283 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004284 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304285 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
4287 /*Once Setkey is done, we can go in BMPS */
4288 if (set_key->keyLength)
4289 ps_global_info->remain_in_power_active_till_dhcp = false;
4290
4291 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304292 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 return status;
4294
4295 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4296 if (ptr_roam_id)
4297 *ptr_roam_id = roam_id;
4298
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004299 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004301 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 session = CSR_GET_SESSION(mac_ctx, session_id);
4303 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004304 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304306 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 }
4308 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4309 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4310 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4311 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4312 set_key->encType)) {
4313 session->pCurRoamProfile->negotiatedUCEncryptionType =
4314 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4315 }
4316 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4317 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4318 set_key->encType)) {
4319 session->pCurRoamProfile->negotiatedUCEncryptionType =
4320 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4321 }
4322 }
4323 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4324 sme_release_global_lock(&mac_ctx->sme);
4325 return status;
4326}
4327
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304328/**
4329 * sme_roam_set_default_key_index - To set default wep key idx
4330 * @hal: pointer to hal handler
4331 * @session_id: session id
4332 * @default_idx: default wep key index
4333 *
4334 * This function prepares a message and post to WMA to set wep default
4335 * key index
4336 *
4337 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4338 */
4339QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4340 uint8_t default_idx)
4341{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004342 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304343 struct wep_update_default_key_idx *update_key;
4344
4345 update_key = qdf_mem_malloc(sizeof(*update_key));
4346 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004347 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304348 return QDF_STATUS_E_NOMEM;
4349 }
4350
4351 update_key->session_id = session_id;
4352 update_key->default_idx = default_idx;
4353
4354 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4355 msg.reserved = 0;
4356 msg.bodyptr = (void *)update_key;
4357
4358 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004359 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004360 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304361 qdf_mem_free(update_key);
4362 return QDF_STATUS_E_FAILURE;
4363 }
4364
4365 return QDF_STATUS_SUCCESS;
4366}
4367
4368
Jeff Johnson8bd23352017-09-26 11:39:24 -07004369/**
4370 * sme_get_rssi() - API to retrieve current RSSI
4371 * @hHal: HAL handle for device
4372 * @callback: SME sends back the requested stats using the callback
4373 * @staId: The station ID for which the RSSI is requested for
4374 * @bssid: The bssid of the connected session
4375 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4376 * RSSI, do not hold up but return this value.
4377 * @pContext: user context to be passed back along with the callback
4378 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304379 * A wrapper function that client calls to register a callback to get RSSI
4380 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004381 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304382 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304383QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304384 tCsrRssiCallback callback, uint8_t staId,
4385 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004386 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304388 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4390
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304391 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4393 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304394 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 status = csr_get_rssi(pMac, callback,
4396 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004397 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 sme_release_global_lock(&pMac->sme);
4399 }
4400 return status;
4401}
4402
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304403/*
4404 * sme_get_snr() -
4405 * A wrapper function that client calls to register a callback to get SNR
4406 *
4407 * callback - SME sends back the requested stats using the callback
4408 * staId - The station ID for which the stats is requested for
4409 * pContext - user context to be passed back along with the callback
4410 * p_cds_context - cds context
4411 * \return QDF_STATUS
4412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304415 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304417 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4419
4420 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304421 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4423 sme_release_global_lock(&pMac->sme);
4424 }
4425 return status;
4426}
4427
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304428/*
4429 * sme_get_statistics() -
4430 * A wrapper function that client calls to register a callback to get
4431 * different PHY level statistics from CSR.
4432 *
4433 * requesterId - different client requesting for statistics,
4434 * HDD, UMA/GAN etc
4435 * statsMask - The different category/categories of stats requester
4436 * is looking for
4437 * callback - SME sends back the requested stats using the callback
4438 * periodicity - If requester needs periodic update in millisec, 0 means
4439 * it's an one time request
4440 * cache - If requester is happy with cached stats
4441 * staId - The station ID for which the stats is requested for
4442 * pContext - user context to be passed back along with the callback
4443 * sessionId - sme session interface
4444 * Return QDF_STATUS
4445 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 eCsrStatsRequesterType requesterId,
4448 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004449 uint8_t staId, void *pContext, uint8_t sessionId)
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);
4453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304455 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304456 status = csr_get_statistics(pMac, requesterId, statsMask,
4457 callback, staId, pContext,
4458 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 sme_release_global_lock(&pMac->sme);
4460 }
4461
4462 return status;
4463
4464}
4465
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304466QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 tCsrLinkStatusCallback callback,
4468 void *pContext, uint8_t sessionId)
4469{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304470 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4472 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004473 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474
4475 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304477 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304479 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 "%s: Not able to allocate memory for link status",
4481 __func__);
4482 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304483 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004484 }
4485
4486 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4487 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4488 pMsg->sessionId = sessionId;
4489 pMac->sme.linkStatusContext = pContext;
4490 pMac->sme.linkStatusCallback = callback;
4491
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004492 message.type = WMA_LINK_STATUS_GET_REQ;
4493 message.bodyptr = pMsg;
4494 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304496 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004497 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4498 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304501 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 pMac->sme.linkStatusContext = NULL;
4503 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304504 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 }
4506
4507 sme_release_global_lock(&pMac->sme);
4508 }
4509
4510 return status;
4511}
4512
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304513/*
4514 * sme_get_country_code() -
4515 * To return the current country code. If no country code is applied,
4516 * default country code is used to fill the buffer.
4517 * If 11d supported is turned off, an error is return and the last
4518 * applied/default country code is used.
4519 * This is a synchronous API.
4520 *
4521 * pBuf - pointer to a caller allocated buffer for returned country code.
4522 * pbLen For input, this parameter indicates how big is the buffer.
4523 * Upon return, this parameter has the number of bytes for
4524 * country. If pBuf doesn't have enough space, this function
4525 * returns fail status and this parameter contains the number
4526 * that is needed.
4527 *
4528 * Return QDF_STATUS SUCCESS.
4529 *
4530 * FAILURE or RESOURCES The API finished and failed.
4531 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304532QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533{
4534 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4535
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304536 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4538
4539 return csr_get_country_code(pMac, pBuf, pbLen);
4540}
4541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542/* some support functions */
4543bool sme_is11d_supported(tHalHandle hHal)
4544{
4545 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4546
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004547 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548}
4549
4550bool sme_is11h_supported(tHalHandle hHal)
4551{
4552 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4553
4554 return csr_is11h_supported(pMac);
4555}
4556
4557bool sme_is_wmm_supported(tHalHandle hHal)
4558{
4559 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4560
4561 return csr_is_wmm_supported(pMac);
4562}
4563
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304564/*
4565 * sme_change_country_code() -
4566 * Change Country code from upperlayer during WLAN driver operation.
4567 * This is a synchronous API.
4568 *
4569 * hHal - The handle returned by mac_open.
4570 * pCountry New Country Code String
4571 * sendRegHint If we want to send reg hint to nl80211
4572 * Return QDF_STATUS SUCCESS.
4573 * FAILURE or RESOURCES The API finished and failed.
4574 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304575QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 tSmeChangeCountryCallback callback,
4577 uint8_t *pCountry,
4578 void *pContext,
4579 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004580 bool countryFromUserSpace,
4581 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304583 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004585 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 tAniChangeCountryCodeReq *pMsg;
4587
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304588 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4590 0));
4591 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304592 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4594 && (!pMac->roam.configParam.
4595 fSupplicantCountryCodeHasPriority)) {
4596
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004597 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598
4599 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304600 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 return status;
4602 }
4603
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304604 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004606 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304608 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 }
4610
4611 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4612 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304613 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614 pMsg->countryFromUserSpace = countryFromUserSpace;
4615 pMsg->sendRegHint = sendRegHint;
4616 pMsg->changeCCCallback = callback;
4617 pMsg->pDevContext = pContext;
4618 pMsg->p_cds_context = p_cds_context;
4619
4620 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4621 msg.bodyptr = pMsg;
4622 msg.reserved = 0;
4623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304624 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004625 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004626 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304627 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304628 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 sme_release_global_lock(&pMac->sme);
4631 }
4632
4633 return status;
4634}
4635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304636/*
4637 * sme_generic_change_country_code() -
4638 * Change Country code from upperlayer during WLAN driver operation.
4639 * This is a synchronous API.
4640 *
4641 * hHal - The handle returned by mac_open.
4642 * pCountry New Country Code String
4643 * reg_domain regulatory domain
4644 * Return QDF_STATUS SUCCESS.
4645 * FAILURE or RESOURCES The API finished and failed.
4646 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304647QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004648 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004652 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 tAniGenericChangeCountryCodeReq *pMsg;
4654
4655 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 "%s: pMac is null", __func__);
4658 return status;
4659 }
4660
4661 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304662 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304663 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664
4665 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004666 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304668 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 }
4670
4671 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4672 pMsg->msgLen =
4673 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304674 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004675 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676
4677 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4678 msg.bodyptr = pMsg;
4679 msg.reserved = 0;
4680
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304681 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004682 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004683 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304684 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304685 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 sme_release_global_lock(&pMac->sme);
4688 }
4689
4690 return status;
4691}
4692
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304693/*
4694 * sme_dhcp_start_ind() -
4695 * API to signal the FW about the DHCP Start event.
4696 *
4697 * hHal - HAL handle for device.
4698 * device_mode - mode(AP,SAP etc) of the device.
4699 * macAddr - MAC address of the adapter.
4700 * sessionId - session ID.
4701 * Return QDF_STATUS SUCCESS.
4702 * FAILURE or RESOURCES The API finished and failed.
4703 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304704QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 uint8_t device_mode,
4706 uint8_t *macAddr, uint8_t sessionId)
4707{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304708 QDF_STATUS status;
4709 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004711 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304713 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714
4715 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304716 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 pSession = CSR_GET_SESSION(pMac, sessionId);
4718
4719 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004720 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304722 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 }
Arif Hussain3316f402016-11-10 13:08:03 -08004724 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304726 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 "%s: Not able to allocate memory for dhcp start",
4730 __func__);
4731 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304732 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 }
4734 pMsg->msgType = WMA_DHCP_START_IND;
4735 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4736 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304737 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304738 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304739 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004740 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004742 message.type = WMA_DHCP_START_IND;
4743 message.bodyptr = pMsg;
4744 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304745 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004746 sessionId, message.type));
4747 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4748 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304749 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304750 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304752 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304753 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 }
4755 sme_release_global_lock(&pMac->sme);
4756 }
4757 return status;
4758}
4759
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304760/*
4761 * sme_dhcp_stop_ind() -
4762 * API to signal the FW about the DHCP complete event.
4763 *
4764 * hHal - HAL handle for device.
4765 * device_mode - mode(AP, SAP etc) of the device.
4766 * macAddr - MAC address of the adapter.
4767 * sessionId - session ID.
4768 * Return QDF_STATUS SUCCESS.
4769 * FAILURE or RESOURCES The API finished and failed.
4770 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304771QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 uint8_t device_mode,
4773 uint8_t *macAddr, uint8_t sessionId)
4774{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304775 QDF_STATUS status;
4776 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004778 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304780 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781
4782 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304783 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 pSession = CSR_GET_SESSION(pMac, sessionId);
4785
4786 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004787 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304789 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004790 }
Arif Hussain3316f402016-11-10 13:08:03 -08004791 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304793 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 "%s: Not able to allocate memory for dhcp stop",
4797 __func__);
4798 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304799 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004800 }
4801
4802 pMsg->msgType = WMA_DHCP_STOP_IND;
4803 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4804 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304805 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304806 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304807 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004808 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004809
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004810 message.type = WMA_DHCP_STOP_IND;
4811 message.bodyptr = pMsg;
4812 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304813 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004814 sessionId, message.type));
4815 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4816 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304817 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304820 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304821 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 }
4823
4824 sme_release_global_lock(&pMac->sme);
4825 }
4826 return status;
4827}
4828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304829/*
4830 * sme_TXFailMonitorStopInd() -
4831 * API to signal the FW to start monitoring TX failures
4832 *
4833 * Return QDF_STATUS SUCCESS.
4834 * FAILURE or RESOURCES The API finished and failed.
4835 */
4836QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4837 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004838 void *txFailIndCallback)
4839{
4840 QDF_STATUS status;
4841 QDF_STATUS qdf_status;
4842 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004843 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004844 tAniTXFailMonitorInd *pMsg;
4845
4846 status = sme_acquire_global_lock(&pMac->sme);
4847 if (QDF_STATUS_SUCCESS == status) {
4848 pMsg = (tAniTXFailMonitorInd *)
4849 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4850 if (NULL == pMsg) {
4851 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4852 "%s: Failed to allocate memory", __func__);
4853 sme_release_global_lock(&pMac->sme);
4854 return QDF_STATUS_E_NOMEM;
4855 }
4856
4857 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4858 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4859
4860 /* tx_fail_count = 0 should disable the Monitoring in FW */
4861 pMsg->tx_fail_count = tx_fail_count;
4862 pMsg->txFailIndCallback = txFailIndCallback;
4863
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004864 message.type = WMA_TX_FAIL_MONITOR_IND;
4865 message.bodyptr = pMsg;
4866 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004867
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004868 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4869 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004870 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4871 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4872 "%s: Post TX Fail monitor Start MSG fail",
4873 __func__);
4874 qdf_mem_free(pMsg);
4875 status = QDF_STATUS_E_FAILURE;
4876 }
4877 sme_release_global_lock(&pMac->sme);
4878 }
4879 return status;
4880}
4881
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304882/*
4883 * sme_set_cfg_privacy() -
4884 * API to set configure privacy parameters
4885 *
4886 * hHal - The handle returned by mac_open.
4887 * pProfile - Pointer CSR Roam profile.
4888 * fPrivacy - This parameter indicates status of privacy
4889 * Return void
4890 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891void sme_set_cfg_privacy(tHalHandle hHal,
4892 tCsrRoamProfile *pProfile, bool fPrivacy)
4893{
4894 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304895
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304896 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4900 sme_release_global_lock(&pMac->sme);
4901 }
4902}
4903
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304904/*
4905 * sme_neighbor_report_request() -
4906 * API to request neighbor report.
4907 *
4908 * hHal - The handle returned by mac_open.
4909 * pRrmNeighborReq - Pointer to a caller allocated object of type
4910 * tRrmNeighborReq. Caller owns the memory and is
4911 * responsible for freeing it.
4912 * Return QDF_STATUS
4913 * QDF_STATUS_E_FAILURE - failure
4914 * QDF_STATUS_SUCCESS success
4915 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304916QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304918 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304920 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304922
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304923 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4925 0));
4926
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304927 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 status =
4929 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304930 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 sme_release_global_lock(&pMac->sme);
4932 }
4933
4934 return status;
4935}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304937/*
4938 * sme_get_wcnss_wlan_compiled_version() -
4939 * This API returns the version of the WCNSS WLAN API with
4940 * which the HOST driver was built
4941 *
4942 * hHal - The handle returned by mac_open.
4943 * pVersion - Points to the Version structure to be filled
4944 * Return QDF_STATUS
4945 * QDF_STATUS_E_INVAL - failure
4946 * QDF_STATUS_SUCCESS success
4947 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304948QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 tSirVersionType *pVersion)
4950{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304951 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304954 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304956 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959
4960 sme_release_global_lock(&pMac->sme);
4961 }
4962
4963 return status;
4964}
4965
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304966/*
4967 * sme_get_wcnss_wlan_reported_version() -
4968 * This API returns the version of the WCNSS WLAN API with
4969 * which the WCNSS driver reports it was built
4970 * hHal - The handle returned by mac_open.
4971 * pVersion - Points to the Version structure to be filled
4972 * Return QDF_STATUS
4973 * QDF_STATUS_E_INVAL - failure
4974 * QDF_STATUS_SUCCESS success
4975 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304976QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977 tSirVersionType *pVersion)
4978{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304979 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4981
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304982 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304984 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304986 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004987
4988 sme_release_global_lock(&pMac->sme);
4989 }
4990
4991 return status;
4992}
4993
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304994/*
4995 * sme_get_wcnss_software_version() -
4996 * This API returns the version string of the WCNSS driver
4997 *
4998 * hHal - The handle returned by mac_open.
4999 * pVersion - Points to the Version string buffer to be filled
5000 * versionBufferSize - THe size of the Version string buffer
5001 * Return QDF_STATUS
5002 * QDF_STATUS_E_INVAL - failure
5003 * QDF_STATUS_SUCCESS success
5004 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305005QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006 uint8_t *pVersion,
5007 uint32_t versionBufferSize)
5008{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305009 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305012 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305013 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07005015 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016 pVersion,
5017 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305018 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305019 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020 sme_release_global_lock(&pMac->sme);
5021 }
5022
5023 return status;
5024}
5025
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305026/*
5027 * sme_get_wcnss_hardware_version() -
5028 * This API returns the version string of the WCNSS hardware
5029 *
5030 * hHal - The handle returned by mac_open.
5031 * pVersion - Points to the Version string buffer to be filled
5032 * versionBufferSize - THe size of the Version string buffer
5033 * Return QDF_STATUS
5034 * QDF_STATUS_E_INVAL - failure
5035 * QDF_STATUS_SUCCESS success
5036 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305037QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 uint8_t *pVersion,
5039 uint32_t versionBufferSize)
5040{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305041 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005042 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5043
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305044 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305046 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305048 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049
5050 sme_release_global_lock(&pMac->sme);
5051 }
5052
5053 return status;
5054}
5055
5056#ifdef FEATURE_WLAN_WAPI
5057
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305058/*
5059 * sme_scan_get_bkid_candidate_list() -
5060 * A wrapper function to return the BKID candidate list
5061 *
5062 * pBkidList - caller allocated buffer point to an array of
5063 * tBkidCandidateInfo
5064 * pNumItems - pointer to a variable that has the number of
5065 * tBkidCandidateInfo allocated when retruning, this is
5066 * either the number needed or number of items put into
5067 * pPmkidList
5068 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5069 * big enough and pNumItems
5070 * has the number of tBkidCandidateInfo.
5071 * Note: pNumItems is a number of tBkidCandidateInfo,
5072 * not sizeof(tBkidCandidateInfo) * something
5073 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305074QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 tBkidCandidateInfo *pBkidList,
5076 uint32_t *pNumItems)
5077{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305078 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5080
5081 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305082 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305084 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5085 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005086 sme_release_global_lock(&pMac->sme);
5087 }
5088
5089 return status;
5090}
5091#endif /* FEATURE_WLAN_WAPI */
5092
5093#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005094/**
5095 * sme_oem_data_req() - send oem data request to WMA
5096 * @hal: HAL handle
5097 * @hdd_oem_req: OEM data request from HDD
5098 *
5099 * Return: QDF_STATUS
5100 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005101QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305103 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005104 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005105 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005107 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005108 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5109 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005110 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005111 return QDF_STATUS_E_FAILURE;
5112 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005114 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5115 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005116 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005117 return QDF_STATUS_E_NOMEM;
5118 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005120 oem_data_req->data_len = hdd_oem_req->data_len;
5121 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5122 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005123 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005124 return QDF_STATUS_E_NOMEM;
5125 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005127 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5128 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005130 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305132 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005133 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305134 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005135 sme_debug("OEM request(length: %d) sent to WMA",
5136 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005137
5138 if (oem_data_req->data_len)
5139 qdf_mem_free(oem_data_req->data);
5140 qdf_mem_free(oem_data_req);
5141
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005142 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 return status;
5144}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145#endif /*FEATURE_OEM_DATA_SUPPORT */
5146
Krunal Soni8d184fa2017-11-20 21:52:05 -08005147QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148{
Arif Hussainee677012017-01-26 17:50:13 -08005149 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005150 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08005151 struct cdp_pdev *pdev;
5152 ol_txrx_peer_handle peer;
5153 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005154 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305156 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005157 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08005158 __func__, params->type_of_persona,
5159 params->sme_session_id, params->subtype_of_persona,
5160 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161
Arif Hussainee677012017-01-26 17:50:13 -08005162 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5163
5164 if (NULL == pdev) {
5165 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5166 "%s: Failed to get pdev handler", __func__);
5167 return status;
5168 }
5169
Krunal Soni8d184fa2017-11-20 21:52:05 -08005170 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005171 if (QDF_IS_STATUS_ERROR(status))
5172 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173
Krunal Soni8d184fa2017-11-20 21:52:05 -08005174 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
5175 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005176 if (peer) {
5177 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5178 "%s: Peer=%d exist with same MAC",
5179 __func__, peer_id);
5180 status = QDF_STATUS_E_INVAL;
5181 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005182 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08005183 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08005184 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005185
5186 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005187 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188
5189 return status;
5190}
5191
Krunal Soni8d184fa2017-11-20 21:52:05 -08005192QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305194 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005195 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305197 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005198 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305200 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005201 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 sme_release_global_lock(&pMac->sme);
5203 }
5204
5205 return status;
5206}
5207
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305208/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305209 * sme_change_mcc_beacon_interval() -
5210 * To update P2P-GO beaconInterval. This function should be called after
5211 * disassociating all the station is done
5212 * This is an asynchronous API.
5213 *
5214 * @sessionId: Session Identifier
5215 * Return QDF_STATUS SUCCESS
5216 * FAILURE or RESOURCES
5217 * The API finished and failed.
5218 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005219QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305221 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005222 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223
Krunal Soni3fa80e22018-01-09 14:16:02 -08005224 if (!mac_ctx) {
5225 sme_err("mac_ctx is NULL");
5226 return status;
5227 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005228 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305229 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005230 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5231 sessionId);
5232 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005233 }
5234 return status;
5235}
5236
5237/**
5238 * sme_set_host_offload(): API to set the host offload feature.
5239 * @hHal: The handle returned by mac_open.
5240 * @sessionId: Session Identifier
5241 * @request: Pointer to the offload request.
5242 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305243 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305245QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 tpSirHostOffloadReq request)
5247{
5248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305249 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305251 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5253 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305254 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255#ifdef WLAN_NS_OFFLOAD
5256 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5257 status = sme_set_ps_ns_offload(hHal, request,
5258 sessionId);
5259 } else
5260#endif /* WLAN_NS_OFFLOAD */
5261 {
5262 status = sme_set_ps_host_offload(hHal, request,
5263 sessionId);
5264 }
5265 sme_release_global_lock(&pMac->sme);
5266 }
5267
5268 return status;
5269}
5270
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305271/*
5272 * sme_set_keep_alive() -
5273 * API to set the Keep Alive feature.
5274 *
5275 * hHal - The handle returned by mac_open.
5276 * request - Pointer to the Keep Alive request.
5277 * Return QDF_STATUS
5278 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305279QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 tpSirKeepAliveReq request)
5281{
5282 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005283 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305285 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305287 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288 FL("WMA_SET_KEEP_ALIVE message"));
5289
5290 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305293 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305295 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305298 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305299 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 }
5301
Anurag Chouhanc5548422016-02-24 18:33:27 +05305302 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305305 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 "buff TP %d input TP %d ", request_buf->timePeriod,
5307 request->timePeriod);
5308 request_buf->sessionId = session_id;
5309
5310 msg.type = WMA_SET_KEEP_ALIVE;
5311 msg.reserved = 0;
5312 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305313 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5314 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305315 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005316 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305317 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305318 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305319 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305320 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 }
5322
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305323 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324}
5325
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305326/*
5327 * sme_get_operation_channel() -
5328 * API to get current channel on which STA is parked his function gives
5329 * channel information only of infra station or IBSS station
5330 *
5331 * hHal, pointer to memory location and sessionId
5332 * Returns QDF_STATUS_SUCCESS
5333 * QDF_STATUS_E_FAILURE
5334 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305335QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 uint8_t sessionId)
5337{
5338 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305339 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340
5341 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5342 pSession = CSR_GET_SESSION(pMac, sessionId);
5343
5344 if ((pSession->connectedProfile.BSSType ==
5345 eCSR_BSS_TYPE_INFRASTRUCTURE)
5346 || (pSession->connectedProfile.BSSType ==
5347 eCSR_BSS_TYPE_IBSS)
5348 || (pSession->connectedProfile.BSSType ==
5349 eCSR_BSS_TYPE_INFRA_AP)
5350 || (pSession->connectedProfile.BSSType ==
5351 eCSR_BSS_TYPE_START_IBSS)) {
5352 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305353 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 }
5355 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305356 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357} /* sme_get_operation_channel ends here */
5358
Abhishek Singh7996eb72015-12-30 17:24:02 +05305359/**
5360 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5361 * management frame indication to PE.
5362 *
5363 * @hal: hal pointer
5364 * @callback: callback pointer to be registered
5365 *
5366 * This function is used to register a callback for management
5367 * frame indication to PE.
5368 *
5369 * Return: Success if msg is posted to PE else Failure.
5370 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305371QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305372 sir_mgmt_frame_ind_callback callback)
5373{
5374 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5375 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305376 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305377
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305378 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305379 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305380 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305381 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005382 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305383 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305384 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305385 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305386 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5387 msg->length = sizeof(*msg);
5388
5389 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005390 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305391 sme_release_global_lock(&mac_ctx->sme);
5392 return status;
5393 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305394 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305395}
5396
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305397/*
5398 * sme_RegisterMgtFrame() -
5399 * To register managment frame of specified type and subtype.
5400 *
5401 * frameType - type of the frame that needs to be passed to HDD.
5402 * matchData - data which needs to be matched before passing frame
5403 * to HDD.
5404 * matchDataLen - Length of matched data.
5405 * Return QDF_STATUS
5406 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305407QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 uint16_t frameType, uint8_t *matchData,
5409 uint16_t matchLen)
5410{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305411 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305415 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 tSirRegisterMgmtFrame *pMsg;
5417 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305418 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5419 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005420
5421 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005422 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305424 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005425 }
5426
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305427 if (!CSR_IS_SESSION_ANY(sessionId) &&
5428 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305429 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 "%s Invalid Sessionid", __func__);
5431 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305432 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433 }
5434
5435 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5436
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305437 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305439 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5442 pMsg->length = len;
5443 pMsg->sessionId = sessionId;
5444 pMsg->registerFrame = true;
5445 pMsg->frameType = frameType;
5446 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305447 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005448 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 }
5450 sme_release_global_lock(&pMac->sme);
5451 }
5452 return status;
5453}
5454
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305455/*
5456 * sme_DeregisterMgtFrame() -
5457 * To De-register managment frame of specified type and subtype.
5458 *
5459 * frameType - type of the frame that needs to be passed to HDD.
5460 * matchData - data which needs to be matched before passing frame
5461 * to HDD.
5462 * matchDataLen - Length of matched data.
5463 * Return QDF_STATUS
5464 */
5465QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 uint16_t frameType, uint8_t *matchData,
5467 uint16_t matchLen)
5468{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305469 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5471
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305472 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5474 0));
5475 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305476 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 tSirRegisterMgmtFrame *pMsg;
5478 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305479 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5480 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481
5482 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005483 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305485 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 }
5487
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305488 if (!CSR_IS_SESSION_ANY(sessionId) &&
5489 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305490 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 "%s Invalid Sessionid", __func__);
5492 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305493 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 }
5495
5496 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5497
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305498 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305500 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5503 pMsg->length = len;
5504 pMsg->registerFrame = false;
5505 pMsg->frameType = frameType;
5506 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305507 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005508 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509 }
5510 sme_release_global_lock(&pMac->sme);
5511 }
5512 return status;
5513}
5514
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305515/**
5516 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5517 * @hal: The handle returned by mac_open
5518 * @session_id: session id
5519 * @buf: pointer to frame
5520 * @len: frame length
5521 *
5522 * Return: QDF_STATUS
5523 */
5524static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5525 const uint8_t *buf, uint32_t len)
5526{
5527 QDF_STATUS status = QDF_STATUS_SUCCESS;
5528 struct sir_mgmt_msg *msg;
5529 uint16_t msg_len;
5530 struct scheduler_msg sch_msg = {0};
5531
5532 sme_debug("prepares auth frame");
5533
5534 msg_len = sizeof(*msg) + len;
5535 msg = qdf_mem_malloc(msg_len);
5536 if (msg == NULL) {
5537 status = QDF_STATUS_E_NOMEM;
5538 } else {
5539 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5540 msg->msg_len = msg_len;
5541 msg->session_id = session_id;
5542 msg->data = (uint8_t *)msg + sizeof(*msg);
5543 qdf_mem_copy(msg->data, buf, len);
5544
5545 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5546 sch_msg.bodyptr = msg;
5547 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5548 }
5549 return status;
5550}
5551
5552QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5553 const uint8_t *buf, uint32_t len)
5554{
5555 QDF_STATUS status = QDF_STATUS_SUCCESS;
5556 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5557
5558 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5559 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5560
5561 status = sme_acquire_global_lock(&mac->sme);
5562 if (QDF_IS_STATUS_SUCCESS(status)) {
5563 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5564 sme_release_global_lock(&mac->sme);
5565 }
5566
5567 return status;
5568}
5569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005571/**
5572 * sme_configure_ext_wow() - configure Extr WoW
5573 * @hHal - The handle returned by mac_open.
5574 * @wlanExtParams - Depicts the wlan Ext params.
5575 * @callback - ext_wow callback to be registered.
5576 * @callback_context - ext_wow callback context
5577 *
5578 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305579 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005580 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305581QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 tpSirExtWoWParams wlanExtParams,
5583 csr_readyToExtWoWCallback callback,
5584 void *callback_context)
5585{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305586 QDF_STATUS status = QDF_STATUS_SUCCESS;
5587 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005589 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305590 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591
5592 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305593 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305595 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5597
5598 pMac->readyToExtWoWCallback = callback;
5599 pMac->readyToExtWoWContext = callback_context;
5600
5601 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305602 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603
5604 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305605 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005606 message.bodyptr = MsgPtr;
5607 message.type = WMA_WLAN_EXT_WOW;
5608 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5609 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305610 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 pMac->readyToExtWoWCallback = NULL;
5612 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305613 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305614 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 }
5616 sme_release_global_lock(&pMac->sme);
5617 } else {
5618 pMac->readyToExtWoWCallback = NULL;
5619 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305620 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 }
5622
5623 return status;
5624}
5625
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305626/*
5627 * sme_configure_app_type1_params() -
5628 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5629 *
5630 * hHal - The handle returned by mac_open.
5631 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5632 * Return QDF_STATUS
5633 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305634QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 tpSirAppType1Params wlanAppType1Params)
5636{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305637 QDF_STATUS status = QDF_STATUS_SUCCESS;
5638 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005640 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305641 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642
5643 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305644 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305646 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005647 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5648 0));
5649
5650 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305651 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305653 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005654 message.bodyptr = MsgPtr;
5655 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5656 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5657 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305658 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305659 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305660 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 }
5662 sme_release_global_lock(&pMac->sme);
5663 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305664 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 }
5666
5667 return status;
5668}
5669
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305670/*
5671 * sme_configure_app_type2_params() -
5672 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5673 *
5674 * hHal - The handle returned by mac_open.
5675 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5676 * Return QDF_STATUS
5677 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305678QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305679 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305681 QDF_STATUS status = QDF_STATUS_SUCCESS;
5682 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005684 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305685 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686
5687 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305688 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305690 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5692 0));
5693
5694 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305695 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305697 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005698 message.bodyptr = MsgPtr;
5699 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5700 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5701 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305702 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305703 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305704 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705 }
5706 sme_release_global_lock(&pMac->sme);
5707 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305708 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 }
5710
5711 return status;
5712}
5713#endif
5714
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305715/*
5716 * sme_get_infra_session_id
5717 * To get the session ID for infra session, if connected
5718 * This is a synchronous API.
5719 *
5720 * hHal - The handle returned by mac_open.
5721 * sessionid, -1 if infra session is not connected
5722 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005723int8_t sme_get_infra_session_id(tHalHandle hHal)
5724{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305725 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 int8_t sessionid = -1;
5727 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5728
5729 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305730 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731
5732 sessionid = csr_get_infra_session_id(pMac);
5733
5734 sme_release_global_lock(&pMac->sme);
5735 }
5736
5737 return sessionid;
5738}
5739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305740/*
5741 * sme_get_infra_operation_channel() -
5742 * To get the operating channel for infra session, if connected
5743 * This is a synchronous API.
5744 *
5745 * hHal - The handle returned by mac_open.
5746 * sessionId - the sessionId returned by sme_open_session.
5747 * Return operating channel, 0 if infra session is not connected
5748 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5750{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305751 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5753 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305754
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305756 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757
5758 channel = csr_get_infra_operation_channel(pMac, sessionId);
5759
5760 sme_release_global_lock(&pMac->sme);
5761 }
5762
5763 return channel;
5764}
5765
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305766/* This routine will return poerating channel on which other BSS is operating
5767 * to be used for concurrency mode. If other BSS is not up or not connected it
5768 * will return 0
5769 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5771{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305772 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5774 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305777 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005778
5779 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5781 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 sme_release_global_lock(&pMac->sme);
5783 }
5784
5785 return channel;
5786}
5787
5788#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5789uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5790 eCsrPhyMode sapPhyMode,
5791 uint8_t cc_switch_mode)
5792{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305793 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5795 uint16_t channel = 0;
5796
5797 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305798 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305800 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5801 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 cc_switch_mode);
5803 sme_release_global_lock(&pMac->sme);
5804 }
5805
5806 return channel;
5807}
5808#endif
5809
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305810/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005811 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005812 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005813 * @cb_fn: Callback function pointer
5814 * @db_ctx: Callback data
5815 *
5816 * Return: QDF_STATUS
5817 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005818QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005819 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5820{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005821 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005822 QDF_STATUS status;
5823
Manikandan Mohan976e7562016-03-15 16:33:31 -07005824 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005825 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005826 mac->sme.get_tsf_cb = cb_fn;
5827 mac->sme.get_tsf_cxt = cb_ctx;
5828 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005829 }
5830 return status;
5831}
5832
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305833/**
5834 * sme_reset_tsfcb() - Reset callback for TSF capture
5835 * @h_hal: Handler return by mac_open
5836 *
5837 * This function reset the tsf capture callback to SME
5838 *
5839 * Return: QDF_STATUS
5840 */
5841QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5842{
5843 tpAniSirGlobal mac;
5844 QDF_STATUS status;
5845
5846 if (!h_hal) {
5847 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5848 FL("h_hal is not valid"));
5849 return QDF_STATUS_E_INVAL;
5850 }
5851 mac = PMAC_STRUCT(h_hal);
5852
5853 status = sme_acquire_global_lock(&mac->sme);
5854 if (QDF_IS_STATUS_SUCCESS(status)) {
5855 mac->sme.get_tsf_cb = NULL;
5856 mac->sme.get_tsf_cxt = NULL;
5857 sme_release_global_lock(&mac->sme);
5858 }
5859 return status;
5860}
5861
Manikandan Mohan976e7562016-03-15 16:33:31 -07005862#ifdef WLAN_FEATURE_TSF
5863/*
5864 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5865 * @h_hal: Handler return by mac_open
5866 * @pinvalue: gpio pin id
5867 *
5868 * Return: QDF_STATUS
5869 */
5870QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5871{
5872 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005873 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005874 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5875
5876 status = sme_acquire_global_lock(&mac->sme);
5877 if (QDF_IS_STATUS_SUCCESS(status)) {
5878 tsf_msg.type = WMA_TSF_GPIO_PIN;
5879 tsf_msg.reserved = 0;
5880 tsf_msg.bodyval = pinvalue;
5881
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005882 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005883 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005884 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005885 status = QDF_STATUS_E_FAILURE;
5886 }
5887 sme_release_global_lock(&mac->sme);
5888 }
5889 return status;
5890}
5891#endif
5892
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005893QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 uint32_t *len)
5895{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305896 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005897 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005899 if (NULL == mac_ctx) {
5900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5901 FL("Invalid MAC context"));
5902 return QDF_STATUS_E_FAILURE;
5903 }
5904
5905 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305906 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005907 status = csr_get_cfg_valid_channels(mac_ctx,
5908 aValidChannels, len);
5909 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 }
5911
5912 return status;
5913}
5914
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005915static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5916{
5917 switch (src) {
5918 case SOURCE_CORE:
5919 return "WORLD MODE";
5920
5921 case SOURCE_DRIVER:
5922 return "BDF file";
5923
5924 case SOURCE_USERSPACE:
5925 return "user-space";
5926
5927 case SOURCE_11D:
5928 return "802.11D IEs in beacons";
5929
5930 default:
5931 return "unknown";
5932 }
5933}
5934
Amar Singhal6edf9732016-11-20 21:43:40 -08005935void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5936{
5937 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5938
5939 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005940
5941 sme_debug("Country source is %s",
5942 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005943}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305944/*
5945 * sme_handle_change_country_code() -
5946 * Change Country code, Reg Domain and channel list
5947 *
5948 * Details Country Code Priority
5949 * If Supplicant country code is priority than 11d is disabled.
5950 * If 11D is enabled, we update the country code after every scan.
5951 * Hence when Supplicant country code is priority, we don't need 11D info.
5952 * Country code from Supplicant is set as current courtry code.
5953 * User can send reset command XX (instead of country code) to reset the
5954 * country code to default values. If 11D is priority,
5955 * Than Supplicant country code code is set to default code. But 11D code
5956 * is set as current country code
5957 *
5958 * pMac - The handle returned by mac_open.
5959 * pMsgBuf - MSG Buffer
5960 * Return QDF_STATUS
5961 */
5962static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5963 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305965 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 tAniChangeCountryCodeReq *pMsg;
5967 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305968 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005969 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305971 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 /*
5973 * if the reset Supplicant country code command is triggered,
5974 * enable 11D, reset the country code and return
5975 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005976 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977 pMac->roam.configParam.Is11dSupportEnabled =
5978 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5979
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005980 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5981 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982
5983 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305984 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305985 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 default_country,
5987 WNI_CFG_COUNTRY_CODE_LEN);
5988 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305989 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 return status;
5991 }
5992 /*
5993 * Update the 11d country to default country so that when
5994 * callback is received for this default country, driver will
5995 * not disable the 11d taking it as valid country by user.
5996 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005997 sme_debug(
5998 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306000 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006001 pMsg->countryCode,
6002 WNI_CFG_COUNTRY_CODE_LEN);
6003 } else {
6004 /* if Supplicant country code has priority, disable 11d */
6005 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306006 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 }
6009
6010 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306011 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012
6013 /* Set Current Country code and Current Regulatory domain */
6014 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306015 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 /* Supplicant country code failed. So give 11D priority */
6017 pMac->roam.configParam.Is11dSupportEnabled =
6018 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006019 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 return status;
6021 }
6022
6023 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306024 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6026
6027 /* Get Domain ID from country code */
6028 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306029 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006030 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07006031 domainIdIoctl,
6032 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306033 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006034 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 return status;
6036 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306037 /* Supplicant country code is invalid, so we are on world mode
6038 * now. So give 11D chance to update
6039 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 pMac->roam.configParam.Is11dSupportEnabled =
6041 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006042 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 }
6044
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006045 if (domainIdIoctl >= REGDOMAIN_COUNT) {
6046 sme_err("Invalid regId %d", domainIdIoctl);
6047 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 } else {
6049 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
6050 /* set again if we find AP with 11d info during scan */
6051 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006052 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306053 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306054 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306055 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 sizeof(pMac->scan.countryCode11d));
6057 }
6058 }
6059
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306060 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306062 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306064 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065}
6066
6067/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006068 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 * @mac_ctx: mac global context
6070 * @msg: request msg packet
6071 *
6072 * If Supplicant country code is priority than 11d is disabled.
6073 * If 11D is enabled, we update the country code after every scan.
6074 * Hence when Supplicant country code is priority, we don't need 11D info.
6075 * Country code from Supplicant is set as current country code.
6076 *
6077 * Return: status of operation
6078 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306079static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006080sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
6081 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306083 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006084 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006085 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006087 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088
Amar Singhal6edf9732016-11-20 21:43:40 -08006089 if (SOURCE_11D != mac_ctx->reg_hint_src) {
6090 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
6091 if (user_ctry_priority)
6092 mac_ctx->roam.configParam.Is11dSupportEnabled =
6093 false;
6094 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306095 if (mac_ctx->roam.configParam.
6096 Is11dSupportEnabled &&
6097 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006099 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006100
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306101 status =
6102 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08006103 mac_ctx,
6104 mac_ctx->scan.countryCode11d,
6105 &reg_domain_id,
6106 SOURCE_11D);
6107 return QDF_STATUS_E_FAILURE;
6108 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006109 }
6110 }
6111 } else {
6112 /* if kernel gets invalid country code; it
6113 * resets the country code to world
6114 */
6115 if (('0' != msg->countryCode[0]) ||
6116 ('0' != msg->countryCode[1]))
6117 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6118 msg->countryCode,
6119 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006121
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006122 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6123 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 /* get the channels based on new cc */
6127 status = csr_get_channel_and_power_list(mac_ctx);
6128
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306129 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006130 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 return status;
6132 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 /* reset info based on new cc, and we are done */
6135 csr_apply_channel_power_info_wrapper(mac_ctx);
6136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006137 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006138
6139 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 * Country IE
6141 */
6142 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006143
Amar Singhal6edf9732016-11-20 21:43:40 -08006144 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306148 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149}
6150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151static bool
6152sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6153{
6154 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306155 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 ch_lst_info = &mac_ctx->scan.base_channels;
6158 for (i = 0; i < ch_lst_info->numChannels; i++) {
6159 if (ch_lst_info->channelList[i] == curr_ch)
6160 return true;
6161 }
6162
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 return false;
6164}
6165/**
6166 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6167 * if channel is not supported
6168 * @mac_ctx: mac global context
6169 *
6170 * If new country code does not support the channel on which STA/P2P client
6171 * is connetced, it sends the disconnect to the AP/P2P GO
6172 *
6173 * Return: void
6174 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306175static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176{
6177 uint8_t session_id, found = false;
6178 uint8_t curr_ch;
6179
6180 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6181 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6182 continue;
6183 found = false;
6184 /* Session is connected.Check the channel */
6185 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6186 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006187 sme_debug("Current Operating channel : %d, session :%d",
6188 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6190 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006191 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 csr_roam_disconnect(mac_ctx, session_id,
6193 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6194 }
6195 }
6196}
6197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306199QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006200 tpSirRcvFltMcAddrList pMulticastAddrs)
6201{
6202 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006203 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306205 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6208 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006210 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006211
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006212 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006213 pSession = CSR_GET_SESSION(pMac, sessionId);
6214 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6215 (!csr_is_conn_state_infra(pMac, sessionId) &&
6216 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306217 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006218 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306220 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006221 }
6222
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306223 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306226 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306228 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 }
6230
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006231 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6232 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306233 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006234 "%s: Request ignored, session %d is not connected or started",
6235 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306236 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306237 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 }
6239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306240 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006241 sizeof(tSirRcvFltMcAddrList));
6242
Anurag Chouhanc5548422016-02-24 18:33:27 +05306243 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6244 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006245 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006246
6247 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6248 msg.reserved = 0;
6249 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306250 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6251 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006252 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006253 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306254 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306255 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306257 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306258 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 }
6260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306261 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263#endif /* WLAN_FEATURE_PACKET_FILTERING */
6264
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306265/*
6266 * sme_is_channel_valid() -
6267 * To check if the channel is valid for currently established domain
6268 * This is a synchronous API.
6269 *
6270 * hHal - The handle returned by mac_open.
6271 * channel - channel to verify
6272 * Return true/false, true if channel is valid
6273 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6275{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306276 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006277 bool valid = false;
6278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6279
6280 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306281 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282
6283 valid = csr_roam_is_channel_valid(pMac, channel);
6284
6285 sme_release_global_lock(&pMac->sme);
6286 }
6287
6288 return valid;
6289}
6290
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306291/*
6292 * sme_set_freq_band() -
6293 * Used to set frequency band.
6294 *
6295 * hHal
6296 * sessionId - Session Identifier
6297 * band value to be configured
6298 * Return QDF_STATUS
6299 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006300QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
6301 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306303 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6305
6306 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306307 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006308 status = csr_set_band(hHal, sessionId, eBand);
6309 sme_release_global_lock(&pMac->sme);
6310 }
6311 return status;
6312}
6313
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306314/*
6315 * sme_get_freq_band() -
6316 * Used to get the current band settings.
6317 *
6318 * hHal
6319 * pBand pointer to hold band value
6320 * Return QDF_STATUS
6321 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006322QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306324 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006325 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6326
6327 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306328 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006329 *pBand = csr_get_current_band(hHal);
6330 sme_release_global_lock(&pMac->sme);
6331 }
6332 return status;
6333}
6334
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306335/*
6336 * sme_set_max_tx_power_per_band() -
6337 * Set the Maximum Transmit Power specific to band dynamically.
6338 * Note: this setting will not persist over reboots.
6339 *
6340 * band
6341 * power to set in dB
6342 * Return QDF_STATUS
6343 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006344QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006345{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006346 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006347 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6348
6349 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306350 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006351 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306352 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006353 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6354 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306355 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 }
6357
6358 pMaxTxPowerPerBandParams->power = dB;
6359 pMaxTxPowerPerBandParams->bandInfo = band;
6360
6361 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6362 msg.reserved = 0;
6363 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306364 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6365 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006366 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006367 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306368 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6370 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306371 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306372 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006373 }
6374
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306375 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376}
6377
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306378/*
6379 * sme_set_max_tx_power() -
6380 * Set the Maximum Transmit Power dynamically. Note: this setting will
6381 * not persist over reboots.
6382 *
6383 * hHal
6384 * pBssid BSSID to set the power cap for
6385 * pBssid pSelfMacAddress self MAC Address
6386 * pBssid power to set in dB
6387 * Return QDF_STATUS
6388 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306389QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6390 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006391{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006392 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006393 tpMaxTxPowerParams pMaxTxParams = NULL;
6394
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306395 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006396 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306397 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306399 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 "%s: Not able to allocate memory for pMaxTxParams",
6401 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306402 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006403 }
6404
Anurag Chouhanc5548422016-02-24 18:33:27 +05306405 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6406 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006407 pMaxTxParams->power = dB;
6408
6409 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6410 msg.reserved = 0;
6411 msg.bodyptr = pMaxTxParams;
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: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6417 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306418 qdf_mem_free(pMaxTxParams);
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
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306425/*
6426 * sme_set_custom_mac_addr() -
6427 * Set the customer Mac Address.
6428 *
6429 * customMacAddr customer MAC Address
6430 * Return QDF_STATUS
6431 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306432QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006434 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006435 tSirMacAddr *pBaseMacAddr;
6436
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306437 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006438 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306439 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306441 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006442 }
6443
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306444 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006445
6446 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6447 msg.reserved = 0;
6448 msg.bodyptr = pBaseMacAddr;
6449
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006450 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006451 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306452 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306453 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306454 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306455 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456 }
6457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306458 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006459}
6460
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306461/*
6462 * sme_set_tx_power() -
6463 * Set Transmit Power dynamically.
6464 *
6465 * hHal
6466 * sessionId Target Session ID
6467 * BSSID
6468 * dev_mode dev_mode such as station, P2PGO, SAP
6469 * dBm power to set
6470 * Return QDF_STATUS
6471 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306472QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306473 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006474 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006476 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 tpMaxTxPowerParams pTxParams = NULL;
6478 int8_t power = (int8_t) dBm;
6479
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306480 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006481 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6482
6483 /* make sure there is no overflow */
6484 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306485 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306487 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006488 }
6489
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306490 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306492 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006493 "%s: Not able to allocate memory for pTxParams",
6494 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306495 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006496 }
6497
Anurag Chouhanc5548422016-02-24 18:33:27 +05306498 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006499 pTxParams->power = power; /* unit is dBm */
6500 pTxParams->dev_mode = dev_mode;
6501 msg.type = WMA_SET_TX_POWER_REQ;
6502 msg.reserved = 0;
6503 msg.bodyptr = pTxParams;
6504
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006505 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006506 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306507 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006508 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6509 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306510 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306511 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006512 }
6513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306514 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515}
6516
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306517QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6518 uint8_t param_val)
6519{
6520 QDF_STATUS status;
6521 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6522
6523 pMac->roam.configParam.is_fils_enabled = !param_val;
6524
6525 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6526 status = wma_cli_set_command((int)session_id,
6527 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6528 !param_val, VDEV_CMD);
6529 if (status)
6530 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6531 "%s: Failed to set enable bcast probe setting",
6532 __func__);
6533
6534 return status;
6535}
6536
6537QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306538 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306540 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306541 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006542 uint16_t len;
6543
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306544 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306545 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306546 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306547 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6548 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306550 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006551 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306552 sme_release_global_lock(&mac_ctx->sme);
6553 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554 }
6555
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306556 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6557 mac_ctx->ignore_assoc_disallowed = param_val;
6558
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306559 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306560 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006561
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306562 len = sizeof(*msg);
6563 msg = qdf_mem_malloc(len);
6564 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306565 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306567 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6568 msg->length = len;
6569 msg->session_id = session_id;
6570 msg->param_type = param_type;
6571 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006572 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006573 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306574 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006575 }
6576 return status;
6577}
6578
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306579/*
6580 * sme_set_tm_level() -
6581 * Set Thermal Mitigation Level to RIVA
6582 *
6583 * hHal - The handle returned by mac_open.
6584 * newTMLevel - new Thermal Mitigation Level
6585 * tmMode - Thermal Mitigation handle mode, default 0
6586 * Return QDF_STATUS
6587 */
6588QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6589 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006590{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306591 QDF_STATUS status = QDF_STATUS_SUCCESS;
6592 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006593 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006594 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595 tAniSetTmLevelReq *setTmLevelReq = NULL;
6596
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306597 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6599 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306600 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006601 setTmLevelReq =
6602 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306603 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006604 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306605 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606 "%s: Not able to allocate memory for sme_set_tm_level",
6607 __func__);
6608 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306609 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006610 }
6611
6612 setTmLevelReq->tmMode = tmMode;
6613 setTmLevelReq->newTmLevel = newTMLevel;
6614
6615 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006616 message.bodyptr = setTmLevelReq;
6617 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306618 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006619 NO_SESSION, message.type));
6620 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6621 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306622 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306623 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006624 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306625 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306626 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 }
6628 sme_release_global_lock(&pMac->sme);
6629 }
6630 return status;
6631}
6632
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306633/*
6634 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6635 * Host and FW.
6636 *
6637 * hHal - HAL handle for device
6638 * Return NONE
6639 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006640void sme_feature_caps_exchange(tHalHandle hHal)
6641{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306642 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306643 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6644 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645}
6646
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306647/*
6648 * sme_disable_feature_capablity() - SME interface to disable Active mode
6649 * offload capablity in Host.
6650 *
6651 * hHal - HAL handle for device
6652 * Return NONE
6653 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006654void sme_disable_feature_capablity(uint8_t feature_index)
6655{
6656}
6657
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306658/*
6659 * sme_reset_power_values_for5_g
6660 * Reset the power values for 5G band with default power values.
6661 *
6662 * hHal - HAL handle for device
6663 * Return NONE
6664 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665void sme_reset_power_values_for5_g(tHalHandle hHal)
6666{
6667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306668
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306669 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6671 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306672 /* Store the channel+power info in the global place: Cfg */
6673 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674}
6675
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306676/*
6677 * sme_update_roam_prefer5_g_hz() -
6678 * Enable/disable Roam prefer 5G runtime option
6679 * This function is called through dynamic setConfig callback function
6680 * to configure the Roam prefer 5G runtime option
6681 *
6682 * hHal - HAL handle for device
6683 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6684 * Return Success or failure
6685 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006686
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306687QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6688 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689{
6690 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306691 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306693 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006694 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6695 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306696 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306697 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006698 "%s: gRoamPrefer5GHz is changed from %d to %d",
6699 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6700 nRoamPrefer5GHz);
6701 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6702 sme_release_global_lock(&pMac->sme);
6703 }
6704
6705 return status;
6706}
6707
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306708/*
6709 * sme_set_roam_intra_band() -
6710 * enable/disable Intra band roaming
6711 * This function is called through dynamic setConfig callback function
6712 * to configure the intra band roaming
6713 * hHal - HAL handle for device
6714 * nRoamIntraBand Enable/Disable Intra band roaming
6715 * Return Success or failure
6716 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306717QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718{
6719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306720 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006721
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306722 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6724 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306725 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306726 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727 "%s: gRoamIntraBand is changed from %d to %d",
6728 __func__, pMac->roam.configParam.nRoamIntraBand,
6729 nRoamIntraBand);
6730 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6731 sme_release_global_lock(&pMac->sme);
6732 }
6733
6734 return status;
6735}
6736
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306737/*
6738 * sme_update_roam_scan_n_probes() -
6739 * Function to update roam scan N probes
6740 * This function is called through dynamic setConfig callback function
6741 * to update roam scan N probes
6742 * hHal - HAL handle for device
6743 * sessionId - Session Identifier
6744 * nProbes number of probe requests to be sent out
6745 * Return Success or failure
6746 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306747QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 const uint8_t nProbes)
6749{
6750 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306751 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006752
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306753 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006754 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6755 NO_SESSION, 0));
6756 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306757 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006759 "%s: gRoamScanNProbes is changed from %d to %d",
6760 __func__, pMac->roam.configParam.nProbes, nProbes);
6761 pMac->roam.configParam.nProbes = nProbes;
6762 sme_release_global_lock(&pMac->sme);
6763 }
6764 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6765 csr_roam_offload_scan(pMac, sessionId,
6766 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6767 REASON_NPROBES_CHANGED);
6768 }
6769 return status;
6770}
6771
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306772/*
6773 * sme_update_roam_scan_home_away_time() -
6774 * Function to update roam scan Home away time
6775 * This function is called through dynamic setConfig callback function
6776 * to update roam scan home away time
6777 *
6778 * hHal - HAL handle for device
6779 * sessionId - Session Identifier
6780 * nRoamScanAwayTime Scan home away time
6781 * bSendOffloadCmd If true then send offload command to firmware
6782 * If false then command is not sent to firmware
6783 * Return Success or failure
6784 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306785QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306787 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788 const bool bSendOffloadCmd)
6789{
6790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306791 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006792
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306793 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6795 NO_SESSION, 0));
6796 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306797 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6800 __func__,
6801 pMac->roam.configParam.nRoamScanHomeAwayTime,
6802 nRoamScanHomeAwayTime);
6803 pMac->roam.configParam.nRoamScanHomeAwayTime =
6804 nRoamScanHomeAwayTime;
6805 sme_release_global_lock(&pMac->sme);
6806 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306807 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6808 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 csr_roam_offload_scan(pMac, sessionId,
6810 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6811 REASON_HOME_AWAY_TIME_CHANGED);
6812 }
6813 return status;
6814}
6815
Abhishek Singh518323d2015-10-19 17:42:01 +05306816/**
6817 * sme_ext_change_channel()- function to post send ECSA
6818 * action frame to csr.
6819 * @hHal: Hal context
6820 * @channel: new channel to switch
6821 * @session_id: senssion it should be sent on.
6822 *
6823 * This function is called to post ECSA frame to csr.
6824 *
6825 * Return: success if msg is sent else return failure
6826 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306827QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306828 uint8_t session_id)
6829{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306830 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306831 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6832 uint8_t channel_state;
6833
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006834 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306835 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006836 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306837
6838 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006839 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306840 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306841 }
6842
6843 status = sme_acquire_global_lock(&mac_ctx->sme);
6844
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306845 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306846 /* update the channel list to the firmware */
6847 status = csr_send_ext_change_channel(mac_ctx,
6848 channel, session_id);
6849 sme_release_global_lock(&mac_ctx->sme);
6850 }
6851
6852 return status;
6853}
6854
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306855/*
6856 * sme_get_roam_intra_band() -
6857 * get Intra band roaming
6858 *
6859 * hHal - HAL handle for device
6860 * Return Success or failure
6861 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862bool sme_get_roam_intra_band(tHalHandle hHal)
6863{
6864 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306865
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306866 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006867 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6868 return pMac->roam.configParam.nRoamIntraBand;
6869}
6870
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306871/*
6872 * sme_get_roam_scan_n_probes() -
6873 * get N Probes
6874 *
6875 * hHal - HAL handle for device
6876 * Return Success or failure
6877 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006878uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6879{
6880 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306881
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006882 return pMac->roam.configParam.nProbes;
6883}
6884
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306885/*
6886 * sme_get_roam_scan_home_away_time() -
6887 * get Roam scan home away time
6888 *
6889 * hHal - HAL handle for device
6890 * Return Success or failure
6891 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006892uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6893{
6894 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006896 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6897}
6898
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306899/*
6900 * sme_update_roam_rssi_diff() -
6901 * Update RoamRssiDiff
6902 * This function is called through dynamic setConfig callback function
6903 * to configure RoamRssiDiff
6904 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6905 *
6906 * hHal - HAL handle for device
6907 * sessionId - Session Identifier
6908 * RoamRssiDiff - minimum rssi difference between potential
6909 * candidate and current AP.
6910 * Return Success or failure
6911 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006912
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306913QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006914 uint8_t RoamRssiDiff)
6915{
6916 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306917 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006919 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6920 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6921 FL("Invalid sme session id: %d"), sessionId);
6922 return QDF_STATUS_E_INVAL;
6923 }
6924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006925 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306926 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306927 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006928 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6929 RoamRssiDiff,
6930 pMac->roam.configParam.RoamRssiDiff,
6931 mac_trace_get_neighbour_roam_state(pMac->roam.
6932 neighborRoamInfo
6933 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306934 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6936 sme_release_global_lock(&pMac->sme);
6937 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006938
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306939 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006940 csr_roam_offload_scan(pMac, sessionId,
6941 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6942 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 return status;
6944}
6945
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306946#ifdef WLAN_FEATURE_FILS_SK
6947QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6948 tCsrRoamProfile *src_profile)
6949{
6950 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6951 QDF_STATUS status = QDF_STATUS_SUCCESS;
6952 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6953 &mac->roam.neighborRoamInfo[session_id];
6954
6955 if (session_id >= CSR_ROAM_SESSION_MAX) {
6956 sme_err("Invalid sme session id: %d", session_id);
6957 return QDF_STATUS_E_INVAL;
6958 }
6959
6960 if (!src_profile) {
6961 sme_err("src roam profile NULL");
6962 return QDF_STATUS_E_INVAL;
6963 }
6964
6965 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6966 (neighbor_roam_info->neighborRoamState !=
6967 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6968 sme_info("Fast roam is disabled or not connected(%d)",
6969 neighbor_roam_info->neighborRoamState);
6970 return QDF_STATUS_E_PERM;
6971 }
6972
6973 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306974 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306975 sme_debug("Updating fils config to fw");
6976 csr_roam_offload_scan(mac, session_id,
6977 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6978 REASON_FILS_PARAMS_CHANGED);
6979 } else {
6980 sme_info("LFR3 not enabled");
6981 return QDF_STATUS_E_INVAL;
6982 }
6983
6984 return status;
6985}
6986
6987void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6988 tCsrRoamProfile *profile, uint32_t if_addr)
6989{
6990 int i;
6991 struct scheduler_msg msg;
6992 QDF_STATUS status;
6993 struct hlp_params *params;
6994 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6995 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6996 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6997 &mac->roam.neighborRoamInfo[session_id];
6998
6999 if (!session) {
7000 sme_err("session NULL");
7001 return;
7002 }
7003
7004 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
7005 (neighbor_roam_info->neighborRoamState !=
7006 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
7007 sme_debug("Fast roam is disabled or not connected(%d)",
7008 neighbor_roam_info->neighborRoamState);
7009 return;
7010 }
7011
7012 params = qdf_mem_malloc(sizeof(*params));
7013 if (!params) {
7014 sme_err("Mem alloc for HLP IE fails");
7015 return;
7016 }
7017 if ((profile->hlp_ie_len +
7018 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
7019 sme_err("HLP IE len exceeds %d",
7020 profile->hlp_ie_len);
7021 qdf_mem_free(params);
7022 return;
7023 }
7024
7025 params->vdev_id = session_id;
7026 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
7027
7028 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
7029 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
7030
7031 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
7032 profile->hlp_ie, profile->hlp_ie_len);
7033
7034 msg.type = SIR_HAL_HLP_IE_INFO;
7035 msg.reserved = 0;
7036 msg.bodyptr = params;
7037 status = sme_acquire_global_lock(&mac->sme);
7038 if (status != QDF_STATUS_SUCCESS) {
7039 sme_err("sme lock acquire fails");
7040 qdf_mem_free(params);
7041 return;
7042 }
7043
7044 if (!QDF_IS_STATUS_SUCCESS
7045 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
7046 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
7047 sme_release_global_lock(&mac->sme);
7048 qdf_mem_free(params);
7049 return;
7050 }
7051
7052 sme_release_global_lock(&mac->sme);
7053}
7054
Jeff Johnson172237b2017-11-07 15:32:59 -08007055void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05307056{
7057 struct fils_join_rsp_params *roam_fils_params;
7058
7059 if (!roam_info) {
7060 sme_err("FILS Roam Info NULL");
7061 return;
7062 }
7063
7064 roam_fils_params = roam_info->fils_join_rsp;
7065 if (!roam_fils_params) {
7066 sme_err("FILS Roam Param NULL");
7067 return;
7068 }
7069
7070 if (roam_fils_params->fils_pmk)
7071 qdf_mem_free(roam_fils_params->fils_pmk);
7072
7073 qdf_mem_free(roam_fils_params);
7074
7075 roam_info->fils_join_rsp = NULL;
7076}
7077
7078#else
7079inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
7080 tCsrRoamProfile *profile, uint32_t if_addr)
7081{}
7082#endif
7083
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307084/*
7085 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
7086 * support at runtime
7087 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7088 * isFastTransitionEnabled.
7089 * This is a synchronous call
7090 *
7091 * hHal - The handle returned by mac_open.
7092 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7093 * successfully.
7094 * Other status means SME is failed to update isFastTransitionEnabled.
7095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307096QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 bool isFastTransitionEnabled)
7098{
7099 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307100 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007101
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307102 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007103 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7104 0));
7105 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307106 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307107 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007108 "%s: FastTransitionEnabled is changed from %d to %d",
7109 __func__,
7110 pMac->roam.configParam.isFastTransitionEnabled,
7111 isFastTransitionEnabled);
7112 pMac->roam.configParam.isFastTransitionEnabled =
7113 isFastTransitionEnabled;
7114 sme_release_global_lock(&pMac->sme);
7115 }
7116
7117 return status;
7118}
7119
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307120/*
7121 * sme_update_wes_mode() -
7122 * Update WES Mode
7123 * This function is called through dynamic setConfig callback function
7124 * to configure isWESModeEnabled
7125 *
7126 * hHal - HAL handle for device
7127 * isWESModeEnabled - WES mode
7128 * sessionId - Session Identifier
7129 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7130 * Other status means SME is failed to update isWESModeEnabled.
7131 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307133QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007134 uint8_t sessionId)
7135{
7136 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307137 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007138
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007139 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7140 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7141 FL("Invalid sme session id: %d"), sessionId);
7142 return QDF_STATUS_E_INVAL;
7143 }
7144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007145 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307146 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307147 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007148 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7149 isWESModeEnabled,
7150 pMac->roam.configParam.isWESModeEnabled,
7151 mac_trace_get_neighbour_roam_state(pMac->roam.
7152 neighborRoamInfo
7153 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307154 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7156 sme_release_global_lock(&pMac->sme);
7157 }
7158
7159 return status;
7160}
7161
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307162/*
7163 * sme_set_roam_scan_control() -
7164 * Set roam scan control
7165 * This function is called to set roam scan control
7166 * if roam scan control is set to 0, roaming scan cache is cleared
7167 * any value other than 0 is treated as invalid value
7168 * hHal - HAL handle for device
7169 * sessionId - Session Identifier
7170 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7171 * Other status means SME failure to update
7172 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307173QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007174 bool roamScanControl)
7175{
7176 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307177 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007178
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307179 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007180 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007181
7182 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7183 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7184 FL("Invalid sme session id: %d"), sessionId);
7185 return QDF_STATUS_E_INVAL;
7186 }
7187
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307189 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307190 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7192 roamScanControl,
7193 pMac->roam.configParam.nRoamScanControl,
7194 mac_trace_get_neighbour_roam_state(pMac->roam.
7195 neighborRoamInfo
7196 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307197 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7199 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307200 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307202 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7203 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007204 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7205 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307206 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7207 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 }
7209 }
7210 sme_release_global_lock(&pMac->sme);
7211 }
7212 return status;
7213}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007214
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307215/*
7216 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7217 * support at runtime
7218 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7219 * isFastRoamIniFeatureEnabled.
7220 * This is a synchronous call
7221 *
7222 * hHal - The handle returned by mac_open.
7223 * sessionId - Session Identifier
7224 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7225 * successfully.
7226 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7227 */
7228QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7229 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7230{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007231 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7232
7233 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7234 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307235 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7237 __func__,
7238 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7239 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307240 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007241 }
7242
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307243 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007244 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7245 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7246 isFastRoamIniFeatureEnabled);
7247 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7248 isFastRoamIniFeatureEnabled;
7249 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307250 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307252 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253}
7254
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307255/**
7256 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7257 * @hal - The handle returned by macOpen.
7258 * @session_id - Session Identifier
7259 * @is_fast_roam_enabled - flag to enable/disable roaming
7260 *
7261 * When Supplicant issues enabled/disable fast roaming on the basis
7262 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7263 *
7264 * Return: QDF_STATUS
7265 */
7266
7267QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7268 const bool is_fast_roam_enabled)
7269{
7270 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307271 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307272 QDF_STATUS status;
7273
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007274 /*
7275 * supplicant_disabled_roaming flag is set to true in
7276 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7277 * request with BSSID. This flag is reset when supplicant sends
7278 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007279 *
7280 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007281 * if roaming is disabled using driver command or INI and
7282 * supplicant_disabled_roaming flag remains set. So make sure to set
7283 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7284 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007285 */
7286 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007287 session->pCurRoamProfile->supplicant_disabled_roaming =
7288 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007289
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307290 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007291 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307292 if (!is_fast_roam_enabled)
7293 return QDF_STATUS_SUCCESS;
7294 return QDF_STATUS_E_FAILURE;
7295 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307296
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307297 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7298 session_id, is_fast_roam_enabled);
7299 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007300 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307301 return QDF_STATUS_E_FAILURE;
7302 }
7303
7304 return QDF_STATUS_SUCCESS;
7305}
7306
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307307/*
7308 * sme_update_is_mawc_ini_feature_enabled() -
7309 * Enable/disable LFR MAWC support at runtime
7310 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7311 * isMAWCIniFeatureEnabled.
7312 * This is a synchronous call
7313 *
7314 * hHal - The handle returned by mac_open.
7315 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7316 * Other status means SME is failed to update MAWCEnabled.
7317 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307318QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319 const bool MAWCEnabled)
7320{
7321 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307322 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007323
7324 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307325 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007327 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007328 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7329 MAWCEnabled);
7330 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7331 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332 sme_release_global_lock(&pMac->sme);
7333 }
7334
7335 return status;
7336
7337}
7338
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007339/**
7340 * sme_stop_roaming() - Stop roaming for a given sessionId
7341 * This is a synchronous call
7342 *
7343 * @hHal - The handle returned by mac_open
7344 * @sessionId - Session Identifier
7345 *
7346 * Return QDF_STATUS_SUCCESS on success
7347 * Other status on failure
7348 */
7349QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007350{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007351 struct scheduler_msg wma_msg = {0};
7352 tSirRetStatus status;
7353 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007354 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7355 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007356 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007357
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007358 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007359 sme_err("incorrect session/vdev ID");
7360 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007362
7363 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05307364
7365 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
7366 if (!roam_info->b_roam_scan_offload_started) {
7367 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007368 return QDF_STATUS_SUCCESS;
7369 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007370 req = qdf_mem_malloc(sizeof(*req));
7371 if (!req) {
7372 sme_err("failed to allocated memory");
7373 return QDF_STATUS_E_NOMEM;
7374 }
7375
7376 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307377 if (reason == eCsrForcedDisassoc)
7378 req->reason = REASON_ROAM_STOP_ALL;
7379 else
7380 req->reason = REASON_ROAM_SYNCH_FAILED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007381 req->sessionId = session_id;
7382 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007383 req->middle_of_roaming = 1;
7384 else
7385 csr_roam_reset_roam_params(mac_ctx);
7386
7387 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7388 wma_msg.bodyptr = req;
7389
7390 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7391 if (eSIR_SUCCESS != status) {
7392 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007393 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007394 qdf_mem_free(req);
7395 return QDF_STATUS_E_FAULT;
7396 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007397 roam_info->b_roam_scan_offload_started = false;
7398 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007399
7400 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007401}
7402
Abhishek Singhd5686472017-09-20 15:18:50 +05307403void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7404{
7405 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7406 QDF_STATUS status = QDF_STATUS_SUCCESS;
7407 struct csr_roam_session *session;
7408
7409 status = sme_acquire_global_lock(&mac_ctx->sme);
7410 if (QDF_IS_STATUS_SUCCESS(status)) {
7411 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7412 session = CSR_GET_SESSION(mac_ctx, session_id);
7413 if (session)
7414 session->discon_in_progress = true;
7415 }
7416 sme_release_global_lock(&mac_ctx->sme);
7417 }
7418}
7419
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307420/*
7421 * sme_start_roaming() - Start roaming for a given sessionId
7422 * This is a synchronous call
7423 *
7424 * hHal - The handle returned by mac_open
7425 * sessionId - Session Identifier
7426 * Return QDF_STATUS_SUCCESS on success
7427 * Other status on failure
7428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307429QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430{
7431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307432 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433
7434 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307435 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007436 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7437 reason);
7438 sme_release_global_lock(&pMac->sme);
7439 }
7440
7441 return status;
7442}
7443
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307444/*
7445 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7446 * Concurrent session exists
7447 * This is a synchronuous call
7448 *
7449 * hHal - The handle returned by mac_open.
7450 * Return QDF_STATUS_SUCCESS
7451 * Other status means SME is failed
7452 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307453QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307455 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456{
7457
7458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307459 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007460
7461 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307462 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007463 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7464 bFastRoamInConIniFeatureEnabled;
7465 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7466 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7467 0;
7468 }
7469 sme_release_global_lock(&pMac->sme);
7470 }
7471
7472 return status;
7473}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307475/*
7476 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7477 * Monitoring at runtime
7478 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7479 * fEnableFwRssiMonitoring.
7480 * This is a synchronous call
7481 *
7482 * hHal - The handle returned by mac_open.
7483 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7484 * config successfully.
7485 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7486 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307487QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007488 bool fEnableFwRssiMonitoring)
7489{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307490 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491
7492 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307493 fEnableFwRssiMonitoring) ==
7494 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307495 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7498 }
7499
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307500 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501}
7502
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307503/*
7504 * sme_set_roam_opportunistic_scan_threshold_diff() -
7505 * Update Opportunistic Scan threshold diff
7506 * This function is called through dynamic setConfig callback function
7507 * to configure nOpportunisticThresholdDiff
7508 *
7509 * hHal - HAL handle for device
7510 * sessionId - Session Identifier
7511 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7512 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7513 * successfully.
7514 * else SME is failed to update nOpportunisticThresholdDiff.
7515 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307516QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007517 uint8_t sessionId,
7518 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307519 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520{
7521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307522 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523
7524 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307525 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007526 status = csr_neighbor_roam_update_config(pMac, sessionId,
7527 nOpportunisticThresholdDiff,
7528 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307529 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007530 pMac->roam.configParam.neighborRoamConfig.
7531 nOpportunisticThresholdDiff =
7532 nOpportunisticThresholdDiff;
7533 }
7534 sme_release_global_lock(&pMac->sme);
7535 }
7536 return status;
7537}
7538
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307539/*
7540 * sme_get_roam_opportunistic_scan_threshold_diff()
7541 * gets Opportunistic Scan threshold diff
7542 * This is a synchronous call
7543 *
7544 * hHal - The handle returned by mac_open
7545 * Return uint8_t - nOpportunisticThresholdDiff
7546 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007547uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7548{
7549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551 return pMac->roam.configParam.neighborRoamConfig.
7552 nOpportunisticThresholdDiff;
7553}
7554
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307555/*
7556 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7557 * This function is called through dynamic setConfig callback function
7558 * to configure nRoamRescanRssiDiff
7559 *
7560 * hHal - HAL handle for device
7561 * sessionId - Session Identifier
7562 * nRoamRescanRssiDiff - roam rescan rssi diff
7563 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7564 * successfully.
7565 * else SME is failed to update nRoamRescanRssiDiff.
7566 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307567QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007568 uint8_t sessionId,
7569 const uint8_t nRoamRescanRssiDiff)
7570{
7571 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307572 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007573
7574 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307575 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007576 status = csr_neighbor_roam_update_config(pMac, sessionId,
7577 nRoamRescanRssiDiff,
7578 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307579 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007580 pMac->roam.configParam.neighborRoamConfig.
7581 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7582 }
7583 sme_release_global_lock(&pMac->sme);
7584 }
7585 return status;
7586}
7587
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307588/*
7589 * sme_get_roam_rescan_rssi_diff()
7590 * gets roam rescan rssi diff
7591 * This is a synchronous call
7592 *
7593 * hHal - The handle returned by mac_open
7594 * Return int8_t - nRoamRescanRssiDiff
7595 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007596uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7597{
7598 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007600 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7601}
7602
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307603/*
7604 * sme_set_roam_bmiss_first_bcnt() -
7605 * Update Roam count for first beacon miss
7606 * This function is called through dynamic setConfig callback function
7607 * to configure nRoamBmissFirstBcnt
7608 * hHal - HAL handle for device
7609 * sessionId - Session Identifier
7610 * nRoamBmissFirstBcnt - Roam first bmiss count
7611 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7612 * successfully.
7613 * else SME is failed to update nRoamBmissFirstBcnt
7614 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307615QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616 uint8_t sessionId,
7617 const uint8_t nRoamBmissFirstBcnt)
7618{
7619 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307620 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007621
7622 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307623 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007624 status = csr_neighbor_roam_update_config(pMac, sessionId,
7625 nRoamBmissFirstBcnt,
7626 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307627 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007628 pMac->roam.configParam.neighborRoamConfig.
7629 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7630 }
7631 sme_release_global_lock(&pMac->sme);
7632 }
7633 return status;
7634}
7635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307636/*
7637 * sme_get_roam_bmiss_first_bcnt() -
7638 * get neighbor roam beacon miss first count
7639 *
7640 * hHal - The handle returned by mac_open.
7641 * Return uint8_t - neighbor roam beacon miss first count
7642 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007643uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7644{
7645 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007647 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7648}
7649
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307650/*
7651 * sme_set_roam_bmiss_final_bcnt() -
7652 * Update Roam count for final beacon miss
7653 * This function is called through dynamic setConfig callback function
7654 * to configure nRoamBmissFinalBcnt
7655 * hHal - HAL handle for device
7656 * sessionId - Session Identifier
7657 * nRoamBmissFinalBcnt - Roam final bmiss count
7658 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7659 * successfully.
7660 * else SME is failed to update nRoamBmissFinalBcnt
7661 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307662QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007663 uint8_t sessionId,
7664 const uint8_t nRoamBmissFinalBcnt)
7665{
7666 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307667 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007668
7669 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307670 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007671 status = csr_neighbor_roam_update_config(pMac, sessionId,
7672 nRoamBmissFinalBcnt,
7673 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307674 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007675 pMac->roam.configParam.neighborRoamConfig.
7676 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7677 }
7678 sme_release_global_lock(&pMac->sme);
7679 }
7680 return status;
7681}
7682
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307683/*
7684 * sme_get_roam_bmiss_final_bcnt() -
7685 * gets Roam count for final beacon miss
7686 * This is a synchronous call
7687 *
7688 * hHal - The handle returned by mac_open
7689 * Return uint8_t - nRoamBmissFinalBcnt
7690 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007691uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7692{
7693 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7696}
7697
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307698/*
7699 * sme_set_roam_beacon_rssi_weight() -
7700 * Update Roam beacon rssi weight
7701 * This function is called through dynamic setConfig callback function
7702 * to configure nRoamBeaconRssiWeight
7703 *
7704 * hHal - HAL handle for device
7705 * sessionId - Session Identifier
7706 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7707 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7708 * successfully.
7709 * else SME is failed to update nRoamBeaconRssiWeight
7710 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307711QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712 uint8_t sessionId,
7713 const uint8_t nRoamBeaconRssiWeight)
7714{
7715 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307716 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007717
7718 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307719 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007720 status = csr_neighbor_roam_update_config(pMac, sessionId,
7721 nRoamBeaconRssiWeight,
7722 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307723 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007724 pMac->roam.configParam.neighborRoamConfig.
7725 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7726 }
7727 sme_release_global_lock(&pMac->sme);
7728 }
7729 return status;
7730}
7731
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307732/*
7733 * sme_get_roam_beacon_rssi_weight() -
7734 * gets Roam beacon rssi weight
7735 * This is a synchronous call
7736 *
7737 * hHal - The handle returned by mac_open
7738 * Return uint8_t - nRoamBeaconRssiWeight
7739 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007740uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7741{
7742 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007744 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7745}
7746
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307747/*
7748 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7749 * rssi threshold
7750 * This is a synchronous call
7751 *
7752 * hHal - The handle returned by mac_open.
7753 * sessionId - Session Identifier
7754 * Return QDF_STATUS_SUCCESS - SME update config successful.
7755 * Other status means SME is failed to update
7756 */
7757QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7758 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7759{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007760 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307761 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762
7763 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307764 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007765 status = csr_neighbor_roam_update_config(pMac,
7766 sessionId, neighborLookupRssiThreshold,
7767 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307768 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007769 pMac->roam.configParam.neighborRoamConfig.
7770 nNeighborLookupRssiThreshold =
7771 neighborLookupRssiThreshold;
7772 }
7773 sme_release_global_lock(&pMac->sme);
7774 }
7775 return status;
7776}
7777
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307778/*
7779 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7780 * This is a synchronous call
7781 *
7782 * hal - The handle returned by macOpen.
7783 * session_id - Session Identifier
7784 * delay_before_vdev_stop - value to be set
7785 * Return QDF_STATUS_SUCCESS - SME update config successful.
7786 * Other status means SME is failed to update
7787 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307788QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007789 uint8_t session_id,
7790 uint8_t delay_before_vdev_stop)
7791{
7792 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307793 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007794
7795 if (session_id >= CSR_ROAM_SESSION_MAX) {
7796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7797 FL("Invalid sme session id: %d"), session_id);
7798 return QDF_STATUS_E_INVAL;
7799 }
7800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307802 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7804 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 pMac->roam.configParam.neighborRoamConfig.
7806 delay_before_vdev_stop,
7807 delay_before_vdev_stop);
7808 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7809 delay_before_vdev_stop = delay_before_vdev_stop;
7810 pMac->roam.configParam.neighborRoamConfig.
7811 delay_before_vdev_stop = delay_before_vdev_stop;
7812 sme_release_global_lock(&pMac->sme);
7813 }
7814 return status;
7815}
7816
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307817/*
7818 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7819 * rssi threshold
7820 * This is a synchronous call
7821 *
7822 * hHal - The handle returned by mac_open.
7823 * Return QDF_STATUS_SUCCESS - SME update config successful.
7824 * Other status means SME is failed to update
7825 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7827{
7828 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007830 return pMac->roam.configParam.neighborRoamConfig.
7831 nNeighborLookupRssiThreshold;
7832}
7833
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307834/*
7835 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7836 * refresh period
7837 * This is a synchronous call
7838 *
7839 * hHal - The handle returned by mac_open.
7840 * sessionId - Session Identifier
7841 * Return QDF_STATUS_SUCCESS - SME update config successful.
7842 * Other status means SME is failed to update
7843 */
7844QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7845 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7846{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307848 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307849 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7851
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007852 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7853 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7854 FL("Invalid sme session id: %d"), sessionId);
7855 return QDF_STATUS_E_INVAL;
7856 }
7857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007858 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307859 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007860 pNeighborRoamConfig =
7861 &pMac->roam.configParam.neighborRoamConfig;
7862 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7865 neighborScanResultsRefreshPeriod,
7866 pMac->roam.configParam.neighborRoamConfig.
7867 nNeighborResultsRefreshPeriod,
7868 mac_trace_get_neighbour_roam_state(pMac->roam.
7869 neighborRoamInfo
7870 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307871 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007872 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7873 neighborScanResultsRefreshPeriod;
7874 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7875 neighborScanResultsRefreshPeriod;
7876
7877 sme_release_global_lock(&pMac->sme);
7878 }
7879 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7880 csr_roam_offload_scan(pMac, sessionId,
7881 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307882 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007883 }
7884 return status;
7885}
7886
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307887/*
7888 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7889 * offload feaure
7890 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7891 * gRoamScanOffloadEnabled.
7892 * This is a synchronous call
7893 *
7894 * hHal - The handle returned by mac_open.
7895 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7896 * Other status means SME is failed to update.
7897 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307898QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007899 bool nRoamScanOffloadEnabled)
7900{
7901 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307902 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007903
7904 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307905 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307906 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307907 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007908 pMac->roam.configParam.isRoamOffloadScanEnabled,
7909 nRoamScanOffloadEnabled);
7910 pMac->roam.configParam.isRoamOffloadScanEnabled =
7911 nRoamScanOffloadEnabled;
7912 sme_release_global_lock(&pMac->sme);
7913 }
7914
7915 return status;
7916}
7917
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307918/*
7919 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7920 * refresh period
7921 * This is a synchronous call
7922 *
7923 * \param hHal - The handle returned by mac_open.
7924 * \return uint16_t - Neighbor scan results refresh period value
7925 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007926uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7927{
7928 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007930 return pMac->roam.configParam.neighborRoamConfig.
7931 nNeighborResultsRefreshPeriod;
7932}
7933
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307934/*
7935 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7936 * This is a synchronuous call
7937 *
7938 * hHal - The handle returned by mac_open.
7939 * Return QDF_STATUS_SUCCESS - SME update config successful.
7940 * Other status means SME is failed to update
7941 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007942uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7943{
7944 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946 return pMac->roam.configParam.neighborRoamConfig.
7947 nEmptyScanRefreshPeriod;
7948}
7949
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307950/*
7951 * sme_update_empty_scan_refresh_period
7952 * Update nEmptyScanRefreshPeriod
7953 * This function is called through dynamic setConfig callback function
7954 * to configure nEmptyScanRefreshPeriod
7955 * Usage: adb shell iwpriv wlan0 setConfig
7956 * nEmptyScanRefreshPeriod=[0 .. 60]
7957 *
7958 * hHal - HAL handle for device
7959 * sessionId - Session Identifier
7960 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7961 * Return Success or failure
7962 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307964QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7965 sessionId, uint16_t
7966 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967{
7968 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307969 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307970 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7972
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007973 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7975 FL("Invalid sme session id: %d"), sessionId);
7976 return QDF_STATUS_E_INVAL;
7977 }
7978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307980 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 pNeighborRoamConfig =
7982 &pMac->roam.configParam.neighborRoamConfig;
7983 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307984 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007985 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7986 nEmptyScanRefreshPeriod,
7987 pMac->roam.configParam.neighborRoamConfig.
7988 nEmptyScanRefreshPeriod,
7989 mac_trace_get_neighbour_roam_state(pMac->roam.
7990 neighborRoamInfo
7991 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307992 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7994 nEmptyScanRefreshPeriod;
7995 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7996 nEmptyScanRefreshPeriod;
7997 sme_release_global_lock(&pMac->sme);
7998 }
7999 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8000 csr_roam_offload_scan(pMac, sessionId,
8001 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8002 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
8003 }
8004 return status;
8005}
8006
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308007/*
8008 * sme_set_neighbor_scan_min_chan_time() -
8009 * Update nNeighborScanMinChanTime
8010 * This function is called through dynamic setConfig callback function
8011 * to configure gNeighborScanChannelMinTime
8012 * Usage: adb shell iwpriv wlan0 setConfig
8013 * gNeighborScanChannelMinTime=[0 .. 60]
8014 *
8015 * hHal - HAL handle for device
8016 * nNeighborScanMinChanTime - Channel minimum dwell time
8017 * sessionId - Session Identifier
8018 * Return Success or failure
8019 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308020QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008021 const uint16_t
8022 nNeighborScanMinChanTime,
8023 uint8_t sessionId)
8024{
8025 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308026 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008028 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8029 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8030 FL("Invalid sme session id: %d"), sessionId);
8031 return QDF_STATUS_E_INVAL;
8032 }
8033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008034 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308035 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308036 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
8038 nNeighborScanMinChanTime,
8039 pMac->roam.configParam.neighborRoamConfig.
8040 nNeighborScanMinChanTime,
8041 mac_trace_get_neighbour_roam_state(pMac->roam.
8042 neighborRoamInfo
8043 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308044 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045
8046 pMac->roam.configParam.neighborRoamConfig.
8047 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
8048 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8049 minChannelScanTime = nNeighborScanMinChanTime;
8050 sme_release_global_lock(&pMac->sme);
8051 }
8052
8053 return status;
8054}
8055
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308056/*
8057 * sme_set_neighbor_scan_max_chan_time() -
8058 * Update nNeighborScanMaxChanTime
8059 * This function is called through dynamic setConfig callback function
8060 * to configure gNeighborScanChannelMaxTime
8061 * Usage: adb shell iwpriv wlan0 setConfig
8062 * gNeighborScanChannelMaxTime=[0 .. 60]
8063 *
8064 * hHal - HAL handle for device
8065 * sessionId - Session Identifier
8066 * nNeighborScanMinChanTime - Channel maximum dwell time
8067 * Return Success or failure
8068 */
8069QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
8070 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 const uint16_t
8072 nNeighborScanMaxChanTime)
8073{
8074 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308075 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308076 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8078
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008079 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8080 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8081 FL("Invalid sme session id: %d"), sessionId);
8082 return QDF_STATUS_E_INVAL;
8083 }
8084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308086 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008087 pNeighborRoamConfig =
8088 &pMac->roam.configParam.neighborRoamConfig;
8089 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308090 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8092 nNeighborScanMaxChanTime,
8093 pMac->roam.configParam.neighborRoamConfig.
8094 nNeighborScanMaxChanTime,
8095 mac_trace_get_neighbour_roam_state(pMac->roam.
8096 neighborRoamInfo
8097 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308098 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008099 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8100 nNeighborScanMaxChanTime;
8101 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8102 nNeighborScanMaxChanTime;
8103 sme_release_global_lock(&pMac->sme);
8104 }
8105 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8106 csr_roam_offload_scan(pMac, sessionId,
8107 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8108 REASON_SCAN_CH_TIME_CHANGED);
8109 }
8110
8111 return status;
8112}
8113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308114/*
8115 * sme_get_neighbor_scan_min_chan_time() -
8116 * get neighbor scan min channel time
8117 *
8118 * hHal - The handle returned by mac_open.
8119 * sessionId - Session Identifier
8120 * Return uint16_t - channel min time value
8121 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8123{
8124 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008125
8126 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8127 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8128 FL("Invalid sme session id: %d"), sessionId);
8129 return 0;
8130 }
8131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008132 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8133 minChannelScanTime;
8134}
8135
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308136/*
8137 * sme_get_neighbor_roam_state() -
8138 * get neighbor roam state
8139 *
8140 * hHal - The handle returned by mac_open.
8141 * sessionId - Session Identifier
8142 * Return uint32_t - neighbor roam state
8143 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8145{
8146 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008147
8148 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8149 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8150 FL("Invalid sme session id: %d"), sessionId);
8151 return 0;
8152 }
8153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8155}
8156
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308157/*
8158 * sme_get_current_roam_state() -
8159 * get current roam state
8160 *
8161 * hHal - The handle returned by mac_open.
8162 * sessionId - Session Identifier
8163 * Return uint32_t - current roam state
8164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8166{
8167 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008169 return pMac->roam.curState[sessionId];
8170}
8171
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308172/*
8173 * sme_get_current_roam_sub_state() -
8174 * \brief get neighbor roam sub state
8175 *
8176 * hHal - The handle returned by mac_open.
8177 * sessionId - Session Identifier
8178 * Return uint32_t - current roam sub state
8179 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8181{
8182 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008184 return pMac->roam.curSubState[sessionId];
8185}
8186
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308187/*
8188 * sme_get_lim_sme_state() -
8189 * get Lim Sme state
8190 *
8191 * hHal - The handle returned by mac_open.
8192 * Return uint32_t - Lim Sme state
8193 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008194uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8195{
8196 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 return pMac->lim.gLimSmeState;
8199}
8200
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308201/*
8202 * sme_get_lim_mlm_state() -
8203 * get Lim Mlm state
8204 *
8205 * hHal - The handle returned by mac_open.
8206 * Return uint32_t - Lim Mlm state
8207 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008208uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8209{
8210 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008212 return pMac->lim.gLimMlmState;
8213}
8214
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308215/*
8216 * sme_is_lim_session_valid() -
8217 * is Lim session valid
8218 *
8219 * hHal - The handle returned by mac_open.
8220 * sessionId - Session Identifier
8221 * Return bool - true or false
8222 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8224{
8225 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308226
8227 if (sessionId > pMac->lim.maxBssId)
8228 return false;
8229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008230 return pMac->lim.gpSession[sessionId].valid;
8231}
8232
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308233/*
8234 * sme_get_lim_sme_session_state() -
8235 * get Lim Sme session state
8236 *
8237 * hHal - The handle returned by mac_open.
8238 * sessionId - Session Identifier
8239 * Return uint32_t - Lim Sme session state
8240 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008241uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8242{
8243 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308244
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008245 return pMac->lim.gpSession[sessionId].limSmeState;
8246}
8247
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308248/*
8249 * sme_get_lim_mlm_session_state() -
8250 * \brief get Lim Mlm session state
8251 *
8252 * hHal - The handle returned by mac_open.
8253 * sessionId - Session Identifier
8254 * Return uint32_t - Lim Mlm session state
8255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008256uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8257{
8258 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008260 return pMac->lim.gpSession[sessionId].limMlmState;
8261}
8262
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308263/*
8264 * sme_get_neighbor_scan_max_chan_time() -
8265 * get neighbor scan max channel time
8266 *
8267 * hHal - The handle returned by mac_open.
8268 * sessionId - Session Identifier
8269 * Return uint16_t - channel max time value
8270 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008271uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8272{
8273 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008274
8275 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8276 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8277 FL("Invalid sme session id: %d"), sessionId);
8278 return 0;
8279 }
8280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008281 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8282 maxChannelScanTime;
8283}
8284
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308285/*
8286 * sme_set_neighbor_scan_period() -
8287 * Update nNeighborScanPeriod
8288 * This function is called through dynamic setConfig callback function
8289 * to configure nNeighborScanPeriod
8290 * Usage: adb shell iwpriv wlan0 setConfig
8291 * nNeighborScanPeriod=[0 .. 1000]
8292 *
8293 * hHal - HAL handle for device
8294 * sessionId - Session Identifier
8295 * nNeighborScanPeriod - neighbor scan period
8296 * Return Success or failure
8297 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308298QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008299 const uint16_t nNeighborScanPeriod)
8300{
8301 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308302 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308303 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008304 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8305
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008306 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8308 FL("Invalid sme session id: %d"), sessionId);
8309 return QDF_STATUS_E_INVAL;
8310 }
8311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008312 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308313 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008314 pNeighborRoamConfig =
8315 &pMac->roam.configParam.neighborRoamConfig;
8316 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308317 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308318 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008319 nNeighborScanPeriod,
8320 pMac->roam.configParam.neighborRoamConfig.
8321 nNeighborScanTimerPeriod,
8322 mac_trace_get_neighbour_roam_state(pMac->roam.
8323 neighborRoamInfo
8324 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308325 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008326 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8327 nNeighborScanPeriod;
8328 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8329 nNeighborScanPeriod;
8330 sme_release_global_lock(&pMac->sme);
8331 }
8332 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8333 csr_roam_offload_scan(pMac, sessionId,
8334 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8335 REASON_SCAN_HOME_TIME_CHANGED);
8336 }
8337
8338 return status;
8339}
8340
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308341/*
8342 * sme_get_neighbor_scan_period() -
8343 * get neighbor scan period
8344 *
8345 * hHal - The handle returned by mac_open.
8346 * sessionId - Session Identifier
8347 * Return uint16_t - neighbor scan period
8348 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008349uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8350{
8351 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008352
8353 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8354 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8355 FL("Invalid sme session id: %d"), sessionId);
8356 return 0;
8357 }
8358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008359 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8360 neighborScanPeriod;
8361}
8362
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308363/**
8364 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8365 * This function is called through dynamic setConfig callback function
8366 * to configure neighbor_scan_min_period
8367 *
8368 * @hal - HAL handle for device
8369 * @session_id - Session Identifier
8370 * @neighbor_scan_min_period - neighbor scan min period
8371 *
8372 * Return - QDF_STATUS
8373 */
8374QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8375 uint8_t session_id,
8376 const uint16_t
8377 neighbor_scan_min_period)
8378{
8379 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8380 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308381 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308382 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008383
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308384 if (session_id >= CSR_ROAM_SESSION_MAX) {
8385 sme_err("Invalid sme session id: %d", session_id);
8386 return QDF_STATUS_E_INVAL;
8387 }
8388
8389 status = sme_acquire_global_lock(&pmac->sme);
8390 if (QDF_IS_STATUS_SUCCESS(status)) {
8391 p_neighbor_roam_config =
8392 &pmac->roam.configParam.neighborRoamConfig;
8393 p_neighbor_roam_info = &pmac->
8394 roam.neighborRoamInfo[session_id];
8395 sme_debug("LFR:set neighbor scan min period, old:%d, "
8396 "new: %d, state: %s",
8397 pmac->roam.configParam.neighborRoamConfig.
8398 neighbor_scan_min_timer_period,
8399 neighbor_scan_min_period,
8400 mac_trace_get_neighbour_roam_state(pmac->roam.
8401 neighborRoamInfo[session_id].
8402 neighborRoamState));
8403 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8404 neighbor_scan_min_period;
8405 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8406 neighbor_scan_min_period;
8407 sme_release_global_lock(&pmac->sme);
8408 }
8409
8410 return status;
8411}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308413/*
8414 * sme_get_roam_rssi_diff() - get Roam rssi diff
8415 * This is a synchronous call
8416 *
8417 * hHal - The handle returned by mac_open.
8418 * Return uint16_t - Rssi diff value
8419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008420uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8421{
8422 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424 return pMac->roam.configParam.RoamRssiDiff;
8425}
8426
8427/**
8428 * sme_change_roam_scan_channel_list() - to change scan channel list
8429 * @hHal: pointer HAL handle returned by mac_open
8430 * @sessionId: sme session id
8431 * @pChannelList: Output channel list
8432 * @numChannels: Output number of channels
8433 *
8434 * This routine is called to Change roam scan channel list.
8435 * This is a synchronous call
8436 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308437 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008438 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308439QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008440 uint8_t *pChannelList,
8441 uint8_t numChannels)
8442{
8443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308444 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008445 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8447 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8448 uint8_t i = 0, j = 0;
8449 tCsrChannelInfo *chan_info;
8450
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008451 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8452 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8453 FL("Invalid sme session id: %d"), sessionId);
8454 return QDF_STATUS_E_INVAL;
8455 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008457 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008458 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308459 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8461 csr_roam_offload_scan(pMac, sessionId,
8462 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8463 REASON_CHANNEL_LIST_CHANGED);
8464 return status;
8465 }
8466 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8467
8468 if (NULL != chan_info->ChannelList) {
8469 for (i = 0; i < chan_info->numOfChannels; i++) {
8470 if (j < sizeof(oldChannelList))
8471 j += snprintf(oldChannelList + j,
8472 sizeof(oldChannelList) -
8473 j, "%d",
8474 chan_info->ChannelList[i]);
8475 else
8476 break;
8477 }
8478 }
8479 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8480 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8481 numChannels);
8482 sme_set_roam_scan_control(hHal, sessionId, 1);
8483 if (NULL != chan_info->ChannelList) {
8484 j = 0;
8485 for (i = 0; i < chan_info->numOfChannels; i++) {
8486 if (j < sizeof(newChannelList))
8487 j += snprintf(newChannelList + j,
8488 sizeof(newChannelList) -
8489 j, " %d",
8490 chan_info->ChannelList[i]);
8491 else
8492 break;
8493 }
8494 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308495 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308496 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008497 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308498 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008499 sme_release_global_lock(&pMac->sme);
8500
8501 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8502 csr_roam_offload_scan(pMac, sessionId,
8503 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8504 REASON_CHANNEL_LIST_CHANGED);
8505 return status;
8506}
8507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008508/**
8509 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8510 * @hHal: HAL pointer
8511 * @pChannelList: Output channel list
8512 * @pNumChannels: Output number of channels
8513 * @sessionId: Session Identifier
8514 *
8515 * To get roam scan channel list This is a synchronous call
8516 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308517 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008518 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308519QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 uint8_t *pChannelList, uint8_t *pNumChannels,
8521 uint8_t sessionId)
8522{
8523 int i = 0;
8524 uint8_t *pOutPtr = pChannelList;
8525 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008526 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308527 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008528
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008529 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8530 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8531 FL("Invalid sme session id: %d"), sessionId);
8532 return QDF_STATUS_E_INVAL;
8533 }
8534
8535 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308537 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008538 return status;
8539 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008541 FL("Roam Scan channel list is NOT yet initialized"));
8542 *pNumChannels = 0;
8543 sme_release_global_lock(&pMac->sme);
8544 return status;
8545 }
8546
8547 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308548 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549 pOutPtr[i] =
8550 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008552 pOutPtr[i] = '\0';
8553 sme_release_global_lock(&pMac->sme);
8554 return status;
8555}
8556
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308557/*
8558 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8559 * This is a synchronuous call
8560 *
8561 * hHal - The handle returned by mac_open.
8562 * Return true (1) - if the ESE feature is enabled
8563 * false (0) - if feature is disabled (compile or runtime)
8564 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008565bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8566{
8567#ifdef FEATURE_WLAN_ESE
8568 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008570 return csr_roam_is_ese_ini_feature_enabled(pMac);
8571#else
8572 return false;
8573#endif
8574}
8575
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308576/*
8577 * sme_get_wes_mode() - get WES Mode
8578 * This is a synchronous call
8579 *
8580 * hHal - The handle returned by mac_open
8581 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8582 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008583bool sme_get_wes_mode(tHalHandle hHal)
8584{
8585 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 return pMac->roam.configParam.isWESModeEnabled;
8588}
8589
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308590/*
8591 * sme_get_roam_scan_control() - get scan control
8592 * This is a synchronous call
8593 *
8594 * hHal - The handle returned by mac_open.
8595 * Return bool - Enabled(1)/Disabled(0)
8596 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008597bool sme_get_roam_scan_control(tHalHandle hHal)
8598{
8599 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008601 return pMac->roam.configParam.nRoamScanControl;
8602}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008603
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308604/*
8605 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8606 * This is a synchronuous call
8607 * hHal - The handle returned by mac_open.
8608 * Return true (1) - if the feature is enabled
8609 * false (0) - if feature is disabled (compile or runtime)
8610 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008611bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8612{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008613 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008615 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616}
8617
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308618/*
8619 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8620 * This is a synchronuous call
8621 *
8622 * hHal - The handle returned by mac_open.
8623 * Return true (1) - if the feature is enabled
8624 * false (0) - if feature is disabled (compile or runtime)
8625 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008626bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8627{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008630 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008631}
8632
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008633/**
8634 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8635 * @feature: enum value of requested feature.
8636 *
8637 * Retrun: 1 if supported; 0 otherwise
8638 */
8639bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008640{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008641 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008642}
8643
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308644QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008645 void *plsContext,
8646 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8647 void *pContext))
8648{
8649
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308650 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008651 tpAniSirGlobal pMac;
8652 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308653 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008654
Jeff Johnsona5317a62017-01-26 08:51:25 -08008655 if (!hHal || !pCallbackfn || !lsReq) {
8656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8657 FL("Invalid parameter"));
8658 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008659 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008660
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308661 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8662 if (!wma_handle) {
8663 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8664 "wma handle is NULL");
8665 return QDF_STATUS_E_FAILURE;
8666 }
8667
Jeff Johnsona5317a62017-01-26 08:51:25 -08008668 pMac = PMAC_STRUCT(hHal);
8669 req = qdf_mem_malloc(sizeof(*req));
8670 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008671 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008672 return QDF_STATUS_E_NOMEM;
8673 }
8674 *req = *lsReq;
8675
8676 status = sme_acquire_global_lock(&pMac->sme);
8677 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008678 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008679 qdf_mem_free(req);
8680 return QDF_STATUS_E_FAILURE;
8681 }
8682
8683 pMac->sme.pLinkSpeedCbContext = plsContext;
8684 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308685 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008686 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 return status;
8689}
8690
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308691QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8692 struct sir_peer_info_req req)
8693{
8694 QDF_STATUS qdf_status;
8695 struct scheduler_msg message = {0};
8696
8697 qdf_status = sme_acquire_global_lock(&mac->sme);
8698 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8699 sme_debug("Failed to get Lock");
8700 return qdf_status;
8701 }
8702 /* serialize the req through MC thread */
8703 message.bodyptr = qdf_mem_malloc(sizeof(req));
8704 if (NULL == message.bodyptr) {
8705 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8706 "%s: Memory allocation failed.", __func__);
8707 sme_release_global_lock(&mac->sme);
8708 return QDF_STATUS_E_NOMEM;
8709 }
8710 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8711 message.type = WMA_GET_PEER_INFO;
8712 message.reserved = 0;
8713 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8714 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8716 "%s: Post get peer info msg fail", __func__);
8717 qdf_mem_free(message.bodyptr);
8718 qdf_status = QDF_STATUS_E_FAILURE;
8719 }
8720 sme_release_global_lock(&mac->sme);
8721 return qdf_status;
8722}
8723
Will Huang558f8082017-05-31 16:22:24 +08008724QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8725 void *context,
8726 void (*callbackfn)(struct sir_peer_info_resp *param,
8727 void *pcontext))
8728{
8729
8730 QDF_STATUS status;
8731 QDF_STATUS qdf_status;
8732 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008733 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008734
8735 status = sme_acquire_global_lock(&mac->sme);
8736 if (QDF_STATUS_SUCCESS == status) {
8737 if (NULL == callbackfn) {
8738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8739 "%s: Indication Call back is NULL",
8740 __func__);
8741 sme_release_global_lock(&mac->sme);
8742 return QDF_STATUS_E_FAILURE;
8743 }
8744
8745 mac->sme.pget_peer_info_ind_cb = callbackfn;
8746 mac->sme.pget_peer_info_cb_context = context;
8747
8748 /* serialize the req through MC thread */
8749 message.bodyptr = qdf_mem_malloc(sizeof(req));
8750 if (NULL == message.bodyptr) {
8751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8752 "%s: Memory allocation failed.", __func__);
8753 sme_release_global_lock(&mac->sme);
8754 return QDF_STATUS_E_NOMEM;
8755 }
8756 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8757 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308758 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008759 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8760 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8762 "%s: Post get peer info msg fail", __func__);
8763 qdf_mem_free(message.bodyptr);
8764 status = QDF_STATUS_E_FAILURE;
8765 }
8766 sme_release_global_lock(&mac->sme);
8767 }
8768 return status;
8769}
8770
8771QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8772 struct sir_peer_info_ext_req *req,
8773 void *context,
8774 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8775 void *pcontext))
8776{
8777 QDF_STATUS status;
8778 QDF_STATUS qdf_status;
8779 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008780 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008781
8782 status = sme_acquire_global_lock(&mac->sme);
8783 if (QDF_STATUS_SUCCESS == status) {
8784 if (NULL == callbackfn) {
8785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8786 "%s: Indication Call back is NULL",
8787 __func__);
8788 sme_release_global_lock(&mac->sme);
8789 return QDF_STATUS_E_FAILURE;
8790 }
8791
8792 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8793 mac->sme.pget_peer_info_ext_cb_context = context;
8794
8795 /* serialize the req through MC thread */
8796 message.bodyptr =
8797 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8798 if (NULL == message.bodyptr) {
8799 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8800 "%s: Memory allocation failed.", __func__);
8801 sme_release_global_lock(&mac->sme);
8802 return QDF_STATUS_E_NOMEM;
8803 }
8804 qdf_mem_copy(message.bodyptr,
8805 req,
8806 sizeof(struct sir_peer_info_ext_req));
8807 message.type = WMA_GET_PEER_INFO_EXT;
8808 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8809 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8811 "%s: Post get rssi msg fail", __func__);
8812 qdf_mem_free(message.bodyptr);
8813 status = QDF_STATUS_E_FAILURE;
8814 }
8815 sme_release_global_lock(&mac->sme);
8816 }
8817 return status;
8818}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008819
8820/*
8821 * SME API to enable/disable WLAN driver initiated SSR
8822 */
8823void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8824{
8825 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308826 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827
8828 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308829 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008830 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008831 /* not serializing this messsage, as this is only going
8832 * to set a variable in WMA/WDI
8833 */
8834 WMA_SetEnableSSR(enableSSR);
8835 sme_release_global_lock(&pMac->sme);
8836 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837}
8838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008839/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8840ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8841{
8842 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8843}
8844
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308845/*
8846 * sme_set_curr_device_mode() - Sets the current operating device mode.
8847 *
8848 * hHal - The handle returned by mac_open.
8849 * currDeviceMode - Current operating device mode.
8850 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008851void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008852 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853{
8854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008857}
8858
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308859/*
8860 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8861 * This is a synchronous call
8862 *
8863 * hHal - The handle returned by mac_open
8864 * sessionId - Session Identifier
8865 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8866 * BSSID, channel etc.)
8867 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8868 * Other status means SME is failed to send the request.
8869 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308871QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008872 uint8_t sessionId,
8873 tCsrHandoffRequest *pHandoffInfo)
8874{
8875 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308876 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008877
8878 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308879 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308880 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881 "%s: invoked", __func__);
8882 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8883 sme_release_global_lock(&pMac->sme);
8884 }
8885
8886 return status;
8887}
8888
8889#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308890/*
8891 * sme_ipa_offload_enable_disable() -
8892 * API to enable/disable IPA offload
8893 *
8894 * hal - The handle returned by macOpen.
8895 * session_id - Session Identifier
8896 * request - Pointer to the offload request.
8897 * Return QDF_STATUS
8898 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308899QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008900 struct sir_ipa_offload_enable_disable *request)
8901{
8902 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308903 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008905 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906
8907 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308908 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308909 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008910 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308911 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308912 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008913 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308914 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008915 }
8916
8917 request_buf->offload_type = request->offload_type;
8918 request_buf->vdev_id = request->vdev_id;
8919 request_buf->enable = request->enable;
8920
8921 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8922 msg.reserved = 0;
8923 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308924 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008925 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308927 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308928 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008929 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308930 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008931 }
8932
8933 sme_release_global_lock(&pMac->sme);
8934 }
8935
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308936 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008937}
8938#endif /* IPA_OFFLOAD */
8939
8940/*
8941 * SME API to check if there is any infra station or
8942 * P2P client is connected
8943 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308944QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008945{
8946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308947
8948 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308949 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308950
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308951 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008952}
8953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954/**
8955 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8956 * @hal: global hal handle
8957 * @addPeriodicTxPtrnParams: request message
8958 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308959 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008960 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308961QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008962sme_add_periodic_tx_ptrn(tHalHandle hal,
8963 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8964{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308965 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008966 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8967 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008968 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008969
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008970 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008971
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308972 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008973 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008974 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308975 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008976 }
8977
8978 *req_msg = *addPeriodicTxPtrnParams;
8979
8980 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308981 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008982 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008983 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308984 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008985 return status;
8986 }
8987
8988 /* Serialize the req through MC thread */
8989 msg.bodyptr = req_msg;
8990 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308991 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8992 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008993 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308994 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008995 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308997 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008998 }
8999 sme_release_global_lock(&mac->sme);
9000 return status;
9001}
9002
9003/**
9004 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
9005 * @hal: global hal handle
9006 * @delPeriodicTxPtrnParams: request message
9007 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309008 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009009 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309010QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009011sme_del_periodic_tx_ptrn(tHalHandle hal,
9012 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
9013{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309014 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009015 tpAniSirGlobal mac = PMAC_STRUCT(hal);
9016 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009017 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009018
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009019 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309021 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009022 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009023 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309024 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009025 }
9026
9027 *req_msg = *delPeriodicTxPtrnParams;
9028
9029 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309030 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009031 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009032 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309033 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009034 return status;
9035 }
9036
9037 /* Serialize the req through MC thread */
9038 msg.bodyptr = req_msg;
9039 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309040 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9041 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009042 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309043 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009044 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009045 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309046 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009047 }
9048 sme_release_global_lock(&mac->sme);
9049 return status;
9050}
9051
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309052/*
9053 * sme_enable_rmc() - enables RMC
9054 * @hHal : Pointer to global HAL handle
9055 * @sessionId : Session ID
9056 *
9057 * Return: QDF_STATUS
9058 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009059QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
9060{
9061 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9062 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009063 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009064 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9065
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009066 SME_ENTER();
9067
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009068 status = sme_acquire_global_lock(&pMac->sme);
9069 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009070 message.bodyptr = NULL;
9071 message.type = WMA_RMC_ENABLE_IND;
9072 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9073 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009074 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9075 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9076 "%s: failed to post message to WMA",
9077 __func__);
9078 status = QDF_STATUS_E_FAILURE;
9079 }
9080 sme_release_global_lock(&pMac->sme);
9081 }
9082 return status;
9083}
9084
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309085/*
9086 * sme_disable_rmc() - disables RMC
9087 * @hHal : Pointer to global HAL handle
9088 * @sessionId : Session ID
9089 *
9090 * Return: QDF_STATUS
9091 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009092QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9093{
9094 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9095 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009096 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009097 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9098
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009099 SME_ENTER();
9100
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009101 status = sme_acquire_global_lock(&pMac->sme);
9102 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009103 message.bodyptr = NULL;
9104 message.type = WMA_RMC_DISABLE_IND;
9105 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9106 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009107 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9108 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9109 "%s: failed to post message to WMA",
9110 __func__);
9111 status = QDF_STATUS_E_FAILURE;
9112 }
9113 sme_release_global_lock(&pMac->sme);
9114 }
9115 return status;
9116}
9117
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309118/*
9119 * sme_send_rmc_action_period() - sends RMC action period param to target
9120 * @hHal : Pointer to global HAL handle
9121 * @sessionId : Session ID
9122 *
9123 * Return: QDF_STATUS
9124 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009125QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9126{
9127 QDF_STATUS status = QDF_STATUS_SUCCESS;
9128 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9129 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009130 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009131
9132 status = sme_acquire_global_lock(&pMac->sme);
9133 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009134 message.bodyptr = NULL;
9135 message.type = WMA_RMC_ACTION_PERIOD_IND;
9136 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9137 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009138 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9139 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9140 "%s: failed to post message to WMA",
9141 __func__);
9142 status = QDF_STATUS_E_FAILURE;
9143 }
9144 sme_release_global_lock(&pMac->sme);
9145 }
9146
9147 return status;
9148}
9149
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309150/*
9151 * sme_request_ibss_peer_info() - request ibss peer info
9152 * @hHal : Pointer to global HAL handle
9153 * @pUserData : Pointer to user data
9154 * @peerInfoCbk : Peer info callback
9155 * @allPeerInfoReqd : All peer info required or not
9156 * @staIdx : sta index
9157 *
9158 * Return: QDF_STATUS
9159 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009160QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9161 pIbssPeerInfoCb peerInfoCbk,
9162 bool allPeerInfoReqd, uint8_t staIdx)
9163{
9164 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9165 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9166 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009167 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009168 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9169
9170 status = sme_acquire_global_lock(&pMac->sme);
9171 if (QDF_STATUS_SUCCESS == status) {
9172 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9173 pMac->sme.peerInfoParams.pUserData = pUserData;
9174
9175 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309176 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009177 if (NULL == pIbssInfoReqParams) {
9178 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9179 "%s: Not able to allocate memory for dhcp start",
9180 __func__);
9181 sme_release_global_lock(&pMac->sme);
9182 return QDF_STATUS_E_NOMEM;
9183 }
9184 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9185 pIbssInfoReqParams->staIdx = staIdx;
9186
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009187 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9188 message.bodyptr = pIbssInfoReqParams;
9189 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009190
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009191 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9192 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009193 if (QDF_STATUS_SUCCESS != qdf_status) {
9194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9195 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9196 __func__);
9197 qdf_mem_free(pIbssInfoReqParams);
9198 qdf_status = QDF_STATUS_E_FAILURE;
9199 }
9200 sme_release_global_lock(&pMac->sme);
9201 }
9202
9203 return qdf_status;
9204}
9205
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309206/*
9207 * sme_send_cesium_enable_ind() -
9208 * Used to send proprietary cesium enable indication to fw
9209 *
9210 * hHal
9211 * sessionId
9212 * Return QDF_STATUS
9213 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009214QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9215{
9216 QDF_STATUS status = QDF_STATUS_SUCCESS;
9217 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009219 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009220
9221 status = sme_acquire_global_lock(&pMac->sme);
9222 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009223 message.bodyptr = NULL;
9224 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9225 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9226 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009227 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9228 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9229 "%s: failed to post message to WMA",
9230 __func__);
9231 status = QDF_STATUS_E_FAILURE;
9232 }
9233 sme_release_global_lock(&pMac->sme);
9234 }
9235
9236 return status;
9237}
9238
Paul Zhang99fe8842017-12-08 14:43:46 +08009239QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
9240 uint16_t latency_level)
9241{
9242 QDF_STATUS status;
9243 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9244 struct wlm_latency_level_param params;
9245 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
9246
9247 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
9248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9249 "%s: WLM latency level setting is disabled",
9250 __func__);
9251 return QDF_STATUS_E_FAILURE;
9252 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08009253 if (!wma) {
9254 sme_err("wma is NULL");
9255 return QDF_STATUS_E_FAILURE;
9256 }
Paul Zhang99fe8842017-12-08 14:43:46 +08009257
9258 params.wlm_latency_level = latency_level;
9259 params.wlm_latency_flags =
9260 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
9261 params.vdev_id = session_id;
9262
9263 status = wma_set_wlm_latency_level(wma, &params);
9264 if (!QDF_IS_STATUS_SUCCESS(status))
9265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9266 "%s: failed to set latency level",
9267 __func__);
9268
9269 return status;
9270}
9271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009272void sme_get_command_q_status(tHalHandle hHal)
9273{
9274 tSmeCmd *pTempCmd = NULL;
9275 tListElem *pEntry;
9276 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9277
9278 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309279 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009280 "%s: pMac is NULL", __func__);
9281 return;
9282 }
9283
Krunal Sonia8270f52017-02-23 19:51:25 -08009284 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309285 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009286 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309287
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009288 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009289 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9290 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309291 if (eSmeCsrCommandMask & pTempCmd->command)
9292 /* CSR command is stuck. See what the reason code is
9293 * for that command
9294 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009295 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009296 } /* if(pTempCmd) */
9297
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009298 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009299 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009301}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009302/**
9303 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9304 * @hal: The handle returned by macOpen
9305 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9306 */
9307void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9308 bool sta_prefer_80MHz_over_160MHz)
9309{
9310 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309311
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009312 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9313}
9314
Agrawal Ashishb141b092016-09-02 19:59:26 +05309315#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009316/**
9317 * sme_set_dot11p_config() - API to set the 802.11p config
9318 * @hHal: The handle returned by macOpen
9319 * @enable_dot11p: 802.11p config param
9320 */
9321void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9322{
9323 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325 pMac->enable_dot11p = enable_dot11p;
9326}
9327
9328/**
9329 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9330 * @src: the source configuration
9331 *
9332 * Return: pointer to the copied OCB configuration
9333 */
9334static struct sir_ocb_config *sme_copy_sir_ocb_config(
9335 struct sir_ocb_config *src)
9336{
9337 struct sir_ocb_config *dst;
9338 uint32_t length;
9339 void *cursor;
9340
9341 length = sizeof(*src) +
9342 src->channel_count * sizeof(*src->channels) +
9343 src->schedule_size * sizeof(*src->schedule) +
9344 src->dcc_ndl_chan_list_len +
9345 src->dcc_ndl_active_state_list_len;
9346
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309347 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 if (!dst)
9349 return NULL;
9350
9351 *dst = *src;
9352
9353 cursor = dst;
9354 cursor += sizeof(*dst);
9355 dst->channels = cursor;
9356 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309357 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009358 src->channel_count * sizeof(*src->channels));
9359 dst->schedule = cursor;
9360 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309361 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009362 src->schedule_size * sizeof(*src->schedule));
9363 dst->dcc_ndl_chan_list = cursor;
9364 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309365 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009366 src->dcc_ndl_chan_list_len);
9367 dst->dcc_ndl_active_state_list = cursor;
9368 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309369 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 src->dcc_ndl_active_state_list,
9371 src->dcc_ndl_active_state_list_len);
9372 return dst;
9373}
9374
9375/**
9376 * sme_ocb_set_config() - Set the OCB configuration
9377 * @hHal: reference to the HAL
9378 * @context: the context of the call
9379 * @callback: the callback to hdd
9380 * @config: the OCB configuration
9381 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309382 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309384QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 ocb_callback callback,
9386 struct sir_ocb_config *config)
9387{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309388 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009390 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391 struct sir_ocb_config *msg_body;
9392
9393 /* Lock the SME structure */
9394 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309395 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009396 return status;
9397
9398 /*
9399 * Check if there is a pending request and return an error if one
9400 * exists
9401 */
9402 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309403 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009404 goto end;
9405 }
9406
9407 msg_body = sme_copy_sir_ocb_config(config);
9408
9409 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309410 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009411 goto end;
9412 }
9413
9414 msg.type = WMA_OCB_SET_CONFIG_CMD;
9415 msg.bodyptr = msg_body;
9416
9417 /* Set the request callback and context */
9418 pMac->sme.ocb_set_config_callback = callback;
9419 pMac->sme.ocb_set_config_context = context;
9420
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009421 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309422 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309423 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009424 FL("Error posting message to WDA: %d"), status);
9425 pMac->sme.ocb_set_config_callback = callback;
9426 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309427 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009428 goto end;
9429 }
9430
9431end:
9432 sme_release_global_lock(&pMac->sme);
9433
9434 return status;
9435}
9436
9437/**
9438 * sme_ocb_set_utc_time() - Set the OCB UTC time
9439 * @hHal: reference to the HAL
9440 * @utc: the UTC time struct
9441 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309442 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309444QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009445{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309446 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009448 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009449 struct sir_ocb_utc *sme_utc;
9450
9451 /* Lock the SME structure */
9452 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309453 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009454 return status;
9455
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309456 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009457 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309458 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009459 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309460 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009461 goto end;
9462 }
9463 *sme_utc = *utc;
9464
9465 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9466 msg.reserved = 0;
9467 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009468 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309469 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309470 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009471 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309472 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009473 goto end;
9474 }
9475
9476end:
9477 sme_release_global_lock(&pMac->sme);
9478
9479 return status;
9480}
9481
9482/**
9483 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9484 * @hHal: reference to the HAL
9485 * @timing_advert: the timing advertisement struct
9486 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309487 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009488 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309489QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009490 struct sir_ocb_timing_advert *timing_advert)
9491{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309492 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009494 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009495 void *buf;
9496 struct sir_ocb_timing_advert *sme_timing_advert;
9497
9498 /* Lock the SME structure */
9499 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309500 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 return status;
9502
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309503 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 timing_advert->template_length);
9505 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309506 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009507 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309508 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009509 goto end;
9510 }
9511
9512 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9513 *sme_timing_advert = *timing_advert;
9514 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309515 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009516 timing_advert->template_value, timing_advert->template_length);
9517
9518 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9519 msg.reserved = 0;
9520 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009521 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309522 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309523 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009524 FL("Not able to post msg to WDA"));
9525 goto end;
9526 }
9527
9528end:
9529 sme_release_global_lock(&pMac->sme);
9530
9531 return status;
9532}
9533
9534/**
9535 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9536 * @hHal: reference to the HAL
9537 * @timing_advert: the timing advertisement struct
9538 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309539 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309541QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009542 struct sir_ocb_timing_advert *timing_advert)
9543{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309544 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009545 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009546 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009547 struct sir_ocb_timing_advert *sme_timing_advert;
9548
9549 /* Lock the SME structure */
9550 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309551 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 return status;
9553
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309554 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309556 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309558 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009559 goto end;
9560 }
9561 *sme_timing_advert = *timing_advert;
9562
9563 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9564 msg.reserved = 0;
9565 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009566 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309567 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309568 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009569 FL("Not able to post msg to WDA"));
9570 goto end;
9571 }
9572
9573end:
9574 sme_release_global_lock(&pMac->sme);
9575
9576 return status;
9577}
9578
9579/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009580 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9581 * @hal_handle: reference to the HAL
9582 * @self_addr: the self MAC address
9583 * @buf: the buffer that will contain the frame
9584 * @timestamp_offset: return for the offset of the timestamp field
9585 * @time_value_offset: return for the time_value field in the TA IE
9586 *
9587 * Return: the length of the buffer.
9588 */
9589int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9590 tSirMacAddr self_addr, uint8_t **buf,
9591 uint32_t *timestamp_offset,
9592 uint32_t *time_value_offset)
9593{
9594 int template_length;
9595 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9596
9597 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9598 timestamp_offset,
9599 time_value_offset);
9600 return template_length;
9601}
9602/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9604 * @hHal: reference to the HAL
9605 * @context: the context of the call
9606 * @callback: the callback to hdd
9607 * @request: the TSF timer request
9608 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309609 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309611QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 ocb_callback callback,
9613 struct sir_ocb_get_tsf_timer *request)
9614{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309615 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009617 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009618 struct sir_ocb_get_tsf_timer *msg_body;
9619
9620 /* Lock the SME structure */
9621 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309622 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623 return status;
9624
9625 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309626 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309628 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009629 goto end;
9630 }
9631 *msg_body = *request;
9632
9633 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9634 msg.bodyptr = msg_body;
9635
9636 /* Set the request callback and the context */
9637 pMac->sme.ocb_get_tsf_timer_callback = callback;
9638 pMac->sme.ocb_get_tsf_timer_context = context;
9639
9640 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009641 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309642 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309643 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009644 FL("Error posting message to WDA: %d"), status);
9645 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9646 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309647 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 goto end;
9649 }
9650
9651end:
9652 sme_release_global_lock(&pMac->sme);
9653
9654 return status;
9655}
9656
9657/**
9658 * sme_dcc_get_stats() - Get the DCC stats
9659 * @hHal: reference to the HAL
9660 * @context: the context of the call
9661 * @callback: the callback to hdd
9662 * @request: the get DCC stats request
9663 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309664 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009665 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309666QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009667 ocb_callback callback,
9668 struct sir_dcc_get_stats *request)
9669{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309670 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009671 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009672 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009673 struct sir_dcc_get_stats *msg_body;
9674
9675 /* Lock the SME structure */
9676 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309677 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009678 return status;
9679
9680 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309681 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009682 request->request_array_len);
9683 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309684 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009685 goto end;
9686 }
9687 *msg_body = *request;
9688 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309689 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009690 request->request_array_len);
9691
9692 msg.type = WMA_DCC_GET_STATS_CMD;
9693 msg.bodyptr = msg_body;
9694
9695 /* Set the request callback and context */
9696 pMac->sme.dcc_get_stats_callback = callback;
9697 pMac->sme.dcc_get_stats_context = context;
9698
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009699 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309700 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309701 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009702 FL("Error posting message to WDA: %d"), status);
9703 pMac->sme.dcc_get_stats_callback = callback;
9704 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309705 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009706 goto end;
9707 }
9708
9709end:
9710 sme_release_global_lock(&pMac->sme);
9711
9712 return status;
9713}
9714
9715/**
9716 * sme_dcc_clear_stats() - Clear the DCC stats
9717 * @hHal: reference to the HAL
9718 * @vdev_id: vdev id for OCB interface
9719 * @dcc_stats_bitmap: the entries in the stats to clear
9720 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309721 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309723QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009724 uint32_t dcc_stats_bitmap)
9725{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309726 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009727 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009728 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009729 struct sir_dcc_clear_stats *request;
9730
9731 /* Lock the SME structure */
9732 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309733 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734 return status;
9735
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309736 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009737 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309740 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009741 goto end;
9742 }
9743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009744 request->vdev_id = vdev_id;
9745 request->dcc_stats_bitmap = dcc_stats_bitmap;
9746
9747 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9748 msg.bodyptr = request;
9749
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009750 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309751 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309752 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009753 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309754 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755 goto end;
9756 }
9757
9758end:
9759 sme_release_global_lock(&pMac->sme);
9760
9761 return status;
9762}
9763
9764/**
9765 * sme_dcc_update_ndl() - Update the DCC settings
9766 * @hHal: reference to the HAL
9767 * @context: the context of the call
9768 * @callback: the callback to hdd
9769 * @request: the update DCC request
9770 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309771 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309773QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009774 ocb_callback callback,
9775 struct sir_dcc_update_ndl *request)
9776{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309777 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009778 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009779 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009780 struct sir_dcc_update_ndl *msg_body;
9781
9782 /* Lock the SME structure */
9783 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309784 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009785 return status;
9786
9787 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309788 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009789 request->dcc_ndl_chan_list_len +
9790 request->dcc_ndl_active_state_list_len);
9791 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309792 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309794 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 goto end;
9796 }
9797
9798 *msg_body = *request;
9799
9800 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9801 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9802 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309803 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009804 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309805 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009806 request->dcc_ndl_active_state_list,
9807 request->dcc_ndl_active_state_list_len);
9808
9809 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9810 msg.bodyptr = msg_body;
9811
9812 /* Set the request callback and the context */
9813 pMac->sme.dcc_update_ndl_callback = callback;
9814 pMac->sme.dcc_update_ndl_context = context;
9815
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009816 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309817 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009819 FL("Error posting message to WDA: %d"), status);
9820 pMac->sme.dcc_update_ndl_callback = NULL;
9821 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309822 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 goto end;
9824 }
9825
9826end:
9827 sme_release_global_lock(&pMac->sme);
9828
9829 return status;
9830}
9831
9832/**
9833 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9834 * event
9835 * @hHal: reference to the HAL
9836 * @context: the context of the call
9837 * @callback: the callback to hdd
9838 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309839 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309841QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009842 ocb_callback callback)
9843{
9844 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309845 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009846
9847 status = sme_acquire_global_lock(&pMac->sme);
9848 pMac->sme.dcc_stats_event_callback = callback;
9849 pMac->sme.dcc_stats_event_context = context;
9850 sme_release_global_lock(&pMac->sme);
9851
9852 return 0;
9853}
9854
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309855/**
9856 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9857 * event
9858 * @h_hal: Hal Handle
9859 *
9860 * This function de-registers the DCC perioc stats callback
9861 *
9862 * Return: QDF_STATUS Enumeration
9863 */
9864QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9865{
9866 tpAniSirGlobal mac;
9867 QDF_STATUS status;
9868
9869 if (!h_hal) {
9870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9871 FL("h_hal is not valid"));
9872 return QDF_STATUS_E_INVAL;
9873 }
9874 mac = PMAC_STRUCT(h_hal);
9875
9876 status = sme_acquire_global_lock(&mac->sme);
9877 if (!QDF_IS_STATUS_SUCCESS(status)) {
9878 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9879 FL("Failed to acquire global lock"));
9880 return status;
9881 }
9882 mac->sme.dcc_stats_event_callback = NULL;
9883 mac->sme.dcc_stats_event_context = NULL;
9884 sme_release_global_lock(&mac->sme);
9885
9886 return status;
9887}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309888#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009890void sme_get_recovery_stats(tHalHandle hHal)
9891{
9892 uint8_t i;
9893
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309894 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009895 "Self Recovery Stats");
9896 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9897 if (eSmeNoCommand !=
9898 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309899 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009900 "timestamp %llu: command 0x%0X: reason %d: session %d",
9901 g_self_recovery_stats.activeCmdStats[i].
9902 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309903 g_self_recovery_stats.activeCmdStats[i].command,
9904 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009905 g_self_recovery_stats.activeCmdStats[i].
9906 sessionId);
9907 }
9908 }
9909}
9910
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309911QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009912{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009913 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009914 tpSirModemPowerStateInd request_buf;
9915 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309917 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009919
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309920 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009921 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309922 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009923 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9924 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309925 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009926 }
9927
9928 request_buf->param = value;
9929
9930 msg.type = WMA_MODEM_POWER_STATE_IND;
9931 msg.reserved = 0;
9932 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309933 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009934 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309935 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309936 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9937 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309938 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309939 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940 }
9941
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309942 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009943}
9944
9945#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309946QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309947 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 uint8_t sessionId,
9949 uint8_t channel_type)
9950{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009951 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009952 tUpdateVHTOpMode *pHtOpMode = NULL;
9953 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9954
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309955 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309956 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009957
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309958 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009959 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309960 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009961 "%s: Not able to allocate memory for setting OP mode",
9962 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309963 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009964 }
9965
9966 switch (channel_type) {
9967 case eHT_CHAN_HT20:
9968 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9969 break;
9970
9971 case eHT_CHAN_HT40MINUS:
9972 case eHT_CHAN_HT40PLUS:
9973 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9974 break;
9975
9976 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309977 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309979 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009980 }
9981
9982 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309983 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009984 sizeof(tSirMacAddr));
9985 pHtOpMode->smesessionId = sessionId;
9986
9987 msg.type = WMA_UPDATE_OP_MODE;
9988 msg.reserved = 0;
9989 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309990 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009991 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309992 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309993 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9994 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309995 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309996 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997 }
9998
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309999 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010000 "%s: Notifed FW about OP mode: %d for staId=%d",
10001 __func__, pHtOpMode->opMode, staId);
10002
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010003 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004}
10005
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010006/*
10007 * sme_set_ht2040_mode() -
10008 * To update HT Operation beacon IE.
10009 *
10010 * Return QDF_STATUS SUCCESS
10011 * FAILURE or RESOURCES
10012 * The API finished and failed.
10013 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010014QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010015 uint8_t channel_type, bool obssEnabled)
10016{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010017 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10019 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010020 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010021
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010022 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
10023 sme_err("Session not valid for session id %d", sessionId);
10024 return QDF_STATUS_E_INVAL;
10025 }
10026 session = CSR_GET_SESSION(pMac, sessionId);
10027 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
10028 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010029
10030 switch (channel_type) {
10031 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010032 if (!session->bssParams.cbMode)
10033 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010034 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
10035 break;
10036 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010037 if (session->bssParams.cbMode)
10038 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010039 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10040 break;
10041 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010042 if (session->bssParams.cbMode)
10043 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010044 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10045 break;
10046 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010047 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010048 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010049 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +053010050 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010051 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010052 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010053 status = csr_set_ht2040_mode(pMac, sessionId,
10054 cbMode, obssEnabled);
10055 sme_release_global_lock(&pMac->sme);
10056 }
10057 return status;
10058}
10059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010060#endif
10061
10062/*
10063 * SME API to enable/disable idle mode powersave
10064 * This should be called only if powersave offload
10065 * is enabled
10066 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010067QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010068{
Anurag Chouhan6d760662016-02-20 16:05:43 +053010069 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070
10071 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010072 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010073 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010074 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010077 " Idle Ps Set Value %d", value);
10078
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010079 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010080 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010081 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010082 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010083 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010084
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010085 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010086}
10087
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010088int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
10089 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010090{
10091 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010092 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010093
10094 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010095 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010096 "%s: pSession is NULL", __func__);
10097 return -EIO;
10098 }
10099 switch (ht_capab) {
10100 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10101 return pSession->htConfig.ht_rx_ldpc;
10102 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10103 return pSession->htConfig.ht_tx_stbc;
10104 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10105 return pSession->htConfig.ht_rx_stbc;
10106 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010107 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010108 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010109 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010112 "invalid ht capability");
10113 return -EIO;
10114 }
10115}
10116
10117int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
10118 int value)
10119{
10120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010121 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010122
10123 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 "%s: pSession is NULL", __func__);
10126 return -EIO;
10127 }
10128
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010129 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010131 "Failed to set ht capability in target");
10132 return -EIO;
10133 }
10134
10135 switch (htCapab) {
10136 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10137 pSession->htConfig.ht_rx_ldpc = value;
10138 break;
10139 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10140 pSession->htConfig.ht_tx_stbc = value;
10141 break;
10142 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10143 pSession->htConfig.ht_rx_stbc = value;
10144 break;
10145 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010146 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010147 pSession->htConfig.ht_sgi20 = value;
10148 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010149 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010150 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010151 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010152 break;
10153 }
10154
Naveen Rawat8029a402017-06-01 10:54:19 -070010155 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010156 return 0;
10157}
10158
10159#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010160/*
10161 * sme_send_rate_update_ind() -
10162 * API to Update rate
10163 *
10164 * hHal - The handle returned by mac_open
10165 * rateUpdateParams - Pointer to rate update params
10166 * Return QDF_STATUS
10167 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010168QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010169 tSirRateUpdateInd *rateUpdateParams)
10170{
10171 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010172 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010173 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010174 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175
10176 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010177 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010178 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010179 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010180 }
10181 *rate_upd = *rateUpdateParams;
10182
10183 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10184 rate_upd->mcastDataRate24GHzTxFlag =
10185 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10186 else if (rate_upd->reliableMcastDataRate ==
10187 HT20_SHORT_GI_MCS7_RATE)
10188 rate_upd->reliableMcastDataRateTxFlag =
10189 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10190
10191 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010192 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 msg.type = WMA_RATE_UPDATE_IND;
10194 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010195 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10196 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010197 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010198 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010199 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010200 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201 __func__);
10202
10203 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010204 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010205 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010206 }
10207
10208 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010209 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 }
10211
10212 return status;
10213}
10214
10215/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010216 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10217 * @hal: Pointer to the mac context
10218 * @session_id: sme session id
10219 * @vendor_ie: vendor ie
10220 * @access_policy: vendor ie access policy
10221 *
10222 * This function updates the vendor ie and access policy to lim.
10223 *
10224 * Return: success or failure.
10225 */
10226QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10227 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10228{
10229 struct sme_update_access_policy_vendor_ie *msg;
10230 uint16_t msg_len;
10231 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010232
10233 msg_len = sizeof(*msg);
10234
10235 msg = qdf_mem_malloc(msg_len);
10236 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010237 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010238 return QDF_STATUS_E_FAILURE;
10239 }
10240
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010241 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10242 msg->length = (uint16_t)msg_len;
10243
10244 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10245
10246 msg->sme_session_id = session_id;
10247 msg->access_policy = access_policy;
10248
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010249 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10250 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010251
Rajeev Kumard138ac52017-01-30 18:38:37 -080010252 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010253
10254 return status;
10255}
10256
10257/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010258 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10259 * @hal: Handle returned by mac_open
10260 * @session_id: Session ID on which short frame retry limit needs to be
10261 * updated to FW
10262 * @short_limit_count_th: Retry count TH to retry short frame.
10263 *
10264 * This function is used to configure count to retry short frame.
10265 *
10266 * Return: QDF_STATUS
10267 */
10268QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10269 struct sme_short_retry_limit *short_retry_limit_th)
10270{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010271 QDF_STATUS status = QDF_STATUS_SUCCESS;
10272 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010273 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010274
10275 srl = qdf_mem_malloc(sizeof(*srl));
10276 if (NULL == srl) {
10277 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10278 "%s: fail to alloc short retry limit", __func__);
10279 return QDF_STATUS_E_FAILURE;
10280 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010281 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010282 short_retry_limit_th->session_id,
10283 short_retry_limit_th->short_retry_limit);
10284
10285 srl->session_id = short_retry_limit_th->session_id;
10286 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10287
10288 qdf_mem_zero(&msg, sizeof(msg));
10289 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10290 msg.reserved = 0;
10291 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010292 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010293 if (status != QDF_STATUS_SUCCESS) {
10294 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10295 FL("Not able to post short retry limit count to WDA"));
10296 qdf_mem_free(srl);
10297 return QDF_STATUS_E_FAILURE;
10298 }
10299
10300 return status;
10301}
10302
10303/**
10304 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10305 * @hal: Handle returned by mac_open
10306 * @session_id: Session ID on which long frames retry TH needs to be updated
10307 * to FW
10308 * @long_limit_count_th: Retry count to retry long frame.
10309 *
10310 * This function is used to configure TH to retry long frame.
10311 *
10312 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010313 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010314QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10315 struct sme_long_retry_limit *long_retry_limit_th)
10316{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010317 QDF_STATUS status = QDF_STATUS_SUCCESS;
10318 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010319 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010320
10321 lrl = qdf_mem_malloc(sizeof(*lrl));
10322 if (NULL == lrl) {
10323 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10324 "%s: fail to alloc long retry limit", __func__);
10325 return QDF_STATUS_E_FAILURE;
10326 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010327 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010328 long_retry_limit_th->session_id,
10329 long_retry_limit_th->long_retry_limit);
10330
10331 lrl->session_id = long_retry_limit_th->session_id;
10332 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10333
10334 qdf_mem_zero(&msg, sizeof(msg));
10335 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10336 msg.reserved = 0;
10337 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010338 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010339
10340 if (status != QDF_STATUS_SUCCESS) {
10341 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10342 FL("Not able to post long retry limit count to WDA"));
10343 qdf_mem_free(lrl);
10344 return QDF_STATUS_E_FAILURE;
10345 }
10346
10347 return status;
10348}
10349
10350/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010351 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10352 * @hal: Handle returned by mac_open
10353 * @session_id: Session ID on which sta_inactivity_timeout needs
10354 * to be updated to FW
10355 * @sta_inactivity_timeout: sta inactivity timeout.
10356 *
10357 * If a station does not send anything in sta_inactivity_timeout seconds, an
10358 * empty data frame is sent to it in order to verify whether it is
10359 * still in range. If this frame is not ACKed, the station will be
10360 * disassociated and then deauthenticated.
10361 *
10362 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010363 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010364QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10365 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10366{
10367 struct sme_sta_inactivity_timeout *inactivity_time;
10368 void *wma_handle;
10369
10370 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10371 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10372 if (NULL == inactivity_time) {
10373 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10374 "%s: fail to alloc inactivity_time", __func__);
10375 return QDF_STATUS_E_FAILURE;
10376 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010377 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010378 FL("sta_inactivity_timeout: %d"),
10379 sta_inactivity_timer->sta_inactivity_timeout);
10380 inactivity_time->session_id = sta_inactivity_timer->session_id;
10381 inactivity_time->sta_inactivity_timeout =
10382 sta_inactivity_timer->sta_inactivity_timeout;
10383
10384 wma_update_sta_inactivity_timeout(wma_handle,
10385 inactivity_time);
10386 return QDF_STATUS_SUCCESS;
10387}
10388
10389/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010390 * sme_get_reg_info() - To get registration info
10391 * @hHal: HAL context
10392 * @chanId: channel id
10393 * @regInfo1: first reg info to fill
10394 * @regInfo2: second reg info to fill
10395 *
10396 * This routine will give you reg info
10397 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010398 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010399 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010400QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010401 uint32_t *regInfo1, uint32_t *regInfo2)
10402{
10403 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010404 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010405 uint8_t i;
10406 bool found = false;
10407
10408 status = sme_acquire_global_lock(&pMac->sme);
10409 *regInfo1 = 0;
10410 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010411 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010412 return status;
10413
10414 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010415 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010417 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010418
10419 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010420 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010421 found = true;
10422 break;
10423 }
10424 }
10425 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010426 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427
10428 sme_release_global_lock(&pMac->sme);
10429 return status;
10430}
10431
10432#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010433/*
10434 * sme_auto_shutdown_cb() -
10435 * Used to plug in callback function for receiving auto shutdown evt
10436 *
10437 * hHal
10438 * pCallbackfn : callback function pointer should be plugged in
10439 * Return QDF_STATUS
10440 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010441QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010442 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010443 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10445
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010446 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010447 "%s: Plug in Auto shutdown event callback", __func__);
10448
10449 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010450 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010451 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010452 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 sme_release_global_lock(&pMac->sme);
10454 }
10455
10456 return status;
10457}
10458
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010459/*
10460 * sme_set_auto_shutdown_timer() -
10461 * API to set auto shutdown timer value in FW.
10462 *
10463 * hHal - The handle returned by mac_open
10464 * timer_val - The auto shutdown timer value to be set
10465 * Return Configuration message posting status, SUCCESS or Fail
10466 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010467QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010469 QDF_STATUS status = QDF_STATUS_SUCCESS;
10470 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10472 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010473 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010474
10475 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010476 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010477 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010478 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010479 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010480 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010481 "%s Request Buffer Alloc Fail", __func__);
10482 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010483 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010484 }
10485
10486 auto_sh_cmd->timer_val = timer_val;
10487
10488 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010489 message.bodyptr = auto_sh_cmd;
10490 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10491 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10492 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010493 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010494 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010496 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010498 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010500 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010501 "%s: Posted Auto shutdown MSG", __func__);
10502 sme_release_global_lock(&pMac->sme);
10503 }
10504
10505 return status;
10506}
10507#endif
10508
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010509/*
10510 * sme_ch_avoid_update_req() -
10511 * API to request channel avoidance update from FW.
10512 *
10513 * hHal - The handle returned by mac_open
10514 * update_type - The udpate_type parameter of this request call
10515 * Return Configuration message posting status, SUCCESS or Fail
10516 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010517QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010519 QDF_STATUS status = QDF_STATUS_SUCCESS;
10520 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10522 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010523 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010524
10525 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010526 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010528 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010530 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010531 "%s Request Buffer Alloc Fail", __func__);
10532 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010533 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010534 }
10535
10536 cauReq->reserved_param = 0;
10537
10538 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010539 message.bodyptr = cauReq;
10540 message.type = WMA_CH_AVOID_UPDATE_REQ;
10541 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10542 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010543 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010544 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010545 "%s: Post Ch Avoid Update MSG fail",
10546 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010547 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010548 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010549 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010550 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010552 "%s: Posted Ch Avoid Update MSG", __func__);
10553 sme_release_global_lock(&pMac->sme);
10554 }
10555
10556 return status;
10557}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010558
10559/**
10560 * sme_set_miracast() - Function to set miracast value to UMAC
10561 * @hal: Handle returned by macOpen
10562 * @filter_type: 0-Disabled, 1-Source, 2-sink
10563 *
10564 * This function passes down the value of miracast set by
10565 * framework to UMAC
10566 *
10567 * Return: Configuration message posting status, SUCCESS or Fail
10568 *
10569 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010570QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010571{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010572 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010573 uint32_t *val;
10574 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10575
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010576 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010577 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010578 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010579 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010580 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010581 }
10582
10583 *val = filter_type;
10584
10585 msg.type = SIR_HAL_SET_MIRACAST;
10586 msg.reserved = 0;
10587 msg.bodyptr = val;
10588
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010589 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010590 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010592 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10593 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010594 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010596 }
10597
10598 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010599 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010600}
10601
10602/**
10603 * sme_set_mas() - Function to set MAS value to UMAC
10604 * @val: 1-Enable, 0-Disable
10605 *
10606 * This function passes down the value of MAS to the UMAC. A
10607 * value of 1 will enable MAS and a value of 0 will disable MAS
10608 *
10609 * Return: Configuration message posting status, SUCCESS or Fail
10610 *
10611 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010612QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010613{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010614 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 uint32_t *ptr_val;
10616
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010617 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010618 if (NULL == ptr_val) {
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: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010621 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010622 }
10623
10624 *ptr_val = val;
10625
10626 msg.type = SIR_HAL_SET_MAS;
10627 msg.reserved = 0;
10628 msg.bodyptr = ptr_val;
10629
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010630 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010631 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010632 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010633 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10634 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010635 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010636 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010637 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010638 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010639}
10640
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010641/**
10642 * sme_roam_channel_change_req() - Channel change to new target channel
10643 * @hHal: handle returned by mac_open
10644 * @bssid: mac address of BSS
10645 * @ch_params: target channel information
10646 * @profile: CSR profile
10647 *
10648 * API to Indicate Channel change to new target channel
10649 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010650 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010651 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010652QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010653 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010654 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010655 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010656{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010657 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659
10660 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010661 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010662
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010663 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010664 profile);
10665 sme_release_global_lock(&pMac->sme);
10666 }
10667 return status;
10668}
10669
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010670/*
10671 * sme_process_channel_change_resp() -
10672 * API to Indicate Channel change response message to SAP.
10673 *
10674 * Return QDF_STATUS
10675 */
10676static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010677 uint16_t msg_type, void *pMsgBuf)
10678{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010680 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010681 eCsrRoamResult roamResult;
10682 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10683 uint32_t SessionId = pChnlParams->peSessionId;
10684
10685 proam_info.channelChangeRespEvent =
10686 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010687 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010688 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010689 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010690 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 return status;
10692 }
10693 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10694 proam_info.channelChangeRespEvent->sessionId = SessionId;
10695 proam_info.channelChangeRespEvent->newChannelNumber =
10696 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010697
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010698 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010699 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010700 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10701 SessionId);
10702 proam_info.channelChangeRespEvent->channelChangeStatus =
10703 1;
10704 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10705 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010706 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010707 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10708 SessionId);
10709 proam_info.channelChangeRespEvent->channelChangeStatus =
10710 0;
10711 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10712 }
10713
10714 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10715 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10716
10717 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010718 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010719 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010720 status);
10721 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010722 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010723
10724 return status;
10725}
10726
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010727/*
10728 * sme_roam_start_beacon_req() -
10729 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10730 *
10731 * hHal - The handle returned by mac_open
10732 * sessionId - session ID
10733 * dfsCacWaitStatus - CAC WAIT status flag
10734 * Return QDF_STATUS
10735 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010736QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737 uint8_t dfsCacWaitStatus)
10738{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010739 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010742 status = sme_acquire_global_lock(&pMac->sme);
10743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010744 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010745 status = csr_roam_start_beacon_req(pMac, bssid,
10746 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010747 sme_release_global_lock(&pMac->sme);
10748 }
10749 return status;
10750}
10751
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010752/**
10753 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10754 * @hHal: handle returned by mac_open
10755 * @bssid: SAP bssid
10756 * @targetChannel: target channel information
10757 * @csaIeReqd: CSA IE Request
10758 * @ch_params: channel information
10759 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010760 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010761 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010762QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010763 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010764 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010766 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010767 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010769 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010770 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010771 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10772 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010773 sme_release_global_lock(&pMac->sme);
10774 }
10775 return status;
10776}
10777
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010778/*
10779 * sme_init_thermal_info() -
10780 * SME API to initialize the thermal mitigation parameters
10781 *
10782 * hHal
10783 * thermalParam : thermal mitigation parameters
10784 * Return QDF_STATUS
10785 */
10786QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10787 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010788{
10789 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010790 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010791 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10792
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010793 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010794 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010797 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798 }
10799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10801 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010802
10803 pWmaParam->throttle_duty_cycle_tbl[0] =
10804 thermalParam.sme_throttle_duty_cycle_tbl[0];
10805 pWmaParam->throttle_duty_cycle_tbl[1] =
10806 thermalParam.sme_throttle_duty_cycle_tbl[1];
10807 pWmaParam->throttle_duty_cycle_tbl[2] =
10808 thermalParam.sme_throttle_duty_cycle_tbl[2];
10809 pWmaParam->throttle_duty_cycle_tbl[3] =
10810 thermalParam.sme_throttle_duty_cycle_tbl[3];
10811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010812 pWmaParam->thermalLevels[0].minTempThreshold =
10813 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10814 pWmaParam->thermalLevels[0].maxTempThreshold =
10815 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10816 pWmaParam->thermalLevels[1].minTempThreshold =
10817 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10818 pWmaParam->thermalLevels[1].maxTempThreshold =
10819 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10820 pWmaParam->thermalLevels[2].minTempThreshold =
10821 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10822 pWmaParam->thermalLevels[2].maxTempThreshold =
10823 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10824 pWmaParam->thermalLevels[3].minTempThreshold =
10825 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10826 pWmaParam->thermalLevels[3].maxTempThreshold =
10827 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010829 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010830 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10831 msg.bodyptr = pWmaParam;
10832
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010833 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010834 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010835 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010836 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10837 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010838 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010839 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010840 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010841 }
10842 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010843 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010844 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010845 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010846 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847}
10848
10849/**
10850 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10851 * @hal: Handle returned by macOpen
10852 * @callback: sme_set_thermal_level_callback
10853 *
10854 * Plug in set thermal level callback
10855 *
10856 * Return: none
10857 */
10858void sme_add_set_thermal_level_callback(tHalHandle hal,
10859 sme_set_thermal_level_callback callback)
10860{
10861 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10862
10863 pMac->sme.set_thermal_level_cb = callback;
10864}
10865
10866/**
10867 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10868 * @hal: Handler to HAL
10869 * @level: Thermal mitigation level
10870 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010871 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010873QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010874{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010875 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010876 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010877 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010879 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010880 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010881 msg.type = WMA_SET_THERMAL_LEVEL;
10882 msg.bodyval = level;
10883
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010884 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010885 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010887 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10888 __func__);
10889 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010890 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010891 }
10892 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010893 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010894 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010895 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896}
10897
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010898/*
10899 * sme_txpower_limit() -
10900 * SME API to set txpower limits
10901 *
10902 * hHal
10903 * psmetx : power limits for 2g/5g
10904 * Return QDF_STATUS
10905 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010906QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010907{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010908 QDF_STATUS status = QDF_STATUS_SUCCESS;
10909 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010910 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010912 tSirTxPowerLimit *tx_power_limit;
10913
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010914 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010915 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010917 "%s: Memory allocation for TxPowerLimit failed!",
10918 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010919 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010920 }
10921
10922 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010923
10924 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010925 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010926 message.type = WMA_TX_POWER_LIMIT;
10927 message.reserved = 0;
10928 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010929
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010930 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10931 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010932 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010933 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010934 "%s: not able to post WMA_TX_POWER_LIMIT",
10935 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010936 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010937 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010938 }
10939 sme_release_global_lock(&pMac->sme);
10940 }
10941 return status;
10942}
10943
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010944QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010946 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010947 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010949 pMac->fEnableDebugLog = set_value;
10950 return status;
10951}
10952
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010953/*
10954 * sme_ap_disable_intra_bss_fwd() -
10955 * SME will send message to WMA to set Intra BSS in txrx
10956 *
10957 * hHal - The handle returned by mac_open
10958 * sessionId - session id ( vdev id)
10959 * disablefwd - bool value that indicate disable intrabss fwd disable
10960 * Return QDF_STATUS
10961 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010962QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010963 bool disablefwd)
10964{
10965 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010966 int status = QDF_STATUS_SUCCESS;
10967 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010968 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010969 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10970
10971 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010972 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010973 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010974 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010975 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010976 }
10977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010978 pSapDisableIntraFwd->sessionId = sessionId;
10979 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10980
10981 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010982 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010984 message.bodyptr = pSapDisableIntraFwd;
10985 message.type = WMA_SET_SAP_INTRABSS_DIS;
10986 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10987 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010988 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10989 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010990 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010991 }
10992 sme_release_global_lock(&pMac->sme);
10993 }
10994 return status;
10995}
10996
10997#ifdef WLAN_FEATURE_STATS_EXT
10998
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010999/*
11000 * sme_stats_ext_register_callback() -
11001 * This function called to register the callback that send vendor event for
11002 * stats ext
11003 *
11004 * callback - callback to be registered
11005 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011006void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
11007{
11008 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11009
11010 pMac->sme.StatsExtCallback = callback;
11011}
11012
lifeng66831662017-05-19 16:01:35 +080011013void sme_stats_ext2_register_callback(tHalHandle hal_handle,
11014 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
11015{
11016 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
11017
11018 pmac->sme.stats_ext2_cb = stats_ext2_cb;
11019}
11020
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011021/**
11022 * sme_stats_ext_deregister_callback() - De-register ext stats callback
11023 * @h_hal: Hal Handle
11024 *
11025 * This function is called to de initialize the HDD NAN feature. Currently
11026 * the only operation required is to de-register a callback with SME.
11027 *
11028 * Return: None
11029 */
11030void sme_stats_ext_deregister_callback(tHalHandle h_hal)
11031{
11032 tpAniSirGlobal pmac;
11033
11034 if (!h_hal) {
11035 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11036 FL("hHal is not valid"));
11037 return;
11038 }
11039
11040 pmac = PMAC_STRUCT(h_hal);
11041 pmac->sme.StatsExtCallback = NULL;
11042}
11043
11044
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011045/*
11046 * sme_stats_ext_request() -
11047 * Function called when HDD receives STATS EXT vendor command from userspace
11048 *
11049 * sessionID - vdevID for the stats ext request
11050 * input - Stats Ext Request structure ptr
11051 * Return QDF_STATUS
11052 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011053QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011054{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011055 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011056 tpStatsExtRequest data;
11057 size_t data_len;
11058
11059 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011060 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011061
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011062 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011063 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011065 data->vdev_id = session_id;
11066 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011067 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011068 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011069 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011070
11071 msg.type = WMA_STATS_EXT_REQUEST;
11072 msg.reserved = 0;
11073 msg.bodyptr = data;
11074
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011075 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080011076 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011078 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
11079 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011080 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011081 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011082 }
11083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011084 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011085}
11086
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011087/*
11088 * sme_stats_ext_event() -
11089 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
11090 * response from WMA
11091 *
11092 * hHal - HAL handle for device
11093 * pMsg - Message body passed from WMA; includes NAN header
11094 * Return QDF_STATUS
11095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011096QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011097{
11098 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011099 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011100
11101 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011102 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011103 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011104 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011105 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011106 pMac->sme.StatsExtCallback(pMac->hHdd,
11107 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108 }
11109
11110 return status;
11111}
11112
11113#endif
11114
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011115/*
11116 * sme_update_dfs_scan_mode() -
11117 * Update DFS roam scan mode
11118 * This function is called through dynamic setConfig callback function
11119 * to configure allowDFSChannelRoam.
11120 * hHal - HAL handle for device
11121 * sessionId - Session Identifier
11122 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
11123 * 1 (passive), 2 (active)
11124 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11125 * successfully.
11126 * Other status means SME failed to update DFS roaming scan config.
11127 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011128QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 uint8_t allowDFSChannelRoam)
11130{
11131 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011132 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011133
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011134 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11136 FL("Invalid sme session id: %d"), sessionId);
11137 return QDF_STATUS_E_INVAL;
11138 }
11139
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011140 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011141 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011143 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011144 allowDFSChannelRoam,
11145 pMac->roam.configParam.allowDFSChannelRoam,
11146 mac_trace_get_neighbour_roam_state(pMac->roam.
11147 neighborRoamInfo
11148 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011149 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011150 pMac->roam.configParam.allowDFSChannelRoam =
11151 allowDFSChannelRoam;
11152 sme_release_global_lock(&pMac->sme);
11153 }
11154 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11155 csr_roam_offload_scan(pMac, sessionId,
11156 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11157 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11158 }
11159
11160 return status;
11161}
11162
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011163/*
11164 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11165 * This is a synchronous call
11166 *
11167 * hHal - The handle returned by mac_open.
11168 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11169 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011170uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11171{
11172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011173
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011174 return pMac->roam.configParam.allowDFSChannelRoam;
11175}
11176
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011177/*
11178 * sme_modify_add_ie() -
11179 * This function sends msg to updates the additional IE buffers in PE
11180 *
11181 * hHal - global structure
11182 * pModifyIE - pointer to tModifyIE structure
11183 * updateType - type of buffer
11184 * Return Success or failure
11185 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011186QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011187 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11188{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011189 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011192 status = sme_acquire_global_lock(&pMac->sme);
11193
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011194 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11196 sme_release_global_lock(&pMac->sme);
11197 }
11198 return status;
11199}
11200
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011201/*
11202 * sme_update_add_ie() -
11203 * This function sends msg to updates the additional IE buffers in PE
11204 *
11205 * hHal - global structure
11206 * pUpdateIE - pointer to structure tUpdateIE
11207 * updateType - type of buffer
11208 * Return Success or failure
11209 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011210QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011211 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11212{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011213 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011214 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011216 status = sme_acquire_global_lock(&pMac->sme);
11217
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011218 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011219 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11220 sme_release_global_lock(&pMac->sme);
11221 }
11222 return status;
11223}
11224
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011225/**
11226 * sme_update_dsc_pto_up_mapping()
11227 * @hHal: HAL context
11228 * @dscpmapping: pointer to DSCP mapping structure
11229 * @sessionId: SME session id
11230 *
11231 * This routine is called to update dscp mapping
11232 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011233 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011234 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011235QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011236 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 uint8_t sessionId)
11238{
11239 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011240 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011241 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011242 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011243 tpPESession pSession = NULL;
11244
11245 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011246 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011247 return status;
11248 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11249 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011250 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011251 FL("Session lookup fails for CSR session"));
11252 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011253 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011254 }
11255 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011256 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011257 FL("Invalid session Id %u"), sessionId);
11258 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011259 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260 }
11261
11262 pSession = pe_find_session_by_bssid(pMac,
11263 pCsrSession->connectedProfile.bssid.bytes,
11264 &peSessionId);
11265
11266 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011267 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 FL(" Session lookup fails for BSSID"));
11269 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011270 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011271 }
11272
11273 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011274 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011276 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011277 }
11278 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11279 for (j = pSession->QosMapSet.dscp_range[i][0];
11280 j <= pSession->QosMapSet.dscp_range[i][1];
11281 j++) {
11282 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11283 && (pSession->QosMapSet.dscp_range[i][1] ==
11284 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011285 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011286 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011287 FL("User Priority %d isn't used"), i);
11288 break;
11289 } else {
11290 dscpmapping[j] = i;
11291 }
11292 }
11293 }
11294 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11295 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11296 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11297 pSession->QosMapSet.dscp_exceptions[i][1];
11298
11299 sme_release_global_lock(&pMac->sme);
11300 return status;
11301}
11302
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011303/*
11304 * sme_abort_roam_scan() -
11305 * API to abort current roam scan cycle by roam scan offload module.
11306 *
11307 * hHal - The handle returned by mac_open.
11308 * sessionId - Session Identifier
11309 * Return QDF_STATUS
11310 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011312QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011313{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011314 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11318 /* acquire the lock for the sme object */
11319 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011320 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011321 csr_roam_offload_scan(pMac, sessionId,
11322 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11323 REASON_ROAM_ABORT_ROAM_SCAN);
11324 /* release the lock for the sme object */
11325 sme_release_global_lock(&pMac->sme);
11326 }
11327 }
11328
11329 return status;
11330}
11331
11332#ifdef FEATURE_WLAN_EXTSCAN
11333/**
11334 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11335 * @hHal: HAL context
11336 * @wifiBand: RF band information
11337 * @aValidChannels: output array to store channel info
11338 * @pNumChannels: output number of channels
11339 *
11340 * SME API to fetch all valid channels filtered by band
11341 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011342 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011343 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011344QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011345 uint8_t wifiBand,
11346 uint32_t *aValidChannels,
11347 uint8_t *pNumChannels)
11348{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011349 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011350 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 uint8_t numChannels = 0;
11352 uint8_t i = 0;
11353 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011354 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011355
11356 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011357 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011358 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011359 }
11360
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011361 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011362 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011363 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011364 }
11365
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011366 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011367 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011368 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011369 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011370 return status;
11371 }
11372
11373 switch (wifiBand) {
11374 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011375 sme_debug("Unspec Band, return all %d valid channels",
11376 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011378 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011379 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011380 break;
11381
11382 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011383 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011385 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011386 aValidChannels[numChannels++] =
11387 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011388 }
11389 break;
11390
11391 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011392 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011393 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011394 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011395 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011396 aValidChannels[numChannels++] =
11397 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011398 }
11399 break;
11400
11401 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011402 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011403 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011404 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11405 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011406 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011407 aValidChannels[numChannels++] =
11408 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011409 }
11410 break;
11411
11412 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011413 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011414 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011415 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011416 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011417 aValidChannels[numChannels++] =
11418 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419 }
11420 break;
11421
11422 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011423 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011424 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011425 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011426 aValidChannels[numChannels++] =
11427 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011428 }
11429 break;
11430
11431 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011432 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011433 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011434 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011435 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011436 aValidChannels[numChannels++] =
11437 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011438 }
11439 break;
11440
11441 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011442 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011443 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011444 }
11445 *pNumChannels = numChannels;
11446
11447 return status;
11448}
11449
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011450/*
11451 * sme_ext_scan_get_capabilities() -
11452 * SME API to fetch extscan capabilities
11453 *
11454 * hHal
11455 * pReq: extscan capabilities structure
11456 * Return QDF_STATUS
11457 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011458QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011459 tSirGetExtScanCapabilitiesReqParams *
11460 pReq)
11461{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011462 QDF_STATUS status = QDF_STATUS_SUCCESS;
11463 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011464 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011465 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011466
11467 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011468 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011469 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011470 message.bodyptr = pReq;
11471 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011472 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011473 NO_SESSION, message.type));
11474 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11475 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011476 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11477 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011478
11479 sme_release_global_lock(&pMac->sme);
11480 }
11481 return status;
11482}
11483
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011484/*
11485 * sme_ext_scan_start() -
11486 * SME API to issue extscan start
11487 *
11488 * hHal
11489 * pStartCmd: extscan start structure
11490 * Return QDF_STATUS
11491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011492QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011493 tSirWifiScanCmdReqParams *pStartCmd)
11494{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011495 QDF_STATUS status = QDF_STATUS_SUCCESS;
11496 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011498 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011499
11500 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011501 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011502 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011503 message.bodyptr = pStartCmd;
11504 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011505 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011506 NO_SESSION, message.type));
11507 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11508 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011509 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11510 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511
11512 sme_release_global_lock(&pMac->sme);
11513 }
11514 return status;
11515}
11516
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011517/*
11518 * sme_ext_scan_stop() -
11519 * SME API to issue extscan stop
11520 *
11521 * hHal
11522 * pStopReq: extscan stop structure
11523 * Return QDF_STATUS
11524 */
11525QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11526 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011527{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011528 QDF_STATUS status = QDF_STATUS_SUCCESS;
11529 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011530 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011531 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011532
11533 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011534 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011535 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011536 message.bodyptr = pStopReq;
11537 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011538 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011539 NO_SESSION, message.type));
11540 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11541 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011542 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11543 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544 sme_release_global_lock(&pMac->sme);
11545 }
11546 return status;
11547}
11548
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011549/*
11550 * sme_set_bss_hotlist() -
11551 * SME API to set BSSID hotlist
11552 *
11553 * hHal
11554 * pSetHotListReq: extscan set hotlist structure
11555 * Return QDF_STATUS
11556 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011557QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558 tSirExtScanSetBssidHotListReqParams *
11559 pSetHotListReq)
11560{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011561 QDF_STATUS status = QDF_STATUS_SUCCESS;
11562 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011564 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565
11566 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011567 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011568 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011569 message.bodyptr = pSetHotListReq;
11570 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011571 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011572 NO_SESSION, message.type));
11573 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11574 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011575 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11576 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011577
11578 sme_release_global_lock(&pMac->sme);
11579 }
11580 return status;
11581}
11582
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011583/*
11584 * sme_reset_bss_hotlist() -
11585 * SME API to reset BSSID hotlist
11586 *
11587 * hHal
11588 * pSetHotListReq: extscan set hotlist structure
11589 * Return QDF_STATUS
11590 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011591QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011592 tSirExtScanResetBssidHotlistReqParams *
11593 pResetReq)
11594{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011595 QDF_STATUS status = QDF_STATUS_SUCCESS;
11596 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011597 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011598 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011599
11600 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011601 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011602 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011603 message.bodyptr = pResetReq;
11604 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011605 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011606 NO_SESSION, message.type));
11607 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11608 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011609 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11610 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011611
11612 sme_release_global_lock(&pMac->sme);
11613 }
11614 return status;
11615}
11616
Manikandan Mohan80dea792016-04-28 16:36:48 -070011617/**
11618 * sme_send_wisa_params(): Pass WISA mode to WMA
11619 * @hal: HAL context
11620 * @wisa_params: pointer to WISA params struct
11621 * @sessionId: SME session id
11622 *
11623 * Pass WISA params to WMA
11624 *
11625 * Return: QDF_STATUS
11626 */
11627QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11628 struct sir_wisa_params *wisa_params)
11629{
11630 QDF_STATUS status = QDF_STATUS_SUCCESS;
11631 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011632 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011633 struct sir_wisa_params *cds_msg_wisa_params;
11634
11635 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11636 if (!cds_msg_wisa_params)
11637 return QDF_STATUS_E_NOMEM;
11638
11639 *cds_msg_wisa_params = *wisa_params;
11640 status = sme_acquire_global_lock(&mac->sme);
11641 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011642 message.bodyptr = cds_msg_wisa_params;
11643 message.type = WMA_SET_WISA_PARAMS;
11644 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011645 sme_release_global_lock(&mac->sme);
11646 }
11647 return status;
11648}
11649
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011650/*
11651 * sme_set_significant_change() -
11652 * SME API to set significant change
11653 *
11654 * hHal
11655 * pSetSignificantChangeReq: extscan set significant change structure
11656 * Return QDF_STATUS
11657 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011658QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011659 tSirExtScanSetSigChangeReqParams *
11660 pSetSignificantChangeReq)
11661{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011662 QDF_STATUS status = QDF_STATUS_SUCCESS;
11663 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011665 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666
11667 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011668 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011669 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011670 message.bodyptr = pSetSignificantChangeReq;
11671 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011672 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011673 NO_SESSION, message.type));
11674 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11675 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011676 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11677 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011678
11679 sme_release_global_lock(&pMac->sme);
11680 }
11681 return status;
11682}
11683
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011684/*
11685 * sme_reset_significant_change
11686 * SME API to reset significant change
11687 *
11688 * hHal
11689 * pResetReq: extscan reset significant change structure
11690 * Return QDF_STATUS
11691 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011692QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011693 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694 *pResetReq)
11695{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011696 QDF_STATUS status = QDF_STATUS_SUCCESS;
11697 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011698 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011699 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011700
11701 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011702 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011703 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011704 message.bodyptr = pResetReq;
11705 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011706 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011707 NO_SESSION, message.type));
11708 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11709 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011710 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11711 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011712
11713 sme_release_global_lock(&pMac->sme);
11714 }
11715 return status;
11716}
11717
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011718/*
11719 * sme_get_cached_results() -
11720 * SME API to get cached results
11721 *
11722 * hHal
11723 * pCachedResultsReq: extscan get cached results structure
11724 * Return QDF_STATUS
11725 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011726QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011727 tSirExtScanGetCachedResultsReqParams *
11728 pCachedResultsReq)
11729{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011730 QDF_STATUS status = QDF_STATUS_SUCCESS;
11731 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011732 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011733 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734
11735 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011736 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011737 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011738 message.bodyptr = pCachedResultsReq;
11739 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011740 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011741 NO_SESSION, message.type));
11742 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11743 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011744 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11745 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746
11747 sme_release_global_lock(&pMac->sme);
11748 }
11749 return status;
11750}
11751
11752/**
11753 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011754 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 * @input: request message
11756 *
11757 * This function constructs the cds message and fill in message type,
11758 * bodyptr with %input and posts it to WDA queue.
11759 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011760 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011761 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011762QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011763 struct wifi_epno_params *input)
11764{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011765 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011767 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 struct wifi_epno_params *req_msg;
11769 int len, i;
11770
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011771 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011772 len = sizeof(*req_msg) +
11773 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011774
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011775 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011776 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011777 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011778 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011779 }
11780
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011781 req_msg->num_networks = input->num_networks;
11782 req_msg->request_id = input->request_id;
11783 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011784
11785 /* Fill only when num_networks are non zero */
11786 if (req_msg->num_networks) {
11787 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11788 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11789 req_msg->initial_score_max = input->initial_score_max;
11790 req_msg->same_network_bonus = input->same_network_bonus;
11791 req_msg->secure_bonus = input->secure_bonus;
11792 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11793 req_msg->current_connection_bonus =
11794 input->current_connection_bonus;
11795
11796 for (i = 0; i < req_msg->num_networks; i++) {
11797 req_msg->networks[i].flags = input->networks[i].flags;
11798 req_msg->networks[i].auth_bit_field =
11799 input->networks[i].auth_bit_field;
11800 req_msg->networks[i].ssid.length =
11801 input->networks[i].ssid.length;
11802 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11803 input->networks[i].ssid.ssId,
11804 req_msg->networks[i].ssid.length);
11805 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011806 }
11807
11808 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011809 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011810 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011812 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011813 return status;
11814 }
11815
11816 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011817 message.bodyptr = req_msg;
11818 message.type = WMA_SET_EPNO_LIST_REQ;
11819 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011820 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011821 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011822 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011823 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011824 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011825 }
11826 sme_release_global_lock(&mac->sme);
11827 return status;
11828}
11829
11830/**
11831 * sme_set_passpoint_list() - set passpoint network list
11832 * @hal: global hal handle
11833 * @input: request message
11834 *
11835 * This function constructs the cds message and fill in message type,
11836 * bodyptr with @input and posts it to WDA queue.
11837 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011838 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011839 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011840QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011841 struct wifi_passpoint_req *input)
11842{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011843 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011844 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011845 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011846 struct wifi_passpoint_req *req_msg;
11847 int len, i;
11848
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011849 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011850 len = sizeof(*req_msg) +
11851 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011852 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011854 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011855 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011856 }
11857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858 req_msg->num_networks = input->num_networks;
11859 req_msg->request_id = input->request_id;
11860 req_msg->session_id = input->session_id;
11861 for (i = 0; i < req_msg->num_networks; i++) {
11862 req_msg->networks[i].id =
11863 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011864 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011865 input->networks[i].realm,
11866 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011867 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 input->networks[i].plmn,
11869 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011870 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011871 input->networks[i].roaming_consortium_ids,
11872 sizeof(req_msg->networks[i].roaming_consortium_ids));
11873 }
11874
11875 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011876 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011877 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011878 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011879 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011880 return status;
11881 }
11882
11883 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011884 message.bodyptr = req_msg;
11885 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11886 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011887 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011888 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011889 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011890 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011891 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011892 }
11893 sme_release_global_lock(&mac->sme);
11894 return status;
11895}
11896
11897/**
11898 * sme_reset_passpoint_list() - reset passpoint network list
11899 * @hHal: global hal handle
11900 * @input: request message
11901 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011902 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011903 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011904QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011905 struct wifi_passpoint_req *input)
11906{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011907 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011908 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011909 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011910 struct wifi_passpoint_req *req_msg;
11911
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011912 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011913 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011914 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011915 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011916 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011917 }
11918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 req_msg->request_id = input->request_id;
11920 req_msg->session_id = input->session_id;
11921
11922 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011923 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011924 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011925 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011926 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011927 return status;
11928 }
11929
11930 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011931 message.bodyptr = req_msg;
11932 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11933 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011934 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011935 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011936 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011937 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011938 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011939 }
11940 sme_release_global_lock(&mac->sme);
11941 return status;
11942}
11943
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011944QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011945 void (*pExtScanIndCb)(void *,
11946 const uint16_t,
11947 void *))
11948{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011949 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011950 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11951
11952 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011953 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011954 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11955 sme_release_global_lock(&pMac->sme);
11956 }
11957 return status;
11958}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011959#endif /* FEATURE_WLAN_EXTSCAN */
11960
11961#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11962
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011963/*
11964 * sme_ll_stats_clear_req() -
11965 * SME API to clear Link Layer Statistics
11966 *
11967 * hHal
11968 * pclearStatsReq: Link Layer clear stats request params structure
11969 * Return QDF_STATUS
11970 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011971QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011972 tSirLLStatsClearReq *pclearStatsReq)
11973{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011974 QDF_STATUS status = QDF_STATUS_SUCCESS;
11975 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011976 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011977 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011978 tSirLLStatsClearReq *clear_stats_req;
11979
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011980 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011981 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011982 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011983 "statsClearReqMask = 0x%X",
11984 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011985 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011986 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011987 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11989 "%s: invalid staId %d",
11990 __func__, pclearStatsReq->staId);
11991 return QDF_STATUS_E_INVAL;
11992 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011993
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011994 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011995
11996 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011997 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011998 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11999 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012000 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012001 }
12002
12003 *clear_stats_req = *pclearStatsReq;
12004
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012005 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012006 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012007 message.bodyptr = clear_stats_req;
12008 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012009 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012010 NO_SESSION, message.type));
12011 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12012 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012013 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012014 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012015 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
12016 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012017 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012018 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012019 }
12020 sme_release_global_lock(&pMac->sme);
12021 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012022 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12023 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012024 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012025 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012026 }
12027
12028 return status;
12029}
12030
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012031/*
12032 * sme_ll_stats_set_req() -
12033 * SME API to set the Link Layer Statistics
12034 *
12035 * hHal
12036 * psetStatsReq: Link Layer set stats request params structure
12037 * Return QDF_STATUS
12038 */
12039QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
12040 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012041{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012042 QDF_STATUS status = QDF_STATUS_SUCCESS;
12043 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012045 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012046 tSirLLStatsSetReq *set_stats_req;
12047
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012049 "%s: MPDU Size = %u", __func__,
12050 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012051 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012052 " Aggressive Stats Collections = %u",
12053 psetStatsReq->aggressiveStatisticsGathering);
12054
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012055 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012056
12057 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012058 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012059 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
12060 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012061 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012062 }
12063
12064 *set_stats_req = *psetStatsReq;
12065
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012066 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012067 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012068 message.bodyptr = set_stats_req;
12069 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012070 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012071 NO_SESSION, message.type));
12072 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12073 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012074 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012075 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012076 "%s: not able to post WMA_LL_STATS_SET_REQ",
12077 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012078 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012079 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080 }
12081 sme_release_global_lock(&pMac->sme);
12082 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012083 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12084 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012085 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012086 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087 }
12088
12089 return status;
12090}
12091
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012092/*
12093 * sme_ll_stats_get_req() -
12094 * SME API to get the Link Layer Statistics
12095 *
12096 * hHal
12097 * pgetStatsReq: Link Layer get stats request params structure
12098 * Return QDF_STATUS
12099 */
12100QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
12101 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012102{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012103 QDF_STATUS status = QDF_STATUS_SUCCESS;
12104 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012105 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012106 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012107 tSirLLStatsGetReq *get_stats_req;
12108
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012109 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012110
12111 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012113 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
12114 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012115 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116 }
12117
12118 *get_stats_req = *pgetStatsReq;
12119
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012120 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012121 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012122 message.bodyptr = get_stats_req;
12123 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012124 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012125 NO_SESSION, message.type));
12126 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12127 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012128 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012129 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012130 "%s: not able to post WMA_LL_STATS_GET_REQ",
12131 __func__);
12132
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012133 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012134 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012135
12136 }
12137 sme_release_global_lock(&pMac->sme);
12138 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012139 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12140 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012141 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012142 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143 }
12144
12145 return status;
12146}
12147
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012148/*
12149 * sme_set_link_layer_stats_ind_cb() -
12150 * SME API to trigger the stats are available after get request
12151 *
12152 * hHal
12153 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012154 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012155 * Return QDF_STATUS
12156 */
12157QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12158 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12159{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012160 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012161 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12162
12163 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012164 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12166 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012167 } else
12168 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12169 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012170
12171 return status;
12172}
12173
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012174/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012175 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12176 * @hal: Mac global handle
12177 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12178 * status notification from FW
12179 *
12180 * Return: eHalStatus
12181 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012182QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12183 (tHddHandle callback_ctx, tSirLLStatsResults
12184 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012185{
12186 QDF_STATUS status;
12187 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12188
12189 status = sme_acquire_global_lock(&mac->sme);
12190 if (status == QDF_STATUS_SUCCESS) {
12191 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12192 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012193 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12195 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012196 return status;
12197}
12198
12199/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012200 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12201 * indication
12202 * @h_hal: Hal Handle
12203 *
12204 * This function reset's the link layer stats indication
12205 *
12206 * Return: QDF_STATUS Enumeration
12207 */
12208
12209QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12210{
12211 QDF_STATUS status;
12212 tpAniSirGlobal pmac;
12213
12214 if (!h_hal) {
12215 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12216 FL("hHal is not valid"));
12217 return QDF_STATUS_E_INVAL;
12218 }
12219 pmac = PMAC_STRUCT(h_hal);
12220
12221 status = sme_acquire_global_lock(&pmac->sme);
12222 if (QDF_IS_STATUS_SUCCESS(status)) {
12223 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12224 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012225 } else
12226 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12227 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012228
12229 return status;
12230}
12231
Zhang Qian73c348a2017-03-13 16:15:55 +080012232/**
12233 * sme_ll_stats_set_thresh - set threshold for mac counters
12234 * @hal, hal layer handle
12235 * @threshold, threshold for mac counters
12236 *
12237 * Return: QDF_STATUS Enumeration
12238 */
12239QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12240 struct sir_ll_ext_stats_threshold *threshold)
12241{
12242 QDF_STATUS status;
12243 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080012244 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080012245 struct sir_ll_ext_stats_threshold *thresh;
12246
12247 if (!threshold) {
12248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12249 FL("threshold is not valid"));
12250 return QDF_STATUS_E_INVAL;
12251 }
12252
12253 if (!hal) {
12254 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12255 FL("hal is not valid"));
12256 return QDF_STATUS_E_INVAL;
12257 }
12258 mac = PMAC_STRUCT(hal);
12259
12260 thresh = qdf_mem_malloc(sizeof(*thresh));
12261 if (!thresh) {
12262 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12263 "%s: Fail to alloc mem", __func__);
12264 return QDF_STATUS_E_NOMEM;
12265 }
12266 *thresh = *threshold;
12267
12268 status = sme_acquire_global_lock(&mac->sme);
12269 if (QDF_IS_STATUS_SUCCESS(status)) {
12270 /* Serialize the req through MC thread */
12271 message.bodyptr = thresh;
12272 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12273 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12274 NO_SESSION, message.type));
12275 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12276 if (!QDF_IS_STATUS_SUCCESS(status)) {
12277 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12278 "%s: not able to post WDA_LL_STATS_GET_REQ",
12279 __func__);
12280 qdf_mem_free(thresh);
12281 }
12282 sme_release_global_lock(&mac->sme);
12283 } else {
12284 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12285 FL("sme_acquire_global_lock error"));
12286 qdf_mem_free(thresh);
12287 }
12288 return status;
12289}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012291#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12292
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012293#ifdef WLAN_POWER_DEBUGFS
12294/**
12295 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12296 * @callback_fn: Pointer to the callback function for Power stats event
12297 * @power_stats_context: Pointer to context
12298 *
12299 * Return: QDF_STATUS
12300 */
12301QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12302 (struct power_stats_response *response,
12303 void *context), void *power_stats_context)
12304{
12305 QDF_STATUS status = QDF_STATUS_SUCCESS;
12306 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012307 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012308
12309 status = sme_acquire_global_lock(&mac_ctx->sme);
12310 if (QDF_IS_STATUS_SUCCESS(status)) {
12311 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012312 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012313 sme_release_global_lock(&mac_ctx->sme);
12314 return QDF_STATUS_E_FAILURE;
12315 }
12316
12317 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12318 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12319 msg.bodyptr = NULL;
12320 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012321 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012322 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012323 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012324 sme_release_global_lock(&mac_ctx->sme);
12325 }
12326 return status;
12327}
12328#endif
12329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012330#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012331/*
12332 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12333 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12334 *
12335 * hHal - The handle returned by mac_open.
12336 * nRoamOffloadEnabled - The bool to update with
12337 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12338 * Other status means SME is failed to update.
12339 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012341QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012342 bool nRoamOffloadEnabled)
12343{
12344 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012345 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012346
12347 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012348 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012349 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012350 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12351 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12352 nRoamOffloadEnabled);
12353 pMac->roam.configParam.isRoamOffloadEnabled =
12354 nRoamOffloadEnabled;
12355 sme_release_global_lock(&pMac->sme);
12356 }
12357
12358 return status;
12359}
12360
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012361/**
12362 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12363 * This is a synchronous call
12364 * @hal_ctx: The handle returned by mac_open.
12365 * @session_id: Session Identifier
12366 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012367 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012368 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12369 * Other status means SME is failed to update.
12370 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012371
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012372QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012373 uint8_t session_id,
12374 bool key_mgmt_offload_enabled,
12375 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012376{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012377 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012378 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012379
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012380 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012381 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012382 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012383 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012384 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12385 __func__, key_mgmt_offload_enabled);
12386 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12387 session_id,
12388 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012389 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012390 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012391 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012392 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012393 }
12394
12395 return status;
12396}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012397#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012398
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012399/*
12400 * sme_get_temperature() -
12401 * SME API to get the pdev temperature
12402 *
12403 * hHal
12404 * temperature context
12405 * pCallbackfn: callback fn with response (temperature)
12406 * Return QDF_STATUS
12407 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012408QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012409 void *tempContext,
12410 void (*pCallbackfn)(int temperature,
12411 void *pContext))
12412{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012413 QDF_STATUS status = QDF_STATUS_SUCCESS;
12414 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012415 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012416 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012417
12418 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012419 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012420 if ((NULL == pCallbackfn) &&
12421 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012422 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012423 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012424 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012425 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426 } else if (NULL != pCallbackfn) {
12427 pMac->sme.pTemperatureCbContext = tempContext;
12428 pMac->sme.pGetTemperatureCb = pCallbackfn;
12429 }
12430 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012431 message.bodyptr = NULL;
12432 message.type = WMA_GET_TEMPERATURE_REQ;
12433 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12434 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012435 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012436 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012437 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012438 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012439 }
12440 sme_release_global_lock(&pMac->sme);
12441 }
12442 return status;
12443}
12444
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012445/*
12446 * sme_set_scanning_mac_oui() -
12447 * SME API to set scanning mac oui
12448 *
12449 * hHal
12450 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12451 * Return QDF_STATUS
12452 */
12453QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12454 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012455{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012456 QDF_STATUS status = QDF_STATUS_SUCCESS;
12457 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012459 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012460
12461 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012462 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012463 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012464 message.bodyptr = pScanMacOui;
12465 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12466 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12467 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012468 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012469 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012470 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012471 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012472 }
12473 sme_release_global_lock(&pMac->sme);
12474 }
12475 return status;
12476}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012477
12478#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012479/*
12480 * sme_set_dhcp_srv_offload() -
12481 * SME API to set DHCP server offload info
12482 *
12483 * hHal
12484 * pDhcpSrvInfo : DHCP server offload info struct
12485 * Return QDF_STATUS
12486 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012487QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012488 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12489{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012490 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012491 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012492 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12494
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012495 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012496
12497 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012498 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012499 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12500 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012501 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012502 }
12503
12504 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12505
12506 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012507 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012508 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012509 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12510 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012511
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012512 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012513 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12514 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012515 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012516 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012517 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012518 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012519 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012520 }
12521 sme_release_global_lock(&pMac->sme);
12522 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012523 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012524 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012525 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012526 }
12527
12528 return status;
12529}
12530#endif /* DHCP_SERVER_OFFLOAD */
12531
Krunal Soniaadaa272017-10-04 16:42:55 -070012532QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12533 uint32_t arg_count, uint32_t *arg)
12534{
12535 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12536 arg_count, arg);
12537}
12538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012539#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012540/*
12541 * sme_set_led_flashing() -
12542 * API to set the Led flashing parameters.
12543 *
12544 * hHal - The handle returned by mac_open.
12545 * x0, x1 - led flashing parameters
12546 * Return QDF_STATUS
12547 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012548QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012549 uint32_t x0, uint32_t x1)
12550{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012551 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012553 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012554 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012555
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012556 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012557 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012558 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012559 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012560 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012561 }
12562
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012563 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012564 ledflashing->pattern_id = type;
12565 ledflashing->led_x0 = x0;
12566 ledflashing->led_x1 = x1;
12567
12568 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012569 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012570 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012571 message.bodyptr = ledflashing;
12572 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012573 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012574 sme_release_global_lock(&pMac->sme);
12575 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012576 if (!QDF_IS_STATUS_SUCCESS(status))
12577 qdf_mem_free(ledflashing);
12578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012579 return status;
12580}
12581#endif
12582
12583/**
12584 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12585 * @h_hal: corestack handler
12586 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012587 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012588 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012589QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012590{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012591 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12593
12594 status = sme_acquire_global_lock(&mac->sme);
12595
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012596 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597
12598 mac->scan.fEnableDFSChnlScan = dfs_flag;
12599
12600 /* update the channel list to the firmware */
12601 status = csr_update_channel_list(mac);
12602
12603 sme_release_global_lock(&mac->sme);
12604 }
12605
12606 return status;
12607}
12608
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012609#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12610/**
12611 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12612 * concurreny rules set to avoid channel interference.
12613 * @hal - Hal context
12614 * @sap_ch - channel to switch
12615 * @sap_phy_mode - phy mode of SAP
12616 * @cc_switch_mode - concurreny switch mode
12617 * @session_id - sme session id.
12618 *
12619 * Return: true if there is no channel interference else return false
12620 */
12621bool sme_validate_sap_channel_switch(tHalHandle hal,
12622 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12623 uint8_t session_id)
12624{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012625 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012626 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012627 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012628 uint16_t intf_channel = 0;
12629
12630 if (!session)
12631 return false;
12632
12633 session->ch_switch_in_progress = true;
12634 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012635 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012636 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12637 sap_phy_mode,
12638 cc_switch_mode);
12639 sme_release_global_lock(&mac->sme);
12640 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012641 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012642 FL("sme_acquire_global_lock error!"));
12643 session->ch_switch_in_progress = false;
12644 return false;
12645 }
12646
12647 session->ch_switch_in_progress = false;
12648 return (intf_channel == 0) ? true : false;
12649}
12650#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012651
12652/**
12653 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12654 * @hal: hal
12655 * @session_id: session ID
12656 * @stats_avg_factor: average stats factor
12657 *
12658 * This function configures the stats avg factor in firmware
12659 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012660 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012661 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012662QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012663 uint16_t stats_avg_factor)
12664{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012665 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012666 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012667 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12668 struct sir_stats_avg_factor *stats_factor;
12669
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012670 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012671
12672 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012673 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012674 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12675 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012676 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012677 }
12678
12679 status = sme_acquire_global_lock(&mac->sme);
12680
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012681 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012682
12683 stats_factor->vdev_id = session_id;
12684 stats_factor->stats_avg_factor = stats_avg_factor;
12685
12686 /* serialize the req through MC thread */
12687 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12688 msg.bodyptr = stats_factor;
12689
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012690 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012691 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012692 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012693 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12694 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012695 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012696 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012697 }
12698 sme_release_global_lock(&mac->sme);
12699 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012701 "%s: sme_acquire_global_lock error!",
12702 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012703 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012704 }
12705
12706 return status;
12707}
12708
12709/**
12710 * sme_configure_guard_time() - function to configure guard time
12711 * @hal: hal
12712 * @session_id: session id
12713 * @guard_time: guard time
12714 *
12715 * This function configures the guard time in firmware
12716 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012717 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012718 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012719QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012720 uint32_t guard_time)
12721{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012722 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012723 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012724 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12725 struct sir_guard_time_request *g_time;
12726
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012727 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012728
12729 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012730 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012731 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12732 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012733 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012734 }
12735
12736 status = sme_acquire_global_lock(&mac->sme);
12737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012738 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012739
12740 g_time->vdev_id = session_id;
12741 g_time->guard_time = guard_time;
12742
12743 /* serialize the req through MC thread */
12744 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12745 msg.bodyptr = g_time;
12746
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012747 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012748 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012749 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012750 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12751 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012752 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012753 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012754 }
12755 sme_release_global_lock(&mac->sme);
12756 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012757 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012758 "%s: sme_acquire_global_lock error!",
12759 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012760 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012761 }
12762
12763 return status;
12764}
12765
12766/**
12767 * sme_configure_modulated_dtim() - function to configure modulated dtim
12768 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12769 * @session_id: session ID
12770 * @modulated_dtim: modulated dtim value
12771 *
12772 * This function configures the modulated dtim in firmware
12773 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012774 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012775 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012776QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012777 uint32_t modulated_dtim)
12778{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012779 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012780 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012781 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12782 wma_cli_set_cmd_t *iwcmd;
12783
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012784 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012785 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012786 QDF_TRACE(QDF_MODULE_ID_SME,
12787 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012788 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012789 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012790 }
12791
12792 status = sme_acquire_global_lock(&mac->sme);
12793
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012794 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012796 iwcmd->param_value = modulated_dtim;
12797 iwcmd->param_vdev_id = session_id;
12798 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12799 iwcmd->param_vp_dev = GEN_CMD;
12800 msg.type = WMA_CLI_SET_CMD;
12801 msg.reserved = 0;
12802 msg.bodyptr = (void *)iwcmd;
12803
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012804 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012805 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012807 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12808 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012809 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012810 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012811 }
12812 sme_release_global_lock(&mac->sme);
12813 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012814 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012815 "%s: sme_acquire_global_lock error!",
12816 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012817 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818 }
12819
12820 return status;
12821}
12822
Mukul Sharma6398b252017-05-01 17:58:12 +053012823/**
12824 * sme_override_listen_interval() - function to override static LI
12825 * @h_hal: SME API to override listen interval
12826 * @session_id: session ID
12827 * @override_li: new LI value passed by user
12828 *
12829 * This function override (enable/disable) static a.k.a ini based LI
12830 *
12831 * Return: QDF_STATUS
12832 */
12833QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12834 uint32_t override_li)
12835{
12836 struct scheduler_msg msg = {0};
12837 QDF_STATUS status = QDF_STATUS_SUCCESS;
12838 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12839 wma_cli_set_cmd_t *iwcmd;
12840
12841 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12842 if (!iwcmd) {
12843 QDF_TRACE(QDF_MODULE_ID_SME,
12844 QDF_TRACE_LEVEL_FATAL,
12845 "%s: qdf_mem_malloc failed", __func__);
12846 return QDF_STATUS_E_NOMEM;
12847 }
12848
12849 status = sme_acquire_global_lock(&mac->sme);
12850
12851 if (status == QDF_STATUS_SUCCESS) {
12852
12853 iwcmd->param_value = override_li;
12854 iwcmd->param_vdev_id = session_id;
12855 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12856 iwcmd->param_vp_dev = GEN_CMD;
12857 msg.type = WMA_CLI_SET_CMD;
12858 msg.reserved = 0;
12859 msg.bodyptr = (void *)iwcmd;
12860
12861 if (!QDF_IS_STATUS_SUCCESS(
12862 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12864 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12865 __func__);
12866 qdf_mem_free(iwcmd);
12867 status = QDF_STATUS_E_FAILURE;
12868 }
12869 sme_release_global_lock(&mac->sme);
12870 } else {
12871 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12872 "%s: sme_acquire_global_lock error!",
12873 __func__);
12874 qdf_mem_free(iwcmd);
12875 }
12876
12877 return status;
12878}
12879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012880/*
12881 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12882 * to either start/stop logging
12883 * @hal: HAL context
12884 * @start_log: Structure containing the wifi start logger params
12885 *
12886 * This function sends the start/stop logging command to WMA
12887 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012888 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012889 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012890QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012891 struct sir_wifi_start_log start_log)
12892{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012893 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012894 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012895 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012896 struct sir_wifi_start_log *req_msg;
12897 uint32_t len;
12898
12899 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012900 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012901 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012902 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012903 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012904 }
12905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012906 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012907 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012908 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012909 req_msg->ini_triggered = start_log.ini_triggered;
12910 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012911 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012912 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012913
12914 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012915 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012916 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012917 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012918 return status;
12919 }
12920
12921 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012922 message.bodyptr = req_msg;
12923 message.type = SIR_HAL_START_STOP_LOGGING;
12924 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012925 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012926 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012927 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012928 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012929 }
12930 sme_release_global_lock(&mac->sme);
12931
12932 return status;
12933}
12934
12935/**
12936 * sme_neighbor_middle_of_roaming() - Function to know if
12937 * STA is in the middle of roaming states
12938 * @hal: Handle returned by macOpen
12939 * @sessionId: sessionId of the STA session
12940 *
12941 * This function is a wrapper to call
12942 * csr_neighbor_middle_of_roaming to know STA is in the
12943 * middle of roaming states
12944 *
12945 * Return: True or False
12946 *
12947 */
12948bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12949{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012950 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12951 bool val = false;
12952
12953 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12954 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12955 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012956 sme_err("Invalid Session: %d", sessionId);
12957
Sandeep Puligillaca631612016-11-08 11:53:52 -080012958 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012959}
12960
12961/*
12962 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12963 * @mac: MAC handle
12964 *
12965 * This function is used to send the command that will
12966 * be used to flush the logs in the firmware
12967 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012968 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012969 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012970QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012971{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012972 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012973 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012975 /* Serialize the req through MC thread */
12976 message.bodyptr = NULL;
12977 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012978 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012979 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012980 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012981 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012982 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012983 return status;
12984}
12985
Jeff Johnsona1e92612017-09-24 15:33:44 -070012986QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012987 sme_ac_enum_type ac, uint8_t tid,
12988 uint8_t pri, uint32_t srvc_int,
12989 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012990 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012991 uint8_t psb, uint32_t sessionId,
12992 uint32_t delay_interval)
12993{
12994 void *wma_handle;
12995 t_wma_trigger_uapsd_params uapsd_params;
12996 enum uapsd_ac access_category;
12997
12998 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012999 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013000 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013001 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013002 }
13003
Anurag Chouhan6d760662016-02-20 16:05:43 +053013004 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013005 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013006 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013007 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013008 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013009 }
13010
13011 switch (ac) {
13012 case SME_AC_BK:
13013 access_category = UAPSD_BK;
13014 break;
13015 case SME_AC_BE:
13016 access_category = UAPSD_BE;
13017 break;
13018 case SME_AC_VI:
13019 access_category = UAPSD_VI;
13020 break;
13021 case SME_AC_VO:
13022 access_category = UAPSD_VO;
13023 break;
13024 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013025 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013026 }
13027
13028 uapsd_params.wmm_ac = access_category;
13029 uapsd_params.user_priority = pri;
13030 uapsd_params.service_interval = srvc_int;
13031 uapsd_params.delay_interval = delay_interval;
13032 uapsd_params.suspend_interval = sus_int;
13033
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013034 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013035 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013036 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013037 "Failed to Trigger Uapsd params for sessionId %d",
13038 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013039 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013040 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013041 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013042}
13043
Jeff Johnsona1e92612017-09-24 15:33:44 -070013044QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013045 sme_ac_enum_type ac,
13046 uint32_t sessionId)
13047{
13048 void *wma_handle;
13049 enum uapsd_ac access_category;
13050
13051 switch (ac) {
13052 case SME_AC_BK:
13053 access_category = UAPSD_BK;
13054 break;
13055 case SME_AC_BE:
13056 access_category = UAPSD_BE;
13057 break;
13058 case SME_AC_VI:
13059 access_category = UAPSD_VI;
13060 break;
13061 case SME_AC_VO:
13062 access_category = UAPSD_VO;
13063 break;
13064 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013065 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013066 }
13067
Anurag Chouhan6d760662016-02-20 16:05:43 +053013068 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013069 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013070 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013071 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013072 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013073 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013074 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013075 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013077 "Failed to disable uapsd for ac %d for sessionId %d",
13078 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013079 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013080 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013081 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013082}
13083
13084/**
13085 * sme_update_nss() - SME API to change the number for spatial streams
13086 * (1 or 2)
13087 * @hal: Handle returned by mac open
13088 * @nss: Number of spatial streams
13089 *
13090 * This function is used to update the number of spatial streams supported.
13091 *
13092 * Return: Success upon successfully changing nss else failure
13093 *
13094 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013095QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013096{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013097 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013098 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13099 uint32_t i, value = 0;
13100 union {
13101 uint16_t cfg_value16;
13102 tSirMacHTCapabilityInfo ht_cap_info;
13103 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013104 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013105
13106 status = sme_acquire_global_lock(&mac_ctx->sme);
13107
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013108 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013109 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13110
13111 /* get the HT capability info*/
13112 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13113 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13114
13115 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13116 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13117 csr_session = &mac_ctx->roam.roamSession[i];
13118 csr_session->htConfig.ht_tx_stbc =
13119 uHTCapabilityInfo.ht_cap_info.txSTBC;
13120 }
13121 }
13122
13123 sme_release_global_lock(&mac_ctx->sme);
13124 }
13125 return status;
13126}
13127
13128/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013129 * sme_update_user_configured_nss() - sets the nss based on user request
13130 * @hal: Pointer to HAL
13131 * @nss: number of streams
13132 *
13133 * Return: None
13134 */
13135void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13136{
13137 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13138
13139 mac_ctx->user_configured_nss = nss;
13140}
13141
13142/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013143 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13144 * @hal: global hal handle
13145 * @cb: callback function pointer
13146 *
13147 * This function stores nud debug stats callback function.
13148 *
13149 * Return: QDF_STATUS enumeration.
13150 */
13151QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13152 void (*cb)(void *, struct rsp_stats *))
13153{
13154 QDF_STATUS status = QDF_STATUS_SUCCESS;
13155 tpAniSirGlobal mac;
13156
13157 if (!hal) {
13158 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13159 FL("hal is not valid"));
13160 return QDF_STATUS_E_INVAL;
13161 }
13162 mac = PMAC_STRUCT(hal);
13163
13164 status = sme_acquire_global_lock(&mac->sme);
13165 if (!QDF_IS_STATUS_SUCCESS(status)) {
13166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13167 FL("sme_acquire_global_lock failed!(status=%d)"),
13168 status);
13169 return status;
13170 }
13171
13172 mac->sme.get_arp_stats_cb = cb;
13173 sme_release_global_lock(&mac->sme);
13174 return status;
13175}
13176
13177/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013178 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013179 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013180 * @cb: callback function pointer
13181 *
13182 * This function stores the rssi threshold breached callback function.
13183 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013184 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013185 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013186QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 void (*cb)(void *, struct rssi_breach_event *))
13188{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013189 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013190 tpAniSirGlobal mac;
13191
13192 if (!h_hal) {
13193 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13194 FL("hHal is not valid"));
13195 return QDF_STATUS_E_INVAL;
13196 }
13197 mac = PMAC_STRUCT(h_hal);
13198
13199 status = sme_acquire_global_lock(&mac->sme);
13200 if (!QDF_IS_STATUS_SUCCESS(status)) {
13201 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13202 FL("sme_acquire_global_lock failed!(status=%d)"),
13203 status);
13204 return status;
13205 }
13206
13207 mac->sme.rssi_threshold_breached_cb = cb;
13208 sme_release_global_lock(&mac->sme);
13209 return status;
13210}
13211
13212/**
13213 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13214 * @hal: global hal handle
13215 *
13216 * This function de-registers the rssi threshold breached callback function.
13217 *
13218 * Return: QDF_STATUS enumeration.
13219 */
13220QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13221{
13222 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13224
13225 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013226 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013227 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013228 return status;
13229 }
13230
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013231 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013232 sme_release_global_lock(&mac->sme);
13233 return status;
13234}
13235
13236/**
13237 * sme_is_any_session_in_connected_state() - SME wrapper API to
13238 * check if any session is in connected state or not.
13239 *
13240 * @hal: Handle returned by mac open
13241 *
13242 * This function is used to check if any valid sme session is in
13243 * connected state or not.
13244 *
13245 * Return: true if any session is connected, else false.
13246 *
13247 */
13248bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13249{
13250 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013251 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013252 bool ret = false;
13253
13254 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013255 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013256 ret = csr_is_any_session_in_connect_state(mac_ctx);
13257 sme_release_global_lock(&mac_ctx->sme);
13258 }
13259 return ret;
13260}
13261
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013262QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13263 void (*cb)(void *,
13264 struct chip_pwr_save_fail_detected_params *)) {
13265
13266 QDF_STATUS status = QDF_STATUS_SUCCESS;
13267 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13268
13269 status = sme_acquire_global_lock(&mac->sme);
13270 if (status != QDF_STATUS_SUCCESS) {
13271 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13272 return status;
13273 }
13274 mac->sme.chip_power_save_fail_cb = cb;
13275 sme_release_global_lock(&mac->sme);
13276 return status;
13277}
13278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013279/**
13280 * sme_set_rssi_monitoring() - set rssi monitoring
13281 * @hal: global hal handle
13282 * @input: request message
13283 *
13284 * This function constructs the vos message and fill in message type,
13285 * bodyptr with @input and posts it to WDA queue.
13286 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013287 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013288 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013289QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290 struct rssi_monitor_req *input)
13291{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013292 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013293 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013294 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013295 struct rssi_monitor_req *req_msg;
13296
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013297 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013298 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013299 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013300 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013301 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013302 }
13303
13304 *req_msg = *input;
13305
13306 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013307 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013308 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013309 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013310 return status;
13311 }
13312
13313 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013314 message.bodyptr = req_msg;
13315 message.type = WMA_SET_RSSI_MONITOR_REQ;
13316 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013317 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013318 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013319 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013320 }
13321 sme_release_global_lock(&mac->sme);
13322
13323 return status;
13324}
13325
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013326/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013327 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013328 * @hal: Handle returned by macOpen
13329 * @msg: PCL channel list and length structure
13330 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013331 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013332 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013333 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013334QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013335{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013336 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013337 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013338 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013339 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013340 uint32_t len, i;
13341
Krunal Soni3fa80e22018-01-09 14:16:02 -080013342 if (!mac) {
13343 sme_err("mac is NULL");
13344 return QDF_STATUS_E_FAILURE;
13345 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013346 len = sizeof(*req_msg);
13347
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013348 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013349 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013350 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013351 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013352 }
13353
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013354 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013355 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013356 req_msg->weight_list[i] = msg.weight_list[i];
13357 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013358
13359 req_msg->pcl_len = msg.pcl_len;
13360
13361 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013362 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013363 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013364 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013365 return status;
13366 }
13367
13368 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013369 message.bodyptr = req_msg;
13370 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13371 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013372 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013373 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013374 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013375 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013376 }
13377 sme_release_global_lock(&mac->sme);
13378
13379 return status;
13380}
13381
13382/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013383 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013384 * @hal: Handle returned by macOpen
13385 * @msg: HW mode structure containing hw mode and callback details
13386 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013387 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013388 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013389 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013390QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013391{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013392 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013393 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013394 tSmeCmd *cmd = NULL;
13395
Krunal Soni3fa80e22018-01-09 14:16:02 -080013396 if (!mac) {
13397 sme_err("mac is NULL");
13398 return QDF_STATUS_E_FAILURE;
13399 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013400 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013401 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013402 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013403 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013404 }
13405
Krunal Soni78618d92017-02-14 21:46:31 -080013406 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013407 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013408 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013409 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013410 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013411 }
13412
13413 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013414 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013415 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13416 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013417 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13418 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013419 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013420 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013421
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013422 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013423 cmd->u.set_hw_mode_cmd.session_id,
13424 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013425 csr_queue_sme_command(mac, cmd, false);
13426
13427 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013428 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429}
13430
13431/**
13432 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13433 * @hal: Handle returned by macOpen
13434 * @callback: HDD callback to be registered
13435 *
13436 * Registers the HDD callback with SME. This callback will be invoked when
13437 * HW mode transition event is received from the FW
13438 *
13439 * Return: None
13440 */
13441void sme_register_hw_mode_trans_cb(tHalHandle hal,
13442 hw_mode_transition_cb callback)
13443{
13444 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13445
13446 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013447}
13448
13449/**
13450 * sme_nss_update_request() - Send beacon templete update to FW with new
13451 * nss value
13452 * @hal: Handle returned by macOpen
13453 * @vdev_id: the session id
13454 * @new_nss: the new nss value
13455 * @cback: hdd callback
13456 * @next_action: next action to happen at policy mgr after beacon update
13457 *
13458 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013459 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013461QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13462 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13463 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13464 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013465{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013466 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013467 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013468 tSmeCmd *cmd = NULL;
13469
Krunal Soni3fa80e22018-01-09 14:16:02 -080013470 if (!mac) {
13471 sme_err("mac is null");
13472 return status;
13473 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013474 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013475 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013476 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013477 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013478 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013479 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013480 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013481 }
13482 cmd->command = e_sme_command_nss_update;
13483 /* Sessionized modules may require this info */
13484 cmd->sessionId = vdev_id;
13485 cmd->u.nss_update_cmd.new_nss = new_nss;
13486 cmd->u.nss_update_cmd.session_id = vdev_id;
13487 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013488 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013489 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013490 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013492 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013493 csr_queue_sme_command(mac, cmd, false);
13494 sme_release_global_lock(&mac->sme);
13495 }
13496 return status;
13497}
13498
13499/**
13500 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13501 * @hal: Handle returned by macOpen
13502 * @msg: Structure containing the dual mac config parameters
13503 *
13504 * Queues configuration information to CSR to configure
13505 * WLAN firmware for the dual MAC features
13506 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013507 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013508 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013509QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013510{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013511 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013512 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013513 tSmeCmd *cmd;
13514
Krunal Soni3fa80e22018-01-09 14:16:02 -080013515 if (!mac) {
13516 sme_err("mac is null");
13517 return QDF_STATUS_E_FAILURE;
13518 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013519 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013520 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013521 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013522 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013523 }
13524
Krunal Soni78618d92017-02-14 21:46:31 -080013525 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013526 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013527 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013528 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013529 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013530 }
13531
13532 cmd->command = e_sme_command_set_dual_mac_config;
13533 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13534 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13535 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13536
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013537 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013538 cmd->u.set_dual_mac_cmd.scan_config,
13539 cmd->u.set_dual_mac_cmd.fw_mode_config);
13540 csr_queue_sme_command(mac, cmd, false);
13541
13542 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013543 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013544}
13545
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013546#ifdef FEATURE_LFR_SUBNET_DETECTION
13547/**
13548 * sme_gateway_param_update() - to update gateway parameters with WMA
13549 * @Hal: hal handle
13550 * @gw_params: request parameters from HDD
13551 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013552 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013553 *
13554 * This routine will update gateway parameters to WMA
13555 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013556QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013557 struct gateway_param_update_req *gw_params)
13558{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013559 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013560 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013561 struct gateway_param_update_req *request_buf;
13562
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013563 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013564 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013565 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013566 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013567 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013568 }
13569
13570 *request_buf = *gw_params;
13571
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013572 message.type = WMA_GW_PARAM_UPDATE_REQ;
13573 message.reserved = 0;
13574 message.bodyptr = request_buf;
13575 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013576 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013577 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013578 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013579 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013580 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013581 }
13582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013583 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013584}
13585#endif /* FEATURE_LFR_SUBNET_DETECTION */
13586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013587/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013588 * sme_soc_set_antenna_mode() - set antenna mode
13589 * @hal: Handle returned by macOpen
13590 * @msg: Structure containing the antenna mode parameters
13591 *
13592 * Send the command to CSR to send
13593 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13594 *
13595 * Return: QDF_STATUS
13596 */
13597QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13598 struct sir_antenna_mode_param *msg)
13599{
13600 QDF_STATUS status = QDF_STATUS_SUCCESS;
13601 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13602 tSmeCmd *cmd;
13603
13604 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013605 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013606 return QDF_STATUS_E_FAILURE;
13607 }
13608
13609 status = sme_acquire_global_lock(&mac->sme);
13610 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013611 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013612 return QDF_STATUS_E_RESOURCES;
13613 }
13614
Krunal Soni78618d92017-02-14 21:46:31 -080013615 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013616 if (!cmd) {
13617 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013618 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013619 return QDF_STATUS_E_NULL_VALUE;
13620 }
13621
13622 cmd->command = e_sme_command_set_antenna_mode;
13623 cmd->u.set_antenna_mode_cmd = *msg;
13624
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013625 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013626 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13627 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13628
13629 csr_queue_sme_command(mac, cmd, false);
13630 sme_release_global_lock(&mac->sme);
13631
13632 return QDF_STATUS_SUCCESS;
13633}
13634
13635/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013636 * sme_set_peer_authorized() - call peer authorized callback
13637 * @peer_addr: peer mac address
13638 * @auth_cb: auth callback
13639 * @vdev_id: vdev id
13640 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013641 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013642 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013643QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013644 sme_peer_authorized_fp auth_cb,
13645 uint32_t vdev_id)
13646{
13647 void *wma_handle;
13648
Anurag Chouhan6d760662016-02-20 16:05:43 +053013649 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013650 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013651 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013652 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013653 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013654 }
13655
13656 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13657 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13658 1, vdev_id);
13659}
13660
13661/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013662 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013663 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013664 * @fcc_constraint: flag to enable/disable the constraint
13665 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013666 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013667 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013668 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013669QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13670 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013671{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013672 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013673 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13674
13675 status = sme_acquire_global_lock(&mac_ptr->sme);
13676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013677 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678
13679 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13680 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013681 if (scan_pending)
13682 mac_ptr->scan.defer_update_channel_list = true;
13683 else
13684 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013685 }
13686
13687 sme_release_global_lock(&mac_ptr->sme);
13688 }
13689
13690 return status;
13691}
13692/**
13693 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13694 * @hal: Global MAC pointer
13695 *
13696 * Return: NULL.
13697 */
13698void sme_setdef_dot11mode(tHalHandle hal)
13699{
13700 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013702 csr_set_default_dot11_mode(mac_ctx);
13703}
13704
13705/**
13706 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13707 * params
13708 * @hal_handle - The handle returned by macOpen.
13709 * @session_id - Session Identifier
13710 * @notify_id - Identifies 1 of the 4 parameters to be modified
13711 * @val New value of the parameter
13712 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013713 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013714 * Other status means SME failed to update
13715 */
13716
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013717QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013718 uint8_t session_id,
13719 uint32_t notify_id,
13720 int32_t val)
13721{
13722 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013723 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013724 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013725 tpCsrNeighborRoamControlInfo nr_info = NULL;
13726 uint32_t reason = 0;
13727
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013728 if (session_id >= CSR_ROAM_SESSION_MAX) {
13729 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13730 FL("Invalid sme session id: %d"), session_id);
13731 return QDF_STATUS_E_INVAL;
13732 }
13733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013734 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013735 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013736 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13737 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13738 switch (notify_id) {
13739 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013740 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013741 "%s: gRoamScanHirssiMaxCount %d => %d",
13742 __func__, nr_config->nhi_rssi_scan_max_count,
13743 val);
13744 nr_config->nhi_rssi_scan_max_count = val;
13745 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13746 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13747 break;
13748
13749 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013750 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013751 FL("gRoamScanHiRssiDelta %d => %d"),
13752 nr_config->nhi_rssi_scan_rssi_delta,
13753 val);
13754 nr_config->nhi_rssi_scan_rssi_delta = val;
13755 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13756 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13757 break;
13758
13759 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013761 FL("gRoamScanHiRssiDelay %d => %d"),
13762 nr_config->nhi_rssi_scan_delay,
13763 val);
13764 nr_config->nhi_rssi_scan_delay = val;
13765 nr_info->cfgParams.hi_rssi_scan_delay = val;
13766 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13767 break;
13768
13769 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013771 FL("gRoamScanHiRssiUpperBound %d => %d"),
13772 nr_config->nhi_rssi_scan_rssi_ub,
13773 val);
13774 nr_config->nhi_rssi_scan_rssi_ub = val;
13775 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13776 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13777 break;
13778
13779 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013781 FL("invalid parameter notify_id %d"),
13782 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013783 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013784 break;
13785 }
13786 sme_release_global_lock(&mac_ctx->sme);
13787 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013788 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013789 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013790 csr_roam_offload_scan(mac_ctx, session_id,
13791 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13792 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013793
13794 return status;
13795}
13796
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013797/**
13798 * sme_update_tgt_services() - update the target services config.
13799 * @hal: HAL pointer.
13800 * @cfg: wma_tgt_services parameters.
13801 *
13802 * update the target services config.
13803 *
13804 * Return: None.
13805 */
13806void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13807{
13808 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13809
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013810 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013811 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013812 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013814 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013815 mac_ctx->is_fils_roaming_supported =
13816 cfg->is_fils_roaming_supported;
13817 sme_debug("mac_ctx->pmf_offload: %d fils_roam support %d",
13818 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013819
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013820}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013821
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013822/**
13823 * sme_is_session_id_valid() - Check if the session id is valid
13824 * @hal: Pointer to HAL
13825 * @session_id: Session id
13826 *
13827 * Checks if the session id is valid or not
13828 *
13829 * Return: True is the session id is valid, false otherwise
13830 */
13831bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13832{
13833 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013834
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013835 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013836 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13837 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013838 return false;
13839 }
13840
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013841 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013842 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013843
13844 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013845}
13846
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013847#ifdef FEATURE_WLAN_TDLS
13848
13849/**
13850 * sme_get_opclass() - determine operating class
13851 * @hal: Pointer to HAL
13852 * @channel: channel id
13853 * @bw_offset: bandwidth offset
13854 * @opclass: pointer to operating class
13855 *
13856 * Function will determine operating class from regdm_get_opclass_from_channel
13857 *
13858 * Return: none
13859 */
13860void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13861 uint8_t *opclass)
13862{
13863 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13864
13865 /* redgm opclass table contains opclass for 40MHz low primary,
13866 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13867 * first we will check if bit for 40MHz is set and if so find
13868 * matching opclass either with low primary or high primary
13869 * (a channel would never be in both) and then search for opclass
13870 * matching 20MHz, else for any BW.
13871 */
13872 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013873 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013874 mac_ctx->scan.countryCodeCurrent,
13875 channel, BW40_LOW_PRIMARY);
13876 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013877 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013878 mac_ctx->scan.countryCodeCurrent,
13879 channel, BW40_HIGH_PRIMARY);
13880 }
13881 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013882 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013883 mac_ctx->scan.countryCodeCurrent,
13884 channel, BW20);
13885 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013886 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013887 mac_ctx->scan.countryCodeCurrent,
13888 channel, BWALL);
13889 }
13890}
13891#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013892
Sandeep Puligillae0875662016-02-12 16:09:21 -080013893/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013894 * sme_set_fw_test() - set fw test
13895 * @fw_test: fw test param
13896 *
13897 * Return: Return QDF_STATUS, otherwise appropriate failure code
13898 */
13899QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13900{
13901 void *wma_handle;
13902
13903 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13904 if (!wma_handle) {
13905 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13906 "wma handle is NULL");
13907 return QDF_STATUS_E_FAILURE;
13908 }
13909 wma_process_fw_test_cmd(wma_handle, fw_test);
13910 return QDF_STATUS_SUCCESS;
13911}
13912
13913/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013914 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13915 * @hal: mac handel
13916 * @vdev_id: vdev identifier
13917 *
13918 * Return: Return QDF_STATUS, otherwise appropriate failure code
13919 */
13920QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13921{
13922 void *wma_handle;
13923
13924 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13925 if (!wma_handle) {
13926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13927 "wma handle is NULL");
13928 return QDF_STATUS_E_FAILURE;
13929 }
13930 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13931 return QDF_STATUS_SUCCESS;
13932}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013933
13934/**
13935 * sme_update_mimo_power_save() - Update MIMO power save
13936 * configuration
13937 * @hal: The handle returned by macOpen
13938 * @is_ht_smps_enabled: enable/disable ht smps
13939 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013940 * @send_smps_action: flag to send smps force mode command
13941 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013942 *
13943 * Return: QDF_STATUS if SME update mimo power save
13944 * configuration sucsess else failue status
13945 */
13946QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13947 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013948 uint8_t ht_smps_mode,
13949 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013950{
13951 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013952
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013953 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013954 is_ht_smps_enabled, ht_smps_mode,
13955 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013956 mac_ctx->roam.configParam.enableHtSmps =
13957 is_ht_smps_enabled;
13958 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013959 mac_ctx->roam.configParam.send_smps_action =
13960 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013961
13962 return QDF_STATUS_SUCCESS;
13963}
13964
13965/**
13966 * sme_is_sta_smps_allowed() - check if the supported nss for
13967 * the session is greater than 1x1 to enable sta SMPS
13968 * @hal: The handle returned by macOpen
13969 * @session_id: session id
13970 *
13971 * Return: bool returns true if supported nss is greater than
13972 * 1x1 else false
13973 */
13974bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13975{
13976 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013977 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013978
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013979 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13980 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013981 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013982 return false;
13983 }
13984
13985 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013986 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013987 return false;
13988 }
13989
13990 return (csr_session->supported_nss_1x1 == true) ? false : true;
13991}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013992
13993/**
13994 * sme_add_beacon_filter() - set the beacon filter configuration
13995 * @hal: The handle returned by macOpen
13996 * @session_id: session id
13997 * @ie_map: bitwise array of IEs
13998 *
13999 * Return: Return QDF_STATUS, otherwise appropriate failure code
14000 */
14001QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
14002 uint32_t session_id,
14003 uint32_t *ie_map)
14004{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014005 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014006 QDF_STATUS qdf_status;
14007 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14008 struct beacon_filter_param *filter_param;
14009
14010 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014011 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014012 return QDF_STATUS_E_FAILURE;
14013 }
14014
14015 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14016 if (NULL == filter_param) {
14017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14018 "%s: fail to alloc filter_param", __func__);
14019 return QDF_STATUS_E_FAILURE;
14020 }
14021
14022 filter_param->vdev_id = session_id;
14023
14024 qdf_mem_copy(filter_param->ie_map, ie_map,
14025 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14026
14027 message.type = WMA_ADD_BCN_FILTER_CMDID;
14028 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014029 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014030 &message);
14031 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14033 "%s: Not able to post msg to WDA!",
14034 __func__);
14035
14036 qdf_mem_free(filter_param);
14037 }
14038 return qdf_status;
14039}
14040
14041/**
14042 * sme_remove_beacon_filter() - set the beacon filter configuration
14043 * @hal: The handle returned by macOpen
14044 * @session_id: session id
14045 *
14046 * Return: Return QDF_STATUS, otherwise appropriate failure code
14047 */
14048QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14049{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014050 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014051 QDF_STATUS qdf_status;
14052 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14053 struct beacon_filter_param *filter_param;
14054
14055 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014056 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014057 return QDF_STATUS_E_FAILURE;
14058 }
14059
14060 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14061 if (NULL == filter_param) {
14062 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14063 "%s: fail to alloc filter_param", __func__);
14064 return QDF_STATUS_E_FAILURE;
14065 }
14066
14067 filter_param->vdev_id = session_id;
14068
14069 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14070 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014071 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014072 &message);
14073 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14074 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14075 "%s: Not able to post msg to WDA!",
14076 __func__);
14077
14078 qdf_mem_free(filter_param);
14079 }
14080 return qdf_status;
14081}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014082
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014083/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014084 * sme_send_disassoc_req_frame - send disassoc req
14085 * @hal: handler to hal
14086 * @session_id: session id
14087 * @peer_mac: peer mac address
14088 * @reason: reason for disassociation
14089 * wait_for_ack: wait for acknowledgment
14090 *
14091 * function to send disassoc request to lim
14092 *
14093 * return: none
14094 */
14095void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14096 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14097{
14098 struct sme_send_disassoc_frm_req *msg;
14099 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14100 A_UINT8 *buf;
14101 A_UINT16 tmp;
14102
14103 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14104
14105 if (NULL == msg)
14106 qdf_status = QDF_STATUS_E_FAILURE;
14107 else
14108 qdf_status = QDF_STATUS_SUCCESS;
14109
14110 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14111 return;
14112
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014113 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14114
14115 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14116
14117 buf = &msg->session_id;
14118
14119 /* session id */
14120 *buf = (A_UINT8) session_id;
14121 buf += sizeof(A_UINT8);
14122
14123 /* transaction id */
14124 *buf = 0;
14125 *(buf + 1) = 0;
14126 buf += sizeof(A_UINT16);
14127
14128 /* Set the peer MAC address before sending the message to LIM */
14129 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14130
14131 buf += QDF_MAC_ADDR_SIZE;
14132
14133 /* reasoncode */
14134 tmp = (uint16_t) reason;
14135 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14136 buf += sizeof(uint16_t);
14137
14138 *buf = wait_for_ack;
14139 buf += sizeof(uint8_t);
14140
Rajeev Kumard138ac52017-01-30 18:38:37 -080014141 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014142
14143 if (qdf_status != QDF_STATUS_SUCCESS)
14144 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14145 FL("cds_send_mb_message Failed"));
14146}
14147
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014148QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14149 bpf_get_offload_cb callback,
14150 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014151{
14152 QDF_STATUS status = QDF_STATUS_SUCCESS;
14153 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014154 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014155
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014156 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014157
14158 status = sme_acquire_global_lock(&mac_ctx->sme);
14159 if (QDF_STATUS_SUCCESS == status) {
14160 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014161 mac_ctx->sme.bpf_get_offload_cb = callback;
14162 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014163 cds_msg.bodyptr = NULL;
14164 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014165 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014166 if (!QDF_IS_STATUS_SUCCESS(status)) {
14167 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14168 FL("Post bpf get offload msg fail"));
14169 status = QDF_STATUS_E_FAILURE;
14170 }
14171 sme_release_global_lock(&mac_ctx->sme);
14172 } else {
14173 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14174 FL("sme_acquire_global_lock error"));
14175 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014176 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014177 return status;
14178}
14179
14180
14181/**
14182 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14183 * @hal: HAL handle
14184 * @bpf_set_offload: struct to set bpf filter instructions.
14185 *
14186 * Return: QDF_STATUS enumeration.
14187 */
14188QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14189 struct sir_bpf_set_offload *req)
14190{
14191 QDF_STATUS status = QDF_STATUS_SUCCESS;
14192 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014193 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014194 struct sir_bpf_set_offload *set_offload;
14195
Arun Khandavallica198b52016-04-26 20:53:35 +053014196 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14197 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014198
14199 if (NULL == set_offload) {
14200 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14201 FL("Failed to alloc set_offload"));
14202 return QDF_STATUS_E_NOMEM;
14203 }
14204
14205 set_offload->session_id = req->session_id;
14206 set_offload->filter_id = req->filter_id;
14207 set_offload->current_offset = req->current_offset;
14208 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014209 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014210 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014211 set_offload->program = ((uint8_t *)set_offload) +
14212 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014213 qdf_mem_copy(set_offload->program, req->program,
14214 set_offload->current_length);
14215 }
14216 status = sme_acquire_global_lock(&mac_ctx->sme);
14217 if (QDF_STATUS_SUCCESS == status) {
14218 /* Serialize the req through MC thread */
14219 cds_msg.bodyptr = set_offload;
14220 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014221 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014222
14223 if (!QDF_IS_STATUS_SUCCESS(status)) {
14224 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14225 FL("Post BPF set offload msg fail"));
14226 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014227 qdf_mem_free(set_offload);
14228 }
14229 sme_release_global_lock(&mac_ctx->sme);
14230 } else {
14231 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14232 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014233 qdf_mem_free(set_offload);
14234 }
14235 return status;
14236}
14237
14238/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014239 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14240 * @hal: hal pointer
14241 *
14242 * Return: wni dot11 mode.
14243 */
14244uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14245{
14246 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14247
14248 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14249 mac_ctx->roam.configParam.uCfgDot11Mode);
14250}
14251
14252/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014253 * sme_create_mon_session() - post message to create PE session for monitormode
14254 * operation
14255 * @hal_handle: Handle to the HAL
14256 * @bssid: pointer to bssid
14257 *
14258 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14259 */
14260QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14261{
14262 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14263 struct sir_create_session *msg;
14264
14265 msg = qdf_mem_malloc(sizeof(*msg));
14266 if (NULL != msg) {
14267 msg->type = eWNI_SME_MON_INIT_SESSION;
14268 msg->msg_len = sizeof(*msg);
14269 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014270 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014271 }
14272 return status;
14273}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014274
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014275void sme_set_chan_info_callback(tHalHandle hal_handle,
14276 void (*callback)(struct scan_chan_info *chan_info))
14277{
14278 tpAniSirGlobal mac;
14279
14280 if (hal_handle == NULL) {
14281 QDF_ASSERT(0);
14282 return;
14283 }
14284 mac = PMAC_STRUCT(hal_handle);
14285 mac->chan_info_cb = callback;
14286}
14287
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014288/**
14289 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14290 * @hal: The handle returned by macOpen
14291 * @params: adaptive_dwelltime_params config
14292 *
14293 * Return: QDF_STATUS if adaptive dwell time update
14294 * configuration sucsess else failure status
14295 */
14296QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14297 struct adaptive_dwelltime_params *params)
14298{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014299 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014300 QDF_STATUS status;
14301 struct adaptive_dwelltime_params *dwelltime_params;
14302
14303 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14304 if (NULL == dwelltime_params) {
14305 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14306 "%s: fail to alloc dwelltime_params", __func__);
14307 return QDF_STATUS_E_NOMEM;
14308 }
14309
14310 dwelltime_params->is_enabled = params->is_enabled;
14311 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14312 dwelltime_params->lpf_weight = params->lpf_weight;
14313 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14314 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14315
14316 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14317 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014318 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014319 if (!QDF_IS_STATUS_SUCCESS(status)) {
14320 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14321 "%s: Not able to post msg to WMA!", __func__);
14322
14323 qdf_mem_free(dwelltime_params);
14324 }
14325 return status;
14326}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014327
14328/**
14329 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14330 * @hal: Pointer to HAL
14331 * @vdev_id: vdev_id for which IE is targeted
14332 *
14333 * Return: None
14334 */
14335void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14336{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014337 struct sir_set_vdev_ies_per_band *p_msg;
14338 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14339
14340 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14341 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014342 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014343 return;
14344 }
14345
14346 p_msg->vdev_id = vdev_id;
14347 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14348 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014349 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014350 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014351 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014352 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014353 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014354}
14355
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014356/**
14357 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14358 * @hal: Pointer to HAL
14359 * @enable2x2: 1x1 or 2x2 mode.
14360 *
14361 * Sends the set pdev IE req with Nss value.
14362 *
14363 * Return: None
14364 */
14365void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14366{
14367 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14368 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14369 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14370
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014371 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14372 eCSR_CFG_DOT11_MODE_AUTO) ||
14373 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14374 eCSR_CFG_DOT11_MODE_11N) ||
14375 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14376 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14377 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14378 eCSR_CFG_DOT11_MODE_11AC) ||
14379 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14380 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14381 return;
14382
14383 status = sme_acquire_global_lock(&mac_ctx->sme);
14384 if (QDF_STATUS_SUCCESS == status) {
14385 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14386 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014387 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014388 sme_release_global_lock(&mac_ctx->sme);
14389 return;
14390 }
14391
14392 ht_vht_cfg->pdev_id = 0;
14393 if (enable2x2)
14394 ht_vht_cfg->nss = 2;
14395 else
14396 ht_vht_cfg->nss = 1;
14397 ht_vht_cfg->dot11mode =
14398 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14399 mac_ctx->roam.configParam.uCfgDot11Mode);
14400
14401 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14402 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014403 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14404 ht_vht_cfg->nss,
14405 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014406 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014407 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014408 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014409
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014410 sme_release_global_lock(&mac_ctx->sme);
14411 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014412}
14413
14414/**
14415 * sme_update_vdev_type_nss() - sets the nss per vdev type
14416 * @hal: Pointer to HAL
14417 * @max_supp_nss: max_supported Nss
14418 * @band: 5G or 2.4G band
14419 *
14420 * Sets the per band Nss for each vdev type based on INI and configured
14421 * chain mask value.
14422 *
14423 * Return: None
14424 */
14425void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014426 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014427{
14428 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14429 struct vdev_type_nss *vdev_nss;
14430
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014431 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014432 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14433 else
14434 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14435
14436 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14437 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14438 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14439 CFG_P2P_GO_NSS(vdev_type_nss));
14440 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14441 CFG_P2P_CLI_NSS(vdev_type_nss));
14442 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14443 CFG_P2P_DEV_NSS(vdev_type_nss));
14444 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14445 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14446 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14447
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014448 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 -070014449 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14450 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14451 vdev_nss->tdls, vdev_nss->ocb);
14452}
Peng Xu8fdaa492016-06-22 10:20:47 -070014453
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014454#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14455#define MAX_BSS_COLOR_VAL 63
14456#define MIN_BSS_COLOR_VAL 1
14457
14458QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14459 uint8_t bss_color)
14460
14461{
14462 struct sir_set_he_bss_color *bss_color_msg;
14463 uint8_t len;
14464
14465 if (!hal) {
14466 sme_err("Invalid hal pointer");
14467 return QDF_STATUS_E_FAULT;
14468 }
14469
14470 sme_debug("Set HE bss_color %d", bss_color);
14471
14472 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14473 sme_debug("Invalid HE bss_color %d", bss_color);
14474 return QDF_STATUS_E_INVAL;
14475 }
14476 len = sizeof(*bss_color_msg);
14477 bss_color_msg = qdf_mem_malloc(len);
14478 if (!bss_color_msg) {
14479 sme_err("mem alloc failed");
14480 return QDF_STATUS_E_NOMEM;
14481 }
14482 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14483 bss_color_msg->length = len;
14484 bss_color_msg->session_id = session_id;
14485 bss_color_msg->bss_color = bss_color;
14486 return umac_send_mb_message_to_mac(bss_color_msg);
14487}
14488#endif
14489
Peng Xu8fdaa492016-06-22 10:20:47 -070014490/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014491 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14492 * @hal: Pointer to HAL
14493 * @hw_dbs_capable: HW DBS capability
14494 *
14495 * Sets HW DBS capability based on INI and fw capability.
14496 *
14497 * Return: None
14498 */
14499void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14500{
14501 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014502
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014503 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14504}
14505
14506/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014507 * sme_register_p2p_lo_event() - Register for the p2p lo event
14508 * @hHal: reference to the HAL
14509 * @context: the context of the call
14510 * @callback: the callback to hdd
14511 *
14512 * This function registers the callback function for P2P listen
14513 * offload stop event.
14514 *
14515 * Return: none
14516 */
14517void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14518 p2p_lo_callback callback)
14519{
14520 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14521 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14522
14523 status = sme_acquire_global_lock(&pMac->sme);
14524 pMac->sme.p2p_lo_event_callback = callback;
14525 pMac->sme.p2p_lo_event_context = context;
14526 sme_release_global_lock(&pMac->sme);
14527}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014528
14529/**
14530 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14531 * @hal: The handle returned by macOpen
14532 * @session_id: session id
14533 * @dbg_args: args for mac pwr debug command
14534 * Return: Return QDF_STATUS, otherwise appropriate failure code
14535 */
14536QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14537 struct sir_mac_pwr_dbg_cmd*
14538 dbg_args)
14539{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014540 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014541 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14542 struct sir_mac_pwr_dbg_cmd *req;
14543 int i;
14544
14545 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014546 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014547 return QDF_STATUS_E_FAILURE;
14548 }
14549
14550 req = qdf_mem_malloc(sizeof(*req));
14551 if (NULL == req) {
14552 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14553 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14554 return QDF_STATUS_E_FAILURE;
14555 }
14556 req->module_id = dbg_args->module_id;
14557 req->pdev_id = dbg_args->pdev_id;
14558 req->num_args = dbg_args->num_args;
14559 for (i = 0; i < req->num_args; i++)
14560 req->args[i] = dbg_args->args[i];
14561
14562 message.type = SIR_HAL_POWER_DBG_CMD;
14563 message.bodyptr = req;
14564
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014565 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014566 (QDF_MODULE_ID_WMA, &message))) {
14567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14568 "%s: Not able to post msg to WDA!",
14569 __func__);
14570 qdf_mem_free(req);
14571 }
14572 return QDF_STATUS_SUCCESS;
14573}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014574/**
14575 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014576 * @dev_mode: connection type.
14577 * @nss2g: Pointer to the 2G Nss parameter.
14578 * @nss5g: Pointer to the 5G Nss parameter.
14579 *
14580 * Fills the 2G and 5G Nss values based on connection type.
14581 *
14582 * Return: None
14583 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014584void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14585 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014586{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014587 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14588
14589 if (NULL == mac_ctx) {
14590 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14591 FL("Invalid MAC context"));
14592 return;
14593 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014594 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14595}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014596
14597/**
14598 * sme_update_sta_roam_policy() - update sta roam policy for
14599 * unsafe and DFS channels.
14600 * @hal_handle: hal handle for getting global mac struct
14601 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14602 * skipped or not
14603 * @skip_unsafe_channels: Param to tell if driver needs to
14604 * skip unsafe channels or not.
14605 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014606 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014607 *
14608 * sme_update_sta_roam_policy update sta rome policies to csr
14609 * this function will call csrUpdateChannelList as well
14610 * to include/exclude DFS channels and unsafe channels.
14611 *
14612 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14613 */
14614QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14615 enum sta_roam_policy_dfs_mode dfs_mode,
14616 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014617 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014618{
14619 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14620 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014621 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014622
14623 if (!mac_ctx) {
14624 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14625 "%s: mac_ctx is null", __func__);
14626 return QDF_STATUS_E_FAILURE;
14627 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014628
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014629 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14630 if (!sme_config) {
14631 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14632 FL("failed to allocate memory for sme_config"));
14633 return QDF_STATUS_E_FAILURE;
14634 }
14635 qdf_mem_zero(sme_config, sizeof(*sme_config));
14636 sme_get_config_param(hal_handle, sme_config);
14637
14638 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014639 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014640 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014641 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014642 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014643 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014644
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014645 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014646
14647 status = csr_update_channel_list(mac_ctx);
14648 if (QDF_STATUS_SUCCESS != status) {
14649 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14650 FL("failed to update the supported channel list"));
14651 }
14652 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14653 csr_roam_offload_scan(mac_ctx, session_id,
14654 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14655 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014656
14657 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014658 return status;
14659}
14660
14661/**
14662 * sme_enable_disable_chanavoidind_event - configure ca event ind
14663 * @hal: handler to hal
14664 * @set_value: enable/disable
14665 *
14666 * function to enable/disable chan avoidance indication
14667 *
14668 * Return: QDF_STATUS
14669 */
14670QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14671 uint8_t set_value)
14672{
14673 QDF_STATUS status;
14674 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014675 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014676
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014677 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014678 status = sme_acquire_global_lock(&mac_ctx->sme);
14679 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014680 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014681 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14682 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014683 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014684 sme_release_global_lock(&mac_ctx->sme);
14685 return status;
14686 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014687 return status;
14688}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014689
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014690/*
14691 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14692 * @hal: reference to the HAL
14693 * @session_id: current session ID
14694 * @ie_data: Pointer to Scan IE data
14695 * @ie_len: Length of @ie_data
14696 *
14697 * Return: QDF_STATUS
14698 */
14699QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14700 uint8_t *ie_data, uint16_t ie_len)
14701{
14702 QDF_STATUS status;
14703 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14704 struct hdd_default_scan_ie *set_ie_params;
14705
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014706 if (!ie_data)
14707 return QDF_STATUS_E_INVAL;
14708
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014709 status = sme_acquire_global_lock(&mac_ctx->sme);
14710 if (QDF_IS_STATUS_SUCCESS(status)) {
14711 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14712 if (!set_ie_params)
14713 status = QDF_STATUS_E_NOMEM;
14714 else {
14715 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14716 set_ie_params->length = sizeof(*set_ie_params);
14717 set_ie_params->session_id = session_id;
14718 set_ie_params->ie_len = ie_len;
14719 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014720 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014721 }
14722 sme_release_global_lock(&mac_ctx->sme);
14723 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014724 return status;
14725}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014726
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014727QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14728 struct sar_limit_cmd_params *sar_limit_cmd)
14729{
14730 void *wma_handle;
14731
14732 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14733 if (!wma_handle) {
14734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14735 "wma handle is NULL");
14736 return QDF_STATUS_E_FAILURE;
14737 }
14738
14739 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14740}
14741
Jeff Johnson6136fb92017-03-30 15:21:49 -070014742#ifdef WLAN_FEATURE_FIPS
14743QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14744 wma_fips_cb callback, void *context)
14745{
14746 void *wma_handle;
14747
14748 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14749 if (!wma_handle) {
14750 sme_err("wma handle is NULL");
14751 return QDF_STATUS_E_FAILURE;
14752 }
14753
14754 return wma_fips_request(wma_handle, param, callback, context);
14755}
14756#endif
14757
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014758QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14759{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014760 void *wma_handle;
14761
14762 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14763 if (!wma_handle) {
14764 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14765 "wma_handle is NULL");
14766 return QDF_STATUS_E_FAILURE;
14767 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014768 if (QDF_STATUS_SUCCESS !=
14769 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14771 "%s: Failed to set cts2self for p2p GO to firmware",
14772 __func__);
14773 return QDF_STATUS_E_FAILURE;
14774 }
14775 return QDF_STATUS_SUCCESS;
14776}
Yingying Tang95409972016-10-20 15:16:15 +080014777
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014778/**
14779 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14780 * @hal: Handle returned by mac_open
14781 * @session_id: Session ID on which tx fail count needs to be updated to FW
14782 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14783 *
14784 * This function is used to set tx fail count threshold to firmware.
14785 * firmware will issue disocnnect with peer device once this threshold is
14786 * reached.
14787 *
14788 * Return: Return QDF_STATUS, otherwise appropriate failure code
14789 */
14790QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14791 uint8_t session_id, uint32_t tx_fail_count)
14792{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014793 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14794 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014795 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014796
14797 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14798 if (NULL == tx_fail_cnt) {
14799 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14800 "%s: fail to alloc filter_param", __func__);
14801 return QDF_STATUS_E_FAILURE;
14802 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014803 sme_debug("session_id: %d tx_fail_count: %d",
14804 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014805 tx_fail_cnt->session_id = session_id;
14806 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14807
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014808 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014809 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14810 msg.reserved = 0;
14811 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014812 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014813
14814 if (!QDF_IS_STATUS_SUCCESS(status)) {
14815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014816 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014817 qdf_mem_free(tx_fail_cnt);
14818 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014819 return status;
14820}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014821
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014822QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14823 void (*cb)(void *, struct sir_lost_link_info *))
14824{
14825 QDF_STATUS status = QDF_STATUS_SUCCESS;
14826 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14827
14828 status = sme_acquire_global_lock(&mac->sme);
14829 if (QDF_IS_STATUS_SUCCESS(status)) {
14830 mac->sme.lost_link_info_cb = cb;
14831 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014832 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014833 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014834 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014835
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014836 return status;
14837}
Yingying Tang95409972016-10-20 15:16:15 +080014838
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014839#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014840bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014841{
14842 return roam_info->isESEAssoc;
14843}
Manjeet Singh2f785062017-03-08 18:14:18 +053014844#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014845/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014846 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014847 * params from ini.
14848 * @hal_handle: Handle returned by mac_open
14849 * @5g_pref_params: pref params from ini.
14850 *
14851 * Returns: None
14852 */
14853void sme_set_5g_band_pref(tHalHandle hal_handle,
14854 struct sme_5g_band_pref_params *pref_params)
14855{
14856
14857 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14858 struct roam_ext_params *roam_params;
14859 QDF_STATUS status = QDF_STATUS_SUCCESS;
14860
14861 if (!pref_params) {
14862 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14863 "Invalid 5G pref params!");
14864 return;
14865 }
14866 status = sme_acquire_global_lock(&mac_ctx->sme);
14867 if (QDF_STATUS_SUCCESS == status) {
14868 roam_params = &mac_ctx->roam.configParam.roam_params;
14869 roam_params->raise_rssi_thresh_5g =
14870 pref_params->rssi_boost_threshold_5g;
14871 roam_params->raise_factor_5g =
14872 pref_params->rssi_boost_factor_5g;
14873 roam_params->max_raise_rssi_5g =
14874 pref_params->max_rssi_boost_5g;
14875 roam_params->drop_rssi_thresh_5g =
14876 pref_params->rssi_penalize_threshold_5g;
14877 roam_params->drop_factor_5g =
14878 pref_params->rssi_penalize_factor_5g;
14879 roam_params->max_drop_rssi_5g =
14880 pref_params->max_rssi_penalize_5g;
14881
14882 sme_release_global_lock(&mac_ctx->sme);
14883 } else
14884 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14885 "Unable to acquire global sme lock");
14886}
14887
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014888
14889bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14890{
14891 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014892
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014893 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14894}
Yingying Tang95409972016-10-20 15:16:15 +080014895
14896#ifdef WLAN_FEATURE_WOW_PULSE
14897/**
14898 * sme_set_wow_pulse() - set wow pulse info
14899 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14900 *
14901 * Return: QDF_STATUS
14902 */
14903QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14904{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014905 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014906 QDF_STATUS status;
14907 struct wow_pulse_mode *wow_pulse_set_cmd;
14908
14909 if (!wow_pulse_set_info) {
14910 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14911 "%s: invalid wow_pulse_set_info pointer", __func__);
14912 return QDF_STATUS_E_FAILURE;
14913 }
14914
14915 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14916 if (NULL == wow_pulse_set_cmd) {
14917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14918 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14919 return QDF_STATUS_E_NOMEM;
14920 }
14921
14922 *wow_pulse_set_cmd = *wow_pulse_set_info;
14923
14924 message.type = WMA_SET_WOW_PULSE_CMD;
14925 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014926 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014927 &message);
14928 if (!QDF_IS_STATUS_SUCCESS(status)) {
14929 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14930 "%s: Not able to post msg to WDA!",
14931 __func__);
14932 qdf_mem_free(wow_pulse_set_cmd);
14933 status = QDF_STATUS_E_FAILURE;
14934 }
14935
14936 return status;
14937}
14938#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014939
14940/**
14941 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14942 * different fields and IEs from bss descriptor.
14943 * @frame_buf: frame buffer to populate
14944 * @bss_descp: bss descriptor
14945 * @bssid: bssid of the beacon frame to populate
14946 * @ie_len: length of IE fields
14947 *
14948 * Return: None
14949 */
14950static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14951 tSirBssDescription *bss_descp,
14952 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014953 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014954{
14955 tDot11fBeacon1 *bcn_fixed;
14956 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14957
14958 /* populate mac header first to indicate beacon */
14959 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14960 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14961 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14962 qdf_mem_copy((uint8_t *) mac_hdr->da,
14963 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14964 sizeof(struct qdf_mac_addr));
14965 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
14966 sizeof(struct qdf_mac_addr));
14967 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
14968 sizeof(struct qdf_mac_addr));
14969
14970 /* now populate fixed params */
14971 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
14972 /* populate timestamp */
14973 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
14974 sizeof(bss_descp->timeStamp));
14975 /* populate beacon interval */
14976 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
14977 /* populate capability */
14978 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
14979 sizeof(bss_descp->capabilityInfo));
14980
14981 /* copy IEs now */
14982 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
14983 + SIR_MAC_B_PR_SSID_OFFSET,
14984 &bss_descp->ieFields, ie_len);
14985}
14986
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014987QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
14988 tCsrRoamProfile *profile,
14989 const uint8_t *bssid,
14990 int8_t *rssi, int8_t *snr)
14991{
14992 tSirBssDescription *bss_descp;
14993 tCsrScanResultFilter *scan_filter;
14994 struct scan_result_list *bss_list;
14995 tScanResultHandle result_handle = NULL;
14996 QDF_STATUS status = QDF_STATUS_SUCCESS;
14997 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14998
14999 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15000 if (NULL == scan_filter) {
15001 sme_err("memory allocation failed");
15002 status = QDF_STATUS_E_NOMEM;
15003 goto free_scan_flter;
15004 }
15005
15006 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15007 profile, scan_filter);
15008 if (QDF_STATUS_SUCCESS != status) {
15009 sme_err("prepare_filter failed");
15010 goto free_scan_flter;
15011 }
15012
15013 /* update filter to get scan result with just target BSSID */
15014 if (NULL == scan_filter->BSSIDs.bssid) {
15015 scan_filter->BSSIDs.bssid =
15016 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15017 if (scan_filter->BSSIDs.bssid == NULL) {
15018 sme_err("malloc failed");
15019 status = QDF_STATUS_E_NOMEM;
15020 goto free_scan_flter;
15021 }
15022 }
15023
15024 scan_filter->BSSIDs.numOfBSSIDs = 1;
15025 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15026 bssid, sizeof(struct qdf_mac_addr));
15027
15028 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15029 if (QDF_STATUS_SUCCESS != status) {
15030 sme_err("parse_scan_result failed");
15031 goto free_scan_flter;
15032 }
15033
15034 bss_list = (struct scan_result_list *)result_handle;
15035 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15036 if (!bss_descp) {
15037 sme_err("unable to fetch bss descriptor");
15038 status = QDF_STATUS_E_FAULT;
15039 goto free_scan_flter;
15040 }
15041
15042 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15043 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15044
15045 if (rssi)
15046 *rssi = bss_descp->rssi;
15047 if (snr)
15048 *snr = bss_descp->sinr;
15049
15050free_scan_flter:
15051 /* free scan filter and exit */
15052 if (scan_filter) {
15053 csr_free_scan_filter(mac_ctx, scan_filter);
15054 qdf_mem_free(scan_filter);
15055 }
15056
15057 if (result_handle)
15058 csr_scan_result_purge(mac_ctx, result_handle);
15059
15060 return status;
15061}
15062
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015063QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15064 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015065 uint8_t **frame_buf, uint32_t *frame_len,
15066 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015067{
15068 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015069 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015070 tCsrScanResultFilter *scan_filter;
15071 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15072 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015073 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015074 uint32_t ie_len;
15075
15076 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15077 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015078 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015079 status = QDF_STATUS_E_NOMEM;
15080 goto free_scan_flter;
15081 }
15082 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15083 profile, scan_filter);
15084 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015085 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015086 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015087 goto free_scan_flter;
15088 }
15089
15090 /* update filter to get scan result with just target BSSID */
15091 if (NULL == scan_filter->BSSIDs.bssid) {
15092 scan_filter->BSSIDs.bssid =
15093 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15094 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015095 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015096 status = QDF_STATUS_E_NOMEM;
15097 goto free_scan_flter;
15098 }
15099 }
15100 scan_filter->BSSIDs.numOfBSSIDs = 1;
15101 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15102 bssid, sizeof(struct qdf_mac_addr));
15103
15104 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15105 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015106 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015107 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015108 goto free_scan_flter;
15109 }
15110
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015111 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015112 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015113 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015114 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015115 status = QDF_STATUS_E_FAULT;
15116 goto free_scan_flter;
15117 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015118
Naveen Rawat81f058c2017-06-02 16:02:39 -070015119 /**
15120 * Length of BSS descriptor is without length of
15121 * length itself and length of pointer that holds ieFields.
15122 *
15123 * tSirBssDescription
15124 * +--------+---------------------------------+---------------+
15125 * | length | other fields | pointer to IEs|
15126 * +--------+---------------------------------+---------------+
15127 * ^
15128 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015129 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015130 ie_len = bss_descp->length + sizeof(bss_descp->length)
15131 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015132 sme_debug("found bss_descriptor ie_len: %d channel %d",
15133 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015134
15135 /* include mac header and fixed params along with IEs in frame */
15136 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15137 *frame_buf = qdf_mem_malloc(*frame_len);
15138 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015139 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015140 status = QDF_STATUS_E_NOMEM;
15141 goto free_scan_flter;
15142 }
15143
15144 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15145
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015146 if (!*channel)
15147 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015148free_scan_flter:
15149 /* free scan filter and exit */
15150 if (scan_filter) {
15151 csr_free_scan_filter(mac_ctx, scan_filter);
15152 qdf_mem_free(scan_filter);
15153 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015154 if (result_handle)
15155 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015156
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015157 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015158}
15159
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015160#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015161QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15162 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015163 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015164{
15165 QDF_STATUS status;
15166 struct wma_roam_invoke_cmd *fastreassoc;
15167 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015168 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015169
15170 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15171 if (NULL == fastreassoc) {
15172 sme_err("qdf_mem_malloc failed for fastreassoc");
15173 return QDF_STATUS_E_NOMEM;
15174 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015175 /* if both are same then set the flag */
15176 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15177 fastreassoc->is_same_bssid = true;
15178 sme_debug("bssid same, bssid[%pM]", bssid);
15179 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015180 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015181 fastreassoc->bssid[0] = bssid[0];
15182 fastreassoc->bssid[1] = bssid[1];
15183 fastreassoc->bssid[2] = bssid[2];
15184 fastreassoc->bssid[3] = bssid[3];
15185 fastreassoc->bssid[4] = bssid[4];
15186 fastreassoc->bssid[5] = bssid[5];
15187
15188 status = sme_get_beacon_frm(hal, profile, bssid,
15189 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015190 &fastreassoc->frame_len,
15191 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015192
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015193 if (!channel) {
15194 sme_err("channel retrieval from BSS desc fails!");
15195 qdf_mem_free(fastreassoc);
15196 return QDF_STATUS_E_FAULT;
15197 }
15198
15199 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015200 if (QDF_STATUS_SUCCESS != status) {
15201 sme_warn("sme_get_beacon_frm failed");
15202 fastreassoc->frame_buf = NULL;
15203 fastreassoc->frame_len = 0;
15204 }
15205
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015206 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15207 connectedProfile.AuthType)) {
15208 sme_debug("Beacon is not required for ESE");
15209 if (fastreassoc->frame_len) {
15210 qdf_mem_free(fastreassoc->frame_buf);
15211 fastreassoc->frame_buf = NULL;
15212 fastreassoc->frame_len = 0;
15213 }
15214 }
15215
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015216 msg.type = SIR_HAL_ROAM_INVOKE;
15217 msg.reserved = 0;
15218 msg.bodyptr = fastreassoc;
15219 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15220 if (QDF_STATUS_SUCCESS != status) {
15221 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15222 qdf_mem_free(fastreassoc);
15223 }
15224
15225 return status;
15226}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015227#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015228
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015229QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15230 tPmkidCacheInfo *pmk_cache_info,
15231 bool is_add)
15232{
15233 struct wmi_unified_pmk_cache *pmk_cache;
15234 struct scheduler_msg msg;
15235
15236 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15237 if (!pmk_cache) {
15238 sme_err("Memory allocation failure");
15239 return QDF_STATUS_E_NOMEM;
15240 }
15241
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015242 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15243
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015244 pmk_cache->session_id = session_id;
15245
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015246 if (!pmk_cache_info)
15247 goto send_flush_cmd;
15248
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015249 if (!pmk_cache_info->ssid_len) {
15250 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15251 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15252 &pmk_cache->bssid);
15253 } else {
15254 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15255 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15256 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15257 pmk_cache_info->ssid,
15258 pmk_cache->ssid.length);
15259 }
15260 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15261 pmk_cache_info->cache_id[1]);
15262
15263 if (is_add)
15264 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15265 else
15266 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15267
15268 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15269 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15270 CSR_RSN_PMKID_SIZE);
15271
15272 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15273 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15274 pmk_cache->pmk_len);
15275
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015276send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015277 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15278 msg.reserved = 0;
15279 msg.bodyptr = pmk_cache;
15280 if (QDF_STATUS_SUCCESS !=
15281 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15282 sme_err("Not able to post message to WDA");
15283 qdf_mem_free(pmk_cache);
15284 return QDF_STATUS_E_FAILURE;
15285 }
15286
15287 return QDF_STATUS_SUCCESS;
15288}
15289
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015290/* ARP DEBUG STATS */
15291
15292/**
15293 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15294 * @hal: handle to hal
15295 * @set_stats_param: pointer to set stats param
15296 *
15297 * Return: Return QDF_STATUS.
15298 */
15299QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15300 struct set_arp_stats_params
15301 *set_stats_param)
15302{
15303 struct set_arp_stats_params *arp_set_param;
15304 struct scheduler_msg msg;
15305
15306 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15307 if (arp_set_param == NULL) {
15308 sme_err("Memory allocation failure");
15309 return QDF_STATUS_E_NOMEM;
15310 }
15311
15312 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15313
15314 msg.type = WMA_SET_ARP_STATS_REQ;
15315 msg.reserved = 0;
15316 msg.bodyptr = arp_set_param;
15317
15318 if (QDF_STATUS_SUCCESS !=
15319 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15320 sme_err("Not able to post message to WDA");
15321 qdf_mem_free(arp_set_param);
15322 return QDF_STATUS_E_FAILURE;
15323 }
15324
15325 return QDF_STATUS_SUCCESS;
15326}
15327
15328/**
15329 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15330 * @hal: handle to hal
15331 * @get_stats_param: pointer to set stats param
15332 *
15333 * Return: Return QDF_STATUS.
15334 */
15335QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15336 struct get_arp_stats_params
15337 *get_stats_param)
15338{
15339 struct get_arp_stats_params *arp_get_param;
15340 struct scheduler_msg msg;
15341
15342 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15343 if (arp_get_param == NULL) {
15344 sme_err("Memory allocation failure");
15345 return QDF_STATUS_E_NOMEM;
15346 }
15347
15348 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15349
15350 msg.type = WMA_GET_ARP_STATS_REQ;
15351 msg.reserved = 0;
15352 msg.bodyptr = arp_get_param;
15353
15354 if (QDF_STATUS_SUCCESS !=
15355 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15356 sme_err("Not able to post message to WDA");
15357 qdf_mem_free(arp_get_param);
15358 return QDF_STATUS_E_FAILURE;
15359 }
15360
15361 return QDF_STATUS_SUCCESS;
15362}
15363
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015364QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15365 uint32_t param_value, uint32_t vdev_id)
15366{
15367 void *wma_handle;
15368
15369 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15370 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015371 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015372 return QDF_STATUS_E_FAILURE;
15373 }
15374
15375 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15376 param_value, vdev_id);
15377}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015378
15379QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015380 bool (*set_connection_info_cb)(bool),
15381 bool (*get_connection_info_cb)(uint8_t *session_id,
15382 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015383{
15384 QDF_STATUS status = QDF_STATUS_SUCCESS;
15385 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15386
15387 status = sme_acquire_global_lock(&pMac->sme);
15388 if (QDF_IS_STATUS_SUCCESS(status)) {
15389 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015390 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015391 sme_release_global_lock(&pMac->sme);
15392 }
15393 return status;
15394}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015395
15396QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15397 void (*cb)(void *, struct rso_cmd_status *))
15398{
15399 QDF_STATUS status = QDF_STATUS_SUCCESS;
15400 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15401
15402 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015403 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015404 return status;
15405}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015406
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015407QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15408 struct wmi_dbs_scan_sel_params *params)
15409{
15410 struct scheduler_msg message = {0};
15411 QDF_STATUS status;
15412 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15413 uint32_t i;
15414
15415 if (0 == params->num_clients) {
15416 sme_err("Num of clients is 0");
15417 return QDF_STATUS_E_FAILURE;
15418 }
15419
15420 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15421 if (!dbs_scan_params) {
15422 sme_err("fail to alloc dbs_scan_params");
15423 return QDF_STATUS_E_NOMEM;
15424 }
15425
15426 dbs_scan_params->num_clients = params->num_clients;
15427 dbs_scan_params->pdev_id = params->pdev_id;
15428 for (i = 0; i < params->num_clients; i++) {
15429 dbs_scan_params->module_id[i] = params->module_id[i];
15430 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15431 dbs_scan_params->num_non_dbs_scans[i] =
15432 params->num_non_dbs_scans[i];
15433 }
15434 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15435 message.bodyptr = dbs_scan_params;
15436 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15437 if (!QDF_IS_STATUS_SUCCESS(status)) {
15438 sme_err("Not able to post msg to WMA!");
15439 qdf_mem_free(dbs_scan_params);
15440 }
15441
15442 return status;
15443}
15444
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015445QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15446{
15447 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15448 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015449 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015450 struct sme_rcpi_req *rcpi_req;
15451
15452 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15453 if (rcpi_req == NULL) {
15454 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15455 "%s: Not able to allocate memory for rcpi req",
15456 __func__);
15457 return QDF_STATUS_E_NOMEM;
15458 }
15459 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15460
15461 status = sme_acquire_global_lock(&pMac->sme);
15462 if (QDF_IS_STATUS_SUCCESS(status)) {
15463 msg.bodyptr = rcpi_req;
15464 msg.type = WMA_GET_RCPI_REQ;
15465 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15466 sme_release_global_lock(&pMac->sme);
15467 if (!QDF_IS_STATUS_SUCCESS(status)) {
15468 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15469 FL("post get rcpi req failed"));
15470 status = QDF_STATUS_E_FAILURE;
15471 qdf_mem_free(rcpi_req);
15472 }
15473 } else {
15474 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15475 FL("sme_acquire_global_lock failed"));
15476 qdf_mem_free(rcpi_req);
15477 }
15478
15479 return status;
15480}
15481
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015482void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15483{
15484 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15485 void *wma_handle;
15486 QDF_STATUS status;
15487
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015488 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015489 if (QDF_STATUS_SUCCESS != status) {
15490 mac_ctx->pdev = NULL;
15491 return;
15492 }
15493 mac_ctx->pdev = pdev;
15494 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15495 if (!wma_handle) {
15496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015497 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015498 return;
15499 }
15500 wma_store_pdev(wma_handle, pdev);
15501}
15502
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015503QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15504 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15505{
15506 QDF_STATUS status;
15507 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15508
15509 status = sme_acquire_global_lock(&mac->sme);
15510 if (QDF_IS_STATUS_SUCCESS(status)) {
15511 mac->sme.congestion_cb = congestion_cb;
15512 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015513 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015514 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015515 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015516 }
15517
15518 return status;
15519}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015520
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015521QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15522 uint32_t param_val)
15523{
15524 return wma_configure_smps_params(vdev_id, param_id, param_val);
15525}
15526
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015527QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15528 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15529{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015530 wma_cli_set_cmd_t *iwcmd;
15531 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015532
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015533 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15534 if (!iwcmd) {
15535 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015536 return QDF_STATUS_E_NOMEM;
15537 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015538
15539 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15540 iwcmd->param_sec_value = 0;
15541 iwcmd->param_vdev_id = vdev_id;
15542 iwcmd->param_id = param_id;
15543 iwcmd->param_vp_dev = req_cat;
15544 iwcmd->param_value = param_val;
15545 wma_ipa_uc_stat_request(iwcmd);
15546 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015547
15548 return status;
15549}
lifeng66831662017-05-19 16:01:35 +080015550
15551QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15552 struct sir_set_rx_reorder_timeout_val *req)
15553{
15554 QDF_STATUS status;
15555
15556 status = wma_set_rx_reorder_timeout_val(hal, req);
15557
15558 return status;
15559}
15560
15561QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15562 struct sir_peer_set_rx_blocksize *req)
15563{
15564 QDF_STATUS status;
15565
15566 status = wma_set_rx_blocksize(hal, req);
15567
15568 return status;
15569}
Naveen Rawat247a8682017-06-05 15:00:31 -070015570
15571int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15572{
15573 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15574}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015575
15576QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15577 void (*cb)(void *, uint32_t bt_activity))
15578{
15579 QDF_STATUS status;
15580 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15581
15582 status = sme_acquire_global_lock(&mac->sme);
15583 if (QDF_IS_STATUS_SUCCESS(status)) {
15584 mac->sme.bt_activity_info_cb = cb;
15585 sme_release_global_lock(&mac->sme);
15586 sme_debug("bt activity info callback set");
15587 } else {
15588 sme_debug("sme_acquire_global_lock failed %d", status);
15589 }
15590
15591 return status;
15592}
lifengd217d192017-05-09 19:44:16 +080015593
15594QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15595 struct get_chain_rssi_req_params *input,
15596 get_chain_rssi_callback callback,
15597 void *context)
15598{
15599 QDF_STATUS status = QDF_STATUS_SUCCESS;
15600 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15601
15602 SME_ENTER();
15603
15604 if (NULL == input) {
15605 sme_err("Invalid req params");
15606 return QDF_STATUS_E_INVAL;
15607 }
15608
15609 mac_ctx->sme.get_chain_rssi_cb = callback;
15610 mac_ctx->sme.get_chain_rssi_context = context;
15611 wma_get_chain_rssi(hal, input);
15612
15613 SME_EXIT();
15614 return status;
15615}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015616
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015617QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15618 struct scheduler_msg *msg)
15619{
15620 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15621
15622 if (msg == NULL) {
15623 sme_err("Empty message for SME Msg callback");
15624 return status;
15625 }
15626 status = sme_process_msg(hal, msg);
15627 return status;
15628}
15629
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015630void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15631{
15632 struct csr_roam_session *session;
15633 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15634
15635 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15636 sme_err("%s Invalid session id: %d", __func__, session_id);
15637 return;
15638 }
15639
15640 session = CSR_GET_SESSION(mac_ctx, session_id);
15641 if (!session) {
15642 sme_err("%s Failed to get session for id: %d",
15643 __func__, session_id);
15644 return;
15645 }
15646
15647 sme_debug("Total No. of Disconnections: %d",
15648 session->disconnect_stats.disconnection_cnt);
15649
15650 sme_debug("No. of Diconnects Triggered by Application: %d",
15651 session->disconnect_stats.disconnection_by_app);
15652
15653 sme_debug("No. of Disassoc Sent by Peer: %d",
15654 session->disconnect_stats.disassoc_by_peer);
15655
15656 sme_debug("No. of Deauth Sent by Peer: %d",
15657 session->disconnect_stats.deauth_by_peer);
15658
15659 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15660 session->disconnect_stats.bmiss);
15661
15662 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15663 session->disconnect_stats.peer_kickout);
15664}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015665
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015666 /**
15667 * sme_set_vc_mode_config() - Set voltage corner config to FW
15668 * @bitmap: Bitmap that referes to voltage corner config with
15669 * different phymode and bw configuration
15670 *
15671 * Return: QDF_STATUS
15672 */
15673QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15674{
15675 void *wma_handle;
15676
15677 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15678 if (!wma_handle) {
15679 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15680 "wma_handle is NULL");
15681 return QDF_STATUS_E_FAILURE;
15682 }
15683 if (QDF_STATUS_SUCCESS !=
15684 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15685 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15686 "%s: Failed to set Voltage Control config to FW",
15687 __func__);
15688 return QDF_STATUS_E_FAILURE;
15689 }
15690 return QDF_STATUS_SUCCESS;
15691}
15692
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015693/**
15694 * sme_set_bmiss_bcnt() - set bmiss config parameters
15695 * @vdev_id: virtual device for the command
15696 * @first_cnt: bmiss first value
15697 * @final_cnt: bmiss final value
15698 *
15699 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15700 */
15701QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15702 uint32_t final_cnt)
15703{
15704 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15705}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015706
15707QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15708 bool is_tos_active, uint32_t max_off_chan_time,
15709 uint32_t rest_time, bool skip_dfs_chan)
15710{
15711 struct sir_limit_off_chan *cmd;
15712 struct scheduler_msg msg = {0};
15713
15714 cmd = qdf_mem_malloc(sizeof(*cmd));
15715 if (!cmd) {
15716 sme_err("qdf_mem_malloc failed for limit off channel");
15717 return QDF_STATUS_E_NOMEM;
15718 }
15719
15720 cmd->vdev_id = vdev_id;
15721 cmd->is_tos_active = is_tos_active;
15722 cmd->max_off_chan_time = max_off_chan_time;
15723 cmd->rest_time = rest_time;
15724 cmd->skip_dfs_chans = skip_dfs_chan;
15725
15726 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15727 msg.reserved = 0;
15728 msg.bodyptr = cmd;
15729
15730 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15731 &msg))) {
15732 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15733 qdf_mem_free(cmd);
15734 return QDF_STATUS_E_FAILURE;
15735 }
15736
15737 return QDF_STATUS_SUCCESS;
15738}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015739
15740/**
15741 * sme_get_status_for_candidate() - Get bss transition status for candidate
15742 * @hal: Handle for HAL
15743 * @conn_bss_desc: connected bss descriptor
15744 * @bss_desc: candidate bss descriptor
15745 * @info: candiadate bss information
15746 * @trans_reason: transition reason code
15747 * @is_bt_in_progress: bt activity indicator
15748 *
15749 * Return : true if candidate is rejected and reject reason is filled
15750 * @info->status. Otherwise returns false.
15751 */
15752static bool sme_get_status_for_candidate(tHalHandle *hal,
15753 tSirBssDescription *conn_bss_desc,
15754 tSirBssDescription *bss_desc,
15755 struct bss_candidate_info *info,
15756 uint8_t trans_reason,
15757 bool is_bt_in_progress)
15758{
15759 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15760
15761 /*
15762 * Low RSSI based rejection
15763 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15764 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15765 * candidate with MBO reason code 4.
15766 */
15767 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15768 mbo_candidate_rssi_thres) &&
15769 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15770 mbo_current_rssi_thres)) {
15771 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15772 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15773 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15774 return true;
15775 }
15776
15777 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15778 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15779 /*
15780 * MCC rejection
15781 * If moving to candidate's channel will result in MCC scenario
15782 * and the rssi of connected bss is greater than
15783 * mbo_current_rssi_mss_thres, then reject the candidate with
15784 * MBO reason code 3.
15785 */
15786 if ((conn_bss_desc->rssi >
15787 mac_ctx->roam.configParam.mbo_thresholds.
15788 mbo_current_rssi_mcc_thres) &&
15789 csr_is_mcc_channel(hal, bss_desc->channelId)) {
15790 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15791 MAC_ADDR_ARRAY(bss_desc->bssId));
15792 info->status =
15793 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15794 return true;
15795 }
15796
15797 /*
15798 * BT coex rejection
15799 * If AP is trying to move the client from 5G to 2.4G and moving
15800 * to 2.4G will result in BT coex and candidate channel rssi is
15801 * less than mbo_candidate_rssi_btc_thres, then reject the
15802 * candidate with MBO reason code 2.
15803 */
15804 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15805 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15806 is_bt_in_progress &&
15807 (bss_desc->rssi <
15808 mac_ctx->roam.configParam.mbo_thresholds.
15809 mbo_candidate_rssi_btc_thres)) {
15810 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15811 MAC_ADDR_ARRAY(bss_desc->bssId));
15812 info->status =
15813 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15814 return true;
15815 }
15816
15817 /*
15818 * LTE coex rejection
15819 * If moving to candidate's channel can cause LTE coex, then
15820 * reject the candidate with MBO reason code 5.
15821 */
15822 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15823 conn_bss_desc->channelId) &&
15824 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
15825 bss_desc->channelId))) {
15826 sme_err("High interference expected if transitioned to BSS "
15827 MAC_ADDRESS_STR" hence reject",
15828 MAC_ADDR_ARRAY(bss_desc->bssId));
15829 info->status =
15830 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
15831 return true;
15832 }
15833 }
15834
15835 return false;
15836}
15837
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015838uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15839 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15840 bool append_ie)
15841{
15842 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15843
15844 return sir_unpack_rsn_ie(mac_ctx, buf, buf_len, rsn_ie, append_ie);
15845}
15846
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015847/**
15848 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
15849 * @adapter : Pointer to adapter
15850 * @transition_reason : Transition reason
15851 * @info : bss candidate information
15852 * @n_candidates : number of candidates
15853 *
15854 * Return : 0 on success otherwise errno
15855 */
15856int sme_get_bss_transition_status(tHalHandle hal,
15857 uint8_t transition_reason,
15858 struct qdf_mac_addr *bssid,
15859 struct bss_candidate_info *info,
15860 uint16_t n_candidates,
15861 bool is_bt_in_progress)
15862{
15863 QDF_STATUS status = QDF_STATUS_SUCCESS;
15864 tSirBssDescription *bss_desc, *conn_bss_desc;
15865 tCsrScanResultInfo *res, *conn_res;
15866 uint16_t i;
15867
15868 if (!n_candidates || !info) {
15869 sme_err("No candidate info available");
15870 return QDF_STATUS_E_INVAL;
15871 }
15872
15873 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15874 if (!conn_res) {
15875 sme_err("Failed to allocate memory for conn_res");
15876 return QDF_STATUS_E_NOMEM;
15877 }
15878
15879 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15880 if (!res) {
15881 sme_err("Failed to allocate memory for conn_res");
15882 status = QDF_STATUS_E_NOMEM;
15883 goto free;
15884 }
15885
15886 /* Get the connected BSS descriptor */
15887 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
15888 if (!QDF_IS_STATUS_SUCCESS(status)) {
15889 sme_err("Failed to find connected BSS in scan list");
15890 goto free;
15891 }
15892 conn_bss_desc = &conn_res->BssDescriptor;
15893
15894 for (i = 0; i < n_candidates; i++) {
15895 /* Get candidate BSS descriptors */
15896 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
15897 res);
15898 if (!QDF_IS_STATUS_SUCCESS(status)) {
15899 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
15900 MAC_ADDR_ARRAY(info[i].bssid.bytes));
15901 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
15902 continue;
15903 }
15904
15905 bss_desc = &res->BssDescriptor;
15906 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
15907 &info[i], transition_reason, is_bt_in_progress)) {
15908 /*
15909 * If status is not over written, it means it is a
15910 * candidate for accept.
15911 */
15912 info[i].status = QCA_STATUS_ACCEPT;
15913 }
15914 }
15915
15916 /* success */
15917 status = QDF_STATUS_SUCCESS;
15918
15919free:
15920 /* free allocated memory */
15921 if (conn_res)
15922 qdf_mem_free(conn_res);
15923 if (res)
15924 qdf_mem_free(res);
15925
15926 return status;
15927}
15928
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015929void sme_enable_roaming_on_connected_sta(tHalHandle hal)
15930{
15931 uint8_t session_id;
15932 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15933 QDF_STATUS status;
15934
15935 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
15936 if (session_id != CSR_SESSION_ID_INVALID)
15937 return;
15938
15939 session_id = csr_get_connected_infra(mac_ctx);
15940 if (session_id == CSR_SESSION_ID_INVALID) {
15941 sme_debug("No STA in conencted state");
15942 return;
15943 }
15944
15945 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
15946 session_id);
15947 status = sme_acquire_global_lock(&mac_ctx->sme);
15948 if (QDF_IS_STATUS_SUCCESS(status)) {
15949 csr_roam_offload_scan(mac_ctx, session_id,
15950 ROAM_SCAN_OFFLOAD_START,
15951 REASON_CTX_INIT);
15952 sme_release_global_lock(&mac_ctx->sme);
15953 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015954}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053015955
Sandeep Puligilla063a4342018-01-10 02:50:14 -080015956int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
15957{
15958 uint8_t vdev_id, chan;
15959 struct csr_roam_session *session;
15960 tpAniSirGlobal mac_ctx;
15961 tHalHandle h_hal;
15962 int16_t freq = 0;
15963
15964 if (vdev == NULL) {
15965 sme_err("Invalid vdev id is passed");
15966 return 0;
15967 }
15968
15969 h_hal = cds_get_context(QDF_MODULE_ID_SME);
15970 mac_ctx = PMAC_STRUCT(h_hal);
15971 vdev_id = wlan_vdev_get_id(vdev);
15972 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
15973 sme_err("Invalid vdev id is passed");
15974 return 0;
15975 }
15976
15977 session = CSR_GET_SESSION(mac_ctx, vdev_id);
15978 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
15979 if (chan)
15980 freq = cds_chan_to_freq(chan);
15981
15982 return freq;
15983}
15984
15985enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
15986{
15987 uint8_t vdev_id;
15988 struct csr_roam_session *session;
15989 tpAniSirGlobal mac_ctx;
15990 tHalHandle h_hal;
15991 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
15992
15993 if (vdev == NULL) {
15994 sme_err("Invalid vdev id is passed");
15995 return CH_WIDTH_INVALID;
15996 }
15997
15998 h_hal = cds_get_context(QDF_MODULE_ID_SME);
15999 mac_ctx = PMAC_STRUCT(h_hal);
16000 vdev_id = wlan_vdev_get_id(vdev);
16001 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16002 sme_err("Invalid vdev id is passed");
16003 return CH_WIDTH_INVALID;
16004 }
16005
16006 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16007
16008 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16009 ch_width = session->connectedProfile.vht_channel_width;
16010
16011 return ch_width;
16012}
16013
16014int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16015 uint16_t *sec20chan_freq)
16016{
16017 uint8_t vdev_id;
16018
16019 vdev_id = wlan_vdev_get_id(vdev);
16020 /* Need to extend */
16021 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016022}
16023
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016024#ifdef WLAN_FEATURE_SAE
16025QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16026 uint8_t sae_status)
16027{
16028 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16029 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16030 struct sir_sae_msg *sae_msg;
16031 struct scheduler_msg sch_msg = {0};
16032
16033 qdf_status = sme_acquire_global_lock(&mac->sme);
16034 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16035 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16036 if (!sae_msg) {
16037 qdf_status = QDF_STATUS_E_NOMEM;
16038 sme_err("SAE: memory allocation failed");
16039 } else {
16040 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16041 sae_msg->length = sizeof(*sae_msg);
16042 sae_msg->session_id = session_id;
16043 sae_msg->sae_status = sae_status;
16044 sme_debug("SAE: sae_status %d session_id %d",
16045 sae_msg->sae_status,
16046 sae_msg->session_id);
16047
16048 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16049 sch_msg.bodyptr = sae_msg;
16050
16051 qdf_status =
16052 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16053 }
16054 sme_release_global_lock(&mac->sme);
16055 }
16056
16057 return qdf_status;
16058}
16059#endif