blob: 6e7e04e07a5de5c8c3c8de8ff702d3b790949a3e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +05302 * Copyright (c) 2012-2017 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053068static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053070static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
71 void *pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053073static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053075static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 void *pMsgBuf);
77
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053078static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053081QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
83#endif
84
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053086static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 uint16_t msg_type, void *pMsgBuf);
88
89/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053090QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053092 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093
94 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053095 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053096 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053097 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 }
99
100 return status;
101}
102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530103QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530105 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106
107 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530108 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530109 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530110 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 }
112
113 return status;
114}
115
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700116tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700117{
118 tpAniSirGlobal mac_ctx;
119 tHalHandle h_hal;
120
121 h_hal = cds_get_context(QDF_MODULE_ID_SME);
122 if (NULL == h_hal) {
123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
124 FL("invalid h_hal"));
125 return NULL;
126 }
127
128 mac_ctx = PMAC_STRUCT(h_hal);
129 if (NULL == mac_ctx) {
130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
131 FL("Invalid MAC context"));
132 return NULL;
133 }
134
135 return mac_ctx;
136}
137
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138/**
139 * sme_process_set_hw_mode_resp() - Process set HW mode response
140 * @mac: Global MAC pointer
141 * @msg: HW mode response
142 *
143 * Processes the HW mode response and invokes the HDD callback
144 * to process further
145 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530146static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147{
Krunal Sonia8270f52017-02-23 19:51:25 -0800148 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 tSmeCmd *command = NULL;
150 bool found;
151 hw_mode_cb callback = NULL;
152 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530153 enum sir_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530154 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800155 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700156
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 param = (struct sir_set_hw_mode_resp *)msg;
158 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700159 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 /* Not returning. Need to check if active command list
161 * needs to be freed
162 */
163 }
164
Krunal Sonia8270f52017-02-23 19:51:25 -0800165 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700167 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530168 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 }
170
171 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
172 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700173 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 }
176
177 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700178 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530179 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 }
181
182 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530183 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800184 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530185
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700186 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530187 command->u.set_hw_mode_cmd.reason,
188 command->u.set_hw_mode_cmd.session_id);
189
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700190 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700191 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700192 goto end;
193 }
194
195 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700196 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700197 goto end;
198 }
199
200 /* Irrespective of the reason for which the hw mode change request
201 * was issued, the policy manager connection table needs to be updated
202 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
203 * set hw mode was successful.
204 */
205 callback(param->status,
206 param->cfgd_hw_mode_index,
207 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800208 param->vdev_mac_map,
209 command->u.set_hw_mode_cmd.context);
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800210 session = CSR_GET_SESSION(mac, session_id);
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700211 if (reason == SIR_UPDATE_REASON_HIDDEN_STA) {
212 /* In the case of hidden SSID, connection update
213 * (set hw mode) is done after the scan with reason
214 * code eCsrScanForSsid completes. The connect/failure
215 * needs to be handled after the response of set hw
216 * mode
217 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800218 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700219 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800220 csr_scan_handle_search_for_ssid(mac,
221 session_id);
222 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700223 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800224 csr_scan_handle_search_for_ssid_failure(mac,
225 session_id);
226 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800227 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 }
229
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530230end:
Krunal Soni72dba662017-02-15 20:13:17 -0800231 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530233 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800235 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800236
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238}
239
240/**
241 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
242 * @mac: Global MAC pointer
243 * @msg: HW mode transition response
244 *
245 * Processes the HW mode transition indication and invoke the HDD callback
246 * to process further
247 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 uint8_t *msg)
250{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 struct sir_hw_mode_trans_ind *param;
252
253 param = (struct sir_hw_mode_trans_ind *)msg;
254 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700255 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 }
258
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800259 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800260 param->new_hw_mode_index,
261 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800262 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530264 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265}
266
Naveen Rawate7d86052015-11-13 12:01:43 -0800267/**
268 * free_sme_cmds() - This function frees memory allocated for SME commands
269 * @mac_ctx: Pointer to Global MAC structure
270 *
271 * This function frees memory allocated for SME commands
272 *
273 * @Return: void
274 */
275static void free_sme_cmds(tpAniSirGlobal mac_ctx)
276{
277 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530278
Naveen Rawate7d86052015-11-13 12:01:43 -0800279 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
280 return;
281
282 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800284
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530285 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800286 mac_ctx->sme.pSmeCmdBufAddr = NULL;
287}
288
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530289static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530291 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 tSmeCmd *pCmd;
293 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800294 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295
296 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530300 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 goto end;
302
Naveen Rawate7d86052015-11-13 12:01:43 -0800303 /* following pointer contains array of pointers for tSmeCmd* */
304 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530305 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800306 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530307 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800308 goto end;
309 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530311 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800312 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
313 /*
314 * Since total size of all commands together can be huge chunk
315 * of memory, allocate SME cmd individually. These SME CMDs are
316 * moved between pending and active queues. And these freeing of
317 * these queues just manipulates the list but does not actually
318 * frees SME CMD pointers. Hence store each SME CMD address in
319 * the array, sme.pSmeCmdBufAddr. This will later facilitate
320 * freeing up of all SME CMDs with just a for loop.
321 */
322 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530323 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800324 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530325 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800326 free_sme_cmds(pMac);
327 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800329 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
330 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
331 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 }
333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530335 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700336 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337
338 return status;
339}
340
Krunal Sonia8270f52017-02-23 19:51:25 -0800341void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342{
Krunal Sonia8270f52017-02-23 19:51:25 -0800343 sme_cmd->command = eSmeNoCommand;
344 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530345 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346}
347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348static void purge_sme_cmd_list(tpAniSirGlobal pMac)
349{
Krunal Soni81f068c2017-02-23 19:51:55 -0800350 /* purge all command lists */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700351 sme_debug("Purging all queues");
Krunal Sonia8270f52017-02-23 19:51:25 -0800352 wlan_serialization_purge_cmd_list(pMac->psoc, NULL,
Krunal Soni81f068c2017-02-23 19:51:55 -0800353 false, false, false, false, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354}
355
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530356static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530358 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359
360 purge_sme_cmd_list(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 csr_ll_close(&pMac->sme.smeCmdFreeList);
362
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530363 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530364 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700365 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 goto done;
367 }
368
Naveen Rawate7d86052015-11-13 12:01:43 -0800369 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530371 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530372 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700373 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374done:
375 return status;
376}
377
Jeff Johnson49c02f92016-10-07 10:29:09 -0700378static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379{
380 switch (pCmd->command) {
381 case eSmeCommandScan:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700382 sme_debug("scan command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 pCmd->u.scanCmd.reason);
384 break;
385
386 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700387 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 pCmd->u.roamCmd.roamReason);
389 break;
390
391 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700392 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 pCmd->u.wmStatusChangeCmd.Type);
394 break;
395
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700397 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 pCmd->command);
399 break;
400 }
401}
402
403tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
404{
405 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
406 tListElem *pEntry;
407 static int sme_command_queue_full;
408
409 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
410
411 /* If we can get another MS Msg buffer, then we are ok. Just link */
412 /* the entry onto the linked list. (We are using the linked list */
413 /* to keep track of tfhe message buffers). */
414 if (pEntry) {
415 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
416 /* reset when free list is available */
417 sme_command_queue_full = 0;
418 } else {
419 int idx = 1;
420
421 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800422 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530423 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530425
426 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
428 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530429 if (eSmeCsrCommandMask & pTempCmd->command)
430 /* CSR command is stuck. See what the reason
431 * code is for that command
432 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 } /* if(pTempCmd) */
435
436 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800437 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800439 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 LL_ACCESS_NOLOCK);
441 while (pEntry && !sme_command_queue_full) {
442 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
443 /* Print only 1st five commands from pending queue. */
444 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530445 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 idx, pTempCmd->command);
447 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530448 if (eSmeCsrCommandMask & pTempCmd->command)
449 /* CSR command is stuck. See what the reason
450 * code is for that command
451 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800453 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 LL_ACCESS_NOLOCK);
455 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800456 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457
Abhishek Singh5ea86532016-04-27 14:10:53 +0530458 if (pMac->roam.configParam.enable_fatal_event)
459 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
460 WLAN_LOG_INDICATOR_HOST_DRIVER,
461 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
462 false,
463 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530464 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530465 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 }
467
468 /* memset to zero */
469 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530472 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530474 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 }
476
477 return pRetCmd;
478}
479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800481 * sme_ser_handle_active_cmd() - handle command activation callback from
482 * new serialization module
483 * @cmd: pointer to new serialization command
484 *
485 * This API is to handle command activation callback from new serialization
486 * callback
487 *
488 * Return: QDF_STATUS_SUCCESS
489 */
490static
491QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
492{
493 tSmeCmd *sme_cmd;
494 tHalHandle hal;
495 tpAniSirGlobal mac_ctx;
496 QDF_STATUS status = QDF_STATUS_SUCCESS;
497 bool do_continue;
498
499 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700500 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800501 return QDF_STATUS_E_FAILURE;
502 }
503
504 hal = cds_get_context(QDF_MODULE_ID_SME);
505 mac_ctx = PMAC_STRUCT(hal);
506 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700507 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800508 return QDF_STATUS_E_FAILURE;
509 }
510 sme_cmd = cmd->umac_cmd;
511 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700512 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800513 return QDF_STATUS_E_FAILURE;
514 }
515
516 switch (sme_cmd->command) {
517 case eSmeCommandRoam:
518 status = csr_roam_process_command(mac_ctx, sme_cmd);
519 break;
520 case eSmeCommandWmStatusChange:
521 csr_roam_process_wm_status_change_command(mac_ctx,
522 sme_cmd);
523 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800524 case eSmeCommandNdpInitiatorRequest:
525 status = csr_process_ndp_initiator_request(mac_ctx, sme_cmd);
526 break;
527 case eSmeCommandNdpResponderRequest:
528 status = csr_process_ndp_responder_request(mac_ctx, sme_cmd);
529 break;
530 case eSmeCommandNdpDataEndInitiatorRequest:
531 status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
532 break;
Krunal Soni81f068c2017-02-23 19:51:55 -0800533 case eSmeCommandScan:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700534 sme_debug("Processing scan offload cmd");
Krunal Soni81f068c2017-02-23 19:51:55 -0800535 qdf_mc_timer_start(&sme_cmd->u.scanCmd.csr_scan_timer,
536 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
537 status = csr_process_scan_command(mac_ctx, sme_cmd);
538 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800539 case eSmeCommandRemainOnChannel:
540 status = p2p_process_remain_on_channel_cmd(mac_ctx, sme_cmd);
541 break;
542 /*
543 * Treat standby differently here because caller may not be able
544 * to handle the failure so we do our best here
545 */
546 case eSmeCommandEnterStandby:
547 break;
548 case eSmeCommandAddTs:
549 case eSmeCommandDelTs:
550#ifndef WLAN_MDM_CODE_REDUCTION_OPT
551 do_continue = qos_process_command(mac_ctx, sme_cmd);
552 if (do_continue)
553 status = QDF_STATUS_E_FAILURE;
554#endif
555 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800556 case e_sme_command_set_hw_mode:
557 csr_process_set_hw_mode(mac_ctx, sme_cmd);
558 break;
559 case e_sme_command_nss_update:
560 csr_process_nss_update_req(mac_ctx, sme_cmd);
561 break;
562 case e_sme_command_set_dual_mac_config:
563 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
564 break;
565 case e_sme_command_set_antenna_mode:
566 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
567 break;
568 default:
569 /* something is wrong */
570 /* remove it from the active list */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700571 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800572 status = QDF_STATUS_E_FAILURE;
573 break;
574 }
575 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700576 sme_err("Releasing memory for %d",
Krunal Sonia8270f52017-02-23 19:51:25 -0800577 sme_cmd->command);
578 csr_release_command(mac_ctx, sme_cmd);
579 }
580 return status;
581}
582
583QDF_STATUS sme_ser_cmd_callback(void *buf,
584 enum wlan_serialization_cb_reason reason)
585{
586 struct wlan_serialization_command *cmd = buf;
587 tHalHandle hal;
588 tpAniSirGlobal mac_ctx;
589 QDF_STATUS status = QDF_STATUS_SUCCESS;
590 tSmeCmd *sme_cmd;
591
592 hal = cds_get_context(QDF_MODULE_ID_SME);
593 mac_ctx = PMAC_STRUCT(hal);
594 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700595 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800596 return QDF_STATUS_E_FAILURE;
597 }
598 /*
599 * Do not acquire lock here as sme global lock is already acquired in
600 * caller or MC thread context
601 */
602 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700603 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800604 return QDF_STATUS_E_FAILURE;
605 }
606
607 switch (reason) {
608 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700609 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800610 status = sme_ser_handle_active_cmd(cmd);
611 break;
612 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700613 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800614 sme_cmd = cmd->umac_cmd;
615 csr_cancel_command(mac_ctx, sme_cmd);
Krunal Sonia8270f52017-02-23 19:51:25 -0800616 break;
617 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700618 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800619 sme_cmd = cmd->umac_cmd;
620 csr_release_command_buffer(mac_ctx, sme_cmd);
621 break;
622 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700623 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800624 break;
625 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700626 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800627 return QDF_STATUS_E_FAILURE;
628 }
629 return status;
630}
631
632/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530633 * sme_get_sessionid_from_activelist() - gets session id
634 * @mac: mac context
635 *
636 * This function is used to get session id from sme command
637 * active list
638 *
639 * Return: returns session id
640 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700641static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530642{
643 tListElem *entry;
644 tSmeCmd *command;
645 uint32_t session_id = CSR_SESSION_ID_INVALID;
646
Krunal Sonia8270f52017-02-23 19:51:25 -0800647 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530648 if (entry) {
649 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
650 session_id = command->sessionId;
651 }
652
653 return session_id;
654}
655
656/**
657 * sme_state_info_dump() - prints state information of sme layer
658 * @buf: buffer pointer
659 * @size: size of buffer to be filled
660 *
661 * This function is used to dump state information of sme layer
662 *
663 * Return: None
664 */
665static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
666{
667 uint32_t session_id, active_session_id;
668 tHalHandle hal;
669 tpAniSirGlobal mac;
670 uint16_t len = 0;
671 char *buf = *buf_ptr;
672 eCsrConnectState connect_state;
673
674 hal = cds_get_context(QDF_MODULE_ID_SME);
675 if (hal == NULL) {
676 QDF_ASSERT(0);
677 return;
678 }
679
680 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530681
682 active_session_id = sme_get_sessionid_from_activelist(mac);
683 if (active_session_id != CSR_SESSION_ID_INVALID) {
684 len += qdf_scnprintf(buf + len, *size - len,
685 "\n active command sessionid %d", active_session_id);
686 }
687
688 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
689 if (CSR_IS_SESSION_VALID(mac, session_id)) {
690 connect_state =
691 mac->roam.roamSession[session_id].connectState;
692 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
693 connect_state)
694 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
695 connect_state)) {
696 len += qdf_scnprintf(buf + len, *size - len,
697 "\n NeighborRoamState: %d",
698 mac->roam.neighborRoamInfo[session_id].
699 neighborRoamState);
700 len += qdf_scnprintf(buf + len, *size - len,
701 "\n RoamState: %d", mac->roam.
702 curState[session_id]);
703 len += qdf_scnprintf(buf + len, *size - len,
704 "\n RoamSubState: %d", mac->roam.
705 curSubState[session_id]);
706 len += qdf_scnprintf(buf + len, *size - len,
707 "\n ConnectState: %d",
708 connect_state);
709 }
710 }
711 }
712
713 *size -= len;
714 *buf_ptr += len;
715}
716
717/**
718 * sme_register_debug_callback() - registration function sme layer
719 * to print sme state information
720 *
721 * Return: None
722 */
723static void sme_register_debug_callback(void)
724{
725 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
726}
727
728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729/* Global APIs */
730
731/**
732 * sme_open() - Initialze all SME modules and put them at idle state
733 * @hHal: The handle returned by mac_open
734 *
735 * The function initializes each module inside SME, PMC, CSR, etc. Upon
736 * successfully return, all modules are at idle state ready to start.
737 * smeOpen must be called before any other SME APIs can be involved.
738 * smeOpen must be called after mac_open.
739 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530740 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 * Other status means SME is failed to be initialized
742 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530743QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530745 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747
748 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530749 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530750 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700752 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530753 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 }
755 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530756 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700757 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 return status;
759 }
760
761 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700763 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 return status;
765 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
767#ifndef WLAN_MDM_CODE_REDUCTION_OPT
768 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530769 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700770 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 return status;
772 }
773#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530775 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530779 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700780 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781 return status;
782 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 sme_p2p_open(pMac);
784 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530785 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700786 wlan_serialization_legacy_init_callback();
787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 return status;
789}
790
791/*
792 * sme_init_chan_list, triggers channel setup based on country code.
793 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700795 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796{
797 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
798
Amar Singhala297bfa2015-10-15 15:07:29 -0700799 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
801 pmac->roam.configParam.Is11dSupportEnabled = false;
802 }
803
804 return csr_init_chan_list(pmac, alpha2);
805}
806
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530807/*
808 * sme_set11dinfo() - Set the 11d information about valid channels
809 * and there power using information from nvRAM
810 * This function is called only for AP.
811 *
812 * This is a synchronous call
813 *
814 * hHal - The handle returned by mac_open.
815 * pSmeConfigParams - a pointer to a caller allocated object of
816 * typedef struct _smeConfigParams.
817 *
818 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
819 *
820 * Other status means SME is failed to update the config parameters.
821 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530823QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530825 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530827 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
829 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700830 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 return status;
832 }
833
834 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700835 if (!QDF_IS_STATUS_SUCCESS(status))
836 sme_err("csr_set_channels failed with status: %d", status);
837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 return status;
839}
840
841/**
842 * sme_set_scan_disable() - Dynamically enable/disable scan
843 * @h_hal: Handle to HAL
844 *
845 * This command gives the user an option to dynamically
846 * enable or disable scans.
847 *
848 * Return: None
849 */
850void sme_set_scan_disable(tHalHandle h_hal, int value)
851{
852 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 mac_ctx->lim.scan_disabled = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530856/*
857 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
858 * This is a synchronous call
859 *
860 * hHal - The handle returned by HostapdAdapter.
861 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
862 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
863 * Other status means, failed to get the current regulatory domain.
864 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530866QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
867 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530869 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
871
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530872 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
874 NO_SESSION, 0));
875 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700876 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 return status;
878 }
879
880 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530881 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882
883 return status;
884}
885
Krunal Sonie3531942016-04-12 17:43:53 -0700886/**
887 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
888 * incoming val
889 * @hal: Handle for Hal layer
890 * @val: New FTM capability value
891 *
892 * Return: None
893 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530894void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
895 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700896{
897 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530898
Krunal Sonie3531942016-04-12 17:43:53 -0700899 mac_ctx->fine_time_meas_cap = val;
900
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530901 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700902 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
903 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
904 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
905 } else {
906 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
907 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
908 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
909 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530910
911 /* Inform this RRM IE change to FW */
912 csr_roam_offload_scan(mac_ctx, session_id,
913 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
914 REASON_CONNECT_IES_CHANGED);
Krunal Sonie3531942016-04-12 17:43:53 -0700915}
916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530917/*
918 * sme_update_config() - Change configurations for all SME moduels
919 * The function updates some configuration for modules in SME, CSR, etc
920 * during SMEs close open sequence.
921 * Modules inside SME apply the new configuration at the next transaction.
922 * This is a synchronous call
923 *
924 * hHal - The handle returned by mac_open.
925 * pSmeConfigParams - a pointer to a caller allocated object of
926 * typedef struct _smeConfigParams.
927 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
928 * Other status means SME is failed to update the config parameters.
929 */
930QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
931 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530933 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
935
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530936 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
938 0));
939 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700940 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 return status;
942 }
943
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530944 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
945 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530947 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700948 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530951 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
952 rrmConfig);
953
954 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700955 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530957
958 /* For SOC, CFG is set before start We don't want to apply global CFG
959 * in connect state because that may cause some side affect
960 */
961 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963
964 /*
965 * If scan offload is enabled then lim has allow the sending of
966 * scan request to firmware even in powersave mode. The firmware has
967 * to take care of exiting from power save mode
968 */
969 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
970
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530971 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530972 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530974
975 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 return status;
978}
979
980/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530981 * sme_update_scan_roam_params() - Update the scan roaming params
982 * @mac_ctx: mac ctx
983 *
984 * Return: void.
985 */
986static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
987{
988 struct roam_filter_params scan_params = {0};
989 struct roam_ext_params *roam_params_src;
990 uint8_t i;
991 QDF_STATUS status;
992
993 roam_params_src = &mac_ctx->roam.configParam.roam_params;
994
995 scan_params.num_bssid_avoid_list =
996 roam_params_src->num_bssid_avoid_list;
997 scan_params.num_bssid_favored =
998 roam_params_src->num_bssid_favored;
999 scan_params.raise_rssi_thresh_5g =
1000 roam_params_src->raise_rssi_thresh_5g;
1001 scan_params.drop_rssi_thresh_5g =
1002 roam_params_src->drop_rssi_thresh_5g;
1003 scan_params.raise_factor_5g =
1004 roam_params_src->raise_factor_5g;
1005 scan_params.drop_factor_5g =
1006 roam_params_src->drop_factor_5g;
1007 scan_params.max_raise_rssi_5g =
1008 roam_params_src->max_raise_rssi_5g;
1009 scan_params.max_drop_rssi_5g =
1010 roam_params_src->max_drop_rssi_5g;
1011 scan_params.is_5g_pref_enabled =
1012 roam_params_src->is_5g_pref_enabled;
1013
1014 if (scan_params.num_bssid_favored > MAX_FAVORED_BSSID)
1015 scan_params.num_bssid_favored = MAX_FAVORED_BSSID;
1016
1017 for (i = 0; i < scan_params.num_bssid_favored; i++) {
1018 qdf_copy_macaddr(&scan_params.bssid_favored[i],
1019 &roam_params_src->bssid_favored[i]);
1020 scan_params.bssid_favored_factor[i] =
1021 roam_params_src->bssid_favored_factor[i];
1022 }
1023
1024 if (scan_params.num_bssid_avoid_list >
1025 MAX_AVOID_LIST_BSSID)
1026 scan_params.num_bssid_avoid_list =
1027 MAX_AVOID_LIST_BSSID;
1028
1029 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
1030 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
1031 &roam_params_src->bssid_avoid_list[i]);
1032 }
1033
1034 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
1035 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001036 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +05301037 status);
1038}
1039
1040/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 * sme_update_roam_params() - Store/Update the roaming params
1042 * @hal: Handle for Hal layer
1043 * @session_id: SME Session ID
1044 * @roam_params_src: The source buffer to copy
1045 * @update_param: Type of parameter to be updated
1046 *
1047 * Return: Return the status of the updation.
1048 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301049QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001050 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 int update_param)
1052{
1053 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1054 struct roam_ext_params *roam_params_dst;
1055 uint8_t i;
1056
1057 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1058 switch (update_param) {
1059 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1060 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001061 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001063 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001065 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001067 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001069 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001071 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001073 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 roam_params_dst->is_5g_pref_enabled = true;
1075 break;
1076 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301077 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1079 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001080 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1082 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001083 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301084 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001085 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 roam_params_dst->ssid_allowed_list[i].length);
1087 }
1088 break;
1089 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301090 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1092 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001093 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301095 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001096 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097 sizeof(tSirMacAddr));
1098 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001099 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100 }
1101 break;
1102 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301103 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301104 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001106 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301108 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001109 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110 }
1111 break;
1112 case REASON_ROAM_GOOD_RSSI_CHANGED:
1113 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001114 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 break;
1116 default:
1117 break;
1118 }
1119 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1120 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301121
1122 sme_update_scan_roam_params(mac_ctx);
1123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 return 0;
1125}
1126
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301127/*
1128 * sme_process_ready_to_suspend() -
1129 * On getting ready to suspend indication, this function calls
1130 * callback registered (HDD callbacks) with SME to inform ready
1131 * to suspend indication.
1132 *
1133 * hHal - Handle returned by mac_open.
1134 * pReadyToSuspend - Parameter received along with ready to suspend
1135 * indication from WMA.
1136 * Return: None
1137 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001138static void sme_process_ready_to_suspend(tHalHandle hHal,
1139 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140{
1141 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1142
1143 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301144 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 "%s: pMac is null", __func__);
1146 return;
1147 }
1148
1149 if (NULL != pMac->readyToSuspendCallback) {
1150 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1151 pReadyToSuspend->suspended);
1152 pMac->readyToSuspendCallback = NULL;
1153 }
1154}
1155
1156#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001158/**
1159 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1160 * @hHal - Handle returned by mac_open.
1161 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1162 * indication from WMA.
1163 *
1164 * On getting ready to Ext WoW indication, this function calls callback
1165 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1166 *
1167 * Return: None
1168 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001169static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1170 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171{
1172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1173
1174 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301175 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 "%s: pMac is null", __func__);
1177 return;
1178 }
1179
1180 if (NULL != pMac->readyToExtWoWCallback) {
1181 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1182 pReadyToExtWoW->status);
1183 pMac->readyToExtWoWCallback = NULL;
1184 pMac->readyToExtWoWContext = NULL;
1185 }
1186
1187}
1188#endif
1189
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301190/*
1191 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1192 * that the NIC is ready tio run.
1193 * The function is called by HDD at the end of initialization stage so PE/HAL
1194 * can enable the NIC to running state.
1195 * This is a synchronous call
1196 *
1197 * @hHal - The handle returned by mac_open.
1198 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1199 * successfully.
1200 * Other status means SME failed to send the message to PE.
1201 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301202QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203{
Abhishek Singhde410b72017-05-22 15:25:39 +05301204 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301205 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1207
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301208 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1210 do {
1211
Abhishek Singhde410b72017-05-22 15:25:39 +05301212 msg = qdf_mem_malloc(sizeof(*msg));
1213 if (!msg) {
1214 sme_err("Memory allocation failed! for msg");
1215 return QDF_STATUS_E_NOMEM;
1216 }
1217 msg->messageType = eWNI_SME_SYS_READY_IND;
1218 msg->length = sizeof(*msg);
1219 msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
1220 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001221 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301223 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1224 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301225 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001227 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 break;
1229 }
1230
1231 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301232 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001233 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 break;
1235 }
1236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 pMac->sme.state = SME_STATE_READY;
1238 } while (0);
1239
1240 return status;
1241}
1242
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001243QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1244{
1245 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1246 QDF_STATUS status = QDF_STATUS_SUCCESS;
1247
1248 if (NULL == mac_ctx) {
1249 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1250 FL("Invalid MAC context"));
1251 return QDF_STATUS_E_FAILURE;
1252 }
1253
1254 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1255 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1256 status = QDF_STATUS_E_INVAL;
1257
1258 return status;
1259}
1260
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301261/*
1262 * sme_start() - Put all SME modules at ready state.
1263 * The function starts each module in SME, PMC, CSR, etc. . Upon
1264 * successfully return, all modules are ready to run.
1265 * This is a synchronous call
1266 *
1267 * hHal - The handle returned by mac_open.
1268 * Return QDF_STATUS_SUCCESS - SME is ready.
1269 * Other status means SME is failed to start
1270 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301271QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301273 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001275 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276
1277 do {
1278 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301279 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001280 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 break;
1282 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001283 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001284 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001285 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1286 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1287 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1288 sme_cbacks.sme_soc_set_dual_mac_config =
1289 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001290 sme_cbacks.sme_change_mcc_beacon_interval =
1291 sme_change_mcc_beacon_interval;
1292 sme_cbacks.sme_get_ap_channel_from_scan =
1293 sme_get_ap_channel_from_scan;
1294 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001295 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1296 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001297 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001298 status);
1299 break;
1300 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001303 /* START RRM */
1304 status = rrm_start(pMac);
1305 if (!QDF_IS_STATUS_SUCCESS(status)) {
1306 sme_err("Failed to start RRM");
1307 break;
1308 }
1309 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 return status;
1311}
1312
1313/**
1314 * sme_handle_scan_req() - Scan request handler
1315 * @mac_ctx: MAC global context
1316 * @msg: message buffer
1317 *
1318 * Scan request message from upper layer is handled as
1319 * part of this API
1320 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301321 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301323static QDF_STATUS sme_handle_scan_req(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 void *msg)
1325{
1326 struct ani_scan_req *scan_msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301327 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 uint16_t session_id;
1329 csr_scan_completeCallback callback;
1330
1331 scan_msg = msg;
1332 session_id = scan_msg->session_id;
1333 callback = scan_msg->callback;
1334 status = csr_scan_request(mac_ctx, session_id,
1335 scan_msg->scan_param,
1336 callback, scan_msg->ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301337 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001338 sme_err("Scan request failed. session_id: %d", session_id);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301339
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301341 qdf_mem_free(scan_msg->scan_param);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 return status;
1343}
1344
1345/**
1346 * sme_handle_roc_req() - Roc request handler
1347 * @mac_ctx: MAC global context
1348 * @msg: message buffer
1349 *
1350 * Roc request message from upper layer is handled as
1351 * part of this API
1352 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301353 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301355static QDF_STATUS sme_handle_roc_req(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 void *msg)
1357{
1358 struct ani_roc_req *roc_msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301359 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 remainOnChanCallback callback;
1361
1362 if (msg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001363 sme_err("ROC request is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 return status;
1365 }
1366
1367 roc_msg = msg;
1368 callback = roc_msg->callback;
1369 status = p2p_remain_on_channel(hal, roc_msg->session_id,
1370 roc_msg->channel, roc_msg->duration, callback,
1371 roc_msg->ctx, roc_msg->is_p2pprobe_allowed,
1372 roc_msg->scan_id);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301373 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001374 sme_err("Scan request failed. session_id: %d scan_id: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 roc_msg->session_id, roc_msg->scan_id);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 return status;
1378}
1379
Arif Hussaincd151632017-02-11 16:57:19 -08001380static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1381 struct scheduler_msg *msg)
1382{
1383 QDF_STATUS status = QDF_STATUS_SUCCESS;
1384 tCsrRoamInfo roam_info = { 0 };
1385 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1386 uint32_t session_id = 0;
1387 eRoamCmdStatus roam_status;
1388 eCsrRoamResult roam_result;
1389
1390 switch (msg->type) {
1391 case eWNI_SME_DFS_RADAR_FOUND:
1392 {
1393 session_id = msg->bodyval;
1394 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1395 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301396 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001397 "sapdfs: Radar indication event occurred");
1398 break;
1399 }
1400 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1401 {
1402 csa_ie_tx_complete_rsp =
1403 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1404 if (!csa_ie_tx_complete_rsp) {
1405 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1406 return QDF_STATUS_E_FAILURE;
1407 }
1408 session_id = csa_ie_tx_complete_rsp->sessionId;
1409 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1410 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301411 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001412 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1413 session_id);
1414 break;
1415 }
1416 case eWNI_SME_DFS_CAC_COMPLETE:
1417 {
1418 session_id = msg->bodyval;
1419 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1420 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301421 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001422 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1423 session_id);
1424 break;
1425 }
1426 default:
1427 {
1428 sme_err("Invalid DFS message: 0x%x", msg->type);
1429 status = QDF_STATUS_E_FAILURE;
1430 return status;
1431 }
1432 }
1433
1434 /* Indicate Radar Event to SAP */
1435 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1436 roam_status, roam_result);
1437 return status;
1438}
1439
1440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301442/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 * Handle the unprotected management frame indication from LIM and
1444 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301445 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301446QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1448{
1449 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301450 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001451 tCsrRoamInfo roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1453
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001454 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1455 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1456 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
1458 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001459 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1461
1462 return status;
1463}
1464#endif
1465
Kapil Gupta8878ad92017-02-13 11:56:04 +05301466QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1467{
1468 QDF_STATUS status = QDF_STATUS_SUCCESS;
1469 tpAniSirGlobal mac = PMAC_STRUCT(hal);
1470 tCsrRoamInfo *roamInfo;
1471 eRoamCmdStatus roamStatus;
1472 eCsrRoamResult roamResult;
1473
1474 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
1475 roamInfo->dfs_event.sessionId = session_id;
1476
1477 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1478 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301479 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301480 "sapdfs: Updated new channel event");
1481
1482 /* Indicate channel Event to SAP */
1483 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1484 roamStatus, roamResult);
1485
1486 qdf_mem_free(roamInfo);
1487 return status;
1488}
1489
1490
Abhishek Singh518323d2015-10-19 17:42:01 +05301491/**
1492 * sme_extended_change_channel_ind()- function to indicate ECSA
1493 * action frame is received in lim to SAP
1494 * @mac_ctx: pointer to global mac structure
1495 * @msg_buf: contain new channel and session id.
1496 *
1497 * This function is called to post ECSA action frame
1498 * receive event to SAP.
1499 *
1500 * Return: success if msg indicated to SAP else return failure
1501 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301502static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301503 void *msg_buf)
1504{
1505 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301507 uint32_t session_id = 0;
1508 tCsrRoamInfo roamInfo = {0};
1509 eRoamCmdStatus roam_status;
1510 eCsrRoamResult roam_result;
1511
Abhishek Singh518323d2015-10-19 17:42:01 +05301512 ext_chan_ind = msg_buf;
1513 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001514 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301515 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301516 }
1517 session_id = ext_chan_ind->session_id;
1518 roamInfo.target_channel = ext_chan_ind->new_channel;
1519 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1520 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001521 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1522 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301523
1524 /* Indicate Ext Channel Change event to SAP */
1525 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1526 roam_status, roam_result);
1527 return status;
1528}
1529
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001530/**
1531 * sme_process_fw_mem_dump_rsp - process fw memory dump response from WMA
1532 *
1533 * @mac_ctx: pointer to MAC handle.
1534 * @msg: pointer to received SME msg.
1535 *
1536 * This function process the received SME message and calls the corresponding
1537 * callback which was already registered with SME.
1538 *
1539 * Return: None
1540 */
1541#ifdef WLAN_FEATURE_MEMDUMP
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001542static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1543 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001544{
1545 if (msg->bodyptr) {
1546 if (mac_ctx->sme.fw_dump_callback)
1547 mac_ctx->sme.fw_dump_callback(mac_ctx->hHdd,
1548 (struct fw_dump_rsp *) msg->bodyptr);
1549 qdf_mem_free(msg->bodyptr);
1550 }
1551}
1552#else
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001553static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1554 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001555{
1556}
1557#endif
1558
1559#ifdef FEATURE_WLAN_ESE
1560/**
1561 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1562 * @hHal: HAL handle
1563 * @sessionId: session id
1564 * @isEseIniFeatureEnabled: ese ini enabled
1565 *
1566 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1567 * isEseIniFeatureEnabled. This is a synchronous call
1568 *
1569 * Return: QDF_STATUS enumeration
1570 */
1571QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1572 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1573{
1574 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1575
1576 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1577 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301578 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001579 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1580 __func__,
1581 pMac->roam.configParam.isEseIniFeatureEnabled,
1582 isEseIniFeatureEnabled);
1583 return QDF_STATUS_SUCCESS;
1584 }
1585
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301586 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001587 "%s: EseEnabled is changed from %d to %d", __func__,
1588 pMac->roam.configParam.isEseIniFeatureEnabled,
1589 isEseIniFeatureEnabled);
1590 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001591 csr_neighbor_roam_update_fast_roaming_enabled(
1592 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001593
1594 if (true == isEseIniFeatureEnabled)
1595 sme_update_fast_transition_enabled(hHal, true);
1596
1597 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1598 csr_roam_offload_scan(pMac, sessionId,
1599 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1600 REASON_ESE_INI_CFG_CHANGED);
1601
1602 return QDF_STATUS_SUCCESS;
1603}
1604
1605/**
1606 * sme_set_plm_request() - set plm request
1607 * @hHal: HAL handle
1608 * @pPlmReq: Pointer to input plm request
1609 *
1610 * Return: QDF_STATUS enumeration
1611 */
1612QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1613{
1614 QDF_STATUS status;
1615 bool ret = false;
1616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001617 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001618 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001619 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301620 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1621 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001622
1623 status = sme_acquire_global_lock(&pMac->sme);
1624 if (!QDF_IS_STATUS_SUCCESS(status))
1625 return status;
1626
1627 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001628 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001629 sme_release_global_lock(&pMac->sme);
1630 return QDF_STATUS_E_FAILURE;
1631 }
1632
1633 if (!pSession->sessionActive) {
1634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1635 FL("Invalid Sessionid"));
1636 sme_release_global_lock(&pMac->sme);
1637 return QDF_STATUS_E_FAILURE;
1638 }
1639
1640 if (!pPlmReq->enable)
1641 goto send_plm_start;
1642 /* validating channel numbers */
1643 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1644 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1645 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001646 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1647 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001648 pPlmReq->plmChList[count])) {
1649 /* DFS channel is provided, no PLM bursts can be
1650 * transmitted. Ignoring these channels.
1651 */
1652 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301653 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001654 FL("DFS channel %d ignored for PLM"),
1655 pPlmReq->plmChList[count]);
1656 continue;
1657 }
1658 } else if (!ret) {
1659 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001661 FL("Unsupported channel %d ignored for PLM"),
1662 pPlmReq->plmChList[count]);
1663 continue;
1664 }
1665 ch_list[valid_count] = pPlmReq->plmChList[count];
1666 valid_count++;
1667 } /* End of for () */
1668
1669 /* Copying back the valid channel list to plm struct */
1670 qdf_mem_set((void *)pPlmReq->plmChList,
1671 pPlmReq->plmNumCh, 0);
1672 if (valid_count)
1673 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1674 valid_count);
1675 /* All are invalid channels, FW need to send the PLM
1676 * report with "incapable" bit set.
1677 */
1678 pPlmReq->plmNumCh = valid_count;
1679
1680send_plm_start:
1681 /* PLM START */
1682 msg.type = WMA_SET_PLM_REQ;
1683 msg.reserved = 0;
1684 msg.bodyptr = pPlmReq;
1685
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001686 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001687 &msg))) {
1688 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1689 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1690 sme_release_global_lock(&pMac->sme);
1691 return QDF_STATUS_E_FAILURE;
1692 }
1693
1694 sme_release_global_lock(&pMac->sme);
1695 return status;
1696}
1697
1698/**
1699 * sme_tsm_ie_ind() - sme tsm ie indication
1700 * @hHal: HAL handle
1701 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 *
1703 * Handle the tsm ie indication from LIM and forward it to HDD.
1704 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001705 * Return: QDF_STATUS enumeration
1706 */
1707static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708{
1709 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001711 tCsrRoamInfo roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301713
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001714 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1715 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1716 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001718 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301719 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 return status;
1721}
1722
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001723/**
1724 * sme_set_cckm_ie() - set cckm ie
1725 * @hHal: HAL handle
1726 * @sessionId: session id
1727 * @pCckmIe: Pointer to CCKM Ie
1728 * @cckmIeLen: Length of @pCckmIe
1729 *
1730 * Function to store the CCKM IE passed from supplicant and use
1731 * it while packing reassociation request.
1732 *
1733 * Return: QDF_STATUS enumeration
1734 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301735QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 uint8_t *pCckmIe, uint8_t cckmIeLen)
1737{
1738 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301739 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301742 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1744 sme_release_global_lock(&pMac->sme);
1745 }
1746 return status;
1747}
1748
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001749/**
1750 * sme_set_ese_beacon_request() - set ese beacon request
1751 * @hHal: HAL handle
1752 * @sessionId: session id
1753 * @pEseBcnReq: Ese beacon report
1754 *
1755 * function to set ESE beacon request parameters
1756 *
1757 * Return: QDF_STATUS enumeration
1758 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301759QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 const tCsrEseBeaconReq *pEseBcnReq)
1761{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001762 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1764 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1765 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1766 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301767 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1769
1770 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001771 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301772 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 }
1774
1775 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301776 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 sizeof(tCsrEseBeaconReq));
1778
1779 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001782 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301783 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 }
1785
1786 pSmeRrmContext->eseBcnReqInProgress = true;
1787
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001788 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789
1790 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1791 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301792 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 pSession->connectedProfile.bssid.bytes,
1794 sizeof(tSirMacAddr));
1795 pSmeBcnReportReq->channelInfo.channelNum = 255;
1796 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1797 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1798
1799 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1800 pBeaconReq =
1801 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1802 pSmeBcnReportReq->fMeasurementtype[counter] =
1803 pBeaconReq->scanMode;
1804 pSmeBcnReportReq->measurementDuration[counter] =
1805 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1806 pSmeBcnReportReq->channelList.channelNumber[counter] =
1807 pBeaconReq->channel;
1808 }
1809
1810 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1811
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301812 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 pSmeRrmContext->eseBcnReqInProgress = false;
1814
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301815 qdf_mem_free(pSmeBcnReportReq);
1816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 return status;
1818}
1819
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001820/**
1821 * sme_get_tsm_stats() - SME get tsm stats
1822 * @hHal: HAL handle
1823 * @callback: SME sends back the requested stats using the callback
1824 * @staId: The station ID for which the stats is requested for
1825 * @bssId: bssid
1826 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001827 * @tid: Traffic id
1828 *
1829 * API register a callback to get TSM Stats.
1830 *
1831 * Return: QDF_STATUS enumeration
1832 */
1833QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1834 tCsrTsmStatsCallback callback,
1835 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001836 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001837{
1838 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1839 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1840
1841 status = sme_acquire_global_lock(&pMac->sme);
1842 if (QDF_IS_STATUS_SUCCESS(status)) {
1843 status = csr_get_tsm_stats(pMac, callback,
1844 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001845 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001846 sme_release_global_lock(&pMac->sme);
1847 }
1848 return status;
1849}
1850
1851/**
1852 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1853 * @hHal: pointer HAL handle returned by mac_open
1854 * @sessionId: sme session id
1855 * @pChannelList: Output channel list
1856 * @numChannels: Output number of channels
1857 *
1858 * This routine is called to set ese roam scan channel list.
1859 * This is a synchronous call
1860 *
1861 * Return: QDF_STATUS
1862 */
1863QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1864 uint8_t sessionId,
1865 uint8_t *pChannelList,
1866 uint8_t numChannels)
1867{
1868 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1869 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001870 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1871 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001872 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1873 uint8_t newChannelList[128] = { 0 };
1874 uint8_t i = 0, j = 0;
1875
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001876 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1877 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1878 FL("Invalid sme session id: %d"), sessionId);
1879 return QDF_STATUS_E_INVAL;
1880 }
1881
1882 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1883 curchnl_list_info =
1884 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1885
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001886 status = sme_acquire_global_lock(&pMac->sme);
1887 if (!QDF_IS_STATUS_SUCCESS(status)) {
1888 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1889 csr_roam_offload_scan(pMac, sessionId,
1890 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1891 REASON_CHANNEL_LIST_CHANGED);
1892 return status;
1893 }
1894 if (NULL != curchnl_list_info->ChannelList) {
1895 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1896 j += snprintf(oldChannelList + j,
1897 sizeof(oldChannelList) - j, "%d",
1898 curchnl_list_info->ChannelList[i]);
1899 }
1900 }
1901 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1902 pChannelList, numChannels,
1903 csr_get_current_band(hHal));
1904 if (QDF_IS_STATUS_SUCCESS(status)) {
1905 if (NULL != curchnl_list_info->ChannelList) {
1906 j = 0;
1907 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1908 j += snprintf(newChannelList + j,
1909 sizeof(newChannelList) - j, "%d",
1910 curchnl_list_info->ChannelList[i]);
1911 }
1912 }
1913 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1914 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1915 newChannelList, oldChannelList,
1916 pNeighborRoamInfo->neighborRoamState);
1917 }
1918 sme_release_global_lock(&pMac->sme);
1919 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1920 csr_roam_offload_scan(pMac, sessionId,
1921 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1922 REASON_CHANNEL_LIST_CHANGED);
1923 return status;
1924}
1925
1926#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927
Jeff Johnson49c02f92016-10-07 10:29:09 -07001928static
1929QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1930 tpSirIbssGetPeerInfoRspParams
1931 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001932{
1933 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1934
1935 if (NULL == pMac) {
1936 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1937 "%s: pMac is null", __func__);
1938 return QDF_STATUS_E_FAILURE;
1939 }
1940 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1941 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1942 "%s: HDD callback is null", __func__);
1943 return QDF_STATUS_E_FAILURE;
1944 }
1945 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1946 &pIbssPeerInfoParams->
1947 ibssPeerInfoRspParams);
1948 return QDF_STATUS_SUCCESS;
1949}
1950
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1953 * @mac: Global MAC pointer
1954 * @msg: Dual mac config response
1955 *
1956 * Processes the dual mac configuration response and invokes the HDD callback
1957 * to process further
1958 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301959static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 uint8_t *msg)
1961{
1962 tListElem *entry = NULL;
1963 tSmeCmd *command = NULL;
1964 bool found;
1965 dual_mac_cb callback = NULL;
1966 struct sir_dual_mac_config_resp *param;
1967
1968 param = (struct sir_dual_mac_config_resp *)msg;
1969 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001970 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 /* Not returning. Need to check if active command list
1972 * needs to be freed
1973 */
1974 }
1975
Krunal Sonia8270f52017-02-23 19:51:25 -08001976 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001978 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301979 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 }
1981
1982 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1983 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001984 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301985 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 }
1987
1988 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001989 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 }
1992
1993 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1994 if (callback) {
1995 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001996 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001998 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 callback(param->status,
2000 command->u.set_dual_mac_cmd.scan_config,
2001 command->u.set_dual_mac_cmd.fw_mode_config);
2002 }
2003 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002004 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005 }
2006
Krunal Soni72dba662017-02-15 20:13:17 -08002007 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 if (found)
2009 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002010 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302012 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013}
2014
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002015/**
2016 * sme_process_antenna_mode_resp() - Process set antenna mode
2017 * response
2018 * @mac: Global MAC pointer
2019 * @msg: antenna mode response
2020 *
2021 * Processes the antenna mode response and invokes the HDD
2022 * callback to process further
2023 */
2024static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
2025 uint8_t *msg)
2026{
2027 tListElem *entry;
2028 tSmeCmd *command;
2029 bool found;
2030 antenna_mode_cb callback;
2031 struct sir_antenna_mode_resp *param;
2032
2033 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302034 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002035 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002036 /* Not returning. Need to check if active command list
2037 * needs to be freed
2038 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002039
Krunal Sonia8270f52017-02-23 19:51:25 -08002040 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002041 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002042 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002043 return QDF_STATUS_E_FAILURE;
2044 }
2045
2046 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2047 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002048 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002049 return QDF_STATUS_E_FAILURE;
2050 }
2051
2052 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002053 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002054 return QDF_STATUS_E_FAILURE;
2055 }
2056
2057 callback =
2058 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
2059 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302060 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002061 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302062 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002063 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002064 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002065 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002066 }
2067
Krunal Soni72dba662017-02-15 20:13:17 -08002068 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002069 if (found)
2070 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002071 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002072
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002073 return QDF_STATUS_SUCCESS;
2074}
2075
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302076/*
2077 * sme_process_msg() - The main message processor for SME.
2078 * The function is called by a message dispatcher when to process a message
2079 * targeted for SME.
2080 * This is a synchronous call
2081 *
2082 * hHal - The handle returned by mac_open.
2083 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
2084 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
2085 * Other status means SME failed to process the message to HAL.
2086 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002087QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302089 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2091
2092 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002093 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 return status;
2095 }
2096 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002098 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302100 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 return status;
2102 }
2103 if (!SME_IS_START(pMac)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002104 sme_warn("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302106 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 goto release_lock;
2108 }
2109 switch (pMsg->type) {
2110#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
2114 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302115 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 break;
2117#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 case WNI_CFG_SET_CNF:
2119 case WNI_CFG_DNLD_CNF:
2120 case WNI_CFG_GET_RSP:
2121 case WNI_CFG_ADD_GRP_ADDR_CNF:
2122 case WNI_CFG_DEL_GRP_ADDR_CNF:
2123 break;
2124 case eWNI_SME_ADDTS_RSP:
2125 case eWNI_SME_DELTS_RSP:
2126 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 /* QoS */
2129 if (pMsg->bodyptr) {
2130#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2131 status = sme_qos_msg_processor(pMac, pMsg->type,
2132 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302133 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134#endif
2135 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002136 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 }
2138 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 case eWNI_SME_NEIGHBOR_REPORT_IND:
2140 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 if (pMsg->bodyptr) {
2142 status = sme_rrm_msg_processor(pMac, pMsg->type,
2143 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302144 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302146 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 }
2148 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 case eWNI_SME_ADD_STA_SELF_RSP:
2150 if (pMsg->bodyptr) {
2151 status = csr_process_add_sta_session_rsp(pMac,
2152 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302153 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002155 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 }
2157 break;
2158 case eWNI_SME_DEL_STA_SELF_RSP:
2159 if (pMsg->bodyptr) {
2160 status = csr_process_del_sta_session_rsp(pMac,
2161 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302162 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002164 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 }
2166 break;
2167 case eWNI_SME_REMAIN_ON_CHN_RSP:
2168 if (pMsg->bodyptr) {
2169 status = sme_remain_on_chn_rsp(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302170 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002172 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 }
2174 break;
2175 case eWNI_SME_REMAIN_ON_CHN_RDY_IND:
2176 if (pMsg->bodyptr) {
2177 status = sme_remain_on_chn_ready(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302178 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002180 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 }
2182 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 case eWNI_SME_CHANGE_COUNTRY_CODE:
2184 if (pMsg->bodyptr) {
2185 status = sme_handle_change_country_code((void *)pMac,
2186 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002189 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 }
2191 break;
2192 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2193 if (pMsg->bodyptr) {
2194 status = sme_handle_generic_change_country_code(
2195 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302196 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002198 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 }
2200 break;
2201 case eWNI_SME_SCAN_CMD:
2202 if (pMsg->bodyptr) {
2203 status = sme_handle_scan_req(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302204 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002206 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 }
2208 break;
2209 case eWNI_SME_ROC_CMD:
2210 if (pMsg->bodyptr) {
2211 status = sme_handle_roc_req(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002214 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 }
2216 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217#ifdef WLAN_FEATURE_11W
2218 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2219 if (pMsg->bodyptr) {
2220 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302221 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002223 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 }
2225 break;
2226#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002227#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 case eWNI_SME_TSM_IE_IND:
2229 if (pMsg->bodyptr) {
2230 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302231 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002233 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 }
2235 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002236#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2238 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2239 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302240 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002242 case eWNI_SME_IBSS_PEER_INFO_RSP:
2243 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002244 sme_ibss_peer_info_response_handler(pMac,
2245 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002246 qdf_mem_free(pMsg->bodyptr);
2247 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002248 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002249 }
2250 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 case eWNI_SME_READY_TO_SUSPEND_IND:
2252 if (pMsg->bodyptr) {
2253 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302254 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002256 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 }
2258 break;
2259#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2260 case eWNI_SME_READY_TO_EXTWOW_IND:
2261 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002262 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302263 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002265 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 }
2267 break;
2268#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2270 case eWNI_SME_AUTO_SHUTDOWN_IND:
2271 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302272 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 FL("Auto shutdown notification"));
2274 pMac->sme.pAutoShutdownNotificationCb();
2275 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302276 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 break;
2278#endif
2279 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002280 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002282 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302283 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 break;
2285 case eWNI_SME_CHANNEL_CHANGE_RSP:
2286 if (pMsg->bodyptr) {
2287 status = sme_process_channel_change_resp(pMac,
2288 pMsg->type,
2289 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302290 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002292 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 }
2294 break;
2295#ifdef WLAN_FEATURE_STATS_EXT
2296 case eWNI_SME_STATS_EXT_EVENT:
2297 if (pMsg->bodyptr) {
2298 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302299 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002301 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 }
2303 break;
2304#endif
Will Huang558f8082017-05-31 16:22:24 +08002305 case eWNI_SME_GET_PEER_INFO_IND:
2306 if (pMac->sme.pget_peer_info_ind_cb)
2307 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2308 pMac->sme.pget_peer_info_cb_context);
2309 qdf_mem_free(pMsg->bodyptr);
2310 break;
2311 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2312 if (pMac->sme.pget_peer_info_ext_ind_cb)
2313 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2314 pMac->sme.pget_peer_info_ext_cb_context);
2315 qdf_mem_free(pMsg->bodyptr);
2316 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 case eWNI_SME_CSA_OFFLOAD_EVENT:
2318 if (pMsg->bodyptr) {
2319 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302320 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 }
2322 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002323 case eWNI_SME_TSF_EVENT:
2324 if (pMac->sme.get_tsf_cb) {
2325 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2326 (struct stsf *)pMsg->bodyptr);
2327 }
2328 if (pMsg->bodyptr)
2329 qdf_mem_free(pMsg->bodyptr);
2330 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331#ifdef WLAN_FEATURE_NAN
2332 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302333 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2334 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 if (pMsg->bodyptr) {
2336 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302337 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 }
2339 break;
2340#endif /* WLAN_FEATURE_NAN */
2341 case eWNI_SME_LINK_STATUS_IND:
2342 {
2343 tAniGetLinkStatus *pLinkStatus =
2344 (tAniGetLinkStatus *) pMsg->bodyptr;
2345 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302346 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 pMac->sme.linkStatusCallback(
2348 pLinkStatus->linkStatus,
2349 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 pMac->sme.linkStatusCallback = NULL;
2352 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302353 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 }
2355 break;
2356 }
2357 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302358 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2360 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 break;
2362 case eWNI_SME_SNR_IND:
2363 {
2364 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 if (pSnrReq) {
2367 if (pSnrReq->snrCallback) {
2368 ((tCsrSnrCallback)
2369 (pSnrReq->snrCallback))
2370 (pSnrReq->snr, pSnrReq->staId,
2371 pSnrReq->pDevContext);
2372 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302373 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 }
2375 break;
2376 }
2377#ifdef FEATURE_WLAN_EXTSCAN
2378 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2379 if (pMac->sme.pExtScanIndCb)
2380 pMac->sme.pExtScanIndCb(pMac->hHdd,
2381 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2382 pMsg->bodyptr);
2383 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002384 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 pMsg->type);
2386
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302387 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 break;
2389 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2390 if (pMac->sme.pExtScanIndCb)
2391 pMac->sme.pExtScanIndCb(pMac->hHdd,
2392 eSIR_EPNO_NETWORK_FOUND_IND,
2393 pMsg->bodyptr);
2394 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002395 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 pMsg->type);
2397
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302398 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 break;
2400#endif
2401 case eWNI_SME_FW_DUMP_IND:
2402 sme_process_fw_mem_dump_rsp(pMac, pMsg);
2403 break;
2404 case eWNI_SME_SET_HW_MODE_RESP:
2405 if (pMsg->bodyptr) {
2406 status = sme_process_set_hw_mode_resp(pMac,
2407 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302408 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 } 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 }
2412 break;
2413 case eWNI_SME_HW_MODE_TRANS_IND:
2414 if (pMsg->bodyptr) {
2415 status = sme_process_hw_mode_trans_ind(pMac,
2416 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302417 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002419 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 }
2421 break;
2422 case eWNI_SME_NSS_UPDATE_RSP:
2423 if (pMsg->bodyptr) {
2424 status = sme_process_nss_update_resp(pMac,
2425 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302426 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002428 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 }
2430 break;
2431 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302432 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 pMac->sme.ocb_set_config_callback(
2434 pMac->sme.ocb_set_config_context,
2435 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302436 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002437 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 pMac->sme.ocb_set_config_callback = NULL;
2439 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302440 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 break;
2442 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302443 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 pMac->sme.ocb_get_tsf_timer_callback(
2445 pMac->sme.ocb_get_tsf_timer_context,
2446 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302447 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002448 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2450 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302451 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 break;
2453 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302454 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 pMac->sme.dcc_get_stats_callback(
2456 pMac->sme.dcc_get_stats_context,
2457 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302458 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002459 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 pMac->sme.dcc_get_stats_callback = NULL;
2461 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302462 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 break;
2464 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302465 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 pMac->sme.dcc_update_ndl_callback(
2467 pMac->sme.dcc_update_ndl_context,
2468 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302469 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002470 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 pMac->sme.dcc_update_ndl_callback = NULL;
2472 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302473 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 break;
2475 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302476 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 pMac->sme.dcc_stats_event_callback(
2478 pMac->sme.dcc_stats_event_context,
2479 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302480 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002481 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302482 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 break;
2484 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2485 if (pMsg->bodyptr) {
2486 status = sme_process_dual_mac_config_resp(pMac,
2487 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302488 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002490 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 }
2492 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2493 if (pMac->sme.set_thermal_level_cb)
2494 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2495 pMsg->bodyval);
2496 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302497 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2498 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302499 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302500 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002501 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2502 if (pMsg->bodyptr) {
2503 status = sme_process_antenna_mode_resp(pMac,
2504 pMsg->bodyptr);
2505 qdf_mem_free(pMsg->bodyptr);
2506 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002507 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002508 }
2509 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002510 case eWNI_SME_NDP_CONFIRM_IND:
2511 case eWNI_SME_NDP_NEW_PEER_IND:
2512 case eWNI_SME_NDP_INITIATOR_RSP:
Abhishek Singh4fef7472016-06-06 11:36:03 -07002513 case eWNI_SME_NDP_INDICATION:
2514 case eWNI_SME_NDP_RESPONDER_RSP:
Naveen Rawatf28315c2016-06-29 18:06:02 -07002515 case eWNI_SME_NDP_END_RSP:
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07002516 case eWNI_SME_NDP_END_IND:
2517 case eWNI_SME_NDP_PEER_DEPARTED_IND:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002518 sme_ndp_msg_processor(pMac, pMsg);
2519 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302520 case eWNI_SME_LOST_LINK_INFO_IND:
2521 if (pMac->sme.lost_link_info_cb)
2522 pMac->sme.lost_link_info_cb(pMac->hHdd,
2523 (struct sir_lost_link_info *)pMsg->bodyptr);
2524 qdf_mem_free(pMsg->bodyptr);
2525 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302526 case eWNI_SME_RSO_CMD_STATUS_IND:
2527 if (pMac->sme.rso_cmd_status_cb)
2528 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002529 qdf_mem_free(pMsg->bodyptr);
2530 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002531 case eWMI_SME_LL_STATS_IND:
2532 if (pMac->sme.link_layer_stats_ext_cb)
2533 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2534 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302535 qdf_mem_free(pMsg->bodyptr);
2536 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302537 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2538 if (pMac->sme.bt_activity_info_cb)
2539 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2540 pMsg->bodyval);
2541 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542 default:
2543
2544 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2545 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2546 /* CSR */
2547 if (pMsg->bodyptr) {
2548 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302549 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302550 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002551 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002553 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302555 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 }
2557 } /* switch */
2558release_lock:
2559 sme_release_global_lock(&pMac->sme);
2560 return status;
2561}
2562
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002563QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2564{
2565 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2566
2567 if (mac_ctx == NULL) {
2568 QDF_ASSERT(0);
2569 return QDF_STATUS_E_FAILURE;
2570 }
2571
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002572 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002573}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575/**
2576 * sme_process_nss_update_resp() - Process nss update response
2577 * @mac: Global MAC pointer
2578 * @msg: nss update response
2579 *
2580 * Processes the nss update response and invokes the HDD
2581 * callback to process further
2582 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302583static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584{
2585 tListElem *entry = NULL;
2586 tSmeCmd *command = NULL;
2587 bool found;
2588 nss_update_cb callback = NULL;
2589 struct sir_beacon_tx_complete_rsp *param;
2590
2591 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302592 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002593 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 /* Not returning. Need to check if active command list
2595 * needs to be freed
2596 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597
Krunal Sonia8270f52017-02-23 19:51:25 -08002598 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002600 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302601 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 }
2603
2604 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2605 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002606 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302607 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 }
2609
2610 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002611 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302612 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 }
2614
2615 callback = command->u.nss_update_cmd.nss_update_cb;
2616 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302617 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002618 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302619 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 callback(command->u.nss_update_cmd.context,
2621 param->tx_status,
2622 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302623 command->u.nss_update_cmd.next_action,
2624 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002626 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 }
2628
Krunal Soni72dba662017-02-15 20:13:17 -08002629 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (found) {
2631 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002632 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002634
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302635 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636}
2637
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302638/* No need to hold the global lock here because this function can only be
2639 * called after sme_stop.
2640 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002641void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642{
2643 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302644 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302645 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 }
2647
2648}
2649
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302650/*
2651 * sme_stop() - Stop all SME modules and put them at idle state
2652 *
2653 * The function stops each module in SME, PMC, CSR, etc. . Upon
2654 * return, all modules are at idle state ready to start.
2655 * This is a synchronous call
2656 *
2657 * hHal - The handle returned by mac_open
2658 * tHalStopType - reason for stopping
2659 * Return QDF_STATUS_SUCCESS - SME is stopped.
2660 * Other status means SME is failed to stop but caller should still
2661 * consider SME is stopped.
2662 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302663QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302665 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2666 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 p2p_stop(hHal);
2670
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002671 status = rrm_stop(pMac);
2672 if (!QDF_IS_STATUS_SUCCESS(status)) {
2673 sme_err("rrm_stop failed with status: %d", status);
2674 }
2675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302677 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002678 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 fail_status = status;
2680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 purge_sme_cmd_list(pMac);
2682
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302683 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685
2686 pMac->sme.state = SME_STATE_STOP;
2687
2688 return status;
2689}
2690
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302691/*
2692 * sme_close() - Release all SME modules and their resources.
2693 * The function release each module in SME, PMC, CSR, etc. . Upon
2694 * return, all modules are at closed state.
2695 *
2696 * No SME APIs can be involved after smeClose except smeOpen.
2697 * smeClose must be called before mac_close.
2698 * This is a synchronous call
2699 *
2700 * hHal - The handle returned by mac_open
2701 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2702 *
2703 * Other status means SME is failed to be closed but caller still cannot
2704 * call any other SME functions except smeOpen.
2705 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302706QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302708 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2709 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2711
2712 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302713 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714
2715 /* Note: pSession will be invalid from here on, do not access */
2716 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302717 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002718 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 fail_status = status;
2720 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2722 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302723 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002724 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 fail_status = status;
2726 }
2727#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302729 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002730 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 fail_status = status;
2732 }
2733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302735 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002736 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 fail_status = status;
2738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739
2740 sme_p2p_close(hHal);
2741
2742 free_sme_cmd_list(pMac);
2743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302745 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302746 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302748 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750
2751 pMac->sme.state = SME_STATE_STOP;
2752
2753 return status;
2754}
2755
2756/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302757 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2758 * scan list
2759 * @hal: hal context.
2760 * @bssid: bssid to be removed
2761 *
2762 * This function remove the given bssid from scan list.
2763 *
2764 * Return: QDF status.
2765 */
2766QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2767 tSirMacAddr bssid)
2768{
2769 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2770 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2771
2772 status = sme_acquire_global_lock(&mac_ctx->sme);
2773 if (QDF_IS_STATUS_SUCCESS(status)) {
2774 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2775 sme_release_global_lock(&mac_ctx->sme);
2776 }
2777
2778 return status;
2779}
2780
Sandeep Puligilla0806e0f2017-03-06 19:25:47 -08002781#ifndef NAPIER_SCAN
Abhishek Singhc9941602016-08-09 16:06:22 +05302782/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 * sme_scan_request() - wrapper function to Request a 11d or full scan from CSR.
2784 * @hal: hal global context
2785 * @session_id: session id
2786 * @scan_req: scan req
2787 * @callback: a callback function that scan calls upon finish, will not
2788 * be called if csr_scan_request returns error
2789 * @ctx: a pointer passed in for the callback
2790 *
2791 * This is a wrapper function to Request a 11d or full scan from CSR. This is
2792 * an asynchronous call
2793 *
2794 * Return: Status of operation
2795 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302796QDF_STATUS sme_scan_request(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 tCsrScanRequest *scan_req,
2798 csr_scan_completeCallback callback, void *ctx)
2799{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302800 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002801 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2802 struct ani_scan_req *scan_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002803 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 uint32_t scan_req_id, scan_count;
2805
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302806 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002807 TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ, session_id,
2808 scan_req->scanType));
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +05302809
2810 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002811 sme_err("Invalid session id: %d", session_id);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +05302812 return status;
2813 }
2814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 if (!mac_ctx->scan.fScanEnable) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002816 sme_err("fScanEnable false");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 return status;
2818 }
2819
Krunal Soni81f068c2017-02-23 19:51:55 -08002820 scan_count = csr_scan_active_ll_count(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 if (scan_count >= mac_ctx->scan.max_scan_count) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002822 sme_err("Max scan reached");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302823 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 }
2825 wma_get_scan_id(&scan_req_id);
2826 scan_req->scan_id = scan_req_id;
2827
2828 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302829 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002830 sme_err("Unable to acquire lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 return status;
2832 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302833 scan_msg = qdf_mem_malloc(sizeof(struct ani_scan_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 if (NULL == scan_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002835 sme_err("Failed to allocate memory for scan_msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302837 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 }
2839 scan_msg->msg_type = eWNI_SME_SCAN_CMD;
2840 scan_msg->msg_len = (uint16_t) sizeof(struct ani_scan_req);
2841 scan_msg->session_id = session_id;
2842 scan_msg->callback = callback;
2843 scan_msg->ctx = ctx;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302844 scan_msg->scan_param = qdf_mem_malloc(sizeof(tCsrScanRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 if (NULL == scan_msg->scan_param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002846 sme_err("Failed to allocate memory for scan_param");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302848 qdf_mem_free(scan_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302849 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 }
2851 csr_scan_copy_request(mac_ctx, scan_msg->scan_param, scan_req);
2852 msg.type = eWNI_SME_SCAN_CMD;
2853 msg.bodyptr = scan_msg;
2854 msg.reserved = 0;
2855 msg.bodyval = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302856 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002857 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002858 sme_err("sme_scan_req failed to post msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 csr_scan_free_request(mac_ctx, scan_msg->scan_param);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 qdf_mem_free(scan_msg->scan_param);
2861 qdf_mem_free(scan_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302862 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 }
2864 sme_release_global_lock(&mac_ctx->sme);
2865 return status;
2866}
Sandeep Puligilla0806e0f2017-03-06 19:25:47 -08002867#else
2868QDF_STATUS sme_scan_request(tHalHandle hal, uint8_t session_id,
2869 tCsrScanRequest *scan_req,
2870 csr_scan_completeCallback callback, void *ctx)
2871{
2872 return QDF_STATUS_SUCCESS;
2873}
2874#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302876/*
2877 * sme_scan_get_result
2878 * A wrapper function to request scan results from CSR.
2879 * This is a synchronous call
2880 *
2881 * pFilter - If pFilter is NULL, all cached results are returned
2882 * phResult - an object for the result.
2883 * Return QDF_STATUS
2884 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302885QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 tCsrScanResultFilter *pFilter,
2887 tScanResultHandle *phResult)
2888{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302889 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2891
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302892 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2894 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 status = csr_scan_get_result(hHal, pFilter, phResult);
2898 sme_release_global_lock(&pMac->sme);
2899 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900
2901 return status;
2902}
2903
2904/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002905 * sme_get_ap_channel_from_scan() - a wrapper function to get
2906 * AP's channel id from
2907 * CSR by filtering the
2908 * result which matches
2909 * our roam profile.
2910 * @profile: SAP profile
2911 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2912 * best ap from scan cache.
2913 *
2914 * This function is written to get AP's channel id from CSR by filtering
2915 * the result which matches our roam profile. This is a synchronous call.
2916 *
2917 * Return: QDF_STATUS.
2918 */
2919QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2920 tScanResultHandle *scan_cache,
2921 uint8_t *ap_chnl_id)
2922{
2923 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2924 profile,
2925 scan_cache,
2926 ap_chnl_id);
2927}
2928
2929/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2931 * channel id from CSR by filtering the
2932 * result which matches our roam profile.
2933 * @profile: SAP adapter
2934 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2935 * best ap from scan cache.
2936 *
2937 * This function is written to get AP's channel id from CSR by filtering
2938 * the result which matches our roam profile. This is a synchronous call.
2939 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302940 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002942QDF_STATUS sme_get_ap_channel_from_scan_cache(
2943 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2944 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302946 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002947 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 tCsrScanResultFilter *scan_filter = NULL;
2949 tScanResultHandle filtered_scan_result = NULL;
2950 tSirBssDescription first_ap_profile;
2951
2952 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302953 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302955 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302957 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302959 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302961 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302962 }
2963 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2964 if (NULL == profile) {
2965 scan_filter->EncryptionType.numEntries = 1;
2966 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302968 } else {
2969 /* Here is the profile we need to connect to */
2970 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 profile,
2972 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302973 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302975 if (QDF_STATUS_SUCCESS == status) {
2976 /* Save the WPS info */
2977 if (NULL != profile) {
2978 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302980 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302983 scan_filter->bWPSAssociation = 0;
2984 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302986 } else {
2987 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2988 FL("Preparing the profile filter failed"));
2989 qdf_mem_free(scan_filter);
2990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 }
2992 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302993 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002994 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302996 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2998 &first_ap_profile);
2999 *scan_cache = filtered_scan_result;
3000 if (0 != first_ap_profile.channelId) {
3001 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303002 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303003 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 FL("Found best AP & its on chnl[%d]"),
3005 first_ap_profile.channelId);
3006 } else {
3007 /*
3008 * This means scan result is empty
3009 * so set the channel to zero, caller should
3010 * take of zero channel id case.
3011 */
3012 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303013 QDF_TRACE(QDF_MODULE_ID_SME,
3014 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303016 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 }
3018 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303019 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303021 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 }
3023 csr_free_scan_filter(mac_ctx, scan_filter);
3024 sme_release_global_lock(&mac_ctx->sme);
3025 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08003028 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303029 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303031 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 return status;
3033}
3034
3035/**
3036 * sme_store_joinreq_param() - This function will pass station's join
3037 * request to store to csr.
3038 * @hal_handle: pointer to hal context.
3039 * @profile: pointer to station's roam profile.
3040 * @scan_cache: pointer to station's scan cache.
3041 * @roam_id: reference to roam_id variable being passed.
3042 * @session_id: station's session id.
3043 *
3044 * This function will pass station's join request further down to csr
3045 * to store it. this stored parameter will be used later.
3046 *
3047 * Return: true or false based on function's overall success.
3048 **/
3049bool sme_store_joinreq_param(tHalHandle hal_handle,
3050 tCsrRoamProfile *profile,
3051 tScanResultHandle scan_cache,
3052 uint32_t *roam_id,
3053 uint32_t session_id)
3054{
3055 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303056 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 bool ret_status = true;
3058
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_STORE_JOIN_REQ,
3061 session_id, 0));
3062 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303063 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303065 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 sme_release_global_lock(&mac_ctx->sme);
3068 } else {
3069 ret_status = false;
3070 }
3071
3072 return ret_status;
3073}
3074
3075/**
3076 * sme_clear_joinreq_param() - This function will pass station's clear
3077 * the join request to csr.
3078 * @hal_handle: pointer to hal context.
3079 * @session_id: station's session id.
3080 *
3081 * This function will pass station's clear join request further down to csr
3082 * to cleanup.
3083 *
3084 * Return: true or false based on function's overall success.
3085 **/
3086bool sme_clear_joinreq_param(tHalHandle hal_handle,
3087 uint32_t session_id)
3088{
3089 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303090 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 bool ret_status = true;
3092
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303093 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
3095 session_id, 0));
3096 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303097 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303099 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 sme_release_global_lock(&mac_ctx->sme);
3102 } else {
3103 ret_status = false;
3104 }
3105
3106 return ret_status;
3107}
3108
3109/**
3110 * sme_issue_stored_joinreq() - This function will issues station's stored
3111 * the join request to csr.
3112 * @hal_handle: pointer to hal context.
3113 * @roam_id: reference to roam_id variable being passed.
3114 * @session_id: station's session id.
3115 *
3116 * This function will issue station's stored join request further down to csr
3117 * to proceed forward.
3118 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303119 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303121QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 uint32_t *roam_id,
3123 uint32_t session_id)
3124{
3125 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303126 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3127 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303129 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
3131 session_id, 0));
3132 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303133 if (QDF_STATUS_SUCCESS == status) {
3134 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 roam_id,
3136 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303137 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 }
3139 sme_release_global_lock(&mac_ctx->sme);
3140 } else {
3141 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303142 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 }
3144 return ret_status;
3145}
3146
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303147/*
3148 * sme_scan_flush_result() -
3149 * A wrapper function to request CSR to clear scan results.
3150 * This is a synchronous call
3151 *
3152 * Return QDF_STATUS
3153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303154QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303156 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3158
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303159 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3161 0, 0));
3162 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303163 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 status = csr_scan_flush_result(hHal);
3165 sme_release_global_lock(&pMac->sme);
3166 }
3167
3168 return status;
3169}
3170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303171/*
3172 * sme_filter_scan_results() -
3173 * A wrapper function to request CSR to clear scan results.
3174 * This is a synchronous call
3175 *
3176 * tHalHandle - HAL context handle
3177 * sessionId - session id
3178 * Return QDF_STATUS
3179 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303182 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3184
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303185 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
3187 sessionId, 0));
3188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303189 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 csr_scan_filter_results(pMac);
3191 sme_release_global_lock(&pMac->sme);
3192 }
3193
3194 return status;
3195}
3196
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303199 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3201
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303202 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
3204 sessionId, 0));
3205 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303206 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 status = csr_scan_flush_selective_result(hHal, true);
3208 sme_release_global_lock(&pMac->sme);
3209 }
3210
3211 return status;
3212}
3213
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303214/*
3215 * sme_scan_result_get_first() -
3216 * A wrapper function to request CSR to returns the first element of
3217 * scan result.
3218 * This is a synchronous call
3219 *
3220 * hScanResult - returned from csr_scan_get_result
3221 * Return tCsrScanResultInfo * - NULL if no result
3222 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
3224 tScanResultHandle hScanResult)
3225{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303226 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3228 tCsrScanResultInfo *pRet = NULL;
3229
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303230 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3232 NO_SESSION, 0));
3233 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303234 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 pRet = csr_scan_result_get_first(pMac, hScanResult);
3236 sme_release_global_lock(&pMac->sme);
3237 }
3238
3239 return pRet;
3240}
3241
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303242/*
3243 * sme_scan_result_get_next() -
3244 * A wrapper function to request CSR to returns the next element of
3245 * scan result. It can be called without calling csr_scan_result_get_first first
3246 * This is a synchronous call
3247 *
3248 * hScanResult - returned from csr_scan_get_result
3249 * Return Null if no result or reach the end
3250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3252 tScanResultHandle hScanResult)
3253{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303254 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3256 tCsrScanResultInfo *pRet = NULL;
3257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303259 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 pRet = csr_scan_result_get_next(pMac, hScanResult);
3261 sme_release_global_lock(&pMac->sme);
3262 }
3263
3264 return pRet;
3265}
3266
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303267/*
3268 * sme_scan_result_purge() -
3269 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3270 * in the list and free memory for each item
3271 * This is a synchronous call
3272 *
3273 * hScanResult - returned from csr_scan_get_result. hScanResult is
3274 * considered gone by
3275 * calling this function and even before this function reutrns.
3276 * Return QDF_STATUS
3277 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003278QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003281 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282
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_MSG_SCAN_RESULT_PURGE,
3285 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003286 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003288 status = csr_scan_result_purge(mac_ctx, hScanResult);
3289 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 }
3291
3292 return status;
3293}
3294
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303295/*
3296 * sme_scan_get_pmkid_candidate_list() -
3297 * A wrapper function to return the PMKID candidate list
3298 * This is a synchronous call
3299 *
3300 * pPmkidList - caller allocated buffer point to an array of
3301 * tPmkidCandidateInfo
3302 * pNumItems - pointer to a variable that has the number of
3303 * tPmkidCandidateInfo allocated when retruning, this is
3304 * either the number needed or number of items put into
3305 * pPmkidList
3306 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3307 * big enough and pNumItems
3308 * has the number of tPmkidCandidateInfo.
3309 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3310 * not sizeof(tPmkidCandidateInfo) * something
3311 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 tPmkidCandidateInfo *pPmkidList,
3314 uint32_t *pNumItems)
3315{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303316 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3318
3319 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303320 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 status =
3322 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3323 pPmkidList,
3324 pNumItems);
3325 sme_release_global_lock(&pMac->sme);
3326 }
3327
3328 return status;
3329}
3330
3331eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3332{
3333 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303334
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 return pMac->roam.configParam.phyMode;
3336}
3337
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303338/*
3339 * sme_get_channel_bonding_mode5_g() -
3340 * get the channel bonding mode for 5G band
3341 *
3342 * hHal - HAL handle
3343 * Return channel bonding mode for 5G
3344 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3346{
3347 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3348 tSmeConfigParams smeConfig;
3349
3350 sme_get_config_param(pMac, &smeConfig);
3351
3352 return smeConfig.csrConfig.channelBondingMode5GHz;
3353}
3354
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303355/*
3356 * sme_get_channel_bonding_mode24_g() -
3357 * get the channel bonding mode for 2.4G band
3358 *
3359 * hHal - HAL handle
3360 * Return channel bonding mode for 2.4G
3361 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3363{
3364 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3365 tSmeConfigParams smeConfig;
3366
3367 sme_get_config_param(pMac, &smeConfig);
3368
3369 return smeConfig.csrConfig.channelBondingMode24GHz;
3370}
3371
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303372/*
3373 * sme_roam_connect() -
3374 * A wrapper function to request CSR to inititiate an association
3375 * This is an asynchronous call.
3376 *
3377 * sessionId - the sessionId returned by sme_open_session.
3378 * pProfile - description of the network to which to connect
3379 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3380 * from csr_scan_get_result
3381 * pRoamId - to get back the request ID
3382 * Return QDF_STATUS
3383 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303384QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3386{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303387 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3389
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303390 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303391 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303393 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303396 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3398 status =
3399 csr_roam_connect(pMac, sessionId, pProfile,
3400 pRoamId);
3401 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003402 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303403 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 }
3405 sme_release_global_lock(&pMac->sme);
3406 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003407 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 }
3409
3410 return status;
3411}
3412
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303413/*
3414 * sme_set_phy_mode() -
3415 * Changes the PhyMode.
3416 *
3417 * hHal - The handle returned by mac_open.
3418 * phyMode new phyMode which is to set
3419 * Return QDF_STATUS SUCCESS.
3420 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303421QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422{
3423 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3424
3425 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 }
3430
3431 pMac->roam.configParam.phyMode = phyMode;
3432 pMac->roam.configParam.uCfgDot11Mode =
3433 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303434 pMac->roam.configParam.phyMode,
3435 pMac->roam.configParam.
3436 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303438 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439}
3440
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303441/*
3442 * sme_roam_reassoc() -
3443 * A wrapper function to request CSR to inititiate a re-association
3444 *
3445 * pProfile - can be NULL to join the currently connected AP. In that
3446 * case modProfileFields should carry the modified field(s) which could trigger
3447 * reassoc
3448 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3449 * that might need modification dynamically once STA is up & running and this
3450 * could trigger a reassoc
3451 * pRoamId - to get back the request ID
3452 * Return QDF_STATUS
3453 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303454QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 tCsrRoamProfile *pProfile,
3456 tCsrRoamModifyProfileFields modProfileFields,
3457 uint32_t *pRoamId, bool fForce)
3458{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303459 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3461
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303462 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303465 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303467 if ((NULL == pProfile) && (fForce == 1))
3468 status = csr_reassoc(pMac, sessionId,
3469 &modProfileFields, pRoamId,
3470 fForce);
3471 else
3472 status = csr_roam_reassoc(pMac, sessionId,
3473 pProfile,
3474 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 }
3478 sme_release_global_lock(&pMac->sme);
3479 }
3480
3481 return status;
3482}
3483
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303484/*
3485 * sme_roam_connect_to_last_profile() -
3486 * A wrapper function to request CSR to disconnect and reconnect with
3487 * the same profile
3488 * This is an asynchronous call.
3489 *
3490 * Return QDF_STATUS. It returns fail if currently connected
3491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303492QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3496
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303497 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3499 sessionId, 0));
3500 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303501 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303502 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3503 status = csr_roam_connect_to_last_profile(pMac,
3504 sessionId);
3505 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303506 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 sme_release_global_lock(&pMac->sme);
3508 }
3509
3510 return status;
3511}
3512
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303513/*
3514 * sme_roam_disconnect() -
3515 * A wrapper function to request CSR to disconnect from a network
3516 * This is an asynchronous call.
3517 *
3518 * reason -- To indicate the reason for disconnecting. Currently, only
3519 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3520 * Return QDF_STATUS
3521 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 eCsrRoamDisconnectReason reason)
3524{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3527
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303528 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3530 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303532 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303533 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303535 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303536 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 sme_release_global_lock(&pMac->sme);
3538 }
3539
3540 return status;
3541}
3542
Abhishek Singhca408032016-09-13 15:26:12 +05303543/* sme_dhcp_done_ind() - send dhcp done ind
3544 * @hal: hal context
3545 * @session_id: session id
3546 *
3547 * Return: void.
3548 */
3549void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3550{
3551 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303552 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303553
3554 if (!mac_ctx)
3555 return;
3556
3557 session = CSR_GET_SESSION(mac_ctx, session_id);
3558 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003559 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303560 return;
3561 }
3562 session->dhcp_done = true;
3563}
3564
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303565/*
3566 * sme_roam_stop_bss() -
3567 * To stop BSS for Soft AP. This is an asynchronous API.
3568 *
3569 * hHal - Global structure
3570 * sessionId - sessionId of SoftAP
3571 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3572 * actual results
3573 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303574QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303576 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303580 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303581 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3582 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
3583 true);
3584 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303585 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 sme_release_global_lock(&pMac->sme);
3587 }
3588
3589 return status;
3590}
3591
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303592/**
3593 * sme_roam_disconnect_sta() - disassociate a station
3594 * @hHal: Global structure
3595 * @sessionId: SessionId of SoftAP
3596 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3597 *
3598 * To disassociate a station. This is an asynchronous API.
3599 *
3600 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3601 * be called to indicate actual result.
3602 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303603QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303604 struct tagCsrDelStaParams *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3608
3609 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303610 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 return status;
3612 }
3613
3614 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303615 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303616 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303618 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303619 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303620 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 sme_release_global_lock(&pMac->sme);
3622 }
3623
3624 return status;
3625}
3626
3627/**
3628 * sme_roam_deauth_sta() - deauthenticate a station
3629 * @hHal: Global structure
3630 * @sessionId: SessionId of SoftAP
3631 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3632 *
3633 * To disassociate a station. This is an asynchronous API.
3634 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 * code on error. Roam callback will be called to indicate actual
3637 * result
3638 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303639QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 struct tagCsrDelStaParams *pDelStaParams)
3641{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303642 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3644
3645 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303646 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 return status;
3648 }
3649
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303650 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303651 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3652 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303655 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 status =
3657 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3658 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303659 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 sme_release_global_lock(&pMac->sme);
3662 }
3663
3664 return status;
3665}
3666
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303667/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303668 * sme_roam_get_associated_stas() -
3669 * To probe the list of associated stations from various modules
3670 * of CORE stack.
3671 * This is an asynchronous API.
3672 *
3673 * sessionId - sessionId of SoftAP
3674 * modId - Module from whom list of associtated stations is
3675 * to be probed. If an invalid module is passed then
3676 * by default QDF_MODULE_ID_PE will be probed.
3677 * pUsrContext - Opaque HDD context
3678 * pfnSapEventCallback - Sap event callback in HDD
3679 * pAssocBuf - Caller allocated memory to be filled with associatd
3680 * stations info
3681 * Return QDF_STATUS
3682 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303684 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 void *pfnSapEventCallback,
3686 uint8_t *pAssocStasBuf)
3687{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3690
3691 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303692 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 return status;
3694 }
3695
3696 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303697 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303698 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303700 csr_roam_get_associated_stas(pMac, sessionId,
3701 modId,
3702 pUsrContext,
3703 pfnSapEventCallback,
3704 pAssocStasBuf);
3705 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303706 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 sme_release_global_lock(&pMac->sme);
3708 }
3709
3710 return status;
3711}
3712
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303713/*
3714 * sme_roam_get_wps_session_overlap() -
3715 * To get the WPS PBC session overlap information.
3716 * This is an asynchronous API.
3717 *
3718 * sessionId - sessionId of SoftAP
3719 * pUsrContext - Opaque HDD context
3720 * pfnSapEventCallback - Sap event callback in HDD
3721 * pRemoveMac - pointer to Mac address which needs to be removed from session
3722 * Return QDF_STATUS
3723 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303724QDF_STATUS sme_roam_get_wps_session_overlap(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 void *pUsrContext, void
3726 *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303727 struct qdf_mac_addr pRemoveMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303729 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3731
3732 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303733 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 return status;
3735 }
3736
3737 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303738 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303739 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3740 status = csr_roam_get_wps_session_overlap(pMac,
3741 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742 pUsrContext,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303743 pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 pRemoveMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303745 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303746 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 sme_release_global_lock(&pMac->sme);
3748 }
3749
3750 return status;
3751}
3752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303753/*
3754 * sme_roam_get_connect_state() -
3755 * A wrapper function to request CSR to return the current connect state
3756 * of Roaming
3757 * This is a synchronous call.
3758 *
3759 * Return QDF_STATUS
3760 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303761QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 eCsrConnectState *pState)
3763{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303764 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3766
3767 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303768 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303769 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3770 status = csr_roam_get_connect_state(pMac, sessionId,
3771 pState);
3772 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303773 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 sme_release_global_lock(&pMac->sme);
3775 }
3776
3777 return status;
3778}
3779
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303780/*
3781 * sme_roam_get_connect_profile() -
3782 * A wrapper function to request CSR to return the current connect
3783 * profile. Caller must call csr_roam_free_connect_profile after it is done
3784 * and before reuse for another csr_roam_get_connect_profile call.
3785 * This is a synchronous call.
3786 *
3787 * pProfile - pointer to a caller allocated structure
3788 * tCsrRoamConnectedProfile
3789 * eturn QDF_STATUS. Failure if not connected
3790 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 tCsrRoamConnectedProfile *pProfile)
3793{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3796
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303797 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3799 sessionId, 0));
3800 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303801 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303802 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3803 status = csr_roam_get_connect_profile(pMac, sessionId,
3804 pProfile);
3805 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303806 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 sme_release_global_lock(&pMac->sme);
3808 }
3809
3810 return status;
3811}
3812
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003813/**
3814 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3815 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3816 *
3817 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3818 *
3819 * Return: none
3820 */
3821void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303823 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3825 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003826 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827}
3828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303829/*
3830 * sme_roam_set_pmkid_cache() -
3831 * A wrapper function to request CSR to return the PMKID candidate list
3832 * This is a synchronous call.
3833
3834 * pPMKIDCache - caller allocated buffer point to an array of
3835 * tPmkidCacheInfo
3836 * numItems - a variable that has the number of tPmkidCacheInfo
3837 * allocated when retruning, this is either the number needed
3838 * or number of items put into pPMKIDCache
3839 * update_entire_cache - this bool value specifies if the entire pmkid
3840 * cache should be overwritten or should it be
3841 * updated entry by entry.
3842 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3843 * big enough and pNumItems has the number of
3844 * tPmkidCacheInfo.
3845 * \Note: pNumItems is a number of tPmkidCacheInfo,
3846 * not sizeof(tPmkidCacheInfo) * something
3847 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303848QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 tPmkidCacheInfo *pPMKIDCache,
3850 uint32_t numItems, bool update_entire_cache)
3851{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303852 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3854
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303855 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3857 numItems));
3858 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303859 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303860 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3861 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3862 pPMKIDCache,
3863 numItems, update_entire_cache);
3864 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303865 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 sme_release_global_lock(&pMac->sme);
3867 }
3868
3869 return status;
3870}
3871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303873 tPmkidCacheInfo *pmksa,
3874 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303876 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303878
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303879 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303880 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3881 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303883 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303884 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303886 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303887 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303888 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 sme_release_global_lock(&pMac->sme);
3890 }
3891 return status;
3892}
3893
3894#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303895/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 * \fn sme_roam_set_psk_pmk
3897 * \brief a wrapper function to request CSR to save PSK/PMK
3898 * This is a synchronous call.
3899 * \param hHal - Global structure
3900 * \param sessionId - SME sessionId
3901 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3902 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3903 * connections. Need to pass this information to
3904 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303905 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303907QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 uint8_t *pPSK_PMK, size_t pmk_len)
3909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303910 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303914 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303915 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3916 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303918 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303919 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 sme_release_global_lock(&pMac->sme);
3921 }
3922 return status;
3923}
3924#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303925/*
3926 * sme_roam_get_security_req_ie() -
3927 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3928 * passes to PE to JOIN request or START_BSS request
3929 * This is a synchronous call.
3930 *
3931 * pLen - caller allocated memory that has the length of pBuf as input.
3932 * Upon returned, *pLen has the needed or IE length in pBuf.
3933 * pBuf - Caller allocated memory that contain the IE field, if any,
3934 * upon return
3935 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3936 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3937 * big enough
3938 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303939QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 uint32_t *pLen, uint8_t *pBuf,
3941 eCsrSecurityType secType)
3942{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3945
3946 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303947 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303948 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3949 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3950 pLen, pBuf);
3951 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303952 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 sme_release_global_lock(&pMac->sme);
3954 }
3955
3956 return status;
3957}
3958
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303959/*
3960 * sme_roam_get_security_rsp_ie() -
3961 * A wrapper function to request CSR to return the WPA or RSN or
3962 * WAPI IE from the beacon or probe rsp if connected
3963 * This is a synchronous call.
3964 *
3965 * pLen - caller allocated memory that has the length of pBuf as input.
3966 * Upon returned, *pLen has the needed or IE length in pBuf.
3967 * pBuf - Caller allocated memory that contain the IE field, if any,
3968 * upon return
3969 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3970 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3971 * big enough
3972 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303973QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003974 uint32_t *pLen, uint8_t *pBuf,
3975 eCsrSecurityType secType)
3976{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303977 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3979
3980 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303981 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303982 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3983 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3984 pLen, pBuf);
3985 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303986 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 sme_release_global_lock(&pMac->sme);
3988 }
3989
3990 return status;
3991
3992}
3993
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303994/*
3995 * sme_roam_get_num_pmkid_cache() -
3996 * A wrapper function to request CSR to return number of PMKID cache
3997 * entries
3998 * This is a synchronous call.
3999 *
4000 * Return uint32_t - the number of PMKID cache entries
4001 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004002uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
4003{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304004 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4006 uint32_t numPmkidCache = 0;
4007
4008 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304009 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4011 numPmkidCache =
4012 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304013 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304014 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304015 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 sme_release_global_lock(&pMac->sme);
4017 }
4018
4019 return numPmkidCache;
4020}
4021
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304022/*
4023 * sme_roam_get_pmkid_cache() -
4024 * A wrapper function to request CSR to return PMKID cache from CSR
4025 * This is a synchronous call.
4026 *
4027 * pNum - caller allocated memory that has the space of the number of
4028 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
4029 * needed or actually number in tPmkidCacheInfo.
4030 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
4031 * any, upon return
4032 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
4033 * big enough
4034 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304035QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304036 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4040
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304041 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
4043 0));
4044 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304045 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304046 if (CSR_IS_SESSION_VALID(pMac, sessionId))
4047 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304049 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304050 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 sme_release_global_lock(&pMac->sme);
4052 }
4053
4054 return status;
4055}
4056
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304057/*
4058 * sme_get_config_param() -
4059 * A wrapper function that HDD calls to get the global settings
4060 * currently maintained by CSR.
4061 * This is a synchronous call.
4062 *
4063 * pParam - caller allocated memory
4064 * Return QDF_STATUS
4065 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304066QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304068 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4070
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304071 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
4073 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304074 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304076 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004077 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 sme_release_global_lock(&pMac->sme);
4079 return status;
4080 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304081 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08004082 &pMac->rrm.rrmSmeContext.rrmConfig,
4083 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05304084 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 sme_release_global_lock(&pMac->sme);
4086 }
4087
4088 return status;
4089}
4090
4091/**
4092 * sme_cfg_set_int() - Sets the cfg parameter value.
4093 * @hal: Handle to hal.
4094 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07004095 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 *
4097 * This function sets the string value in cfg parameter.
4098 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304099 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304101QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102{
4103 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304104 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105
4106 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304107 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108
4109 return status;
4110}
4111
4112/**
4113 * sme_cfg_set_str() - Sets the cfg parameter string.
4114 * @hal: Handle to hal.
4115 * @cfg_id: Configuration parameter ID.
4116 * @str: Pointer to the string buffer.
4117 * @length: Length of the string.
4118 *
4119 * This function sets the string value in cfg parameter.
4120 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304121 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304123QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 uint32_t length)
4125{
4126 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304127 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128
4129 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304130 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131
4132 return status;
4133}
4134
4135/**
4136 * sme_cfg_get_int() - Gets the cfg parameter value.
4137 * @hal: Handle to hal.
4138 * @cfg_id: Configuration parameter ID.
4139 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07004140 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 *
4142 * This function gets the value of the cfg parameter.
4143 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304144 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304146QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147{
4148 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304149 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150
4151 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304152 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153
4154 return status;
4155}
4156
4157/**
4158 * sme_cfg_get_str() - Gets the cfg parameter string.
4159 * @hal: Handle to hal.
4160 * @cfg_id: Configuration parameter ID.
4161 * @str: Pointer to the string buffer.
4162 * @length: Pointer to length of the string.
4163 *
4164 * This function gets the string value of the cfg parameter.
4165 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304166 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304168QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 uint32_t *length)
4170{
4171 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304172 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173
4174 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304175 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176
4177 return status;
4178}
4179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304180/*
4181 * sme_get_modify_profile_fields() -
4182 * HDD or SME - QOS calls this function to get the current values of
4183 * connected profile fields, changing which can cause reassoc.
4184 * This function must be called after CFG is downloaded and STA is in connected
4185 * state. Also, make sure to call this function to get the current profile
4186 * fields before calling the reassoc. So that pModifyProfileFields will have
4187 * all the latest values plus the one(s) has been updated as part of reassoc
4188 * request.
4189 *
4190 * pModifyProfileFields - pointer to the connected profile fields
4191 * changing which can cause reassoc
4192 * Return QDF_STATUS
4193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304194QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 tCsrRoamModifyProfileFields *
4196 pModifyProfileFields)
4197{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304198 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4200
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304201 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
4203 0));
4204 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304205 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304206 if (CSR_IS_SESSION_VALID(pMac, sessionId))
4207 status = csr_get_modify_profile_fields(pMac, sessionId,
4208 pModifyProfileFields);
4209 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304210 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 sme_release_global_lock(&pMac->sme);
4212 }
4213
4214 return status;
4215}
4216
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304217/*
4218 * sme_set_dhcp_till_power_active_flag() -
4219 * Sets/Clears DHCP related flag to disable/enable auto PS
4220 *
4221 * hal - The handle returned by mac_open.
4222 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
4224{
4225 tpAniSirGlobal mac = PMAC_STRUCT(hal);
4226 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
4227
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304228 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
4230 flag));
4231 /* Set/Clear the DHCP flag which will disable/enable auto PS */
4232 ps_global_info->remain_in_power_active_till_dhcp = flag;
4233}
4234
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304235/*
4236 * sme_register11d_scan_done_callback() -
4237 * Register a routine of type csr_scan_completeCallback which is
4238 * called whenever an 11d scan is done
4239 *
4240 * hHal - The handle returned by mac_open.
4241 * callback - 11d scan complete routine to be registered
4242 * Return QDF_STATUS
4243 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304245 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4249
4250 pMac->scan.callback11dScanDone = callback;
4251
4252 return status;
4253}
4254
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304255/**
4256 * sme_deregister11d_scan_done_callback() - De-register scandone callback
4257 * @h_hal: Handler return by mac_open
4258 *
4259 * This function De-registers the scandone callback to SME
4260 *
4261 * Return: None
4262 */
4263void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
4264{
4265 tpAniSirGlobal pmac;
4266
4267 if (!h_hal) {
4268 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4269 FL("hHal is not valid"));
4270 return;
4271 }
4272
4273 pmac = PMAC_STRUCT(h_hal);
4274 pmac->scan.callback11dScanDone = NULL;
4275}
4276
4277
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278#ifdef FEATURE_OEM_DATA_SUPPORT
4279/**
4280 * sme_register_oem_data_rsp_callback() - Register a routine of
4281 * type send_oem_data_rsp_msg
4282 * @h_hal: Handle returned by mac_open.
4283 * @callback: Callback to send response
4284 * to oem application.
4285 *
4286 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4287 * callback function.
4288 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304289 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304291QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 sme_send_oem_data_rsp_msg callback)
4293{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304294 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4296
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004297 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298
4299 return status;
4300
4301}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304302
4303/**
4304 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4305 * @h_hal: Handler return by mac_open
4306 * This function De-registers the OEM data response callback to SME
4307 *
4308 * Return: None
4309 */
4310void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4311{
4312 tpAniSirGlobal pmac;
4313
4314 if (!h_hal) {
4315 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4316 FL("hHal is not valid"));
4317 return;
4318 }
4319 pmac = PMAC_STRUCT(h_hal);
4320
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004321 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304322}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323
4324/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004325 * sme_oem_update_capability() - update UMAC's oem related capability.
4326 * @hal: Handle returned by mac_open
4327 * @oem_cap: pointer to oem_capability
4328 *
4329 * This function updates OEM capability to UMAC. Currently RTT
4330 * related capabilities are updated. More capabilities can be
4331 * added in future.
4332 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304333 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004334 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304335QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004336 struct sme_oem_capability *cap)
4337{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304338 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004339 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4340 uint8_t *bytes;
4341
4342 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4343
4344 if (cap->ftm_rr)
4345 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4346 if (cap->lci_capability)
4347 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4348
4349 return status;
4350}
4351
4352/**
4353 * sme_oem_get_capability() - get oem capability
4354 * @hal: Handle returned by mac_open
4355 * @oem_cap: pointer to oem_capability
4356 *
4357 * This function is used to get the OEM capability from UMAC.
4358 * Currently RTT related capabilities are received. More
4359 * capabilities can be added in future.
4360 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304361 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004362 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304363QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004364 struct sme_oem_capability *cap)
4365{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304366 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004367 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4368 uint8_t *bytes;
4369
4370 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4371
4372 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4373 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4374
4375 return status;
4376}
Naveen Rawat910726a2017-03-06 11:42:51 -08004377#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004378
4379/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4381 * function to MAC/SYS
4382 *
4383 * @hal: hal handle
4384 * @callback: hdd function that has to be registered
4385 *
4386 * Return: void
4387 */
4388void sme_register_ftm_msg_processor(tHalHandle hal,
4389 hdd_ftm_msg_processor callback)
4390{
4391 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4392
4393 if (mac_ctx == NULL) {
Naveen Rawatcf684762016-06-27 15:30:24 -07004394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4395 FL("mac ctx is NULL"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 return;
4397 }
Naveen Rawatcf684762016-06-27 15:30:24 -07004398
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 mac_ctx->ftm_msg_processor_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400}
4401
4402/**
4403 * sme_wow_add_pattern() - add a wow pattern in fw
4404 * @hHal: handle returned by mac_open
4405 * @pattern: pointer to input pattern
4406 *
4407 * Add a pattern for Pattern Byte Matching in WoW mode. Firmware will
4408 * do a pattern match on these patterns when WoW is enabled during system
4409 * suspend.
4410 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304411 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413QDF_STATUS sme_wow_add_pattern(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 struct wow_add_pattern *pattern,
4415 uint8_t session_id)
4416{
4417 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4418 struct wow_add_pattern *ptrn;
4419 tSirRetStatus ret_code = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004420 struct scheduler_msg msg_q = {0};
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304421 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN, session_id,
4423 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304424 ptrn = qdf_mem_malloc(sizeof(*ptrn));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 if (NULL == ptrn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004426 sme_err("Fail to allocate memory for WoWLAN Add Bcast Pattern");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304427 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304429 (void)qdf_mem_copy(ptrn, pattern, sizeof(*ptrn));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430
4431 msg_q.type = WMA_WOW_ADD_PTRN;
4432 msg_q.reserved = 0;
4433 msg_q.bodyptr = ptrn;
4434 msg_q.bodyval = 0;
4435
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004436 sme_debug("Sending WMA_WOWL_ADD_BCAST_PTRN to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4438 if (eSIR_SUCCESS != ret_code) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004439 sme_err("Posting WMA_WOWL_ADD_BCAST_PTRN failed, reason: %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 ret_code);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07004441 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 }
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07004443 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444}
4445
4446/**
4447 * sme_wow_delete_pattern() - delete user configured wow pattern in target
4448 * @hHal: handle returned by mac_open.
4449 * @pattern: pointer to delete pattern parameter
4450 * @sessionId: session id
4451 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304452 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304454QDF_STATUS sme_wow_delete_pattern(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 struct wow_delete_pattern *pattern, uint8_t sessionId)
4456{
4457 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
4458 struct wow_delete_pattern *delete_ptrn;
4459 tSirRetStatus ret_code = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004460 struct scheduler_msg msg_q = {0};
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304461 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN, sessionId,
4463 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304464 delete_ptrn = qdf_mem_malloc(sizeof(*delete_ptrn));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 if (NULL == delete_ptrn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004466 sme_err("Allocation failed for WoWLAN Delete Bcast Pattern");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304467 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304469 (void)qdf_mem_copy(delete_ptrn, pattern, sizeof(*delete_ptrn));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 msg_q.type = WMA_WOW_DEL_PTRN;
4471 msg_q.reserved = 0;
4472 msg_q.bodyptr = delete_ptrn;
4473 msg_q.bodyval = 0;
4474
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004475 sme_debug("Sending WMA_WOWL_DEL_BCAST_PTRN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476
4477 ret_code = wma_post_ctrl_msg(pMac, &msg_q);
4478 if (eSIR_SUCCESS != ret_code) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004479 sme_err("Posting WMA_WOWL_DEL_BCAST_PTRN failed, reason: %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 ret_code);
Srinivas Girigowdaaa685282017-06-27 22:54:48 -07004481 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 }
Srinivas Girigowdaaa685282017-06-27 22:54:48 -07004483
4484 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485}
4486
4487/**
4488 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4489 * @hal_ctx - The handle returned by mac_open.
4490 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4491 * Used for success/failure notification by SME
4492 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4493 * back to HDD at the time of callback.
4494 * @wake_reason_ind_cb - Callback routine provided by HDD.
4495 * Used for Wake Reason Indication by SME
4496 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4497 * back to HDD at the time of callback.
4498 *
4499 * WoWLAN works on top of BMPS mode.
4500 * If the device is not in BMPS mode,
4501 * SME will will cache the information that
4502 * WOWL has been enabled and attempt to put the device
4503 * in BMPS. On entry into BMPS, SME will enable the
4504 * WOWL mode.
4505 * Note 1: If we exit BMPS mode (someone requests full power),
4506 * we will NOT resume WOWL when we go back to BMPS again.
4507 * Request for full power (while in WOWL mode) means disable
4508 * WOWL and go to full power.
4509 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4510 * On entry into BMPS, SME will give priority to UAPSD and
4511 * enable only UAPSD if both UAPSD and WOWL are required.
4512 * Currently there is no requirement or use case to support
4513 * UAPSD and WOWL at the same time.
4514 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304515 * Return: QDF_STATUS
4516 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4517 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4518 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 * WOWL after BMPS mode is entered.
4520 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304521QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 void (*enter_wowl_callback_routine)(void
4523 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304524 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 void *enter_wowl_callback_context,
4526#ifdef WLAN_WAKEUP_EVENTS
4527 void (*wakeIndicationCB)(void *callback_context,
4528 tpSirWakeReasonInd
4529 wake_reason_ind),
4530 void *wakeIndicationCBContext,
4531#endif /* WLAN_WAKEUP_EVENTS */
4532 tpSirSmeWowlEnterParams wowl_enter_params,
4533 uint8_t session_id)
4534{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304535 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4537 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304538
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304539 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4541
4542 /* cache the WOWL information */
4543 ps_global_info->ps_params[session_id].wowl_enter_params =
4544 *wowl_enter_params;
4545 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4546 enter_wowl_callback_routine;
4547 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4548 enter_wowl_callback_context;
4549#ifdef WLAN_WAKEUP_EVENTS
4550 /* Cache the Wake Reason Indication callback information */
4551 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4552 wakeIndicationCB;
4553 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4554 wakeIndicationCBContext;
4555#endif /* WLAN_WAKEUP_EVENTS */
4556
4557 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4558 return status;
4559}
4560/**
4561 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4562 * @hal_ctx - The handle returned by mac_open.
4563 * @wowl_exit_params - Carries info on which smesession
4564 * wowl exit is requested.
4565 *
4566 * SME will initiate exit from WoWLAN mode and device will be
4567 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304568 * Return QDF_STATUS
4569 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4570 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304572QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 tpSirSmeWowlExitParams wowl_exit_params)
4574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304575 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004576 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4577 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304578
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304579 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4581 session_id = wowl_exit_params->sessionId;
4582 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4583 return status;
4584}
4585
4586/**
4587 * sme_roam_set_key() - To set encryption key.
4588 * @hal: hal global context
4589 * @session_id: session id
4590 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4591 * @ptr_roam_id: Upon success return, this is the id caller can use to
4592 * identify the request in roamcallback
4593 *
4594 * This function should be called only when connected. This is an asynchronous
4595 * API.
4596 *
4597 * Return: Status of operation
4598 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304599QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304602 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4604 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304605 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4607
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304608 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 session_id, 0));
4610 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004611 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304612 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 }
4614 /*Once Setkey is done, we can go in BMPS */
4615 if (set_key->keyLength)
4616 ps_global_info->remain_in_power_active_till_dhcp = false;
4617
4618 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304619 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 return status;
4621
4622 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4623 if (ptr_roam_id)
4624 *ptr_roam_id = roam_id;
4625
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004626 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004628 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 session = CSR_GET_SESSION(mac_ctx, session_id);
4630 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004631 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304633 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 }
4635 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4636 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4637 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4638 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4639 set_key->encType)) {
4640 session->pCurRoamProfile->negotiatedUCEncryptionType =
4641 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4642 }
4643 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4644 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4645 set_key->encType)) {
4646 session->pCurRoamProfile->negotiatedUCEncryptionType =
4647 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4648 }
4649 }
4650 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4651 sme_release_global_lock(&mac_ctx->sme);
4652 return status;
4653}
4654
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304655/**
4656 * sme_roam_set_default_key_index - To set default wep key idx
4657 * @hal: pointer to hal handler
4658 * @session_id: session id
4659 * @default_idx: default wep key index
4660 *
4661 * This function prepares a message and post to WMA to set wep default
4662 * key index
4663 *
4664 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4665 */
4666QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4667 uint8_t default_idx)
4668{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004669 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304670 struct wep_update_default_key_idx *update_key;
4671
4672 update_key = qdf_mem_malloc(sizeof(*update_key));
4673 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004674 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304675 return QDF_STATUS_E_NOMEM;
4676 }
4677
4678 update_key->session_id = session_id;
4679 update_key->default_idx = default_idx;
4680
4681 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4682 msg.reserved = 0;
4683 msg.bodyptr = (void *)update_key;
4684
4685 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004686 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004687 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304688 qdf_mem_free(update_key);
4689 return QDF_STATUS_E_FAILURE;
4690 }
4691
4692 return QDF_STATUS_SUCCESS;
4693}
4694
4695
Jeff Johnson8bd23352017-09-26 11:39:24 -07004696/**
4697 * sme_get_rssi() - API to retrieve current RSSI
4698 * @hHal: HAL handle for device
4699 * @callback: SME sends back the requested stats using the callback
4700 * @staId: The station ID for which the RSSI is requested for
4701 * @bssid: The bssid of the connected session
4702 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4703 * RSSI, do not hold up but return this value.
4704 * @pContext: user context to be passed back along with the callback
4705 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304706 * A wrapper function that client calls to register a callback to get RSSI
4707 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004708 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304709 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304710QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304711 tCsrRssiCallback callback, uint8_t staId,
4712 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004713 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304715 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4717
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304718 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4720 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304721 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 status = csr_get_rssi(pMac, callback,
4723 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004724 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 sme_release_global_lock(&pMac->sme);
4726 }
4727 return status;
4728}
4729
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304730/*
4731 * sme_get_snr() -
4732 * A wrapper function that client calls to register a callback to get SNR
4733 *
4734 * callback - SME sends back the requested stats using the callback
4735 * staId - The station ID for which the stats is requested for
4736 * pContext - user context to be passed back along with the callback
4737 * p_cds_context - cds context
4738 * \return QDF_STATUS
4739 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304742 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304744 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4746
4747 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304748 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4750 sme_release_global_lock(&pMac->sme);
4751 }
4752 return status;
4753}
4754
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304755/*
4756 * sme_get_statistics() -
4757 * A wrapper function that client calls to register a callback to get
4758 * different PHY level statistics from CSR.
4759 *
4760 * requesterId - different client requesting for statistics,
4761 * HDD, UMA/GAN etc
4762 * statsMask - The different category/categories of stats requester
4763 * is looking for
4764 * callback - SME sends back the requested stats using the callback
4765 * periodicity - If requester needs periodic update in millisec, 0 means
4766 * it's an one time request
4767 * cache - If requester is happy with cached stats
4768 * staId - The station ID for which the stats is requested for
4769 * pContext - user context to be passed back along with the callback
4770 * sessionId - sme session interface
4771 * Return QDF_STATUS
4772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304773QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774 eCsrStatsRequesterType requesterId,
4775 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004776 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304778 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4780
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304782 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304783 status = csr_get_statistics(pMac, requesterId, statsMask,
4784 callback, staId, pContext,
4785 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 sme_release_global_lock(&pMac->sme);
4787 }
4788
4789 return status;
4790
4791}
4792
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304793QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 tCsrLinkStatusCallback callback,
4795 void *pContext, uint8_t sessionId)
4796{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304797 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004798 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4799 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004800 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801
4802 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304803 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304804 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 "%s: Not able to allocate memory for link status",
4808 __func__);
4809 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304810 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 }
4812
4813 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4814 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4815 pMsg->sessionId = sessionId;
4816 pMac->sme.linkStatusContext = pContext;
4817 pMac->sme.linkStatusCallback = callback;
4818
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004819 message.type = WMA_LINK_STATUS_GET_REQ;
4820 message.bodyptr = pMsg;
4821 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304823 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004824 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4825 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304826 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304828 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 pMac->sme.linkStatusContext = NULL;
4830 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304831 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 }
4833
4834 sme_release_global_lock(&pMac->sme);
4835 }
4836
4837 return status;
4838}
4839
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304840/*
4841 * sme_get_country_code() -
4842 * To return the current country code. If no country code is applied,
4843 * default country code is used to fill the buffer.
4844 * If 11d supported is turned off, an error is return and the last
4845 * applied/default country code is used.
4846 * This is a synchronous API.
4847 *
4848 * pBuf - pointer to a caller allocated buffer for returned country code.
4849 * pbLen For input, this parameter indicates how big is the buffer.
4850 * Upon return, this parameter has the number of bytes for
4851 * country. If pBuf doesn't have enough space, this function
4852 * returns fail status and this parameter contains the number
4853 * that is needed.
4854 *
4855 * Return QDF_STATUS SUCCESS.
4856 *
4857 * FAILURE or RESOURCES The API finished and failed.
4858 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304859QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860{
4861 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4862
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304863 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4865
4866 return csr_get_country_code(pMac, pBuf, pbLen);
4867}
4868
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869/* some support functions */
4870bool sme_is11d_supported(tHalHandle hHal)
4871{
4872 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4873
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004874 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875}
4876
4877bool sme_is11h_supported(tHalHandle hHal)
4878{
4879 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4880
4881 return csr_is11h_supported(pMac);
4882}
4883
4884bool sme_is_wmm_supported(tHalHandle hHal)
4885{
4886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4887
4888 return csr_is_wmm_supported(pMac);
4889}
4890
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304891/*
4892 * sme_change_country_code() -
4893 * Change Country code from upperlayer during WLAN driver operation.
4894 * This is a synchronous API.
4895 *
4896 * hHal - The handle returned by mac_open.
4897 * pCountry New Country Code String
4898 * sendRegHint If we want to send reg hint to nl80211
4899 * Return QDF_STATUS SUCCESS.
4900 * FAILURE or RESOURCES The API finished and failed.
4901 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304902QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 tSmeChangeCountryCallback callback,
4904 uint8_t *pCountry,
4905 void *pContext,
4906 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004907 bool countryFromUserSpace,
4908 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304910 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004912 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 tAniChangeCountryCodeReq *pMsg;
4914
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304915 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4917 0));
4918 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304919 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4921 && (!pMac->roam.configParam.
4922 fSupplicantCountryCodeHasPriority)) {
4923
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004924 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925
4926 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304927 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928 return status;
4929 }
4930
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304931 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004933 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304935 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 }
4937
4938 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4939 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304940 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 pMsg->countryFromUserSpace = countryFromUserSpace;
4942 pMsg->sendRegHint = sendRegHint;
4943 pMsg->changeCCCallback = callback;
4944 pMsg->pDevContext = pContext;
4945 pMsg->p_cds_context = p_cds_context;
4946
4947 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4948 msg.bodyptr = pMsg;
4949 msg.reserved = 0;
4950
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304951 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004952 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004953 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304954 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304955 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 sme_release_global_lock(&pMac->sme);
4958 }
4959
4960 return status;
4961}
4962
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304963/*
4964 * sme_generic_change_country_code() -
4965 * Change Country code from upperlayer during WLAN driver operation.
4966 * This is a synchronous API.
4967 *
4968 * hHal - The handle returned by mac_open.
4969 * pCountry New Country Code String
4970 * reg_domain regulatory domain
4971 * Return QDF_STATUS SUCCESS.
4972 * FAILURE or RESOURCES The API finished and failed.
4973 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304974QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004975 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004979 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 tAniGenericChangeCountryCodeReq *pMsg;
4981
4982 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304983 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 "%s: pMac is null", __func__);
4985 return status;
4986 }
4987
4988 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304989 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304990 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991
4992 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004993 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304995 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004996 }
4997
4998 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4999 pMsg->msgLen =
5000 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305001 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005002 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003
5004 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
5005 msg.bodyptr = pMsg;
5006 msg.reserved = 0;
5007
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305008 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005009 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005010 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305011 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305012 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 sme_release_global_lock(&pMac->sme);
5015 }
5016
5017 return status;
5018}
5019
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305020/*
5021 * sme_dhcp_start_ind() -
5022 * API to signal the FW about the DHCP Start event.
5023 *
5024 * hHal - HAL handle for device.
5025 * device_mode - mode(AP,SAP etc) of the device.
5026 * macAddr - MAC address of the adapter.
5027 * sessionId - session ID.
5028 * Return QDF_STATUS SUCCESS.
5029 * FAILURE or RESOURCES The API finished and failed.
5030 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305031QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 uint8_t device_mode,
5033 uint8_t *macAddr, uint8_t sessionId)
5034{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305035 QDF_STATUS status;
5036 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005037 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005038 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305040 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041
5042 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305043 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044 pSession = CSR_GET_SESSION(pMac, sessionId);
5045
5046 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005047 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305049 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 }
Arif Hussain3316f402016-11-10 13:08:03 -08005051 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305053 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005054 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305055 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 "%s: Not able to allocate memory for dhcp start",
5057 __func__);
5058 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305059 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 }
5061 pMsg->msgType = WMA_DHCP_START_IND;
5062 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5063 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305064 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305065 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305066 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005067 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005069 message.type = WMA_DHCP_START_IND;
5070 message.bodyptr = pMsg;
5071 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305072 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005073 sessionId, message.type));
5074 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5075 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305076 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305079 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305080 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 }
5082 sme_release_global_lock(&pMac->sme);
5083 }
5084 return status;
5085}
5086
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305087/*
5088 * sme_dhcp_stop_ind() -
5089 * API to signal the FW about the DHCP complete event.
5090 *
5091 * hHal - HAL handle for device.
5092 * device_mode - mode(AP, SAP etc) of the device.
5093 * macAddr - MAC address of the adapter.
5094 * sessionId - session ID.
5095 * Return QDF_STATUS SUCCESS.
5096 * FAILURE or RESOURCES The API finished and failed.
5097 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305098QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 uint8_t device_mode,
5100 uint8_t *macAddr, uint8_t sessionId)
5101{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305102 QDF_STATUS status;
5103 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005105 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305107 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108
5109 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305110 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 pSession = CSR_GET_SESSION(pMac, sessionId);
5112
5113 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005114 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305116 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 }
Arif Hussain3316f402016-11-10 13:08:03 -08005118 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305120 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 "%s: Not able to allocate memory for dhcp stop",
5124 __func__);
5125 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305126 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 }
5128
5129 pMsg->msgType = WMA_DHCP_STOP_IND;
5130 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
5131 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305132 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305133 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05305134 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07005135 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005137 message.type = WMA_DHCP_STOP_IND;
5138 message.bodyptr = pMsg;
5139 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305140 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005141 sessionId, message.type));
5142 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5143 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305144 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305145 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305147 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305148 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005149 }
5150
5151 sme_release_global_lock(&pMac->sme);
5152 }
5153 return status;
5154}
5155
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305156/*
5157 * sme_TXFailMonitorStopInd() -
5158 * API to signal the FW to start monitoring TX failures
5159 *
5160 * Return QDF_STATUS SUCCESS.
5161 * FAILURE or RESOURCES The API finished and failed.
5162 */
5163QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
5164 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005165 void *txFailIndCallback)
5166{
5167 QDF_STATUS status;
5168 QDF_STATUS qdf_status;
5169 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005170 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005171 tAniTXFailMonitorInd *pMsg;
5172
5173 status = sme_acquire_global_lock(&pMac->sme);
5174 if (QDF_STATUS_SUCCESS == status) {
5175 pMsg = (tAniTXFailMonitorInd *)
5176 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
5177 if (NULL == pMsg) {
5178 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5179 "%s: Failed to allocate memory", __func__);
5180 sme_release_global_lock(&pMac->sme);
5181 return QDF_STATUS_E_NOMEM;
5182 }
5183
5184 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
5185 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
5186
5187 /* tx_fail_count = 0 should disable the Monitoring in FW */
5188 pMsg->tx_fail_count = tx_fail_count;
5189 pMsg->txFailIndCallback = txFailIndCallback;
5190
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005191 message.type = WMA_TX_FAIL_MONITOR_IND;
5192 message.bodyptr = pMsg;
5193 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005194
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005195 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5196 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005197 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5198 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5199 "%s: Post TX Fail monitor Start MSG fail",
5200 __func__);
5201 qdf_mem_free(pMsg);
5202 status = QDF_STATUS_E_FAILURE;
5203 }
5204 sme_release_global_lock(&pMac->sme);
5205 }
5206 return status;
5207}
5208
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305209/*
5210 * sme_set_cfg_privacy() -
5211 * API to set configure privacy parameters
5212 *
5213 * hHal - The handle returned by mac_open.
5214 * pProfile - Pointer CSR Roam profile.
5215 * fPrivacy - This parameter indicates status of privacy
5216 * Return void
5217 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218void sme_set_cfg_privacy(tHalHandle hHal,
5219 tCsrRoamProfile *pProfile, bool fPrivacy)
5220{
5221 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305222
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305223 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305225 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
5227 sme_release_global_lock(&pMac->sme);
5228 }
5229}
5230
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305231/*
5232 * sme_neighbor_report_request() -
5233 * API to request neighbor report.
5234 *
5235 * hHal - The handle returned by mac_open.
5236 * pRrmNeighborReq - Pointer to a caller allocated object of type
5237 * tRrmNeighborReq. Caller owns the memory and is
5238 * responsible for freeing it.
5239 * Return QDF_STATUS
5240 * QDF_STATUS_E_FAILURE - failure
5241 * QDF_STATUS_SUCCESS success
5242 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305243QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305245 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305247 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305249
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305250 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
5252 0));
5253
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305254 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 status =
5256 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305257 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 sme_release_global_lock(&pMac->sme);
5259 }
5260
5261 return status;
5262}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305264/*
5265 * sme_get_wcnss_wlan_compiled_version() -
5266 * This API returns the version of the WCNSS WLAN API with
5267 * which the HOST driver was built
5268 *
5269 * hHal - The handle returned by mac_open.
5270 * pVersion - Points to the Version structure to be filled
5271 * Return QDF_STATUS
5272 * QDF_STATUS_E_INVAL - failure
5273 * QDF_STATUS_SUCCESS success
5274 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305275QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 tSirVersionType *pVersion)
5277{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305278 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5280
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305281 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305283 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305285 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286
5287 sme_release_global_lock(&pMac->sme);
5288 }
5289
5290 return status;
5291}
5292
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305293/*
5294 * sme_get_wcnss_wlan_reported_version() -
5295 * This API returns the version of the WCNSS WLAN API with
5296 * which the WCNSS driver reports it was built
5297 * hHal - The handle returned by mac_open.
5298 * pVersion - Points to the Version structure to be filled
5299 * Return QDF_STATUS
5300 * QDF_STATUS_E_INVAL - failure
5301 * QDF_STATUS_SUCCESS success
5302 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305303QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 tSirVersionType *pVersion)
5305{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305306 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5308
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305309 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305311 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305313 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314
5315 sme_release_global_lock(&pMac->sme);
5316 }
5317
5318 return status;
5319}
5320
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305321/*
5322 * sme_get_wcnss_software_version() -
5323 * This API returns the version string of the WCNSS driver
5324 *
5325 * hHal - The handle returned by mac_open.
5326 * pVersion - Points to the Version string buffer to be filled
5327 * versionBufferSize - THe size of the Version string buffer
5328 * Return QDF_STATUS
5329 * QDF_STATUS_E_INVAL - failure
5330 * QDF_STATUS_SUCCESS success
5331 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305332QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 uint8_t *pVersion,
5334 uint32_t versionBufferSize)
5335{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305336 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305339 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305340 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07005342 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 pVersion,
5344 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305345 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305346 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005347 sme_release_global_lock(&pMac->sme);
5348 }
5349
5350 return status;
5351}
5352
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305353/*
5354 * sme_get_wcnss_hardware_version() -
5355 * This API returns the version string of the WCNSS hardware
5356 *
5357 * hHal - The handle returned by mac_open.
5358 * pVersion - Points to the Version string buffer to be filled
5359 * versionBufferSize - THe size of the Version string buffer
5360 * Return QDF_STATUS
5361 * QDF_STATUS_E_INVAL - failure
5362 * QDF_STATUS_SUCCESS success
5363 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305364QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 uint8_t *pVersion,
5366 uint32_t versionBufferSize)
5367{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305368 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5370
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305371 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305373 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305375 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376
5377 sme_release_global_lock(&pMac->sme);
5378 }
5379
5380 return status;
5381}
5382
5383#ifdef FEATURE_WLAN_WAPI
5384
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305385/*
5386 * sme_scan_get_bkid_candidate_list() -
5387 * A wrapper function to return the BKID candidate list
5388 *
5389 * pBkidList - caller allocated buffer point to an array of
5390 * tBkidCandidateInfo
5391 * pNumItems - pointer to a variable that has the number of
5392 * tBkidCandidateInfo allocated when retruning, this is
5393 * either the number needed or number of items put into
5394 * pPmkidList
5395 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5396 * big enough and pNumItems
5397 * has the number of tBkidCandidateInfo.
5398 * Note: pNumItems is a number of tBkidCandidateInfo,
5399 * not sizeof(tBkidCandidateInfo) * something
5400 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305401QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 tBkidCandidateInfo *pBkidList,
5403 uint32_t *pNumItems)
5404{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305405 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5407
5408 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305409 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305411 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5412 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 sme_release_global_lock(&pMac->sme);
5414 }
5415
5416 return status;
5417}
5418#endif /* FEATURE_WLAN_WAPI */
5419
5420#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005421/**
5422 * sme_oem_data_req() - send oem data request to WMA
5423 * @hal: HAL handle
5424 * @hdd_oem_req: OEM data request from HDD
5425 *
5426 * Return: QDF_STATUS
5427 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005428QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305430 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005431 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005432 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005434 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005435 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5436 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005437 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005438 return QDF_STATUS_E_FAILURE;
5439 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005441 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5442 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005443 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005444 return QDF_STATUS_E_NOMEM;
5445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005447 oem_data_req->data_len = hdd_oem_req->data_len;
5448 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5449 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005450 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005451 return QDF_STATUS_E_NOMEM;
5452 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005454 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5455 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005457 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305459 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005460 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305461 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005462 sme_debug("OEM request(length: %d) sent to WMA",
5463 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005464
5465 if (oem_data_req->data_len)
5466 qdf_mem_free(oem_data_req->data);
5467 qdf_mem_free(oem_data_req);
5468
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005469 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 return status;
5471}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472#endif /*FEATURE_OEM_DATA_SUPPORT */
5473
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305474/*
5475 * sme_open_session() - Open a session for scan/roam operation.
5476 *
5477 * This is a synchronous API.
5478 *
5479 * hHal - The handle returned by mac_open.
5480 * callback - A pointer to the function caller specifies for
5481 * roam/connect status indication
5482 * pContext - The context passed with callback
5483 * pSelfMacAddr - Caller allocated memory filled with self MAC address
5484 * (6 bytes)
5485 * pbSessionId - pointer to a caller allocated buffer for returned session ID
5486 *
5487 * Return QDF_STATUS_SUCCESS - session is opened. sessionId returned.
5488 *
5489 * Other status means SME is failed to open the session.
5490 * QDF_STATUS_E_RESOURCES - no more session available.
5491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305492QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
Dustin Brownd28772b2017-03-17 14:16:07 -07005493 void *pContext, uint8_t *pSelfMacAddr,
5494 uint8_t session_id, uint32_t type, uint32_t subType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495{
Arif Hussainee677012017-01-26 17:50:13 -08005496 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Arif Hussainee677012017-01-26 17:50:13 -08005498 struct cdp_pdev *pdev;
5499 ol_txrx_peer_handle peer;
5500 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005501 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305503 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005504 "%s: type=%d, session_id %d subType=%d addr:%pM",
5505 __func__, type, session_id, subType, pSelfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506
Arif Hussainee677012017-01-26 17:50:13 -08005507 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5508
5509 if (NULL == pdev) {
5510 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5511 "%s: Failed to get pdev handler", __func__);
5512 return status;
5513 }
5514
Dustin Brownd28772b2017-03-17 14:16:07 -07005515 status = sme_acquire_global_lock(&pMac->sme);
5516 if (QDF_IS_STATUS_ERROR(status))
5517 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005519 peer = cdp_peer_find_by_addr(soc, pdev, pSelfMacAddr, &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005520 if (peer) {
5521 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5522 "%s: Peer=%d exist with same MAC",
5523 __func__, peer_id);
5524 status = QDF_STATUS_E_INVAL;
5525 } else {
5526 status = csr_roam_open_session(pMac, callback, pContext,
5527 pSelfMacAddr, session_id, type, subType);
5528 }
Dustin Brownd28772b2017-03-17 14:16:07 -07005529 sme_release_global_lock(&pMac->sme);
5530
5531 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
5532 session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533
5534 return status;
5535}
5536
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305537/*
5538 * sme_close_session() - Open a session for scan/roam operation.
5539 *
5540 * This is a synchronous API.
5541 *
5542 * hHal - The handle returned by mac_open.
5543 * sessionId - A previous opened session's ID.
5544 * Return QDF_STATUS_SUCCESS - session is closed.
5545 * Other status means SME is failed to open the session.
5546 * QDF_STATUS_E_INVAL - session is not opened.
5547 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305548QDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 csr_roamSessionCloseCallback callback,
5550 void *pContext)
5551{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305552 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5554
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305555 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
5557 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305558 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 status = csr_roam_close_session(pMac, sessionId, false,
5560 callback, pContext);
5561
5562 sme_release_global_lock(&pMac->sme);
5563 }
5564
5565 return status;
5566}
5567
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305568/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305569 * sme_change_mcc_beacon_interval() -
5570 * To update P2P-GO beaconInterval. This function should be called after
5571 * disassociating all the station is done
5572 * This is an asynchronous API.
5573 *
5574 * @sessionId: Session Identifier
5575 * Return QDF_STATUS SUCCESS
5576 * FAILURE or RESOURCES
5577 * The API finished and failed.
5578 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005579QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305581 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005582 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005584 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305585 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005586 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5587 sessionId);
5588 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 }
5590 return status;
5591}
5592
5593/**
5594 * sme_set_host_offload(): API to set the host offload feature.
5595 * @hHal: The handle returned by mac_open.
5596 * @sessionId: Session Identifier
5597 * @request: Pointer to the offload request.
5598 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305599 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305601QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 tpSirHostOffloadReq request)
5603{
5604 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305605 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305607 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5609 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305610 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611#ifdef WLAN_NS_OFFLOAD
5612 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5613 status = sme_set_ps_ns_offload(hHal, request,
5614 sessionId);
5615 } else
5616#endif /* WLAN_NS_OFFLOAD */
5617 {
5618 status = sme_set_ps_host_offload(hHal, request,
5619 sessionId);
5620 }
5621 sme_release_global_lock(&pMac->sme);
5622 }
5623
5624 return status;
5625}
5626
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305627/*
5628 * sme_set_keep_alive() -
5629 * API to set the Keep Alive feature.
5630 *
5631 * hHal - The handle returned by mac_open.
5632 * request - Pointer to the Keep Alive request.
5633 * Return QDF_STATUS
5634 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305635QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 tpSirKeepAliveReq request)
5637{
5638 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005639 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305641 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305643 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 FL("WMA_SET_KEEP_ALIVE message"));
5645
5646 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305649 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005650 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305651 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305653 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305654 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305655 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 }
5657
Anurag Chouhanc5548422016-02-24 18:33:27 +05305658 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305659 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305661 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 "buff TP %d input TP %d ", request_buf->timePeriod,
5663 request->timePeriod);
5664 request_buf->sessionId = session_id;
5665
5666 msg.type = WMA_SET_KEEP_ALIVE;
5667 msg.reserved = 0;
5668 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305669 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5670 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305671 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005672 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305673 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305674 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305675 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305676 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 }
5678
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305679 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680}
5681
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305682/*
5683 * sme_get_operation_channel() -
5684 * API to get current channel on which STA is parked his function gives
5685 * channel information only of infra station or IBSS station
5686 *
5687 * hHal, pointer to memory location and sessionId
5688 * Returns QDF_STATUS_SUCCESS
5689 * QDF_STATUS_E_FAILURE
5690 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305691QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 uint8_t sessionId)
5693{
5694 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305695 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696
5697 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5698 pSession = CSR_GET_SESSION(pMac, sessionId);
5699
5700 if ((pSession->connectedProfile.BSSType ==
5701 eCSR_BSS_TYPE_INFRASTRUCTURE)
5702 || (pSession->connectedProfile.BSSType ==
5703 eCSR_BSS_TYPE_IBSS)
5704 || (pSession->connectedProfile.BSSType ==
5705 eCSR_BSS_TYPE_INFRA_AP)
5706 || (pSession->connectedProfile.BSSType ==
5707 eCSR_BSS_TYPE_START_IBSS)) {
5708 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305709 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 }
5711 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305712 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713} /* sme_get_operation_channel ends here */
5714
Abhishek Singh7996eb72015-12-30 17:24:02 +05305715/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305716 * sme_register_p2p_ack_ind_callback() - p2p ack indication callback
5717 * @hal: hal pointer
5718 * @callback: callback pointer to be registered
5719 *
5720 * This function is used to register a callback to PE for p2p ack
5721 * indication
5722 *
5723 * Return: Success if msg is posted to PE else Failure.
5724 */
5725QDF_STATUS sme_register_p2p_ack_ind_callback(tHalHandle hal,
5726 sir_p2p_ack_ind_callback callback)
5727{
5728 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5729 struct sir_sme_p2p_ack_ind_cb_req *msg;
5730 QDF_STATUS status = QDF_STATUS_SUCCESS;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005731
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305732 status = sme_acquire_global_lock(&mac_ctx->sme);
5733 if (QDF_IS_STATUS_SUCCESS(status)) {
5734 msg = qdf_mem_malloc(sizeof(*msg));
5735 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005736 sme_err("Failed to allocate memory");
5737 sme_release_global_lock(&mac_ctx->sme);
5738 return QDF_STATUS_E_NOMEM;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305739 }
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305740 msg->message_type = eWNI_SME_REGISTER_P2P_ACK_CB;
5741 msg->length = sizeof(*msg);
5742
5743 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005744 status = umac_send_mb_message_to_mac(msg);
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305745 sme_release_global_lock(&mac_ctx->sme);
5746 return status;
5747 }
5748 return status;
5749}
5750
5751/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05305752 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5753 * management frame indication to PE.
5754 *
5755 * @hal: hal pointer
5756 * @callback: callback pointer to be registered
5757 *
5758 * This function is used to register a callback for management
5759 * frame indication to PE.
5760 *
5761 * Return: Success if msg is posted to PE else Failure.
5762 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305763QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305764 sir_mgmt_frame_ind_callback callback)
5765{
5766 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5767 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305768 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305769
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305770 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305771 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305772 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305773 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005774 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305775 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305776 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305777 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305778 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5779 msg->length = sizeof(*msg);
5780
5781 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005782 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305783 sme_release_global_lock(&mac_ctx->sme);
5784 return status;
5785 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305786 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305787}
5788
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305789/*
5790 * sme_RegisterMgtFrame() -
5791 * To register managment frame of specified type and subtype.
5792 *
5793 * frameType - type of the frame that needs to be passed to HDD.
5794 * matchData - data which needs to be matched before passing frame
5795 * to HDD.
5796 * matchDataLen - Length of matched data.
5797 * Return QDF_STATUS
5798 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305799QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 uint16_t frameType, uint8_t *matchData,
5801 uint16_t matchLen)
5802{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305803 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305807 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 tSirRegisterMgmtFrame *pMsg;
5809 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305810 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5811 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005812
5813 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005814 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305816 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 }
5818
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305819 if (!CSR_IS_SESSION_ANY(sessionId) &&
5820 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305821 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005822 "%s Invalid Sessionid", __func__);
5823 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305824 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825 }
5826
5827 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5828
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305829 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005830 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305831 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5834 pMsg->length = len;
5835 pMsg->sessionId = sessionId;
5836 pMsg->registerFrame = true;
5837 pMsg->frameType = frameType;
5838 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305839 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005840 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 }
5842 sme_release_global_lock(&pMac->sme);
5843 }
5844 return status;
5845}
5846
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305847/*
5848 * sme_DeregisterMgtFrame() -
5849 * To De-register managment frame of specified type and subtype.
5850 *
5851 * frameType - type of the frame that needs to be passed to HDD.
5852 * matchData - data which needs to be matched before passing frame
5853 * to HDD.
5854 * matchDataLen - Length of matched data.
5855 * Return QDF_STATUS
5856 */
5857QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 uint16_t frameType, uint8_t *matchData,
5859 uint16_t matchLen)
5860{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305861 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5863
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305864 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5866 0));
5867 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305868 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869 tSirRegisterMgmtFrame *pMsg;
5870 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305871 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5872 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873
5874 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005875 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005876 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305877 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 }
5879
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305880 if (!CSR_IS_SESSION_ANY(sessionId) &&
5881 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305882 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 "%s Invalid Sessionid", __func__);
5884 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305885 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886 }
5887
5888 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5889
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305890 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305892 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5895 pMsg->length = len;
5896 pMsg->registerFrame = false;
5897 pMsg->frameType = frameType;
5898 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305899 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005900 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901 }
5902 sme_release_global_lock(&pMac->sme);
5903 }
5904 return status;
5905}
5906
5907/**
5908 * sme_remain_on_channel - API to request remain on channel for 'x' duration
5909 *
5910 * @hHal: pointer to MAC handle
5911 * @session_id: Session identifier
5912 * @channel: channel information
5913 * @duration: duration in ms
5914 * @callback: HDD registered callback to process reaminOnChannelRsp
5915 * @context: HDD Callback param
5916 * @scan_id: scan identifier
5917 *
5918 * This function process the roc request and generates scan identifier.s
5919 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305920 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305922QDF_STATUS sme_remain_on_channel(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 uint8_t channel, uint32_t duration,
5924 remainOnChanCallback callback,
5925 void *pContext, uint8_t isP2PProbeReqAllowed,
5926 uint32_t *scan_id)
5927{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305928 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5930 uint32_t san_req_id, scan_count;
5931 struct ani_roc_req *roc_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005932 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933
5934
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305935 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN, session_id, 0));
5937
Krunal Soni81f068c2017-02-23 19:51:55 -08005938 scan_count = csr_scan_active_ll_count(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 if (scan_count >= mac_ctx->scan.max_scan_count) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005940 sme_err("Max scan reached");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305941 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 }
5943
5944 wma_get_scan_id(&san_req_id);
5945 *scan_id = san_req_id;
5946 status = sme_acquire_global_lock(&mac_ctx->sme);
5947
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305948 roc_msg = qdf_mem_malloc(sizeof(struct ani_roc_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 if (NULL == roc_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005950 sme_err("scan_req: failed to allocate mem for msg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305952 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 }
5954 roc_msg->msg_type = eWNI_SME_ROC_CMD;
5955 roc_msg->msg_len = (uint16_t) sizeof(struct ani_roc_req);
5956 roc_msg->session_id = session_id;
5957 roc_msg->callback = callback;
5958 roc_msg->duration = duration;
5959 roc_msg->channel = channel;
5960 roc_msg->is_p2pprobe_allowed = isP2PProbeReqAllowed;
5961 roc_msg->ctx = pContext;
5962 roc_msg->scan_id = *scan_id;
5963 msg.type = eWNI_SME_ROC_CMD;
5964 msg.bodyptr = roc_msg;
5965 msg.reserved = 0;
5966 msg.bodyval = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305967 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005968 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005969 sme_err("sme_scan_req failed to post msg");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305970 qdf_mem_free(roc_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305971 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 }
5973 sme_release_global_lock(&mac_ctx->sme);
5974 return status;
5975}
5976
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305977/*
5978 * sme_report_probe_req() -
5979 * API to enable/disable forwarding of probeReq to apps in p2p.
5980 *
5981 * hHal - The handle returned by mac_open.
5982 * falg: to set the Probe request forarding to wpa_supplicant in listen state
5983 * in p2p
5984 * Return QDF_STATUS
5985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986
5987#ifndef WLAN_FEATURE_CONCURRENT_P2P
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305988QDF_STATUS sme_report_probe_req(tHalHandle hHal, uint8_t flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305990 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5992
5993 do {
5994 /* acquire the lock for the sme object */
5995 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305996 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997 /* call set in context */
5998 pMac->p2pContext.probeReqForwarding = flag;
5999 /* release the lock for the sme object */
6000 sme_release_global_lock(&pMac->sme);
6001 }
6002 } while (0);
6003
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006004 return status;
6005}
6006
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306007/*
6008 * sme_update_p2p_ie() -
6009 * API to set the P2p Ie in p2p context
6010 *
6011 * hHal - The handle returned by mac_open.
6012 * p2pIe - Ptr to p2pIe from HDD.
6013 * p2pIeLength: length of p2pIe
6014 * Return QDF_STATUS
6015 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306017QDF_STATUS sme_update_p2p_ie(tHalHandle hHal, void *p2pIe, uint32_t p2pIeLength)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306019 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6021
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306022 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 TRACE_CODE_SME_RX_HDD_UPDATE_P2P_IE, NO_SESSION, 0));
6024 /* acquire the lock for the sme object */
6025 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306026 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 if (NULL != pMac->p2pContext.probeRspIe) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306028 qdf_mem_free(pMac->p2pContext.probeRspIe);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 pMac->p2pContext.probeRspIeLength = 0;
6030 }
6031
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306032 pMac->p2pContext.probeRspIe = qdf_mem_malloc(p2pIeLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 if (NULL == pMac->p2pContext.probeRspIe) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006034 sme_err("Unable to allocate P2P IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 pMac->p2pContext.probeRspIeLength = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306036 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 } else {
6038 pMac->p2pContext.probeRspIeLength = p2pIeLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306039 qdf_mem_copy((uint8_t *) pMac->p2pContext.probeRspIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 p2pIe, p2pIeLength);
6041 }
6042
6043 /* release the lock for the sme object */
6044 sme_release_global_lock(&pMac->sme);
6045 }
6046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 return status;
6048}
6049#endif
6050
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306051/*
6052 * sme_send_action() -
6053 * API to send action frame from supplicant.
6054 *
6055 * hHal - The handle returned by mac_open.
6056 * Return QDF_STATUS
6057 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306059QDF_STATUS sme_send_action(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 const uint8_t *pBuf, uint32_t len,
6061 uint16_t wait, bool noack,
6062 uint16_t channel_freq)
6063{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306064 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6066
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306067 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 TRACE_CODE_SME_RX_HDD_SEND_ACTION, sessionId, 0));
6069 /* acquire the lock for the sme object */
6070 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306071 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072 p2p_send_action(hHal, sessionId, pBuf, len, wait, noack,
6073 channel_freq);
6074 /* release the lock for the sme object */
6075 sme_release_global_lock(&pMac->sme);
6076 }
6077
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078 return status;
6079}
6080
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306081QDF_STATUS sme_cancel_remain_on_channel(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 uint8_t sessionId, uint32_t scan_id)
6083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306084 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6086
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306087 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN, sessionId,
6089 0));
6090 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306091 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 status = p2p_cancel_remain_on_channel(hHal, sessionId, scan_id);
6093 sme_release_global_lock(&pMac->sme);
6094 }
6095 return status;
6096}
6097
6098/* Power Save Related */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306099QDF_STATUS sme_p2p_set_ps(tHalHandle hHal, tP2pPsConfig *data)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306101 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6103
6104 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306105 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 status = p2p_set_ps(hHal, data);
6107 sme_release_global_lock(&pMac->sme);
6108 }
6109 return status;
6110}
6111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07006113/**
6114 * sme_configure_ext_wow() - configure Extr WoW
6115 * @hHal - The handle returned by mac_open.
6116 * @wlanExtParams - Depicts the wlan Ext params.
6117 * @callback - ext_wow callback to be registered.
6118 * @callback_context - ext_wow callback context
6119 *
6120 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306121 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07006122 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306123QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 tpSirExtWoWParams wlanExtParams,
6125 csr_readyToExtWoWCallback callback,
6126 void *callback_context)
6127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306128 QDF_STATUS status = QDF_STATUS_SUCCESS;
6129 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006131 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306132 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133
6134 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306135 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306137 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
6139
6140 pMac->readyToExtWoWCallback = callback;
6141 pMac->readyToExtWoWContext = callback_context;
6142
6143 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306144 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145
6146 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306147 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006148 message.bodyptr = MsgPtr;
6149 message.type = WMA_WLAN_EXT_WOW;
6150 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6151 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306152 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153 pMac->readyToExtWoWCallback = NULL;
6154 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306155 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306156 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 }
6158 sme_release_global_lock(&pMac->sme);
6159 } else {
6160 pMac->readyToExtWoWCallback = NULL;
6161 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306162 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 }
6164
6165 return status;
6166}
6167
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306168/*
6169 * sme_configure_app_type1_params() -
6170 * SME will pass this request to lower mac to configure Indoor WoW parameters.
6171 *
6172 * hHal - The handle returned by mac_open.
6173 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
6174 * Return QDF_STATUS
6175 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306176QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 tpSirAppType1Params wlanAppType1Params)
6178{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306179 QDF_STATUS status = QDF_STATUS_SUCCESS;
6180 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006182 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306183 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184
6185 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306186 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306188 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
6190 0));
6191
6192 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306193 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006194 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306195 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006196 message.bodyptr = MsgPtr;
6197 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
6198 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6199 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306200 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306201 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306202 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 }
6204 sme_release_global_lock(&pMac->sme);
6205 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306206 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 }
6208
6209 return status;
6210}
6211
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306212/*
6213 * sme_configure_app_type2_params() -
6214 * SME will pass this request to lower mac to configure Indoor WoW parameters.
6215 *
6216 * hHal - The handle returned by mac_open.
6217 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
6218 * Return QDF_STATUS
6219 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306220QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306221 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306223 QDF_STATUS status = QDF_STATUS_SUCCESS;
6224 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006226 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306227 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228
6229 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306230 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306232 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
6234 0));
6235
6236 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306237 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306239 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006240 message.bodyptr = MsgPtr;
6241 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
6242 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6243 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306244 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306245 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306246 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247 }
6248 sme_release_global_lock(&pMac->sme);
6249 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306250 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251 }
6252
6253 return status;
6254}
6255#endif
6256
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306257/*
6258 * sme_get_infra_session_id
6259 * To get the session ID for infra session, if connected
6260 * This is a synchronous API.
6261 *
6262 * hHal - The handle returned by mac_open.
6263 * sessionid, -1 if infra session is not connected
6264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265int8_t sme_get_infra_session_id(tHalHandle hHal)
6266{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306267 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006268 int8_t sessionid = -1;
6269 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6270
6271 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306272 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273
6274 sessionid = csr_get_infra_session_id(pMac);
6275
6276 sme_release_global_lock(&pMac->sme);
6277 }
6278
6279 return sessionid;
6280}
6281
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306282/*
6283 * sme_get_infra_operation_channel() -
6284 * To get the operating channel for infra session, if connected
6285 * This is a synchronous API.
6286 *
6287 * hHal - The handle returned by mac_open.
6288 * sessionId - the sessionId returned by sme_open_session.
6289 * Return operating channel, 0 if infra session is not connected
6290 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006291uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
6292{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306293 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6295 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306298 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299
6300 channel = csr_get_infra_operation_channel(pMac, sessionId);
6301
6302 sme_release_global_lock(&pMac->sme);
6303 }
6304
6305 return channel;
6306}
6307
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306308/* This routine will return poerating channel on which other BSS is operating
6309 * to be used for concurrency mode. If other BSS is not up or not connected it
6310 * will return 0
6311 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006312uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
6313{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306314 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6316 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306317
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006318 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306319 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320
6321 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306322 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
6323 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 sme_release_global_lock(&pMac->sme);
6325 }
6326
6327 return channel;
6328}
6329
6330#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6331uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
6332 eCsrPhyMode sapPhyMode,
6333 uint8_t cc_switch_mode)
6334{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306335 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006336 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6337 uint16_t channel = 0;
6338
6339 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306340 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306342 csr_check_concurrent_channel_overlap(pMac, sap_ch,
6343 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006344 cc_switch_mode);
6345 sme_release_global_lock(&pMac->sme);
6346 }
6347
6348 return channel;
6349}
6350#endif
6351
Arun Khandavalli4b55da72016-07-19 19:55:01 +05306352/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006353 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07006354 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006355 * @cb_fn: Callback function pointer
6356 * @db_ctx: Callback data
6357 *
6358 * Return: QDF_STATUS
6359 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07006360QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006361 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
6362{
Manikandan Mohan976e7562016-03-15 16:33:31 -07006363 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006364 QDF_STATUS status;
6365
Manikandan Mohan976e7562016-03-15 16:33:31 -07006366 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006367 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07006368 mac->sme.get_tsf_cb = cb_fn;
6369 mac->sme.get_tsf_cxt = cb_ctx;
6370 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07006371 }
6372 return status;
6373}
6374
Arun Khandavalli4b55da72016-07-19 19:55:01 +05306375/**
6376 * sme_reset_tsfcb() - Reset callback for TSF capture
6377 * @h_hal: Handler return by mac_open
6378 *
6379 * This function reset the tsf capture callback to SME
6380 *
6381 * Return: QDF_STATUS
6382 */
6383QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
6384{
6385 tpAniSirGlobal mac;
6386 QDF_STATUS status;
6387
6388 if (!h_hal) {
6389 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6390 FL("h_hal is not valid"));
6391 return QDF_STATUS_E_INVAL;
6392 }
6393 mac = PMAC_STRUCT(h_hal);
6394
6395 status = sme_acquire_global_lock(&mac->sme);
6396 if (QDF_IS_STATUS_SUCCESS(status)) {
6397 mac->sme.get_tsf_cb = NULL;
6398 mac->sme.get_tsf_cxt = NULL;
6399 sme_release_global_lock(&mac->sme);
6400 }
6401 return status;
6402}
6403
Manikandan Mohan976e7562016-03-15 16:33:31 -07006404#ifdef WLAN_FEATURE_TSF
6405/*
6406 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
6407 * @h_hal: Handler return by mac_open
6408 * @pinvalue: gpio pin id
6409 *
6410 * Return: QDF_STATUS
6411 */
6412QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
6413{
6414 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006415 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07006416 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
6417
6418 status = sme_acquire_global_lock(&mac->sme);
6419 if (QDF_IS_STATUS_SUCCESS(status)) {
6420 tsf_msg.type = WMA_TSF_GPIO_PIN;
6421 tsf_msg.reserved = 0;
6422 tsf_msg.bodyval = pinvalue;
6423
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006424 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07006425 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006426 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07006427 status = QDF_STATUS_E_FAILURE;
6428 }
6429 sme_release_global_lock(&mac->sme);
6430 }
6431 return status;
6432}
6433#endif
6434
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08006435QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006436 uint32_t *len)
6437{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306438 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08006439 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08006441 if (NULL == mac_ctx) {
6442 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6443 FL("Invalid MAC context"));
6444 return QDF_STATUS_E_FAILURE;
6445 }
6446
6447 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306448 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08006449 status = csr_get_cfg_valid_channels(mac_ctx,
6450 aValidChannels, len);
6451 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006452 }
6453
6454 return status;
6455}
6456
Amar Singhal6edf9732016-11-20 21:43:40 -08006457void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
6458{
6459 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
6460
6461 mac_ctx->reg_hint_src = cc_src;
6462}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306463/*
6464 * sme_handle_change_country_code() -
6465 * Change Country code, Reg Domain and channel list
6466 *
6467 * Details Country Code Priority
6468 * If Supplicant country code is priority than 11d is disabled.
6469 * If 11D is enabled, we update the country code after every scan.
6470 * Hence when Supplicant country code is priority, we don't need 11D info.
6471 * Country code from Supplicant is set as current courtry code.
6472 * User can send reset command XX (instead of country code) to reset the
6473 * country code to default values. If 11D is priority,
6474 * Than Supplicant country code code is set to default code. But 11D code
6475 * is set as current country code
6476 *
6477 * pMac - The handle returned by mac_open.
6478 * pMsgBuf - MSG Buffer
6479 * Return QDF_STATUS
6480 */
6481static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
6482 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306484 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 tAniChangeCountryCodeReq *pMsg;
6486 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306487 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07006488 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306490 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 /*
6492 * if the reset Supplicant country code command is triggered,
6493 * enable 11D, reset the country code and return
6494 */
Ankit Guptaa5076012016-09-14 11:32:19 -07006495 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006496 pMac->roam.configParam.Is11dSupportEnabled =
6497 pMac->roam.configParam.Is11dSupportEnabledOriginal;
6498
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07006499 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
6500 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501
6502 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306503 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306504 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505 default_country,
6506 WNI_CFG_COUNTRY_CODE_LEN);
6507 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306508 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 return status;
6510 }
6511 /*
6512 * Update the 11d country to default country so that when
6513 * callback is received for this default country, driver will
6514 * not disable the 11d taking it as valid country by user.
6515 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006516 sme_debug(
6517 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006518 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306519 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006520 pMsg->countryCode,
6521 WNI_CFG_COUNTRY_CODE_LEN);
6522 } else {
6523 /* if Supplicant country code has priority, disable 11d */
6524 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306525 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006526 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 }
6528
6529 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306530 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531
6532 /* Set Current Country code and Current Regulatory domain */
6533 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306534 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006535 /* Supplicant country code failed. So give 11D priority */
6536 pMac->roam.configParam.Is11dSupportEnabled =
6537 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006538 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539 return status;
6540 }
6541
6542 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306543 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
6545
6546 /* Get Domain ID from country code */
6547 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306548 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07006550 domainIdIoctl,
6551 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306552 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006553 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554 return status;
6555 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306556 /* Supplicant country code is invalid, so we are on world mode
6557 * now. So give 11D chance to update
6558 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006559 pMac->roam.configParam.Is11dSupportEnabled =
6560 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006561 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562 }
6563
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006564 if (domainIdIoctl >= REGDOMAIN_COUNT) {
6565 sme_err("Invalid regId %d", domainIdIoctl);
6566 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567 } else {
6568 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
6569 /* set again if we find AP with 11d info during scan */
6570 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006571 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306572 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306573 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306574 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006575 sizeof(pMac->scan.countryCode11d));
6576 }
6577 }
6578
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306579 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306581 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306583 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006584}
6585
6586/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006587 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588 * @mac_ctx: mac global context
6589 * @msg: request msg packet
6590 *
6591 * If Supplicant country code is priority than 11d is disabled.
6592 * If 11D is enabled, we update the country code after every scan.
6593 * Hence when Supplicant country code is priority, we don't need 11D info.
6594 * Country code from Supplicant is set as current country code.
6595 *
6596 * Return: status of operation
6597 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306598static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006599sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
6600 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306602 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006603 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006604 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006606 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006607
Amar Singhal6edf9732016-11-20 21:43:40 -08006608 if (SOURCE_11D != mac_ctx->reg_hint_src) {
6609 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
6610 if (user_ctry_priority)
6611 mac_ctx->roam.configParam.Is11dSupportEnabled =
6612 false;
6613 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306614 if (mac_ctx->roam.configParam.
6615 Is11dSupportEnabled &&
6616 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006617
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006618 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006619
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306620 status =
6621 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08006622 mac_ctx,
6623 mac_ctx->scan.countryCode11d,
6624 &reg_domain_id,
6625 SOURCE_11D);
6626 return QDF_STATUS_E_FAILURE;
6627 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006628 }
6629 }
6630 } else {
6631 /* if kernel gets invalid country code; it
6632 * resets the country code to world
6633 */
6634 if (('0' != msg->countryCode[0]) ||
6635 ('0' != msg->countryCode[1]))
6636 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6637 msg->countryCode,
6638 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006639 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006640
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006641 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6642 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645 /* get the channels based on new cc */
6646 status = csr_get_channel_and_power_list(mac_ctx);
6647
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306648 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006649 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006650 return status;
6651 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006652
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006653 /* reset info based on new cc, and we are done */
6654 csr_apply_channel_power_info_wrapper(mac_ctx);
6655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006656 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006657
6658 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006659 * Country IE
6660 */
6661 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006662
Amar Singhal6edf9732016-11-20 21:43:40 -08006663 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6664
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006666
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306667 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668}
6669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670static bool
6671sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6672{
6673 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306674 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 ch_lst_info = &mac_ctx->scan.base_channels;
6677 for (i = 0; i < ch_lst_info->numChannels; i++) {
6678 if (ch_lst_info->channelList[i] == curr_ch)
6679 return true;
6680 }
6681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006682 return false;
6683}
6684/**
6685 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6686 * if channel is not supported
6687 * @mac_ctx: mac global context
6688 *
6689 * If new country code does not support the channel on which STA/P2P client
6690 * is connetced, it sends the disconnect to the AP/P2P GO
6691 *
6692 * Return: void
6693 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306694static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006695{
6696 uint8_t session_id, found = false;
6697 uint8_t curr_ch;
6698
6699 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6700 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6701 continue;
6702 found = false;
6703 /* Session is connected.Check the channel */
6704 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6705 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006706 sme_debug("Current Operating channel : %d, session :%d",
6707 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006708 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6709 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006710 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 csr_roam_disconnect(mac_ctx, session_id,
6712 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6713 }
6714 }
6715}
6716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306718QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006719 tpSirRcvFltMcAddrList pMulticastAddrs)
6720{
6721 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006722 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306724 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006725
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306726 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6727 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006729 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006730
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006731 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006732 pSession = CSR_GET_SESSION(pMac, sessionId);
6733 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6734 (!csr_is_conn_state_infra(pMac, sessionId) &&
6735 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006737 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006738 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306739 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 }
6741
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306742 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306744 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306745 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006746 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306747 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 }
6749
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006750 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6751 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306752 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006753 "%s: Request ignored, session %d is not connected or started",
6754 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306755 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306756 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006757 }
6758
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306759 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006760 sizeof(tSirRcvFltMcAddrList));
6761
Anurag Chouhanc5548422016-02-24 18:33:27 +05306762 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6763 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006764 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006765
6766 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6767 msg.reserved = 0;
6768 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306769 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6770 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006771 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006772 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306773 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306774 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006775 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306776 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306777 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 }
6779
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306780 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006781}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006782#endif /* WLAN_FEATURE_PACKET_FILTERING */
6783
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306784/*
6785 * sme_is_channel_valid() -
6786 * To check if the channel is valid for currently established domain
6787 * This is a synchronous API.
6788 *
6789 * hHal - The handle returned by mac_open.
6790 * channel - channel to verify
6791 * Return true/false, true if channel is valid
6792 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006793bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6794{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306795 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 bool valid = false;
6797 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6798
6799 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306800 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006801
6802 valid = csr_roam_is_channel_valid(pMac, channel);
6803
6804 sme_release_global_lock(&pMac->sme);
6805 }
6806
6807 return valid;
6808}
6809
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306810/*
6811 * sme_set_freq_band() -
6812 * Used to set frequency band.
6813 *
6814 * hHal
6815 * sessionId - Session Identifier
6816 * band value to be configured
6817 * Return QDF_STATUS
6818 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306819QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006820{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306821 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6823
6824 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306825 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006826 status = csr_set_band(hHal, sessionId, eBand);
6827 sme_release_global_lock(&pMac->sme);
6828 }
6829 return status;
6830}
6831
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306832/*
6833 * sme_get_freq_band() -
6834 * Used to get the current band settings.
6835 *
6836 * hHal
6837 * pBand pointer to hold band value
6838 * Return QDF_STATUS
6839 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306840QDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006841{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306842 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006843 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6844
6845 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306846 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006847 *pBand = csr_get_current_band(hHal);
6848 sme_release_global_lock(&pMac->sme);
6849 }
6850 return status;
6851}
6852
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306853/*
6854 * sme_set_max_tx_power_per_band() -
6855 * Set the Maximum Transmit Power specific to band dynamically.
6856 * Note: this setting will not persist over reboots.
6857 *
6858 * band
6859 * power to set in dB
6860 * Return QDF_STATUS
6861 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306862QDF_STATUS sme_set_max_tx_power_per_band(eCsrBand band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006864 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6866
6867 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306868 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006869 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6872 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306873 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006874 }
6875
6876 pMaxTxPowerPerBandParams->power = dB;
6877 pMaxTxPowerPerBandParams->bandInfo = band;
6878
6879 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6880 msg.reserved = 0;
6881 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306882 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6883 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006884 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006885 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006887 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6888 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306889 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306890 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891 }
6892
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306893 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006894}
6895
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306896/*
6897 * sme_set_max_tx_power() -
6898 * Set the Maximum Transmit Power dynamically. Note: this setting will
6899 * not persist over reboots.
6900 *
6901 * hHal
6902 * pBssid BSSID to set the power cap for
6903 * pBssid pSelfMacAddress self MAC Address
6904 * pBssid power to set in dB
6905 * Return QDF_STATUS
6906 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306907QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6908 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006909{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006910 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006911 tpMaxTxPowerParams pMaxTxParams = NULL;
6912
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306913 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006914 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306915 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006916 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006918 "%s: Not able to allocate memory for pMaxTxParams",
6919 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306920 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006921 }
6922
Anurag Chouhanc5548422016-02-24 18:33:27 +05306923 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6924 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006925 pMaxTxParams->power = dB;
6926
6927 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6928 msg.reserved = 0;
6929 msg.bodyptr = pMaxTxParams;
6930
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006931 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006932 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306933 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006934 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6935 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306936 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306937 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006938 }
6939
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941}
6942
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306943/*
6944 * sme_set_custom_mac_addr() -
6945 * Set the customer Mac Address.
6946 *
6947 * customMacAddr customer MAC Address
6948 * Return QDF_STATUS
6949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306950QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006951{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006952 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006953 tSirMacAddr *pBaseMacAddr;
6954
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306955 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006956 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306957 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006958 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306959 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006960 }
6961
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306962 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006963
6964 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6965 msg.reserved = 0;
6966 msg.bodyptr = pBaseMacAddr;
6967
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006968 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006969 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306971 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306972 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306973 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006974 }
6975
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306976 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006977}
6978
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306979/*
6980 * sme_set_tx_power() -
6981 * Set Transmit Power dynamically.
6982 *
6983 * hHal
6984 * sessionId Target Session ID
6985 * BSSID
6986 * dev_mode dev_mode such as station, P2PGO, SAP
6987 * dBm power to set
6988 * Return QDF_STATUS
6989 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306990QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306991 struct qdf_mac_addr pBSSId,
6992 enum tQDF_ADAPTER_MODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006994 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995 tpMaxTxPowerParams pTxParams = NULL;
6996 int8_t power = (int8_t) dBm;
6997
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306998 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
7000
7001 /* make sure there is no overflow */
7002 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307003 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007004 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307005 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006 }
7007
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307008 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007009 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011 "%s: Not able to allocate memory for pTxParams",
7012 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307013 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007014 }
7015
Anurag Chouhanc5548422016-02-24 18:33:27 +05307016 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007017 pTxParams->power = power; /* unit is dBm */
7018 pTxParams->dev_mode = dev_mode;
7019 msg.type = WMA_SET_TX_POWER_REQ;
7020 msg.reserved = 0;
7021 msg.bodyptr = pTxParams;
7022
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08007023 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08007024 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307025 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
7027 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307028 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307029 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007030 }
7031
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307032 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007033}
7034
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307035QDF_STATUS sme_update_session_param(tHalHandle hal,
7036 uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307037 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007038{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307039 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307040 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041 uint16_t len;
7042
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307043 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307044 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307045 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307046 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
7047 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007048
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307049 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007050 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307051 sme_release_global_lock(&mac_ctx->sme);
7052 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053 }
7054
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05307055 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
7056 mac_ctx->ignore_assoc_disallowed = param_val;
7057
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307058 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307059 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307061 len = sizeof(*msg);
7062 msg = qdf_mem_malloc(len);
7063 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307064 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007065 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307066 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
7067 msg->length = len;
7068 msg->session_id = session_id;
7069 msg->param_type = param_type;
7070 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08007071 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007072 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05307073 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074 }
7075 return status;
7076}
7077
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307078/*
7079 * sme_set_tm_level() -
7080 * Set Thermal Mitigation Level to RIVA
7081 *
7082 * hHal - The handle returned by mac_open.
7083 * newTMLevel - new Thermal Mitigation Level
7084 * tmMode - Thermal Mitigation handle mode, default 0
7085 * Return QDF_STATUS
7086 */
7087QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
7088 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307090 QDF_STATUS status = QDF_STATUS_SUCCESS;
7091 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007092 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07007093 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094 tAniSetTmLevelReq *setTmLevelReq = NULL;
7095
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307096 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
7098 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307099 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007100 setTmLevelReq =
7101 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307102 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007103 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007105 "%s: Not able to allocate memory for sme_set_tm_level",
7106 __func__);
7107 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307108 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 }
7110
7111 setTmLevelReq->tmMode = tmMode;
7112 setTmLevelReq->newTmLevel = newTMLevel;
7113
7114 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08007115 message.bodyptr = setTmLevelReq;
7116 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05307117 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08007118 NO_SESSION, message.type));
7119 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
7120 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307121 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307124 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307125 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007126 }
7127 sme_release_global_lock(&pMac->sme);
7128 }
7129 return status;
7130}
7131
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307132/*
7133 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
7134 * Host and FW.
7135 *
7136 * hHal - HAL handle for device
7137 * Return NONE
7138 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139void sme_feature_caps_exchange(tHalHandle hHal)
7140{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307141 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307142 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
7143 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007144}
7145
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307146/*
7147 * sme_disable_feature_capablity() - SME interface to disable Active mode
7148 * offload capablity in Host.
7149 *
7150 * hHal - HAL handle for device
7151 * Return NONE
7152 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153void sme_disable_feature_capablity(uint8_t feature_index)
7154{
7155}
7156
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307157/*
7158 * sme_reset_power_values_for5_g
7159 * Reset the power values for 5G band with default power values.
7160 *
7161 * hHal - HAL handle for device
7162 * Return NONE
7163 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007164void sme_reset_power_values_for5_g(tHalHandle hHal)
7165{
7166 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307167
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307168 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007169 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
7170 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307171 /* Store the channel+power info in the global place: Cfg */
7172 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007173}
7174
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307175/*
7176 * sme_update_roam_prefer5_g_hz() -
7177 * Enable/disable Roam prefer 5G runtime option
7178 * This function is called through dynamic setConfig callback function
7179 * to configure the Roam prefer 5G runtime option
7180 *
7181 * hHal - HAL handle for device
7182 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
7183 * Return Success or failure
7184 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307186QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
7187 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188{
7189 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307190 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007191
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307192 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007193 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
7194 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307195 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007197 "%s: gRoamPrefer5GHz is changed from %d to %d",
7198 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
7199 nRoamPrefer5GHz);
7200 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
7201 sme_release_global_lock(&pMac->sme);
7202 }
7203
7204 return status;
7205}
7206
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307207/*
7208 * sme_set_roam_intra_band() -
7209 * enable/disable Intra band roaming
7210 * This function is called through dynamic setConfig callback function
7211 * to configure the intra band roaming
7212 * hHal - HAL handle for device
7213 * nRoamIntraBand Enable/Disable Intra band roaming
7214 * Return Success or failure
7215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307216QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007217{
7218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307219 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307221 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007222 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
7223 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307224 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007226 "%s: gRoamIntraBand is changed from %d to %d",
7227 __func__, pMac->roam.configParam.nRoamIntraBand,
7228 nRoamIntraBand);
7229 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
7230 sme_release_global_lock(&pMac->sme);
7231 }
7232
7233 return status;
7234}
7235
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307236/*
7237 * sme_update_roam_scan_n_probes() -
7238 * Function to update roam scan N probes
7239 * This function is called through dynamic setConfig callback function
7240 * to update roam scan N probes
7241 * hHal - HAL handle for device
7242 * sessionId - Session Identifier
7243 * nProbes number of probe requests to be sent out
7244 * Return Success or failure
7245 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307246QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007247 const uint8_t nProbes)
7248{
7249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307250 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307252 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
7254 NO_SESSION, 0));
7255 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307256 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307257 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007258 "%s: gRoamScanNProbes is changed from %d to %d",
7259 __func__, pMac->roam.configParam.nProbes, nProbes);
7260 pMac->roam.configParam.nProbes = nProbes;
7261 sme_release_global_lock(&pMac->sme);
7262 }
7263 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7264 csr_roam_offload_scan(pMac, sessionId,
7265 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7266 REASON_NPROBES_CHANGED);
7267 }
7268 return status;
7269}
7270
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307271/*
7272 * sme_update_roam_scan_home_away_time() -
7273 * Function to update roam scan Home away time
7274 * This function is called through dynamic setConfig callback function
7275 * to update roam scan home away time
7276 *
7277 * hHal - HAL handle for device
7278 * sessionId - Session Identifier
7279 * nRoamScanAwayTime Scan home away time
7280 * bSendOffloadCmd If true then send offload command to firmware
7281 * If false then command is not sent to firmware
7282 * Return Success or failure
7283 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307284QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007285 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307286 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287 const bool bSendOffloadCmd)
7288{
7289 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307290 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307292 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007293 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
7294 NO_SESSION, 0));
7295 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307296 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007298 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
7299 __func__,
7300 pMac->roam.configParam.nRoamScanHomeAwayTime,
7301 nRoamScanHomeAwayTime);
7302 pMac->roam.configParam.nRoamScanHomeAwayTime =
7303 nRoamScanHomeAwayTime;
7304 sme_release_global_lock(&pMac->sme);
7305 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307306 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
7307 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007308 csr_roam_offload_scan(pMac, sessionId,
7309 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7310 REASON_HOME_AWAY_TIME_CHANGED);
7311 }
7312 return status;
7313}
7314
Abhishek Singh518323d2015-10-19 17:42:01 +05307315/**
7316 * sme_ext_change_channel()- function to post send ECSA
7317 * action frame to csr.
7318 * @hHal: Hal context
7319 * @channel: new channel to switch
7320 * @session_id: senssion it should be sent on.
7321 *
7322 * This function is called to post ECSA frame to csr.
7323 *
7324 * Return: success if msg is sent else return failure
7325 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307326QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05307327 uint8_t session_id)
7328{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307329 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05307330 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
7331 uint8_t channel_state;
7332
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007333 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05307334 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07007335 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05307336
7337 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007338 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307339 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05307340 }
7341
7342 status = sme_acquire_global_lock(&mac_ctx->sme);
7343
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307344 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05307345 /* update the channel list to the firmware */
7346 status = csr_send_ext_change_channel(mac_ctx,
7347 channel, session_id);
7348 sme_release_global_lock(&mac_ctx->sme);
7349 }
7350
7351 return status;
7352}
7353
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307354/*
7355 * sme_get_roam_intra_band() -
7356 * get Intra band roaming
7357 *
7358 * hHal - HAL handle for device
7359 * Return Success or failure
7360 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361bool sme_get_roam_intra_band(tHalHandle hHal)
7362{
7363 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307364
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307365 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007366 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
7367 return pMac->roam.configParam.nRoamIntraBand;
7368}
7369
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307370/*
7371 * sme_get_roam_scan_n_probes() -
7372 * get N Probes
7373 *
7374 * hHal - HAL handle for device
7375 * Return Success or failure
7376 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007377uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
7378{
7379 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 return pMac->roam.configParam.nProbes;
7382}
7383
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307384/*
7385 * sme_get_roam_scan_home_away_time() -
7386 * get Roam scan home away time
7387 *
7388 * hHal - HAL handle for device
7389 * Return Success or failure
7390 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007391uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
7392{
7393 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007395 return pMac->roam.configParam.nRoamScanHomeAwayTime;
7396}
7397
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307398/*
7399 * sme_update_roam_rssi_diff() -
7400 * Update RoamRssiDiff
7401 * This function is called through dynamic setConfig callback function
7402 * to configure RoamRssiDiff
7403 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
7404 *
7405 * hHal - HAL handle for device
7406 * sessionId - Session Identifier
7407 * RoamRssiDiff - minimum rssi difference between potential
7408 * candidate and current AP.
7409 * Return Success or failure
7410 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007411
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307412QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 uint8_t RoamRssiDiff)
7414{
7415 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307416 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007417
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007418 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7419 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7420 FL("Invalid sme session id: %d"), sessionId);
7421 return QDF_STATUS_E_INVAL;
7422 }
7423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007424 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307425 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007427 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
7428 RoamRssiDiff,
7429 pMac->roam.configParam.RoamRssiDiff,
7430 mac_trace_get_neighbour_roam_state(pMac->roam.
7431 neighborRoamInfo
7432 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307433 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
7435 sme_release_global_lock(&pMac->sme);
7436 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007437
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307438 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 csr_roam_offload_scan(pMac, sessionId,
7440 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7441 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 return status;
7443}
7444
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307445/*
7446 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
7447 * support at runtime
7448 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7449 * isFastTransitionEnabled.
7450 * This is a synchronous call
7451 *
7452 * hHal - The handle returned by mac_open.
7453 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7454 * successfully.
7455 * Other status means SME is failed to update isFastTransitionEnabled.
7456 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307457QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458 bool isFastTransitionEnabled)
7459{
7460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307461 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007462
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307463 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7465 0));
7466 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307467 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307468 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469 "%s: FastTransitionEnabled is changed from %d to %d",
7470 __func__,
7471 pMac->roam.configParam.isFastTransitionEnabled,
7472 isFastTransitionEnabled);
7473 pMac->roam.configParam.isFastTransitionEnabled =
7474 isFastTransitionEnabled;
7475 sme_release_global_lock(&pMac->sme);
7476 }
7477
7478 return status;
7479}
7480
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307481/*
7482 * sme_update_wes_mode() -
7483 * Update WES Mode
7484 * This function is called through dynamic setConfig callback function
7485 * to configure isWESModeEnabled
7486 *
7487 * hHal - HAL handle for device
7488 * isWESModeEnabled - WES mode
7489 * sessionId - Session Identifier
7490 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7491 * Other status means SME is failed to update isWESModeEnabled.
7492 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007493
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307494QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007495 uint8_t sessionId)
7496{
7497 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307498 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007500 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7501 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7502 FL("Invalid sme session id: %d"), sessionId);
7503 return QDF_STATUS_E_INVAL;
7504 }
7505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007506 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307507 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307508 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007509 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7510 isWESModeEnabled,
7511 pMac->roam.configParam.isWESModeEnabled,
7512 mac_trace_get_neighbour_roam_state(pMac->roam.
7513 neighborRoamInfo
7514 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307515 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007516 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7517 sme_release_global_lock(&pMac->sme);
7518 }
7519
7520 return status;
7521}
7522
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307523/*
7524 * sme_set_roam_scan_control() -
7525 * Set roam scan control
7526 * This function is called to set roam scan control
7527 * if roam scan control is set to 0, roaming scan cache is cleared
7528 * any value other than 0 is treated as invalid value
7529 * hHal - HAL handle for device
7530 * sessionId - Session Identifier
7531 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7532 * Other status means SME failure to update
7533 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307534QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535 bool roamScanControl)
7536{
7537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307538 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307540 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007541 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007542
7543 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7544 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7545 FL("Invalid sme session id: %d"), sessionId);
7546 return QDF_STATUS_E_INVAL;
7547 }
7548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007549 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307550 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307551 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007552 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7553 roamScanControl,
7554 pMac->roam.configParam.nRoamScanControl,
7555 mac_trace_get_neighbour_roam_state(pMac->roam.
7556 neighborRoamInfo
7557 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307558 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007559 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7560 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307561 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307563 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7564 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7566 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307567 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7568 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569 }
7570 }
7571 sme_release_global_lock(&pMac->sme);
7572 }
7573 return status;
7574}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007575
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307576/*
7577 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7578 * support at runtime
7579 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7580 * isFastRoamIniFeatureEnabled.
7581 * This is a synchronous call
7582 *
7583 * hHal - The handle returned by mac_open.
7584 * sessionId - Session Identifier
7585 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7586 * successfully.
7587 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7588 */
7589QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7590 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7591{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007592 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7593
7594 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7595 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307596 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007597 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7598 __func__,
7599 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7600 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307601 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007602 }
7603
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307604 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007605 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7606 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7607 isFastRoamIniFeatureEnabled);
7608 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7609 isFastRoamIniFeatureEnabled;
7610 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307611 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007612
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307613 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007614}
7615
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307616/**
7617 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7618 * @hal - The handle returned by macOpen.
7619 * @session_id - Session Identifier
7620 * @is_fast_roam_enabled - flag to enable/disable roaming
7621 *
7622 * When Supplicant issues enabled/disable fast roaming on the basis
7623 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7624 *
7625 * Return: QDF_STATUS
7626 */
7627
7628QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7629 const bool is_fast_roam_enabled)
7630{
7631 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307632 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307633 QDF_STATUS status;
7634
Arif Hussaina48a9c02017-01-31 14:37:45 -08007635 /* do_not_roam flag is set in wlan_hdd_cfg80211_connect_start
7636 * when supplicant initiate connect request with BSSID.
7637 * This flag reset when supplicant sends vendor command to enable
7638 * roaming after association.
7639 *
7640 * This request from wpa_supplicant will be skipped in this function
7641 * if roaming is disabled using driver command or INI and do_not_roam
7642 * flag remains set. So make sure to set do_not_roam flag as per
7643 * wpa_supplicant even if roam request from wpa_supplicant ignored.
7644 */
7645 if (session && session->pCurRoamProfile)
7646 session->pCurRoamProfile->do_not_roam = !is_fast_roam_enabled;
7647
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307648 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007649 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307650 if (!is_fast_roam_enabled)
7651 return QDF_STATUS_SUCCESS;
7652 return QDF_STATUS_E_FAILURE;
7653 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307654
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307655 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7656 session_id, is_fast_roam_enabled);
7657 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007658 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307659 return QDF_STATUS_E_FAILURE;
7660 }
7661
7662 return QDF_STATUS_SUCCESS;
7663}
7664
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307665/*
7666 * sme_update_is_mawc_ini_feature_enabled() -
7667 * Enable/disable LFR MAWC support at runtime
7668 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7669 * isMAWCIniFeatureEnabled.
7670 * This is a synchronous call
7671 *
7672 * hHal - The handle returned by mac_open.
7673 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7674 * Other status means SME is failed to update MAWCEnabled.
7675 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307676QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677 const bool MAWCEnabled)
7678{
7679 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307680 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007681
7682 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307683 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307684 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007686 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7687 MAWCEnabled);
7688 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7689 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690 sme_release_global_lock(&pMac->sme);
7691 }
7692
7693 return status;
7694
7695}
7696
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007697/**
7698 * sme_stop_roaming() - Stop roaming for a given sessionId
7699 * This is a synchronous call
7700 *
7701 * @hHal - The handle returned by mac_open
7702 * @sessionId - Session Identifier
7703 *
7704 * Return QDF_STATUS_SUCCESS on success
7705 * Other status on failure
7706 */
7707QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007708{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007709 struct scheduler_msg wma_msg = {0};
7710 tSirRetStatus status;
7711 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007712 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7713 tpCsrNeighborRoamControlInfo roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007714
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007715 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007716 sme_err("incorrect session/vdev ID");
7717 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007719 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007720 req = qdf_mem_malloc(sizeof(*req));
7721 if (!req) {
7722 sme_err("failed to allocated memory");
7723 return QDF_STATUS_E_NOMEM;
7724 }
7725
7726 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307727 if (reason == eCsrForcedDisassoc)
7728 req->reason = REASON_ROAM_STOP_ALL;
7729 else
7730 req->reason = REASON_ROAM_SYNCH_FAILED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007731 req->sessionId = session_id;
7732 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007733 req->middle_of_roaming = 1;
7734 else
7735 csr_roam_reset_roam_params(mac_ctx);
7736
7737 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7738 wma_msg.bodyptr = req;
7739
7740 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7741 if (eSIR_SUCCESS != status) {
7742 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007743 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007744 qdf_mem_free(req);
7745 return QDF_STATUS_E_FAULT;
7746 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007747 roam_info->b_roam_scan_offload_started = false;
7748 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007749
7750 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751}
7752
Abhishek Singhd5686472017-09-20 15:18:50 +05307753void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7754{
7755 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7756 QDF_STATUS status = QDF_STATUS_SUCCESS;
7757 struct csr_roam_session *session;
7758
7759 status = sme_acquire_global_lock(&mac_ctx->sme);
7760 if (QDF_IS_STATUS_SUCCESS(status)) {
7761 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7762 session = CSR_GET_SESSION(mac_ctx, session_id);
7763 if (session)
7764 session->discon_in_progress = true;
7765 }
7766 sme_release_global_lock(&mac_ctx->sme);
7767 }
7768}
7769
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307770/*
7771 * sme_start_roaming() - Start roaming for a given sessionId
7772 * This is a synchronous call
7773 *
7774 * hHal - The handle returned by mac_open
7775 * sessionId - Session Identifier
7776 * Return QDF_STATUS_SUCCESS on success
7777 * Other status on failure
7778 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307779QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780{
7781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307782 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007783
7784 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307785 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7787 reason);
7788 sme_release_global_lock(&pMac->sme);
7789 }
7790
7791 return status;
7792}
7793
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307794/*
7795 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7796 * Concurrent session exists
7797 * This is a synchronuous call
7798 *
7799 * hHal - The handle returned by mac_open.
7800 * Return QDF_STATUS_SUCCESS
7801 * Other status means SME is failed
7802 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307803QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307805 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007806{
7807
7808 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307809 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810
7811 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307812 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007813 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7814 bFastRoamInConIniFeatureEnabled;
7815 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7816 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7817 0;
7818 }
7819 sme_release_global_lock(&pMac->sme);
7820 }
7821
7822 return status;
7823}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007824
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307825/*
7826 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7827 * Monitoring at runtime
7828 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7829 * fEnableFwRssiMonitoring.
7830 * This is a synchronous call
7831 *
7832 * hHal - The handle returned by mac_open.
7833 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7834 * config successfully.
7835 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7836 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307837QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007838 bool fEnableFwRssiMonitoring)
7839{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307840 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841
7842 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307843 fEnableFwRssiMonitoring) ==
7844 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307845 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307846 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007847 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7848 }
7849
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307850 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851}
7852
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307853/*
7854 * sme_set_roam_opportunistic_scan_threshold_diff() -
7855 * Update Opportunistic Scan threshold diff
7856 * This function is called through dynamic setConfig callback function
7857 * to configure nOpportunisticThresholdDiff
7858 *
7859 * hHal - HAL handle for device
7860 * sessionId - Session Identifier
7861 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7862 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7863 * successfully.
7864 * else SME is failed to update nOpportunisticThresholdDiff.
7865 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307866QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867 uint8_t sessionId,
7868 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307869 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007870{
7871 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307872 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007873
7874 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307875 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007876 status = csr_neighbor_roam_update_config(pMac, sessionId,
7877 nOpportunisticThresholdDiff,
7878 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307879 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007880 pMac->roam.configParam.neighborRoamConfig.
7881 nOpportunisticThresholdDiff =
7882 nOpportunisticThresholdDiff;
7883 }
7884 sme_release_global_lock(&pMac->sme);
7885 }
7886 return status;
7887}
7888
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307889/*
7890 * sme_get_roam_opportunistic_scan_threshold_diff()
7891 * gets Opportunistic Scan threshold diff
7892 * This is a synchronous call
7893 *
7894 * hHal - The handle returned by mac_open
7895 * Return uint8_t - nOpportunisticThresholdDiff
7896 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007897uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7898{
7899 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901 return pMac->roam.configParam.neighborRoamConfig.
7902 nOpportunisticThresholdDiff;
7903}
7904
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307905/*
7906 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7907 * This function is called through dynamic setConfig callback function
7908 * to configure nRoamRescanRssiDiff
7909 *
7910 * hHal - HAL handle for device
7911 * sessionId - Session Identifier
7912 * nRoamRescanRssiDiff - roam rescan rssi diff
7913 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7914 * successfully.
7915 * else SME is failed to update nRoamRescanRssiDiff.
7916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307917QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007918 uint8_t sessionId,
7919 const uint8_t nRoamRescanRssiDiff)
7920{
7921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307922 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007923
7924 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307925 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007926 status = csr_neighbor_roam_update_config(pMac, sessionId,
7927 nRoamRescanRssiDiff,
7928 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307929 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007930 pMac->roam.configParam.neighborRoamConfig.
7931 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7932 }
7933 sme_release_global_lock(&pMac->sme);
7934 }
7935 return status;
7936}
7937
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307938/*
7939 * sme_get_roam_rescan_rssi_diff()
7940 * gets roam rescan rssi diff
7941 * This is a synchronous call
7942 *
7943 * hHal - The handle returned by mac_open
7944 * Return int8_t - nRoamRescanRssiDiff
7945 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7947{
7948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007950 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7951}
7952
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307953/*
7954 * sme_set_roam_bmiss_first_bcnt() -
7955 * Update Roam count for first beacon miss
7956 * This function is called through dynamic setConfig callback function
7957 * to configure nRoamBmissFirstBcnt
7958 * hHal - HAL handle for device
7959 * sessionId - Session Identifier
7960 * nRoamBmissFirstBcnt - Roam first bmiss count
7961 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7962 * successfully.
7963 * else SME is failed to update nRoamBmissFirstBcnt
7964 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307965QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 uint8_t sessionId,
7967 const uint8_t nRoamBmissFirstBcnt)
7968{
7969 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307970 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971
7972 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307973 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007974 status = csr_neighbor_roam_update_config(pMac, sessionId,
7975 nRoamBmissFirstBcnt,
7976 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307977 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007978 pMac->roam.configParam.neighborRoamConfig.
7979 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7980 }
7981 sme_release_global_lock(&pMac->sme);
7982 }
7983 return status;
7984}
7985
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307986/*
7987 * sme_get_roam_bmiss_first_bcnt() -
7988 * get neighbor roam beacon miss first count
7989 *
7990 * hHal - The handle returned by mac_open.
7991 * Return uint8_t - neighbor roam beacon miss first count
7992 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007993uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7994{
7995 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307996
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7998}
7999
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308000/*
8001 * sme_set_roam_bmiss_final_bcnt() -
8002 * Update Roam count for final beacon miss
8003 * This function is called through dynamic setConfig callback function
8004 * to configure nRoamBmissFinalBcnt
8005 * hHal - HAL handle for device
8006 * sessionId - Session Identifier
8007 * nRoamBmissFinalBcnt - Roam final bmiss count
8008 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
8009 * successfully.
8010 * else SME is failed to update nRoamBmissFinalBcnt
8011 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308012QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008013 uint8_t sessionId,
8014 const uint8_t nRoamBmissFinalBcnt)
8015{
8016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308017 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008018
8019 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308020 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07008021 status = csr_neighbor_roam_update_config(pMac, sessionId,
8022 nRoamBmissFinalBcnt,
8023 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308024 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008025 pMac->roam.configParam.neighborRoamConfig.
8026 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
8027 }
8028 sme_release_global_lock(&pMac->sme);
8029 }
8030 return status;
8031}
8032
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308033/*
8034 * sme_get_roam_bmiss_final_bcnt() -
8035 * gets Roam count for final beacon miss
8036 * This is a synchronous call
8037 *
8038 * hHal - The handle returned by mac_open
8039 * Return uint8_t - nRoamBmissFinalBcnt
8040 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008041uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
8042{
8043 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
8046}
8047
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308048/*
8049 * sme_set_roam_beacon_rssi_weight() -
8050 * Update Roam beacon rssi weight
8051 * This function is called through dynamic setConfig callback function
8052 * to configure nRoamBeaconRssiWeight
8053 *
8054 * hHal - HAL handle for device
8055 * sessionId - Session Identifier
8056 * nRoamBeaconRssiWeight - Roam beacon rssi weight
8057 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
8058 * successfully.
8059 * else SME is failed to update nRoamBeaconRssiWeight
8060 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308061QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008062 uint8_t sessionId,
8063 const uint8_t nRoamBeaconRssiWeight)
8064{
8065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308066 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008067
8068 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308069 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07008070 status = csr_neighbor_roam_update_config(pMac, sessionId,
8071 nRoamBeaconRssiWeight,
8072 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308073 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008074 pMac->roam.configParam.neighborRoamConfig.
8075 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
8076 }
8077 sme_release_global_lock(&pMac->sme);
8078 }
8079 return status;
8080}
8081
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308082/*
8083 * sme_get_roam_beacon_rssi_weight() -
8084 * gets Roam beacon rssi weight
8085 * This is a synchronous call
8086 *
8087 * hHal - The handle returned by mac_open
8088 * Return uint8_t - nRoamBeaconRssiWeight
8089 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
8091{
8092 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008094 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
8095}
8096
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308097/*
8098 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
8099 * rssi threshold
8100 * This is a synchronous call
8101 *
8102 * hHal - The handle returned by mac_open.
8103 * sessionId - Session Identifier
8104 * Return QDF_STATUS_SUCCESS - SME update config successful.
8105 * Other status means SME is failed to update
8106 */
8107QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
8108 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
8109{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308111 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112
8113 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308114 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07008115 status = csr_neighbor_roam_update_config(pMac,
8116 sessionId, neighborLookupRssiThreshold,
8117 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308118 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008119 pMac->roam.configParam.neighborRoamConfig.
8120 nNeighborLookupRssiThreshold =
8121 neighborLookupRssiThreshold;
8122 }
8123 sme_release_global_lock(&pMac->sme);
8124 }
8125 return status;
8126}
8127
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308128/*
8129 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
8130 * This is a synchronous call
8131 *
8132 * hal - The handle returned by macOpen.
8133 * session_id - Session Identifier
8134 * delay_before_vdev_stop - value to be set
8135 * Return QDF_STATUS_SUCCESS - SME update config successful.
8136 * Other status means SME is failed to update
8137 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308138QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139 uint8_t session_id,
8140 uint8_t delay_before_vdev_stop)
8141{
8142 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308143 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008144
8145 if (session_id >= CSR_ROAM_SESSION_MAX) {
8146 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8147 FL("Invalid sme session id: %d"), session_id);
8148 return QDF_STATUS_E_INVAL;
8149 }
8150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008151 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308152 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308153 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
8154 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008155 pMac->roam.configParam.neighborRoamConfig.
8156 delay_before_vdev_stop,
8157 delay_before_vdev_stop);
8158 pMac->roam.neighborRoamInfo[session_id].cfgParams.
8159 delay_before_vdev_stop = delay_before_vdev_stop;
8160 pMac->roam.configParam.neighborRoamConfig.
8161 delay_before_vdev_stop = delay_before_vdev_stop;
8162 sme_release_global_lock(&pMac->sme);
8163 }
8164 return status;
8165}
8166
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308167/*
8168 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
8169 * rssi threshold
8170 * This is a synchronous call
8171 *
8172 * hHal - The handle returned by mac_open.
8173 * Return QDF_STATUS_SUCCESS - SME update config successful.
8174 * Other status means SME is failed to update
8175 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008176uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
8177{
8178 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308179
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008180 return pMac->roam.configParam.neighborRoamConfig.
8181 nNeighborLookupRssiThreshold;
8182}
8183
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308184/*
8185 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
8186 * refresh period
8187 * This is a synchronous call
8188 *
8189 * hHal - The handle returned by mac_open.
8190 * sessionId - Session Identifier
8191 * Return QDF_STATUS_SUCCESS - SME update config successful.
8192 * Other status means SME is failed to update
8193 */
8194QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
8195 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
8196{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308198 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308199 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008200 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8201
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008202 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8203 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8204 FL("Invalid sme session id: %d"), sessionId);
8205 return QDF_STATUS_E_INVAL;
8206 }
8207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008208 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308209 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008210 pNeighborRoamConfig =
8211 &pMac->roam.configParam.neighborRoamConfig;
8212 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308213 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
8215 neighborScanResultsRefreshPeriod,
8216 pMac->roam.configParam.neighborRoamConfig.
8217 nNeighborResultsRefreshPeriod,
8218 mac_trace_get_neighbour_roam_state(pMac->roam.
8219 neighborRoamInfo
8220 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308221 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008222 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
8223 neighborScanResultsRefreshPeriod;
8224 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
8225 neighborScanResultsRefreshPeriod;
8226
8227 sme_release_global_lock(&pMac->sme);
8228 }
8229 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8230 csr_roam_offload_scan(pMac, sessionId,
8231 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308232 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008233 }
8234 return status;
8235}
8236
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308237/*
8238 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
8239 * offload feaure
8240 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
8241 * gRoamScanOffloadEnabled.
8242 * This is a synchronous call
8243 *
8244 * hHal - The handle returned by mac_open.
8245 * Return QDF_STATUS_SUCCESS - SME update config successfully.
8246 * Other status means SME is failed to update.
8247 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308248QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008249 bool nRoamScanOffloadEnabled)
8250{
8251 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308252 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253
8254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308255 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308256 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308257 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 pMac->roam.configParam.isRoamOffloadScanEnabled,
8259 nRoamScanOffloadEnabled);
8260 pMac->roam.configParam.isRoamOffloadScanEnabled =
8261 nRoamScanOffloadEnabled;
8262 sme_release_global_lock(&pMac->sme);
8263 }
8264
8265 return status;
8266}
8267
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308268/*
8269 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
8270 * refresh period
8271 * This is a synchronous call
8272 *
8273 * \param hHal - The handle returned by mac_open.
8274 * \return uint16_t - Neighbor scan results refresh period value
8275 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008276uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
8277{
8278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008280 return pMac->roam.configParam.neighborRoamConfig.
8281 nNeighborResultsRefreshPeriod;
8282}
8283
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308284/*
8285 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
8286 * This is a synchronuous call
8287 *
8288 * hHal - The handle returned by mac_open.
8289 * Return QDF_STATUS_SUCCESS - SME update config successful.
8290 * Other status means SME is failed to update
8291 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008292uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
8293{
8294 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008296 return pMac->roam.configParam.neighborRoamConfig.
8297 nEmptyScanRefreshPeriod;
8298}
8299
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308300/*
8301 * sme_update_empty_scan_refresh_period
8302 * Update nEmptyScanRefreshPeriod
8303 * This function is called through dynamic setConfig callback function
8304 * to configure nEmptyScanRefreshPeriod
8305 * Usage: adb shell iwpriv wlan0 setConfig
8306 * nEmptyScanRefreshPeriod=[0 .. 60]
8307 *
8308 * hHal - HAL handle for device
8309 * sessionId - Session Identifier
8310 * nEmptyScanRefreshPeriod - scan period following empty scan results.
8311 * Return Success or failure
8312 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008313
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308314QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
8315 sessionId, uint16_t
8316 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008317{
8318 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308319 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308320 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008321 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8322
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008323 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8324 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8325 FL("Invalid sme session id: %d"), sessionId);
8326 return QDF_STATUS_E_INVAL;
8327 }
8328
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308330 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331 pNeighborRoamConfig =
8332 &pMac->roam.configParam.neighborRoamConfig;
8333 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308334 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008335 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
8336 nEmptyScanRefreshPeriod,
8337 pMac->roam.configParam.neighborRoamConfig.
8338 nEmptyScanRefreshPeriod,
8339 mac_trace_get_neighbour_roam_state(pMac->roam.
8340 neighborRoamInfo
8341 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308342 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008343 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
8344 nEmptyScanRefreshPeriod;
8345 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
8346 nEmptyScanRefreshPeriod;
8347 sme_release_global_lock(&pMac->sme);
8348 }
8349 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8350 csr_roam_offload_scan(pMac, sessionId,
8351 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8352 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
8353 }
8354 return status;
8355}
8356
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308357/*
8358 * sme_set_neighbor_scan_min_chan_time() -
8359 * Update nNeighborScanMinChanTime
8360 * This function is called through dynamic setConfig callback function
8361 * to configure gNeighborScanChannelMinTime
8362 * Usage: adb shell iwpriv wlan0 setConfig
8363 * gNeighborScanChannelMinTime=[0 .. 60]
8364 *
8365 * hHal - HAL handle for device
8366 * nNeighborScanMinChanTime - Channel minimum dwell time
8367 * sessionId - Session Identifier
8368 * Return Success or failure
8369 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308370QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008371 const uint16_t
8372 nNeighborScanMinChanTime,
8373 uint8_t sessionId)
8374{
8375 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308376 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008377
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008378 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8379 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8380 FL("Invalid sme session id: %d"), sessionId);
8381 return QDF_STATUS_E_INVAL;
8382 }
8383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308385 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308386 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008387 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
8388 nNeighborScanMinChanTime,
8389 pMac->roam.configParam.neighborRoamConfig.
8390 nNeighborScanMinChanTime,
8391 mac_trace_get_neighbour_roam_state(pMac->roam.
8392 neighborRoamInfo
8393 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308394 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008395
8396 pMac->roam.configParam.neighborRoamConfig.
8397 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
8398 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8399 minChannelScanTime = nNeighborScanMinChanTime;
8400 sme_release_global_lock(&pMac->sme);
8401 }
8402
8403 return status;
8404}
8405
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308406/*
8407 * sme_set_neighbor_scan_max_chan_time() -
8408 * Update nNeighborScanMaxChanTime
8409 * This function is called through dynamic setConfig callback function
8410 * to configure gNeighborScanChannelMaxTime
8411 * Usage: adb shell iwpriv wlan0 setConfig
8412 * gNeighborScanChannelMaxTime=[0 .. 60]
8413 *
8414 * hHal - HAL handle for device
8415 * sessionId - Session Identifier
8416 * nNeighborScanMinChanTime - Channel maximum dwell time
8417 * Return Success or failure
8418 */
8419QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
8420 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421 const uint16_t
8422 nNeighborScanMaxChanTime)
8423{
8424 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308425 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308426 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008427 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8428
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008429 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8430 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8431 FL("Invalid sme session id: %d"), sessionId);
8432 return QDF_STATUS_E_INVAL;
8433 }
8434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308436 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008437 pNeighborRoamConfig =
8438 &pMac->roam.configParam.neighborRoamConfig;
8439 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308440 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8442 nNeighborScanMaxChanTime,
8443 pMac->roam.configParam.neighborRoamConfig.
8444 nNeighborScanMaxChanTime,
8445 mac_trace_get_neighbour_roam_state(pMac->roam.
8446 neighborRoamInfo
8447 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308448 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008449 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8450 nNeighborScanMaxChanTime;
8451 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8452 nNeighborScanMaxChanTime;
8453 sme_release_global_lock(&pMac->sme);
8454 }
8455 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8456 csr_roam_offload_scan(pMac, sessionId,
8457 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8458 REASON_SCAN_CH_TIME_CHANGED);
8459 }
8460
8461 return status;
8462}
8463
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308464/*
8465 * sme_get_neighbor_scan_min_chan_time() -
8466 * get neighbor scan min channel time
8467 *
8468 * hHal - The handle returned by mac_open.
8469 * sessionId - Session Identifier
8470 * Return uint16_t - channel min time value
8471 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008472uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8473{
8474 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008475
8476 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8477 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8478 FL("Invalid sme session id: %d"), sessionId);
8479 return 0;
8480 }
8481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8483 minChannelScanTime;
8484}
8485
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308486/*
8487 * sme_get_neighbor_roam_state() -
8488 * get neighbor roam state
8489 *
8490 * hHal - The handle returned by mac_open.
8491 * sessionId - Session Identifier
8492 * Return uint32_t - neighbor roam state
8493 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8495{
8496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008497
8498 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8500 FL("Invalid sme session id: %d"), sessionId);
8501 return 0;
8502 }
8503
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008504 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8505}
8506
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308507/*
8508 * sme_get_current_roam_state() -
8509 * get current roam state
8510 *
8511 * hHal - The handle returned by mac_open.
8512 * sessionId - Session Identifier
8513 * Return uint32_t - current roam state
8514 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8516{
8517 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519 return pMac->roam.curState[sessionId];
8520}
8521
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308522/*
8523 * sme_get_current_roam_sub_state() -
8524 * \brief get neighbor roam sub state
8525 *
8526 * hHal - The handle returned by mac_open.
8527 * sessionId - Session Identifier
8528 * Return uint32_t - current roam sub state
8529 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008530uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8531{
8532 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308533
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534 return pMac->roam.curSubState[sessionId];
8535}
8536
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308537/*
8538 * sme_get_lim_sme_state() -
8539 * get Lim Sme state
8540 *
8541 * hHal - The handle returned by mac_open.
8542 * Return uint32_t - Lim Sme state
8543 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008544uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8545{
8546 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548 return pMac->lim.gLimSmeState;
8549}
8550
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308551/*
8552 * sme_get_lim_mlm_state() -
8553 * get Lim Mlm state
8554 *
8555 * hHal - The handle returned by mac_open.
8556 * Return uint32_t - Lim Mlm state
8557 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8559{
8560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562 return pMac->lim.gLimMlmState;
8563}
8564
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308565/*
8566 * sme_is_lim_session_valid() -
8567 * is Lim session valid
8568 *
8569 * hHal - The handle returned by mac_open.
8570 * sessionId - Session Identifier
8571 * Return bool - true or false
8572 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008573bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8574{
8575 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308576
8577 if (sessionId > pMac->lim.maxBssId)
8578 return false;
8579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008580 return pMac->lim.gpSession[sessionId].valid;
8581}
8582
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308583/*
8584 * sme_get_lim_sme_session_state() -
8585 * get Lim Sme session state
8586 *
8587 * hHal - The handle returned by mac_open.
8588 * sessionId - Session Identifier
8589 * Return uint32_t - Lim Sme session state
8590 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008591uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8592{
8593 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008595 return pMac->lim.gpSession[sessionId].limSmeState;
8596}
8597
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308598/*
8599 * sme_get_lim_mlm_session_state() -
8600 * \brief get Lim Mlm session state
8601 *
8602 * hHal - The handle returned by mac_open.
8603 * sessionId - Session Identifier
8604 * Return uint32_t - Lim Mlm session state
8605 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008606uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8607{
8608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 return pMac->lim.gpSession[sessionId].limMlmState;
8611}
8612
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308613/*
8614 * sme_get_neighbor_scan_max_chan_time() -
8615 * get neighbor scan max channel time
8616 *
8617 * hHal - The handle returned by mac_open.
8618 * sessionId - Session Identifier
8619 * Return uint16_t - channel max time value
8620 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008621uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8622{
8623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008624
8625 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8626 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8627 FL("Invalid sme session id: %d"), sessionId);
8628 return 0;
8629 }
8630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008631 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8632 maxChannelScanTime;
8633}
8634
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308635/*
8636 * sme_set_neighbor_scan_period() -
8637 * Update nNeighborScanPeriod
8638 * This function is called through dynamic setConfig callback function
8639 * to configure nNeighborScanPeriod
8640 * Usage: adb shell iwpriv wlan0 setConfig
8641 * nNeighborScanPeriod=[0 .. 1000]
8642 *
8643 * hHal - HAL handle for device
8644 * sessionId - Session Identifier
8645 * nNeighborScanPeriod - neighbor scan period
8646 * Return Success or failure
8647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308648QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 const uint16_t nNeighborScanPeriod)
8650{
8651 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308652 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308653 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008654 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8655
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008656 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8657 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8658 FL("Invalid sme session id: %d"), sessionId);
8659 return QDF_STATUS_E_INVAL;
8660 }
8661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008662 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308663 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008664 pNeighborRoamConfig =
8665 &pMac->roam.configParam.neighborRoamConfig;
8666 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308668 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008669 nNeighborScanPeriod,
8670 pMac->roam.configParam.neighborRoamConfig.
8671 nNeighborScanTimerPeriod,
8672 mac_trace_get_neighbour_roam_state(pMac->roam.
8673 neighborRoamInfo
8674 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308675 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008676 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8677 nNeighborScanPeriod;
8678 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8679 nNeighborScanPeriod;
8680 sme_release_global_lock(&pMac->sme);
8681 }
8682 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8683 csr_roam_offload_scan(pMac, sessionId,
8684 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8685 REASON_SCAN_HOME_TIME_CHANGED);
8686 }
8687
8688 return status;
8689}
8690
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308691/*
8692 * sme_get_neighbor_scan_period() -
8693 * get neighbor scan period
8694 *
8695 * hHal - The handle returned by mac_open.
8696 * sessionId - Session Identifier
8697 * Return uint16_t - neighbor scan period
8698 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008699uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8700{
8701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008702
8703 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8705 FL("Invalid sme session id: %d"), sessionId);
8706 return 0;
8707 }
8708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008709 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8710 neighborScanPeriod;
8711}
8712
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308713/**
8714 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8715 * This function is called through dynamic setConfig callback function
8716 * to configure neighbor_scan_min_period
8717 *
8718 * @hal - HAL handle for device
8719 * @session_id - Session Identifier
8720 * @neighbor_scan_min_period - neighbor scan min period
8721 *
8722 * Return - QDF_STATUS
8723 */
8724QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8725 uint8_t session_id,
8726 const uint16_t
8727 neighbor_scan_min_period)
8728{
8729 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8730 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308731 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308732 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008733
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308734 if (session_id >= CSR_ROAM_SESSION_MAX) {
8735 sme_err("Invalid sme session id: %d", session_id);
8736 return QDF_STATUS_E_INVAL;
8737 }
8738
8739 status = sme_acquire_global_lock(&pmac->sme);
8740 if (QDF_IS_STATUS_SUCCESS(status)) {
8741 p_neighbor_roam_config =
8742 &pmac->roam.configParam.neighborRoamConfig;
8743 p_neighbor_roam_info = &pmac->
8744 roam.neighborRoamInfo[session_id];
8745 sme_debug("LFR:set neighbor scan min period, old:%d, "
8746 "new: %d, state: %s",
8747 pmac->roam.configParam.neighborRoamConfig.
8748 neighbor_scan_min_timer_period,
8749 neighbor_scan_min_period,
8750 mac_trace_get_neighbour_roam_state(pmac->roam.
8751 neighborRoamInfo[session_id].
8752 neighborRoamState));
8753 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8754 neighbor_scan_min_period;
8755 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8756 neighbor_scan_min_period;
8757 sme_release_global_lock(&pmac->sme);
8758 }
8759
8760 return status;
8761}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008762
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308763/*
8764 * sme_get_roam_rssi_diff() - get Roam rssi diff
8765 * This is a synchronous call
8766 *
8767 * hHal - The handle returned by mac_open.
8768 * Return uint16_t - Rssi diff value
8769 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008770uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8771{
8772 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 return pMac->roam.configParam.RoamRssiDiff;
8775}
8776
8777/**
8778 * sme_change_roam_scan_channel_list() - to change scan channel list
8779 * @hHal: pointer HAL handle returned by mac_open
8780 * @sessionId: sme session id
8781 * @pChannelList: Output channel list
8782 * @numChannels: Output number of channels
8783 *
8784 * This routine is called to Change roam scan channel list.
8785 * This is a synchronous call
8786 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308787 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008788 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308789QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008790 uint8_t *pChannelList,
8791 uint8_t numChannels)
8792{
8793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308794 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008795 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008796 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8797 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8798 uint8_t i = 0, j = 0;
8799 tCsrChannelInfo *chan_info;
8800
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008801 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8803 FL("Invalid sme session id: %d"), sessionId);
8804 return QDF_STATUS_E_INVAL;
8805 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008806
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008807 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008808 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308809 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8811 csr_roam_offload_scan(pMac, sessionId,
8812 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8813 REASON_CHANNEL_LIST_CHANGED);
8814 return status;
8815 }
8816 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8817
8818 if (NULL != chan_info->ChannelList) {
8819 for (i = 0; i < chan_info->numOfChannels; i++) {
8820 if (j < sizeof(oldChannelList))
8821 j += snprintf(oldChannelList + j,
8822 sizeof(oldChannelList) -
8823 j, "%d",
8824 chan_info->ChannelList[i]);
8825 else
8826 break;
8827 }
8828 }
8829 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8830 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8831 numChannels);
8832 sme_set_roam_scan_control(hHal, sessionId, 1);
8833 if (NULL != chan_info->ChannelList) {
8834 j = 0;
8835 for (i = 0; i < chan_info->numOfChannels; i++) {
8836 if (j < sizeof(newChannelList))
8837 j += snprintf(newChannelList + j,
8838 sizeof(newChannelList) -
8839 j, " %d",
8840 chan_info->ChannelList[i]);
8841 else
8842 break;
8843 }
8844 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308845 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308846 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308848 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 sme_release_global_lock(&pMac->sme);
8850
8851 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8852 csr_roam_offload_scan(pMac, sessionId,
8853 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8854 REASON_CHANNEL_LIST_CHANGED);
8855 return status;
8856}
8857
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008858/**
8859 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8860 * @hHal: HAL pointer
8861 * @pChannelList: Output channel list
8862 * @pNumChannels: Output number of channels
8863 * @sessionId: Session Identifier
8864 *
8865 * To get roam scan channel list This is a synchronous call
8866 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308869QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 uint8_t *pChannelList, uint8_t *pNumChannels,
8871 uint8_t sessionId)
8872{
8873 int i = 0;
8874 uint8_t *pOutPtr = pChannelList;
8875 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008876 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308877 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008879 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8880 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8881 FL("Invalid sme session id: %d"), sessionId);
8882 return QDF_STATUS_E_INVAL;
8883 }
8884
8885 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008886 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308887 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 return status;
8889 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308890 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891 FL("Roam Scan channel list is NOT yet initialized"));
8892 *pNumChannels = 0;
8893 sme_release_global_lock(&pMac->sme);
8894 return status;
8895 }
8896
8897 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308898 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 pOutPtr[i] =
8900 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902 pOutPtr[i] = '\0';
8903 sme_release_global_lock(&pMac->sme);
8904 return status;
8905}
8906
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308907/*
8908 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8909 * This is a synchronuous call
8910 *
8911 * hHal - The handle returned by mac_open.
8912 * Return true (1) - if the ESE feature is enabled
8913 * false (0) - if feature is disabled (compile or runtime)
8914 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008915bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8916{
8917#ifdef FEATURE_WLAN_ESE
8918 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008920 return csr_roam_is_ese_ini_feature_enabled(pMac);
8921#else
8922 return false;
8923#endif
8924}
8925
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308926/*
8927 * sme_get_wes_mode() - get WES Mode
8928 * This is a synchronous call
8929 *
8930 * hHal - The handle returned by mac_open
8931 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8932 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933bool sme_get_wes_mode(tHalHandle hHal)
8934{
8935 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008937 return pMac->roam.configParam.isWESModeEnabled;
8938}
8939
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308940/*
8941 * sme_get_roam_scan_control() - get scan control
8942 * This is a synchronous call
8943 *
8944 * hHal - The handle returned by mac_open.
8945 * Return bool - Enabled(1)/Disabled(0)
8946 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008947bool sme_get_roam_scan_control(tHalHandle hHal)
8948{
8949 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308950
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008951 return pMac->roam.configParam.nRoamScanControl;
8952}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008953
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308954/*
8955 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8956 * This is a synchronuous call
8957 * hHal - The handle returned by mac_open.
8958 * Return true (1) - if the feature is enabled
8959 * false (0) - if feature is disabled (compile or runtime)
8960 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008961bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8962{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008963 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008965 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008966}
8967
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308968/*
8969 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8970 * This is a synchronuous call
8971 *
8972 * hHal - The handle returned by mac_open.
8973 * Return true (1) - if the feature is enabled
8974 * false (0) - if feature is disabled (compile or runtime)
8975 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008976bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8977{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008981}
8982
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008983/**
8984 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8985 * @feature: enum value of requested feature.
8986 *
8987 * Retrun: 1 if supported; 0 otherwise
8988 */
8989bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008990{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008991 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008992}
8993
8994#ifdef FEATURE_WLAN_TDLS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308995/*
8996 * sme_update_fw_tdls_state() -
8997 * SME will send message to WMA to set TDLS state in f/w
8998 *
8999 * hHal - The handle returned by mac_open
9000 * psmeTdlsParams - TDLS state info to update in f/w
9001 * useSmeLock - Need to acquire SME Global Lock before state update or not
9002 * Return QDF_STATUS
9003 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309004QDF_STATUS sme_update_fw_tdls_state(tHalHandle hHal, void *psmeTdlsParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009005 bool useSmeLock)
9006{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309007 QDF_STATUS status = QDF_STATUS_SUCCESS;
9008 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009009 tpAniSirGlobal pMac = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009010 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009011
Mukul Sharmaeae172c2016-09-03 13:40:46 +05309012 pMac = PMAC_STRUCT(hHal);
9013 if (NULL == pMac) {
9014 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9015 FL("pMac is Null"));
9016 return QDF_STATUS_E_FAILURE;
9017 }
9018
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009019 /* only acquire sme global lock before state update if asked to */
9020 if (useSmeLock) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009021 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309022 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009023 return status;
9024 }
9025
9026 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009027 message.bodyptr = psmeTdlsParams;
9028 message.type = WMA_UPDATE_FW_TDLS_STATE;
9029 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309030 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
9031 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009032
9033 /* release the lock if it was acquired */
9034 if (useSmeLock)
9035 sme_release_global_lock(&pMac->sme);
9036
9037 return status;
9038}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009039#endif /* FEATURE_WLAN_TDLS */
9040
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309041QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009042 void *plsContext,
9043 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
9044 void *pContext))
9045{
9046
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309047 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08009048 tpAniSirGlobal pMac;
9049 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05309050 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009051
Jeff Johnsona5317a62017-01-26 08:51:25 -08009052 if (!hHal || !pCallbackfn || !lsReq) {
9053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9054 FL("Invalid parameter"));
9055 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009056 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08009057
Mukul Sharmac3886aa2017-05-04 17:53:22 +05309058 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
9059 if (!wma_handle) {
9060 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9061 "wma handle is NULL");
9062 return QDF_STATUS_E_FAILURE;
9063 }
9064
Jeff Johnsona5317a62017-01-26 08:51:25 -08009065 pMac = PMAC_STRUCT(hHal);
9066 req = qdf_mem_malloc(sizeof(*req));
9067 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07009068 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08009069 return QDF_STATUS_E_NOMEM;
9070 }
9071 *req = *lsReq;
9072
9073 status = sme_acquire_global_lock(&pMac->sme);
9074 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07009075 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08009076 qdf_mem_free(req);
9077 return QDF_STATUS_E_FAILURE;
9078 }
9079
9080 pMac->sme.pLinkSpeedCbContext = plsContext;
9081 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05309082 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08009083 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08009084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009085 return status;
9086}
9087
Will Huang558f8082017-05-31 16:22:24 +08009088QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
9089 void *context,
9090 void (*callbackfn)(struct sir_peer_info_resp *param,
9091 void *pcontext))
9092{
9093
9094 QDF_STATUS status;
9095 QDF_STATUS qdf_status;
9096 tpAniSirGlobal mac = PMAC_STRUCT(hal);
9097 struct scheduler_msg message;
9098
9099 status = sme_acquire_global_lock(&mac->sme);
9100 if (QDF_STATUS_SUCCESS == status) {
9101 if (NULL == callbackfn) {
9102 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9103 "%s: Indication Call back is NULL",
9104 __func__);
9105 sme_release_global_lock(&mac->sme);
9106 return QDF_STATUS_E_FAILURE;
9107 }
9108
9109 mac->sme.pget_peer_info_ind_cb = callbackfn;
9110 mac->sme.pget_peer_info_cb_context = context;
9111
9112 /* serialize the req through MC thread */
9113 message.bodyptr = qdf_mem_malloc(sizeof(req));
9114 if (NULL == message.bodyptr) {
9115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9116 "%s: Memory allocation failed.", __func__);
9117 sme_release_global_lock(&mac->sme);
9118 return QDF_STATUS_E_NOMEM;
9119 }
9120 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
9121 message.type = WMA_GET_PEER_INFO;
9122 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
9123 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9125 "%s: Post get peer info msg fail", __func__);
9126 qdf_mem_free(message.bodyptr);
9127 status = QDF_STATUS_E_FAILURE;
9128 }
9129 sme_release_global_lock(&mac->sme);
9130 }
9131 return status;
9132}
9133
9134QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
9135 struct sir_peer_info_ext_req *req,
9136 void *context,
9137 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
9138 void *pcontext))
9139{
9140 QDF_STATUS status;
9141 QDF_STATUS qdf_status;
9142 tpAniSirGlobal mac = PMAC_STRUCT(hal);
9143 struct scheduler_msg message;
9144
9145 status = sme_acquire_global_lock(&mac->sme);
9146 if (QDF_STATUS_SUCCESS == status) {
9147 if (NULL == callbackfn) {
9148 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9149 "%s: Indication Call back is NULL",
9150 __func__);
9151 sme_release_global_lock(&mac->sme);
9152 return QDF_STATUS_E_FAILURE;
9153 }
9154
9155 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
9156 mac->sme.pget_peer_info_ext_cb_context = context;
9157
9158 /* serialize the req through MC thread */
9159 message.bodyptr =
9160 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
9161 if (NULL == message.bodyptr) {
9162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9163 "%s: Memory allocation failed.", __func__);
9164 sme_release_global_lock(&mac->sme);
9165 return QDF_STATUS_E_NOMEM;
9166 }
9167 qdf_mem_copy(message.bodyptr,
9168 req,
9169 sizeof(struct sir_peer_info_ext_req));
9170 message.type = WMA_GET_PEER_INFO_EXT;
9171 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
9172 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9173 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9174 "%s: Post get rssi msg fail", __func__);
9175 qdf_mem_free(message.bodyptr);
9176 status = QDF_STATUS_E_FAILURE;
9177 }
9178 sme_release_global_lock(&mac->sme);
9179 }
9180 return status;
9181}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182
9183/*
9184 * SME API to enable/disable WLAN driver initiated SSR
9185 */
9186void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
9187{
9188 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309189 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009190
9191 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309192 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07009193 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009194 /* not serializing this messsage, as this is only going
9195 * to set a variable in WMA/WDI
9196 */
9197 WMA_SetEnableSSR(enableSSR);
9198 sme_release_global_lock(&pMac->sme);
9199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009200}
9201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009202/*convert the ini value to the ENUM used in csr and MAC for CB state*/
9203ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
9204{
9205 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
9206}
9207
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309208/*
9209 * sme_set_curr_device_mode() - Sets the current operating device mode.
9210 *
9211 * hHal - The handle returned by mac_open.
9212 * currDeviceMode - Current operating device mode.
9213 */
Peng Xuf5d60c82015-10-02 17:17:03 -07009214void sme_set_curr_device_mode(tHalHandle hHal,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309215 enum tQDF_ADAPTER_MODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009216{
9217 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220}
9221
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309222/*
9223 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
9224 * This is a synchronous call
9225 *
9226 * hHal - The handle returned by mac_open
9227 * sessionId - Session Identifier
9228 * pHandoffInfo - info provided by HDD with the handoff request (namely:
9229 * BSSID, channel etc.)
9230 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
9231 * Other status means SME is failed to send the request.
9232 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309234QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009235 uint8_t sessionId,
9236 tCsrHandoffRequest *pHandoffInfo)
9237{
9238 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309239 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009240
9241 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309242 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309243 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009244 "%s: invoked", __func__);
9245 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
9246 sme_release_global_lock(&pMac->sme);
9247 }
9248
9249 return status;
9250}
9251
9252#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309253/*
9254 * sme_ipa_offload_enable_disable() -
9255 * API to enable/disable IPA offload
9256 *
9257 * hal - The handle returned by macOpen.
9258 * session_id - Session Identifier
9259 * request - Pointer to the offload request.
9260 * Return QDF_STATUS
9261 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309262QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009263 struct sir_ipa_offload_enable_disable *request)
9264{
9265 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309266 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009267 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009268 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009269
9270 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309271 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309272 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009273 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309274 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309275 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009276 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309277 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009278 }
9279
9280 request_buf->offload_type = request->offload_type;
9281 request_buf->vdev_id = request->vdev_id;
9282 request_buf->enable = request->enable;
9283
9284 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
9285 msg.reserved = 0;
9286 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309287 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009288 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309289 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309290 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309291 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009292 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309293 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009294 }
9295
9296 sme_release_global_lock(&pMac->sme);
9297 }
9298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309299 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009300}
9301#endif /* IPA_OFFLOAD */
9302
9303/*
9304 * SME API to check if there is any infra station or
9305 * P2P client is connected
9306 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309307QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009308{
9309 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309310
9311 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309312 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309313
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309314 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009315}
9316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009317/**
9318 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
9319 * @hal: global hal handle
9320 * @addPeriodicTxPtrnParams: request message
9321 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309322 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009323 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309324QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325sme_add_periodic_tx_ptrn(tHalHandle hal,
9326 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
9327{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309328 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009329 tpAniSirGlobal mac = PMAC_STRUCT(hal);
9330 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009331 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009333 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309335 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009337 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309338 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009339 }
9340
9341 *req_msg = *addPeriodicTxPtrnParams;
9342
9343 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309344 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009345 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009346 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309347 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 return status;
9349 }
9350
9351 /* Serialize the req through MC thread */
9352 msg.bodyptr = req_msg;
9353 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309354 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9355 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009356 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309357 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009358 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309360 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 }
9362 sme_release_global_lock(&mac->sme);
9363 return status;
9364}
9365
9366/**
9367 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
9368 * @hal: global hal handle
9369 * @delPeriodicTxPtrnParams: request message
9370 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309371 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309373QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009374sme_del_periodic_tx_ptrn(tHalHandle hal,
9375 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
9376{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309377 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378 tpAniSirGlobal mac = PMAC_STRUCT(hal);
9379 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009380 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009381
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009382 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309384 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009386 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309387 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009388 }
9389
9390 *req_msg = *delPeriodicTxPtrnParams;
9391
9392 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309393 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009394 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309396 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009397 return status;
9398 }
9399
9400 /* Serialize the req through MC thread */
9401 msg.bodyptr = req_msg;
9402 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309403 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9404 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009405 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309406 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009407 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009408 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309409 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009410 }
9411 sme_release_global_lock(&mac->sme);
9412 return status;
9413}
9414
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309415/*
9416 * sme_enable_rmc() - enables RMC
9417 * @hHal : Pointer to global HAL handle
9418 * @sessionId : Session ID
9419 *
9420 * Return: QDF_STATUS
9421 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009422QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
9423{
9424 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9425 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009426 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009427 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9428
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009429 SME_ENTER();
9430
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009431 status = sme_acquire_global_lock(&pMac->sme);
9432 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009433 message.bodyptr = NULL;
9434 message.type = WMA_RMC_ENABLE_IND;
9435 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9436 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009437 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9438 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9439 "%s: failed to post message to WMA",
9440 __func__);
9441 status = QDF_STATUS_E_FAILURE;
9442 }
9443 sme_release_global_lock(&pMac->sme);
9444 }
9445 return status;
9446}
9447
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309448/*
9449 * sme_disable_rmc() - disables RMC
9450 * @hHal : Pointer to global HAL handle
9451 * @sessionId : Session ID
9452 *
9453 * Return: QDF_STATUS
9454 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009455QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9456{
9457 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009459 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009460 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9461
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009462 SME_ENTER();
9463
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009464 status = sme_acquire_global_lock(&pMac->sme);
9465 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009466 message.bodyptr = NULL;
9467 message.type = WMA_RMC_DISABLE_IND;
9468 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9469 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009470 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9472 "%s: failed to post message to WMA",
9473 __func__);
9474 status = QDF_STATUS_E_FAILURE;
9475 }
9476 sme_release_global_lock(&pMac->sme);
9477 }
9478 return status;
9479}
9480
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309481/*
9482 * sme_send_rmc_action_period() - sends RMC action period param to target
9483 * @hHal : Pointer to global HAL handle
9484 * @sessionId : Session ID
9485 *
9486 * Return: QDF_STATUS
9487 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009488QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9489{
9490 QDF_STATUS status = QDF_STATUS_SUCCESS;
9491 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9492 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009493 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009494
9495 status = sme_acquire_global_lock(&pMac->sme);
9496 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009497 message.bodyptr = NULL;
9498 message.type = WMA_RMC_ACTION_PERIOD_IND;
9499 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9500 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009501 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9502 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9503 "%s: failed to post message to WMA",
9504 __func__);
9505 status = QDF_STATUS_E_FAILURE;
9506 }
9507 sme_release_global_lock(&pMac->sme);
9508 }
9509
9510 return status;
9511}
9512
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309513/*
9514 * sme_request_ibss_peer_info() - request ibss peer info
9515 * @hHal : Pointer to global HAL handle
9516 * @pUserData : Pointer to user data
9517 * @peerInfoCbk : Peer info callback
9518 * @allPeerInfoReqd : All peer info required or not
9519 * @staIdx : sta index
9520 *
9521 * Return: QDF_STATUS
9522 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009523QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9524 pIbssPeerInfoCb peerInfoCbk,
9525 bool allPeerInfoReqd, uint8_t staIdx)
9526{
9527 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9528 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9529 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009530 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009531 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9532
9533 status = sme_acquire_global_lock(&pMac->sme);
9534 if (QDF_STATUS_SUCCESS == status) {
9535 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9536 pMac->sme.peerInfoParams.pUserData = pUserData;
9537
9538 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309539 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009540 if (NULL == pIbssInfoReqParams) {
9541 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9542 "%s: Not able to allocate memory for dhcp start",
9543 __func__);
9544 sme_release_global_lock(&pMac->sme);
9545 return QDF_STATUS_E_NOMEM;
9546 }
9547 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9548 pIbssInfoReqParams->staIdx = staIdx;
9549
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009550 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9551 message.bodyptr = pIbssInfoReqParams;
9552 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009553
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009554 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9555 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009556 if (QDF_STATUS_SUCCESS != qdf_status) {
9557 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9558 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9559 __func__);
9560 qdf_mem_free(pIbssInfoReqParams);
9561 qdf_status = QDF_STATUS_E_FAILURE;
9562 }
9563 sme_release_global_lock(&pMac->sme);
9564 }
9565
9566 return qdf_status;
9567}
9568
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309569/*
9570 * sme_send_cesium_enable_ind() -
9571 * Used to send proprietary cesium enable indication to fw
9572 *
9573 * hHal
9574 * sessionId
9575 * Return QDF_STATUS
9576 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009577QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9578{
9579 QDF_STATUS status = QDF_STATUS_SUCCESS;
9580 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9581 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009582 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009583
9584 status = sme_acquire_global_lock(&pMac->sme);
9585 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009586 message.bodyptr = NULL;
9587 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9588 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9589 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009590 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9592 "%s: failed to post message to WMA",
9593 __func__);
9594 status = QDF_STATUS_E_FAILURE;
9595 }
9596 sme_release_global_lock(&pMac->sme);
9597 }
9598
9599 return status;
9600}
9601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009602void sme_get_command_q_status(tHalHandle hHal)
9603{
9604 tSmeCmd *pTempCmd = NULL;
9605 tListElem *pEntry;
9606 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9607
9608 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 "%s: pMac is NULL", __func__);
9611 return;
9612 }
9613
Krunal Sonia8270f52017-02-23 19:51:25 -08009614 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309615 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009616 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309617
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009618 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009619 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9620 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309621 if (eSmeCsrCommandMask & pTempCmd->command)
9622 /* CSR command is stuck. See what the reason code is
9623 * for that command
9624 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009625 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009626 } /* if(pTempCmd) */
9627
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009628 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009629 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009632/**
9633 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9634 * @hal: The handle returned by macOpen
9635 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9636 */
9637void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9638 bool sta_prefer_80MHz_over_160MHz)
9639{
9640 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309641
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009642 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9643}
9644
Agrawal Ashishb141b092016-09-02 19:59:26 +05309645#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646/**
9647 * sme_set_dot11p_config() - API to set the 802.11p config
9648 * @hHal: The handle returned by macOpen
9649 * @enable_dot11p: 802.11p config param
9650 */
9651void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9652{
9653 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009655 pMac->enable_dot11p = enable_dot11p;
9656}
9657
9658/**
9659 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9660 * @src: the source configuration
9661 *
9662 * Return: pointer to the copied OCB configuration
9663 */
9664static struct sir_ocb_config *sme_copy_sir_ocb_config(
9665 struct sir_ocb_config *src)
9666{
9667 struct sir_ocb_config *dst;
9668 uint32_t length;
9669 void *cursor;
9670
9671 length = sizeof(*src) +
9672 src->channel_count * sizeof(*src->channels) +
9673 src->schedule_size * sizeof(*src->schedule) +
9674 src->dcc_ndl_chan_list_len +
9675 src->dcc_ndl_active_state_list_len;
9676
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309677 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009678 if (!dst)
9679 return NULL;
9680
9681 *dst = *src;
9682
9683 cursor = dst;
9684 cursor += sizeof(*dst);
9685 dst->channels = cursor;
9686 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309687 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009688 src->channel_count * sizeof(*src->channels));
9689 dst->schedule = cursor;
9690 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309691 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009692 src->schedule_size * sizeof(*src->schedule));
9693 dst->dcc_ndl_chan_list = cursor;
9694 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309695 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009696 src->dcc_ndl_chan_list_len);
9697 dst->dcc_ndl_active_state_list = cursor;
9698 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309699 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009700 src->dcc_ndl_active_state_list,
9701 src->dcc_ndl_active_state_list_len);
9702 return dst;
9703}
9704
9705/**
9706 * sme_ocb_set_config() - Set the OCB configuration
9707 * @hHal: reference to the HAL
9708 * @context: the context of the call
9709 * @callback: the callback to hdd
9710 * @config: the OCB configuration
9711 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309712 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309714QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009715 ocb_callback callback,
9716 struct sir_ocb_config *config)
9717{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309718 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009720 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009721 struct sir_ocb_config *msg_body;
9722
9723 /* Lock the SME structure */
9724 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309725 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009726 return status;
9727
9728 /*
9729 * Check if there is a pending request and return an error if one
9730 * exists
9731 */
9732 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309733 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734 goto end;
9735 }
9736
9737 msg_body = sme_copy_sir_ocb_config(config);
9738
9739 if (!msg_body) {
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
9744 msg.type = WMA_OCB_SET_CONFIG_CMD;
9745 msg.bodyptr = msg_body;
9746
9747 /* Set the request callback and context */
9748 pMac->sme.ocb_set_config_callback = callback;
9749 pMac->sme.ocb_set_config_context = context;
9750
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009751 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309752 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309753 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754 FL("Error posting message to WDA: %d"), status);
9755 pMac->sme.ocb_set_config_callback = callback;
9756 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309757 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009758 goto end;
9759 }
9760
9761end:
9762 sme_release_global_lock(&pMac->sme);
9763
9764 return status;
9765}
9766
9767/**
9768 * sme_ocb_set_utc_time() - Set the OCB UTC time
9769 * @hHal: reference to the HAL
9770 * @utc: the UTC time struct
9771 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309772 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309774QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009775{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309776 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009778 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009779 struct sir_ocb_utc *sme_utc;
9780
9781 /* Lock the SME structure */
9782 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309783 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009784 return status;
9785
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309786 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009787 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309788 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009789 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309790 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 goto end;
9792 }
9793 *sme_utc = *utc;
9794
9795 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9796 msg.reserved = 0;
9797 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009798 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309799 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309800 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009801 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309802 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803 goto end;
9804 }
9805
9806end:
9807 sme_release_global_lock(&pMac->sme);
9808
9809 return status;
9810}
9811
9812/**
9813 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9814 * @hHal: reference to the HAL
9815 * @timing_advert: the timing advertisement struct
9816 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309817 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009818 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309819QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009820 struct sir_ocb_timing_advert *timing_advert)
9821{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309822 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009824 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009825 void *buf;
9826 struct sir_ocb_timing_advert *sme_timing_advert;
9827
9828 /* Lock the SME structure */
9829 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309830 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 return status;
9832
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309833 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 timing_advert->template_length);
9835 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309836 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309838 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009839 goto end;
9840 }
9841
9842 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9843 *sme_timing_advert = *timing_advert;
9844 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309845 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009846 timing_advert->template_value, timing_advert->template_length);
9847
9848 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9849 msg.reserved = 0;
9850 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009851 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309852 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309853 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854 FL("Not able to post msg to WDA"));
9855 goto end;
9856 }
9857
9858end:
9859 sme_release_global_lock(&pMac->sme);
9860
9861 return status;
9862}
9863
9864/**
9865 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9866 * @hHal: reference to the HAL
9867 * @timing_advert: the timing advertisement struct
9868 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309869 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309871QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 struct sir_ocb_timing_advert *timing_advert)
9873{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309874 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009876 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009877 struct sir_ocb_timing_advert *sme_timing_advert;
9878
9879 /* Lock the SME structure */
9880 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309881 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 return status;
9883
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309884 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009885 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009887 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309888 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009889 goto end;
9890 }
9891 *sme_timing_advert = *timing_advert;
9892
9893 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9894 msg.reserved = 0;
9895 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009896 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309897 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009899 FL("Not able to post msg to WDA"));
9900 goto end;
9901 }
9902
9903end:
9904 sme_release_global_lock(&pMac->sme);
9905
9906 return status;
9907}
9908
9909/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009910 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9911 * @hal_handle: reference to the HAL
9912 * @self_addr: the self MAC address
9913 * @buf: the buffer that will contain the frame
9914 * @timestamp_offset: return for the offset of the timestamp field
9915 * @time_value_offset: return for the time_value field in the TA IE
9916 *
9917 * Return: the length of the buffer.
9918 */
9919int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9920 tSirMacAddr self_addr, uint8_t **buf,
9921 uint32_t *timestamp_offset,
9922 uint32_t *time_value_offset)
9923{
9924 int template_length;
9925 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9926
9927 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9928 timestamp_offset,
9929 time_value_offset);
9930 return template_length;
9931}
9932/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9934 * @hHal: reference to the HAL
9935 * @context: the context of the call
9936 * @callback: the callback to hdd
9937 * @request: the TSF timer request
9938 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309939 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309941QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009942 ocb_callback callback,
9943 struct sir_ocb_get_tsf_timer *request)
9944{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309945 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009947 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 struct sir_ocb_get_tsf_timer *msg_body;
9949
9950 /* Lock the SME structure */
9951 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309952 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009953 return status;
9954
9955 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309956 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009957 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309958 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009959 goto end;
9960 }
9961 *msg_body = *request;
9962
9963 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9964 msg.bodyptr = msg_body;
9965
9966 /* Set the request callback and the context */
9967 pMac->sme.ocb_get_tsf_timer_callback = callback;
9968 pMac->sme.ocb_get_tsf_timer_context = context;
9969
9970 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009971 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309972 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309973 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009974 FL("Error posting message to WDA: %d"), status);
9975 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9976 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309977 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978 goto end;
9979 }
9980
9981end:
9982 sme_release_global_lock(&pMac->sme);
9983
9984 return status;
9985}
9986
9987/**
9988 * sme_dcc_get_stats() - Get the DCC stats
9989 * @hHal: reference to the HAL
9990 * @context: the context of the call
9991 * @callback: the callback to hdd
9992 * @request: the get DCC stats request
9993 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309994 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309996QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997 ocb_callback callback,
9998 struct sir_dcc_get_stats *request)
9999{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010000 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010001 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010002 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010003 struct sir_dcc_get_stats *msg_body;
10004
10005 /* Lock the SME structure */
10006 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010007 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010008 return status;
10009
10010 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010011 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010012 request->request_array_len);
10013 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010014 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010015 goto end;
10016 }
10017 *msg_body = *request;
10018 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010019 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010020 request->request_array_len);
10021
10022 msg.type = WMA_DCC_GET_STATS_CMD;
10023 msg.bodyptr = msg_body;
10024
10025 /* Set the request callback and context */
10026 pMac->sme.dcc_get_stats_callback = callback;
10027 pMac->sme.dcc_get_stats_context = context;
10028
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010029 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010030 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010031 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010032 FL("Error posting message to WDA: %d"), status);
10033 pMac->sme.dcc_get_stats_callback = callback;
10034 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010035 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010036 goto end;
10037 }
10038
10039end:
10040 sme_release_global_lock(&pMac->sme);
10041
10042 return status;
10043}
10044
10045/**
10046 * sme_dcc_clear_stats() - Clear the DCC stats
10047 * @hHal: reference to the HAL
10048 * @vdev_id: vdev id for OCB interface
10049 * @dcc_stats_bitmap: the entries in the stats to clear
10050 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010051 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010052 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010053QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010054 uint32_t dcc_stats_bitmap)
10055{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010056 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010057 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010058 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010059 struct sir_dcc_clear_stats *request;
10060
10061 /* Lock the SME structure */
10062 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010063 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010064 return status;
10065
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010066 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010067 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010068 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010069 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010070 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010071 goto end;
10072 }
10073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010074 request->vdev_id = vdev_id;
10075 request->dcc_stats_bitmap = dcc_stats_bitmap;
10076
10077 msg.type = WMA_DCC_CLEAR_STATS_CMD;
10078 msg.bodyptr = request;
10079
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010080 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010081 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010083 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010084 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010085 goto end;
10086 }
10087
10088end:
10089 sme_release_global_lock(&pMac->sme);
10090
10091 return status;
10092}
10093
10094/**
10095 * sme_dcc_update_ndl() - Update the DCC settings
10096 * @hHal: reference to the HAL
10097 * @context: the context of the call
10098 * @callback: the callback to hdd
10099 * @request: the update DCC request
10100 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010101 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010103QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010104 ocb_callback callback,
10105 struct sir_dcc_update_ndl *request)
10106{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010107 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010109 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110 struct sir_dcc_update_ndl *msg_body;
10111
10112 /* Lock the SME structure */
10113 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010114 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010115 return status;
10116
10117 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010118 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119 request->dcc_ndl_chan_list_len +
10120 request->dcc_ndl_active_state_list_len);
10121 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010123 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010124 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010125 goto end;
10126 }
10127
10128 *msg_body = *request;
10129
10130 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
10131 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
10132 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010133 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010134 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010135 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010136 request->dcc_ndl_active_state_list,
10137 request->dcc_ndl_active_state_list_len);
10138
10139 msg.type = WMA_DCC_UPDATE_NDL_CMD;
10140 msg.bodyptr = msg_body;
10141
10142 /* Set the request callback and the context */
10143 pMac->sme.dcc_update_ndl_callback = callback;
10144 pMac->sme.dcc_update_ndl_context = context;
10145
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010146 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010147 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010148 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010149 FL("Error posting message to WDA: %d"), status);
10150 pMac->sme.dcc_update_ndl_callback = NULL;
10151 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010152 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010153 goto end;
10154 }
10155
10156end:
10157 sme_release_global_lock(&pMac->sme);
10158
10159 return status;
10160}
10161
10162/**
10163 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
10164 * event
10165 * @hHal: reference to the HAL
10166 * @context: the context of the call
10167 * @callback: the callback to hdd
10168 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010169 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010170 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010171QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010172 ocb_callback callback)
10173{
10174 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010175 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176
10177 status = sme_acquire_global_lock(&pMac->sme);
10178 pMac->sme.dcc_stats_event_callback = callback;
10179 pMac->sme.dcc_stats_event_context = context;
10180 sme_release_global_lock(&pMac->sme);
10181
10182 return 0;
10183}
10184
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010185/**
10186 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
10187 * event
10188 * @h_hal: Hal Handle
10189 *
10190 * This function de-registers the DCC perioc stats callback
10191 *
10192 * Return: QDF_STATUS Enumeration
10193 */
10194QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
10195{
10196 tpAniSirGlobal mac;
10197 QDF_STATUS status;
10198
10199 if (!h_hal) {
10200 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10201 FL("h_hal is not valid"));
10202 return QDF_STATUS_E_INVAL;
10203 }
10204 mac = PMAC_STRUCT(h_hal);
10205
10206 status = sme_acquire_global_lock(&mac->sme);
10207 if (!QDF_IS_STATUS_SUCCESS(status)) {
10208 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10209 FL("Failed to acquire global lock"));
10210 return status;
10211 }
10212 mac->sme.dcc_stats_event_callback = NULL;
10213 mac->sme.dcc_stats_event_context = NULL;
10214 sme_release_global_lock(&mac->sme);
10215
10216 return status;
10217}
Agrawal Ashishb141b092016-09-02 19:59:26 +053010218#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010220void sme_get_recovery_stats(tHalHandle hHal)
10221{
10222 uint8_t i;
10223
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010224 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 "Self Recovery Stats");
10226 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
10227 if (eSmeNoCommand !=
10228 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010229 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 "timestamp %llu: command 0x%0X: reason %d: session %d",
10231 g_self_recovery_stats.activeCmdStats[i].
10232 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010233 g_self_recovery_stats.activeCmdStats[i].command,
10234 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 g_self_recovery_stats.activeCmdStats[i].
10236 sessionId);
10237 }
10238 }
10239}
10240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010241QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010242{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010243 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010244 tpSirModemPowerStateInd request_buf;
10245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10246
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010247 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010248 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010250 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010251 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010253 "%s: Not able to allocate memory for MODEM POWER STATE IND",
10254 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010255 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010256 }
10257
10258 request_buf->param = value;
10259
10260 msg.type = WMA_MODEM_POWER_STATE_IND;
10261 msg.reserved = 0;
10262 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010263 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010264 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010266 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
10267 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010268 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010269 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010270 }
10271
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010272 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010273}
10274
10275#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010276QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010277 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010278 uint8_t sessionId,
10279 uint8_t channel_type)
10280{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010281 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 tUpdateVHTOpMode *pHtOpMode = NULL;
10283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10284
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010285 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010286 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010288 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010289 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010290 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010291 "%s: Not able to allocate memory for setting OP mode",
10292 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010293 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010294 }
10295
10296 switch (channel_type) {
10297 case eHT_CHAN_HT20:
10298 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
10299 break;
10300
10301 case eHT_CHAN_HT40MINUS:
10302 case eHT_CHAN_HT40PLUS:
10303 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
10304 break;
10305
10306 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010309 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010310 }
10311
10312 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010313 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010314 sizeof(tSirMacAddr));
10315 pHtOpMode->smesessionId = sessionId;
10316
10317 msg.type = WMA_UPDATE_OP_MODE;
10318 msg.reserved = 0;
10319 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010320 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010321 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010322 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010323 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
10324 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010325 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010326 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 }
10328
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010329 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010330 "%s: Notifed FW about OP mode: %d for staId=%d",
10331 __func__, pHtOpMode->opMode, staId);
10332
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010333 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334}
10335
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010336/*
10337 * sme_set_ht2040_mode() -
10338 * To update HT Operation beacon IE.
10339 *
10340 * Return QDF_STATUS SUCCESS
10341 * FAILURE or RESOURCES
10342 * The API finished and failed.
10343 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010344QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 uint8_t channel_type, bool obssEnabled)
10346{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010347 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010348 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10349 ePhyChanBondState cbMode;
10350
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010351 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352 "%s: Update HT operation beacon IE, channel_type=%d",
10353 __func__, channel_type);
10354
10355 switch (channel_type) {
10356 case eHT_CHAN_HT20:
10357 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
10358 break;
10359 case eHT_CHAN_HT40MINUS:
10360 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
10361 break;
10362 case eHT_CHAN_HT40PLUS:
10363 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
10364 break;
10365 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010366 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010367 "%s:Error!!! Invalid HT20/40 mode !", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010368 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 }
10370 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010371 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372 status = csr_set_ht2040_mode(pMac, sessionId,
10373 cbMode, obssEnabled);
10374 sme_release_global_lock(&pMac->sme);
10375 }
10376 return status;
10377}
10378
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010379#endif
10380
10381/*
10382 * SME API to enable/disable idle mode powersave
10383 * This should be called only if powersave offload
10384 * is enabled
10385 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010386QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010387{
Anurag Chouhan6d760662016-02-20 16:05:43 +053010388 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389
10390 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010391 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010392 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010394 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010395 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010396 " Idle Ps Set Value %d", value);
10397
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010398 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010399 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010400 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010401 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010403
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010404 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010405}
10406
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010407int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
10408 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010409{
10410 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010411 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010412
10413 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010414 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010415 "%s: pSession is NULL", __func__);
10416 return -EIO;
10417 }
10418 switch (ht_capab) {
10419 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10420 return pSession->htConfig.ht_rx_ldpc;
10421 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10422 return pSession->htConfig.ht_tx_stbc;
10423 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10424 return pSession->htConfig.ht_rx_stbc;
10425 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010426 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010428 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010429 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010430 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 "invalid ht capability");
10432 return -EIO;
10433 }
10434}
10435
10436int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
10437 int value)
10438{
10439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010440 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441
10442 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010444 "%s: pSession is NULL", __func__);
10445 return -EIO;
10446 }
10447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010448 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010449 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010450 "Failed to set ht capability in target");
10451 return -EIO;
10452 }
10453
10454 switch (htCapab) {
10455 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10456 pSession->htConfig.ht_rx_ldpc = value;
10457 break;
10458 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10459 pSession->htConfig.ht_tx_stbc = value;
10460 break;
10461 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10462 pSession->htConfig.ht_rx_stbc = value;
10463 break;
10464 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010465 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010466 pSession->htConfig.ht_sgi20 = value;
10467 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010469 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010470 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010471 break;
10472 }
10473
Naveen Rawat8029a402017-06-01 10:54:19 -070010474 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010475 return 0;
10476}
10477
10478#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010479/*
10480 * sme_send_rate_update_ind() -
10481 * API to Update rate
10482 *
10483 * hHal - The handle returned by mac_open
10484 * rateUpdateParams - Pointer to rate update params
10485 * Return QDF_STATUS
10486 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010487QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010488 tSirRateUpdateInd *rateUpdateParams)
10489{
10490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010491 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010492 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010493 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010494
10495 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010498 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 }
10500 *rate_upd = *rateUpdateParams;
10501
10502 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10503 rate_upd->mcastDataRate24GHzTxFlag =
10504 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10505 else if (rate_upd->reliableMcastDataRate ==
10506 HT20_SHORT_GI_MCS7_RATE)
10507 rate_upd->reliableMcastDataRateTxFlag =
10508 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10509
10510 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010511 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 msg.type = WMA_RATE_UPDATE_IND;
10513 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010514 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10515 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010516 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010517 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010518 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010519 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520 __func__);
10521
10522 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010523 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010524 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010525 }
10526
10527 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010528 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010529 }
10530
10531 return status;
10532}
10533
10534/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010535 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10536 * @hal: Pointer to the mac context
10537 * @session_id: sme session id
10538 * @vendor_ie: vendor ie
10539 * @access_policy: vendor ie access policy
10540 *
10541 * This function updates the vendor ie and access policy to lim.
10542 *
10543 * Return: success or failure.
10544 */
10545QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10546 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10547{
10548 struct sme_update_access_policy_vendor_ie *msg;
10549 uint16_t msg_len;
10550 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010551
10552 msg_len = sizeof(*msg);
10553
10554 msg = qdf_mem_malloc(msg_len);
10555 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010556 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010557 return QDF_STATUS_E_FAILURE;
10558 }
10559
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010560 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10561 msg->length = (uint16_t)msg_len;
10562
10563 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10564
10565 msg->sme_session_id = session_id;
10566 msg->access_policy = access_policy;
10567
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010568 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10569 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010570
Rajeev Kumard138ac52017-01-30 18:38:37 -080010571 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010572
10573 return status;
10574}
10575
10576/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010577 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10578 * @hal: Handle returned by mac_open
10579 * @session_id: Session ID on which short frame retry limit needs to be
10580 * updated to FW
10581 * @short_limit_count_th: Retry count TH to retry short frame.
10582 *
10583 * This function is used to configure count to retry short frame.
10584 *
10585 * Return: QDF_STATUS
10586 */
10587QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10588 struct sme_short_retry_limit *short_retry_limit_th)
10589{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010590 QDF_STATUS status = QDF_STATUS_SUCCESS;
10591 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010592 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010593
10594 srl = qdf_mem_malloc(sizeof(*srl));
10595 if (NULL == srl) {
10596 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10597 "%s: fail to alloc short retry limit", __func__);
10598 return QDF_STATUS_E_FAILURE;
10599 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010600 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010601 short_retry_limit_th->session_id,
10602 short_retry_limit_th->short_retry_limit);
10603
10604 srl->session_id = short_retry_limit_th->session_id;
10605 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10606
10607 qdf_mem_zero(&msg, sizeof(msg));
10608 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10609 msg.reserved = 0;
10610 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010611 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010612 if (status != QDF_STATUS_SUCCESS) {
10613 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10614 FL("Not able to post short retry limit count to WDA"));
10615 qdf_mem_free(srl);
10616 return QDF_STATUS_E_FAILURE;
10617 }
10618
10619 return status;
10620}
10621
10622/**
10623 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10624 * @hal: Handle returned by mac_open
10625 * @session_id: Session ID on which long frames retry TH needs to be updated
10626 * to FW
10627 * @long_limit_count_th: Retry count to retry long frame.
10628 *
10629 * This function is used to configure TH to retry long frame.
10630 *
10631 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010632 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010633QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10634 struct sme_long_retry_limit *long_retry_limit_th)
10635{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010636 QDF_STATUS status = QDF_STATUS_SUCCESS;
10637 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010638 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010639
10640 lrl = qdf_mem_malloc(sizeof(*lrl));
10641 if (NULL == lrl) {
10642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10643 "%s: fail to alloc long retry limit", __func__);
10644 return QDF_STATUS_E_FAILURE;
10645 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010646 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010647 long_retry_limit_th->session_id,
10648 long_retry_limit_th->long_retry_limit);
10649
10650 lrl->session_id = long_retry_limit_th->session_id;
10651 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10652
10653 qdf_mem_zero(&msg, sizeof(msg));
10654 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10655 msg.reserved = 0;
10656 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010657 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010658
10659 if (status != QDF_STATUS_SUCCESS) {
10660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10661 FL("Not able to post long retry limit count to WDA"));
10662 qdf_mem_free(lrl);
10663 return QDF_STATUS_E_FAILURE;
10664 }
10665
10666 return status;
10667}
10668
10669/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010670 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10671 * @hal: Handle returned by mac_open
10672 * @session_id: Session ID on which sta_inactivity_timeout needs
10673 * to be updated to FW
10674 * @sta_inactivity_timeout: sta inactivity timeout.
10675 *
10676 * If a station does not send anything in sta_inactivity_timeout seconds, an
10677 * empty data frame is sent to it in order to verify whether it is
10678 * still in range. If this frame is not ACKed, the station will be
10679 * disassociated and then deauthenticated.
10680 *
10681 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010682 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010683QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10684 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10685{
10686 struct sme_sta_inactivity_timeout *inactivity_time;
10687 void *wma_handle;
10688
10689 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10690 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10691 if (NULL == inactivity_time) {
10692 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10693 "%s: fail to alloc inactivity_time", __func__);
10694 return QDF_STATUS_E_FAILURE;
10695 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010697 FL("sta_inactivity_timeout: %d"),
10698 sta_inactivity_timer->sta_inactivity_timeout);
10699 inactivity_time->session_id = sta_inactivity_timer->session_id;
10700 inactivity_time->sta_inactivity_timeout =
10701 sta_inactivity_timer->sta_inactivity_timeout;
10702
10703 wma_update_sta_inactivity_timeout(wma_handle,
10704 inactivity_time);
10705 return QDF_STATUS_SUCCESS;
10706}
10707
10708/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 * sme_get_reg_info() - To get registration info
10710 * @hHal: HAL context
10711 * @chanId: channel id
10712 * @regInfo1: first reg info to fill
10713 * @regInfo2: second reg info to fill
10714 *
10715 * This routine will give you reg info
10716 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010717 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010718 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010719QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010720 uint32_t *regInfo1, uint32_t *regInfo2)
10721{
10722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010723 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010724 uint8_t i;
10725 bool found = false;
10726
10727 status = sme_acquire_global_lock(&pMac->sme);
10728 *regInfo1 = 0;
10729 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010730 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010731 return status;
10732
10733 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010734 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010735 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010736 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010737
10738 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010739 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010740 found = true;
10741 break;
10742 }
10743 }
10744 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010745 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010746
10747 sme_release_global_lock(&pMac->sme);
10748 return status;
10749}
10750
10751#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010752/*
10753 * sme_auto_shutdown_cb() -
10754 * Used to plug in callback function for receiving auto shutdown evt
10755 *
10756 * hHal
10757 * pCallbackfn : callback function pointer should be plugged in
10758 * Return QDF_STATUS
10759 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010760QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010761 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010762 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10764
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010765 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010766 "%s: Plug in Auto shutdown event callback", __func__);
10767
10768 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010769 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010770 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010771 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010772 sme_release_global_lock(&pMac->sme);
10773 }
10774
10775 return status;
10776}
10777
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010778/*
10779 * sme_set_auto_shutdown_timer() -
10780 * API to set auto shutdown timer value in FW.
10781 *
10782 * hHal - The handle returned by mac_open
10783 * timer_val - The auto shutdown timer value to be set
10784 * Return Configuration message posting status, SUCCESS or Fail
10785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010786QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010787{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010788 QDF_STATUS status = QDF_STATUS_SUCCESS;
10789 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10791 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010792 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793
10794 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010795 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010797 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010799 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800 "%s Request Buffer Alloc Fail", __func__);
10801 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010802 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010803 }
10804
10805 auto_sh_cmd->timer_val = timer_val;
10806
10807 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010808 message.bodyptr = auto_sh_cmd;
10809 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10810 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10811 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010812 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010814 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010815 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010816 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010817 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010818 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010819 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010820 "%s: Posted Auto shutdown MSG", __func__);
10821 sme_release_global_lock(&pMac->sme);
10822 }
10823
10824 return status;
10825}
10826#endif
10827
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010828/*
10829 * sme_ch_avoid_update_req() -
10830 * API to request channel avoidance update from FW.
10831 *
10832 * hHal - The handle returned by mac_open
10833 * update_type - The udpate_type parameter of this request call
10834 * Return Configuration message posting status, SUCCESS or Fail
10835 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010836QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010837{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010838 QDF_STATUS status = QDF_STATUS_SUCCESS;
10839 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010840 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10841 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010842 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010843
10844 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010845 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010846 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010847 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010848 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010849 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010850 "%s Request Buffer Alloc Fail", __func__);
10851 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010852 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 }
10854
10855 cauReq->reserved_param = 0;
10856
10857 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010858 message.bodyptr = cauReq;
10859 message.type = WMA_CH_AVOID_UPDATE_REQ;
10860 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10861 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010862 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010864 "%s: Post Ch Avoid Update MSG fail",
10865 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010866 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010868 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010869 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010871 "%s: Posted Ch Avoid Update MSG", __func__);
10872 sme_release_global_lock(&pMac->sme);
10873 }
10874
10875 return status;
10876}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877
10878/**
10879 * sme_set_miracast() - Function to set miracast value to UMAC
10880 * @hal: Handle returned by macOpen
10881 * @filter_type: 0-Disabled, 1-Source, 2-sink
10882 *
10883 * This function passes down the value of miracast set by
10884 * framework to UMAC
10885 *
10886 * Return: Configuration message posting status, SUCCESS or Fail
10887 *
10888 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010889QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010890{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010891 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010892 uint32_t *val;
10893 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10894
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010895 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010897 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010899 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010900 }
10901
10902 *val = filter_type;
10903
10904 msg.type = SIR_HAL_SET_MIRACAST;
10905 msg.reserved = 0;
10906 msg.bodyptr = val;
10907
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010908 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010909 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010910 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10912 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010913 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010914 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010915 }
10916
10917 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010918 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010919}
10920
10921/**
10922 * sme_set_mas() - Function to set MAS value to UMAC
10923 * @val: 1-Enable, 0-Disable
10924 *
10925 * This function passes down the value of MAS to the UMAC. A
10926 * value of 1 will enable MAS and a value of 0 will disable MAS
10927 *
10928 * Return: Configuration message posting status, SUCCESS or Fail
10929 *
10930 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010931QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010932{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010933 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010934 uint32_t *ptr_val;
10935
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010936 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010937 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010938 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010939 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010940 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010941 }
10942
10943 *ptr_val = val;
10944
10945 msg.type = SIR_HAL_SET_MAS;
10946 msg.reserved = 0;
10947 msg.bodyptr = ptr_val;
10948
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010949 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010950 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010952 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10953 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010954 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010955 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010956 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010957 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010958}
10959
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010960/**
10961 * sme_roam_channel_change_req() - Channel change to new target channel
10962 * @hHal: handle returned by mac_open
10963 * @bssid: mac address of BSS
10964 * @ch_params: target channel information
10965 * @profile: CSR profile
10966 *
10967 * API to Indicate Channel change to new target channel
10968 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010969 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010970 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010971QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010972 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010973 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010974 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010976 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010977 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010978
10979 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010980 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010981
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010982 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 profile);
10984 sme_release_global_lock(&pMac->sme);
10985 }
10986 return status;
10987}
10988
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010989/*
10990 * sme_process_channel_change_resp() -
10991 * API to Indicate Channel change response message to SAP.
10992 *
10993 * Return QDF_STATUS
10994 */
10995static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010996 uint16_t msg_type, void *pMsgBuf)
10997{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010998 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999 tCsrRoamInfo proam_info = { 0 };
11000 eCsrRoamResult roamResult;
11001 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
11002 uint32_t SessionId = pChnlParams->peSessionId;
11003
11004 proam_info.channelChangeRespEvent =
11005 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011006 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011007 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011008 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011009 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011010 return status;
11011 }
11012 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
11013 proam_info.channelChangeRespEvent->sessionId = SessionId;
11014 proam_info.channelChangeRespEvent->newChannelNumber =
11015 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011016
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011017 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011018 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011019 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
11020 SessionId);
11021 proam_info.channelChangeRespEvent->channelChangeStatus =
11022 1;
11023 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
11024 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011025 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011026 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
11027 SessionId);
11028 proam_info.channelChangeRespEvent->channelChangeStatus =
11029 0;
11030 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
11031 }
11032
11033 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
11034 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
11035
11036 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011037 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011038 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011039 status);
11040 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011041 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011042
11043 return status;
11044}
11045
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011046/*
11047 * sme_roam_start_beacon_req() -
11048 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
11049 *
11050 * hHal - The handle returned by mac_open
11051 * sessionId - session ID
11052 * dfsCacWaitStatus - CAC WAIT status flag
11053 * Return QDF_STATUS
11054 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053011055QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011056 uint8_t dfsCacWaitStatus)
11057{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011058 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011059 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011061 status = sme_acquire_global_lock(&pMac->sme);
11062
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011063 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011064 status = csr_roam_start_beacon_req(pMac, bssid,
11065 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011066 sme_release_global_lock(&pMac->sme);
11067 }
11068 return status;
11069}
11070
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080011071/**
11072 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
11073 * @hHal: handle returned by mac_open
11074 * @bssid: SAP bssid
11075 * @targetChannel: target channel information
11076 * @csaIeReqd: CSA IE Request
11077 * @ch_params: channel information
11078 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011079 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080011080 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053011081QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011082 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080011083 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011084{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011085 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011088 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011089 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080011090 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
11091 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 sme_release_global_lock(&pMac->sme);
11093 }
11094 return status;
11095}
11096
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011097/*
11098 * sme_init_thermal_info() -
11099 * SME API to initialize the thermal mitigation parameters
11100 *
11101 * hHal
11102 * thermalParam : thermal mitigation parameters
11103 * Return QDF_STATUS
11104 */
11105QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
11106 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011107{
11108 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011109 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11111
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011112 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011114 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011115 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011116 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011117 }
11118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011119 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
11120 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070011121
11122 pWmaParam->throttle_duty_cycle_tbl[0] =
11123 thermalParam.sme_throttle_duty_cycle_tbl[0];
11124 pWmaParam->throttle_duty_cycle_tbl[1] =
11125 thermalParam.sme_throttle_duty_cycle_tbl[1];
11126 pWmaParam->throttle_duty_cycle_tbl[2] =
11127 thermalParam.sme_throttle_duty_cycle_tbl[2];
11128 pWmaParam->throttle_duty_cycle_tbl[3] =
11129 thermalParam.sme_throttle_duty_cycle_tbl[3];
11130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 pWmaParam->thermalLevels[0].minTempThreshold =
11132 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
11133 pWmaParam->thermalLevels[0].maxTempThreshold =
11134 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
11135 pWmaParam->thermalLevels[1].minTempThreshold =
11136 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
11137 pWmaParam->thermalLevels[1].maxTempThreshold =
11138 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
11139 pWmaParam->thermalLevels[2].minTempThreshold =
11140 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
11141 pWmaParam->thermalLevels[2].maxTempThreshold =
11142 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
11143 pWmaParam->thermalLevels[3].minTempThreshold =
11144 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
11145 pWmaParam->thermalLevels[3].maxTempThreshold =
11146 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
11147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011148 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011149 msg.type = WMA_INIT_THERMAL_INFO_CMD;
11150 msg.bodyptr = pWmaParam;
11151
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011152 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011153 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011154 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
11156 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011157 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011158 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011159 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011160 }
11161 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011162 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011163 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011164 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011165 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166}
11167
11168/**
11169 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
11170 * @hal: Handle returned by macOpen
11171 * @callback: sme_set_thermal_level_callback
11172 *
11173 * Plug in set thermal level callback
11174 *
11175 * Return: none
11176 */
11177void sme_add_set_thermal_level_callback(tHalHandle hal,
11178 sme_set_thermal_level_callback callback)
11179{
11180 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
11181
11182 pMac->sme.set_thermal_level_cb = callback;
11183}
11184
11185/**
11186 * sme_set_thermal_level() - SME API to set the thermal mitigation level
11187 * @hal: Handler to HAL
11188 * @level: Thermal mitigation level
11189 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011190 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011191 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011192QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011193{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011194 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011196 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011197
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011198 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011199 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011200 msg.type = WMA_SET_THERMAL_LEVEL;
11201 msg.bodyval = level;
11202
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011203 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011204 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011205 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011206 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
11207 __func__);
11208 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011209 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011210 }
11211 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011212 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011213 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011214 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011215}
11216
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011217/*
11218 * sme_txpower_limit() -
11219 * SME API to set txpower limits
11220 *
11221 * hHal
11222 * psmetx : power limits for 2g/5g
11223 * Return QDF_STATUS
11224 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011225QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011226{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011227 QDF_STATUS status = QDF_STATUS_SUCCESS;
11228 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011229 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011230 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080011231 tSirTxPowerLimit *tx_power_limit;
11232
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011233 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080011234 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011235 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080011236 "%s: Memory allocation for TxPowerLimit failed!",
11237 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011238 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080011239 }
11240
11241 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242
11243 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011244 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011245 message.type = WMA_TX_POWER_LIMIT;
11246 message.reserved = 0;
11247 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011248
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011249 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11250 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011251 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253 "%s: not able to post WMA_TX_POWER_LIMIT",
11254 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011255 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011256 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011257 }
11258 sme_release_global_lock(&pMac->sme);
11259 }
11260 return status;
11261}
11262
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011263QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011264{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011265 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011266 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 pMac->fEnableDebugLog = set_value;
11269 return status;
11270}
11271
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011272/*
11273 * sme_ap_disable_intra_bss_fwd() -
11274 * SME will send message to WMA to set Intra BSS in txrx
11275 *
11276 * hHal - The handle returned by mac_open
11277 * sessionId - session id ( vdev id)
11278 * disablefwd - bool value that indicate disable intrabss fwd disable
11279 * Return QDF_STATUS
11280 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011281QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282 bool disablefwd)
11283{
11284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011285 int status = QDF_STATUS_SUCCESS;
11286 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011287 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
11289
11290 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011291 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011292 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011293 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011294 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011295 }
11296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011297 pSapDisableIntraFwd->sessionId = sessionId;
11298 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
11299
11300 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011301 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011302 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011303 message.bodyptr = pSapDisableIntraFwd;
11304 message.type = WMA_SET_SAP_INTRABSS_DIS;
11305 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11306 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011307 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
11308 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011309 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011310 }
11311 sme_release_global_lock(&pMac->sme);
11312 }
11313 return status;
11314}
11315
11316#ifdef WLAN_FEATURE_STATS_EXT
11317
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011318/*
11319 * sme_stats_ext_register_callback() -
11320 * This function called to register the callback that send vendor event for
11321 * stats ext
11322 *
11323 * callback - callback to be registered
11324 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011325void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
11326{
11327 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11328
11329 pMac->sme.StatsExtCallback = callback;
11330}
11331
lifeng66831662017-05-19 16:01:35 +080011332void sme_stats_ext2_register_callback(tHalHandle hal_handle,
11333 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
11334{
11335 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
11336
11337 pmac->sme.stats_ext2_cb = stats_ext2_cb;
11338}
11339
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011340/**
11341 * sme_stats_ext_deregister_callback() - De-register ext stats callback
11342 * @h_hal: Hal Handle
11343 *
11344 * This function is called to de initialize the HDD NAN feature. Currently
11345 * the only operation required is to de-register a callback with SME.
11346 *
11347 * Return: None
11348 */
11349void sme_stats_ext_deregister_callback(tHalHandle h_hal)
11350{
11351 tpAniSirGlobal pmac;
11352
11353 if (!h_hal) {
11354 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11355 FL("hHal is not valid"));
11356 return;
11357 }
11358
11359 pmac = PMAC_STRUCT(h_hal);
11360 pmac->sme.StatsExtCallback = NULL;
11361}
11362
11363
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011364/*
11365 * sme_stats_ext_request() -
11366 * Function called when HDD receives STATS EXT vendor command from userspace
11367 *
11368 * sessionID - vdevID for the stats ext request
11369 * input - Stats Ext Request structure ptr
11370 * Return QDF_STATUS
11371 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011372QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011373{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011374 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011375 tpStatsExtRequest data;
11376 size_t data_len;
11377
11378 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011379 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011380
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011381 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011382 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384 data->vdev_id = session_id;
11385 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011386 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011387 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011388 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389
11390 msg.type = WMA_STATS_EXT_REQUEST;
11391 msg.reserved = 0;
11392 msg.bodyptr = data;
11393
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011394 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080011395 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011396 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011397 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
11398 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011399 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011400 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401 }
11402
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011403 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011404}
11405
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011406/*
11407 * sme_stats_ext_event() -
11408 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
11409 * response from WMA
11410 *
11411 * hHal - HAL handle for device
11412 * pMsg - Message body passed from WMA; includes NAN header
11413 * Return QDF_STATUS
11414 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011415QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011416{
11417 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011418 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419
11420 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011421 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011422 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011423 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011424 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011425 pMac->sme.StatsExtCallback(pMac->hHdd,
11426 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011427 }
11428
11429 return status;
11430}
11431
11432#endif
11433
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011434/*
11435 * sme_update_dfs_scan_mode() -
11436 * Update DFS roam scan mode
11437 * This function is called through dynamic setConfig callback function
11438 * to configure allowDFSChannelRoam.
11439 * hHal - HAL handle for device
11440 * sessionId - Session Identifier
11441 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
11442 * 1 (passive), 2 (active)
11443 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11444 * successfully.
11445 * Other status means SME failed to update DFS roaming scan config.
11446 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011447QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011448 uint8_t allowDFSChannelRoam)
11449{
11450 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011451 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011453 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11454 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11455 FL("Invalid sme session id: %d"), sessionId);
11456 return QDF_STATUS_E_INVAL;
11457 }
11458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011459 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011460 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011461 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011462 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463 allowDFSChannelRoam,
11464 pMac->roam.configParam.allowDFSChannelRoam,
11465 mac_trace_get_neighbour_roam_state(pMac->roam.
11466 neighborRoamInfo
11467 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011468 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011469 pMac->roam.configParam.allowDFSChannelRoam =
11470 allowDFSChannelRoam;
11471 sme_release_global_lock(&pMac->sme);
11472 }
11473 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11474 csr_roam_offload_scan(pMac, sessionId,
11475 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11476 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11477 }
11478
11479 return status;
11480}
11481
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011482/*
11483 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11484 * This is a synchronous call
11485 *
11486 * hHal - The handle returned by mac_open.
11487 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11488 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011489uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11490{
11491 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011492
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011493 return pMac->roam.configParam.allowDFSChannelRoam;
11494}
11495
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011496/*
11497 * sme_modify_add_ie() -
11498 * This function sends msg to updates the additional IE buffers in PE
11499 *
11500 * hHal - global structure
11501 * pModifyIE - pointer to tModifyIE structure
11502 * updateType - type of buffer
11503 * Return Success or failure
11504 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011505QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011506 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11507{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011508 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011510
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011511 status = sme_acquire_global_lock(&pMac->sme);
11512
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011513 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011514 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11515 sme_release_global_lock(&pMac->sme);
11516 }
11517 return status;
11518}
11519
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011520/*
11521 * sme_update_add_ie() -
11522 * This function sends msg to updates the additional IE buffers in PE
11523 *
11524 * hHal - global structure
11525 * pUpdateIE - pointer to structure tUpdateIE
11526 * updateType - type of buffer
11527 * Return Success or failure
11528 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011529QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011530 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11531{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011532 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011533 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011535 status = sme_acquire_global_lock(&pMac->sme);
11536
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011537 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011538 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11539 sme_release_global_lock(&pMac->sme);
11540 }
11541 return status;
11542}
11543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544/**
11545 * sme_update_dsc_pto_up_mapping()
11546 * @hHal: HAL context
11547 * @dscpmapping: pointer to DSCP mapping structure
11548 * @sessionId: SME session id
11549 *
11550 * This routine is called to update dscp mapping
11551 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011552 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011553 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011554QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011555 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011556 uint8_t sessionId)
11557{
11558 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011559 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011561 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011562 tpPESession pSession = NULL;
11563
11564 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011565 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011566 return status;
11567 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11568 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011569 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011570 FL("Session lookup fails for CSR session"));
11571 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011572 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 }
11574 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011575 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011576 FL("Invalid session Id %u"), sessionId);
11577 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011578 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011579 }
11580
11581 pSession = pe_find_session_by_bssid(pMac,
11582 pCsrSession->connectedProfile.bssid.bytes,
11583 &peSessionId);
11584
11585 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011586 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 FL(" Session lookup fails for BSSID"));
11588 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011589 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011590 }
11591
11592 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011593 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011594 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596 }
11597 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11598 for (j = pSession->QosMapSet.dscp_range[i][0];
11599 j <= pSession->QosMapSet.dscp_range[i][1];
11600 j++) {
11601 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11602 && (pSession->QosMapSet.dscp_range[i][1] ==
11603 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011604 QDF_TRACE(QDF_MODULE_ID_SME,
11605 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011606 FL("User Priority %d isn't used"), i);
11607 break;
11608 } else {
11609 dscpmapping[j] = i;
11610 }
11611 }
11612 }
11613 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11614 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11615 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11616 pSession->QosMapSet.dscp_exceptions[i][1];
11617
11618 sme_release_global_lock(&pMac->sme);
11619 return status;
11620}
11621
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011622/*
11623 * sme_abort_roam_scan() -
11624 * API to abort current roam scan cycle by roam scan offload module.
11625 *
11626 * hHal - The handle returned by mac_open.
11627 * sessionId - Session Identifier
11628 * Return QDF_STATUS
11629 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011630
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011631QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011632{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011633 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011634 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011636 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11637 /* acquire the lock for the sme object */
11638 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011639 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011640 csr_roam_offload_scan(pMac, sessionId,
11641 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11642 REASON_ROAM_ABORT_ROAM_SCAN);
11643 /* release the lock for the sme object */
11644 sme_release_global_lock(&pMac->sme);
11645 }
11646 }
11647
11648 return status;
11649}
11650
11651#ifdef FEATURE_WLAN_EXTSCAN
11652/**
11653 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11654 * @hHal: HAL context
11655 * @wifiBand: RF band information
11656 * @aValidChannels: output array to store channel info
11657 * @pNumChannels: output number of channels
11658 *
11659 * SME API to fetch all valid channels filtered by band
11660 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011661 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011662 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011663QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664 uint8_t wifiBand,
11665 uint32_t *aValidChannels,
11666 uint8_t *pNumChannels)
11667{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011668 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011669 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670 uint8_t numChannels = 0;
11671 uint8_t i = 0;
11672 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011673 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674
11675 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011676 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011677 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011678 }
11679
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011680 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011681 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011682 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011683 }
11684
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011685 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011686 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011687 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011688 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011689 return status;
11690 }
11691
11692 switch (wifiBand) {
11693 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011694 sme_debug("Unspec Band, return all %d valid channels",
11695 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011696 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011697 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011698 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 break;
11700
11701 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011702 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011703 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011704 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011705 aValidChannels[numChannels++] =
11706 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011707 }
11708 break;
11709
11710 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011711 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011712 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011713 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011714 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011715 aValidChannels[numChannels++] =
11716 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011717 }
11718 break;
11719
11720 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011721 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011722 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011723 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11724 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011725 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 aValidChannels[numChannels++] =
11727 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728 }
11729 break;
11730
11731 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011732 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011734 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011735 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011736 aValidChannels[numChannels++] =
11737 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011738 }
11739 break;
11740
11741 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011742 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011744 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011745 aValidChannels[numChannels++] =
11746 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011747 }
11748 break;
11749
11750 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011751 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011752 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011753 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011754 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 aValidChannels[numChannels++] =
11756 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011757 }
11758 break;
11759
11760 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011761 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011762 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011763 }
11764 *pNumChannels = numChannels;
11765
11766 return status;
11767}
11768
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011769/*
11770 * sme_ext_scan_get_capabilities() -
11771 * SME API to fetch extscan capabilities
11772 *
11773 * hHal
11774 * pReq: extscan capabilities structure
11775 * Return QDF_STATUS
11776 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011777QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011778 tSirGetExtScanCapabilitiesReqParams *
11779 pReq)
11780{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011781 QDF_STATUS status = QDF_STATUS_SUCCESS;
11782 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011783 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011784 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011785
11786 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011787 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011788 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011789 message.bodyptr = pReq;
11790 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011791 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011792 NO_SESSION, message.type));
11793 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11794 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011795 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11796 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797
11798 sme_release_global_lock(&pMac->sme);
11799 }
11800 return status;
11801}
11802
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011803/*
11804 * sme_ext_scan_start() -
11805 * SME API to issue extscan start
11806 *
11807 * hHal
11808 * pStartCmd: extscan start structure
11809 * Return QDF_STATUS
11810 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011811QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812 tSirWifiScanCmdReqParams *pStartCmd)
11813{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011814 QDF_STATUS status = QDF_STATUS_SUCCESS;
11815 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011816 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011817 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011818
11819 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011820 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011821 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011822 message.bodyptr = pStartCmd;
11823 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011824 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011825 NO_SESSION, message.type));
11826 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11827 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011828 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11829 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011830
11831 sme_release_global_lock(&pMac->sme);
11832 }
11833 return status;
11834}
11835
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011836/*
11837 * sme_ext_scan_stop() -
11838 * SME API to issue extscan stop
11839 *
11840 * hHal
11841 * pStopReq: extscan stop structure
11842 * Return QDF_STATUS
11843 */
11844QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11845 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011846{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011847 QDF_STATUS status = QDF_STATUS_SUCCESS;
11848 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011849 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011850 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011851
11852 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011853 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011854 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011855 message.bodyptr = pStopReq;
11856 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011857 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011858 NO_SESSION, message.type));
11859 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11860 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011861 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11862 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011863 sme_release_global_lock(&pMac->sme);
11864 }
11865 return status;
11866}
11867
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011868/*
11869 * sme_set_bss_hotlist() -
11870 * SME API to set BSSID hotlist
11871 *
11872 * hHal
11873 * pSetHotListReq: extscan set hotlist structure
11874 * Return QDF_STATUS
11875 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011876QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011877 tSirExtScanSetBssidHotListReqParams *
11878 pSetHotListReq)
11879{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011880 QDF_STATUS status = QDF_STATUS_SUCCESS;
11881 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011882 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011883 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011884
11885 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011886 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011887 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011888 message.bodyptr = pSetHotListReq;
11889 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011890 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011891 NO_SESSION, message.type));
11892 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11893 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011894 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11895 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896
11897 sme_release_global_lock(&pMac->sme);
11898 }
11899 return status;
11900}
11901
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011902/*
11903 * sme_reset_bss_hotlist() -
11904 * SME API to reset BSSID hotlist
11905 *
11906 * hHal
11907 * pSetHotListReq: extscan set hotlist structure
11908 * Return QDF_STATUS
11909 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011910QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011911 tSirExtScanResetBssidHotlistReqParams *
11912 pResetReq)
11913{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011914 QDF_STATUS status = QDF_STATUS_SUCCESS;
11915 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011916 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011917 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011918
11919 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011920 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011922 message.bodyptr = pResetReq;
11923 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011924 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011925 NO_SESSION, message.type));
11926 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11927 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011928 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11929 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011930
11931 sme_release_global_lock(&pMac->sme);
11932 }
11933 return status;
11934}
11935
Manikandan Mohan80dea792016-04-28 16:36:48 -070011936/**
11937 * sme_send_wisa_params(): Pass WISA mode to WMA
11938 * @hal: HAL context
11939 * @wisa_params: pointer to WISA params struct
11940 * @sessionId: SME session id
11941 *
11942 * Pass WISA params to WMA
11943 *
11944 * Return: QDF_STATUS
11945 */
11946QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11947 struct sir_wisa_params *wisa_params)
11948{
11949 QDF_STATUS status = QDF_STATUS_SUCCESS;
11950 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011951 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011952 struct sir_wisa_params *cds_msg_wisa_params;
11953
11954 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11955 if (!cds_msg_wisa_params)
11956 return QDF_STATUS_E_NOMEM;
11957
11958 *cds_msg_wisa_params = *wisa_params;
11959 status = sme_acquire_global_lock(&mac->sme);
11960 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011961 message.bodyptr = cds_msg_wisa_params;
11962 message.type = WMA_SET_WISA_PARAMS;
11963 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011964 sme_release_global_lock(&mac->sme);
11965 }
11966 return status;
11967}
11968
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011969/*
11970 * sme_set_significant_change() -
11971 * SME API to set significant change
11972 *
11973 * hHal
11974 * pSetSignificantChangeReq: extscan set significant change structure
11975 * Return QDF_STATUS
11976 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011977QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011978 tSirExtScanSetSigChangeReqParams *
11979 pSetSignificantChangeReq)
11980{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011981 QDF_STATUS status = QDF_STATUS_SUCCESS;
11982 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011983 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011984 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011985
11986 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011987 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011988 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011989 message.bodyptr = pSetSignificantChangeReq;
11990 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011991 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011992 NO_SESSION, message.type));
11993 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11994 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011995 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11996 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011997
11998 sme_release_global_lock(&pMac->sme);
11999 }
12000 return status;
12001}
12002
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012003/*
12004 * sme_reset_significant_change
12005 * SME API to reset significant change
12006 *
12007 * hHal
12008 * pResetReq: extscan reset significant change structure
12009 * Return QDF_STATUS
12010 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012011QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012012 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012013 *pResetReq)
12014{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012015 QDF_STATUS status = QDF_STATUS_SUCCESS;
12016 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012017 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012018 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012019
12020 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012021 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012022 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012023 message.bodyptr = pResetReq;
12024 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012025 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012026 NO_SESSION, message.type));
12027 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12028 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012029 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
12030 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012031
12032 sme_release_global_lock(&pMac->sme);
12033 }
12034 return status;
12035}
12036
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012037/*
12038 * sme_get_cached_results() -
12039 * SME API to get cached results
12040 *
12041 * hHal
12042 * pCachedResultsReq: extscan get cached results structure
12043 * Return QDF_STATUS
12044 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012045QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012046 tSirExtScanGetCachedResultsReqParams *
12047 pCachedResultsReq)
12048{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012049 QDF_STATUS status = QDF_STATUS_SUCCESS;
12050 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012051 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012052 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012053
12054 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012055 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012056 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012057 message.bodyptr = pCachedResultsReq;
12058 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012059 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012060 NO_SESSION, message.type));
12061 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12062 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012063 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
12064 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012065
12066 sme_release_global_lock(&pMac->sme);
12067 }
12068 return status;
12069}
12070
12071/**
12072 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012073 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012074 * @input: request message
12075 *
12076 * This function constructs the cds message and fill in message type,
12077 * bodyptr with %input and posts it to WDA queue.
12078 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012079 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012081QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012082 struct wifi_epno_params *input)
12083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012084 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012085 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012086 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087 struct wifi_epno_params *req_msg;
12088 int len, i;
12089
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012090 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012091 len = sizeof(*req_msg) +
12092 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053012093
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012094 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012095 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012096 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012097 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012098 }
12099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012100 req_msg->num_networks = input->num_networks;
12101 req_msg->request_id = input->request_id;
12102 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053012103
12104 /* Fill only when num_networks are non zero */
12105 if (req_msg->num_networks) {
12106 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
12107 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
12108 req_msg->initial_score_max = input->initial_score_max;
12109 req_msg->same_network_bonus = input->same_network_bonus;
12110 req_msg->secure_bonus = input->secure_bonus;
12111 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
12112 req_msg->current_connection_bonus =
12113 input->current_connection_bonus;
12114
12115 for (i = 0; i < req_msg->num_networks; i++) {
12116 req_msg->networks[i].flags = input->networks[i].flags;
12117 req_msg->networks[i].auth_bit_field =
12118 input->networks[i].auth_bit_field;
12119 req_msg->networks[i].ssid.length =
12120 input->networks[i].ssid.length;
12121 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
12122 input->networks[i].ssid.ssId,
12123 req_msg->networks[i].ssid.length);
12124 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012125 }
12126
12127 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053012128 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012129 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012130 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012131 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012132 return status;
12133 }
12134
12135 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012136 message.bodyptr = req_msg;
12137 message.type = WMA_SET_EPNO_LIST_REQ;
12138 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012139 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012140 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012141 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012142 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012143 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012144 }
12145 sme_release_global_lock(&mac->sme);
12146 return status;
12147}
12148
12149/**
12150 * sme_set_passpoint_list() - set passpoint network list
12151 * @hal: global hal handle
12152 * @input: request message
12153 *
12154 * This function constructs the cds message and fill in message type,
12155 * bodyptr with @input and posts it to WDA queue.
12156 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012157 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012159QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012160 struct wifi_passpoint_req *input)
12161{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012162 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012164 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165 struct wifi_passpoint_req *req_msg;
12166 int len, i;
12167
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012168 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012169 len = sizeof(*req_msg) +
12170 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012171 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012172 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012173 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012174 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012175 }
12176
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012177 req_msg->num_networks = input->num_networks;
12178 req_msg->request_id = input->request_id;
12179 req_msg->session_id = input->session_id;
12180 for (i = 0; i < req_msg->num_networks; i++) {
12181 req_msg->networks[i].id =
12182 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012183 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012184 input->networks[i].realm,
12185 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012186 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012187 input->networks[i].plmn,
12188 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012189 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012190 input->networks[i].roaming_consortium_ids,
12191 sizeof(req_msg->networks[i].roaming_consortium_ids));
12192 }
12193
12194 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053012195 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012196 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012197 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012198 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012199 return status;
12200 }
12201
12202 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012203 message.bodyptr = req_msg;
12204 message.type = WMA_SET_PASSPOINT_LIST_REQ;
12205 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012206 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012207 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012208 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012209 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012210 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012211 }
12212 sme_release_global_lock(&mac->sme);
12213 return status;
12214}
12215
12216/**
12217 * sme_reset_passpoint_list() - reset passpoint network list
12218 * @hHal: global hal handle
12219 * @input: request message
12220 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012221 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012223QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012224 struct wifi_passpoint_req *input)
12225{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012226 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012227 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012228 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012229 struct wifi_passpoint_req *req_msg;
12230
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012231 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012232 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012233 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012234 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012235 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012236 }
12237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012238 req_msg->request_id = input->request_id;
12239 req_msg->session_id = input->session_id;
12240
12241 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053012242 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012243 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012244 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012245 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012246 return status;
12247 }
12248
12249 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012250 message.bodyptr = req_msg;
12251 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
12252 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012253 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012254 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012255 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012256 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012257 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012258 }
12259 sme_release_global_lock(&mac->sme);
12260 return status;
12261}
12262
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012263QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264 void (*pExtScanIndCb)(void *,
12265 const uint16_t,
12266 void *))
12267{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012268 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012269 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12270
12271 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012272 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012273 pMac->sme.pExtScanIndCb = pExtScanIndCb;
12274 sme_release_global_lock(&pMac->sme);
12275 }
12276 return status;
12277}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012278#endif /* FEATURE_WLAN_EXTSCAN */
12279
12280#ifdef WLAN_FEATURE_LINK_LAYER_STATS
12281
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012282/*
12283 * sme_ll_stats_clear_req() -
12284 * SME API to clear Link Layer Statistics
12285 *
12286 * hHal
12287 * pclearStatsReq: Link Layer clear stats request params structure
12288 * Return QDF_STATUS
12289 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012290QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012291 tSirLLStatsClearReq *pclearStatsReq)
12292{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012293 QDF_STATUS status = QDF_STATUS_SUCCESS;
12294 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012296 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012297 tSirLLStatsClearReq *clear_stats_req;
12298
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012299 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012300 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012301 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302 "statsClearReqMask = 0x%X",
12303 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012304 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012305 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070012306 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
12307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12308 "%s: invalid staId %d",
12309 __func__, pclearStatsReq->staId);
12310 return QDF_STATUS_E_INVAL;
12311 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012312
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012313 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012314
12315 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012317 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
12318 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012319 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012320 }
12321
12322 *clear_stats_req = *pclearStatsReq;
12323
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012324 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012325 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012326 message.bodyptr = clear_stats_req;
12327 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012328 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012329 NO_SESSION, message.type));
12330 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12331 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012332 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012333 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012334 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
12335 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012336 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012337 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 }
12339 sme_release_global_lock(&pMac->sme);
12340 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012341 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12342 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012343 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012344 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012345 }
12346
12347 return status;
12348}
12349
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012350/*
12351 * sme_ll_stats_set_req() -
12352 * SME API to set the Link Layer Statistics
12353 *
12354 * hHal
12355 * psetStatsReq: Link Layer set stats request params structure
12356 * Return QDF_STATUS
12357 */
12358QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
12359 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012360{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012361 QDF_STATUS status = QDF_STATUS_SUCCESS;
12362 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012363 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012364 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012365 tSirLLStatsSetReq *set_stats_req;
12366
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012368 "%s: MPDU Size = %u", __func__,
12369 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012370 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012371 " Aggressive Stats Collections = %u",
12372 psetStatsReq->aggressiveStatisticsGathering);
12373
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012374 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012375
12376 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012377 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012378 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
12379 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012380 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381 }
12382
12383 *set_stats_req = *psetStatsReq;
12384
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012385 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012386 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012387 message.bodyptr = set_stats_req;
12388 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012389 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012390 NO_SESSION, message.type));
12391 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12392 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012393 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012395 "%s: not able to post WMA_LL_STATS_SET_REQ",
12396 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012397 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012398 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012399 }
12400 sme_release_global_lock(&pMac->sme);
12401 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012402 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12403 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012404 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012405 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012406 }
12407
12408 return status;
12409}
12410
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012411/*
12412 * sme_ll_stats_get_req() -
12413 * SME API to get the Link Layer Statistics
12414 *
12415 * hHal
12416 * pgetStatsReq: Link Layer get stats request params structure
12417 * Return QDF_STATUS
12418 */
12419QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
12420 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012422 QDF_STATUS status = QDF_STATUS_SUCCESS;
12423 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012424 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012425 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426 tSirLLStatsGetReq *get_stats_req;
12427
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012428 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012429
12430 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012431 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012432 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
12433 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012434 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012435 }
12436
12437 *get_stats_req = *pgetStatsReq;
12438
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012439 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012441 message.bodyptr = get_stats_req;
12442 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012443 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012444 NO_SESSION, message.type));
12445 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12446 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012447 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012449 "%s: not able to post WMA_LL_STATS_GET_REQ",
12450 __func__);
12451
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012452 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012453 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012454
12455 }
12456 sme_release_global_lock(&pMac->sme);
12457 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012458 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12459 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012460 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012461 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012462 }
12463
12464 return status;
12465}
12466
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012467/*
12468 * sme_set_link_layer_stats_ind_cb() -
12469 * SME API to trigger the stats are available after get request
12470 *
12471 * hHal
12472 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012474 * Return QDF_STATUS
12475 */
12476QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12477 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12478{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012479 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12481
12482 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012483 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012484 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12485 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012486 } else
12487 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12488 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012489
12490 return status;
12491}
12492
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012493/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012494 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12495 * @hal: Mac global handle
12496 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12497 * status notification from FW
12498 *
12499 * Return: eHalStatus
12500 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012501QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12502 (tHddHandle callback_ctx, tSirLLStatsResults
12503 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012504{
12505 QDF_STATUS status;
12506 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12507
12508 status = sme_acquire_global_lock(&mac->sme);
12509 if (status == QDF_STATUS_SUCCESS) {
12510 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12511 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012512 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012513 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12514 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012515 return status;
12516}
12517
12518/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012519 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12520 * indication
12521 * @h_hal: Hal Handle
12522 *
12523 * This function reset's the link layer stats indication
12524 *
12525 * Return: QDF_STATUS Enumeration
12526 */
12527
12528QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12529{
12530 QDF_STATUS status;
12531 tpAniSirGlobal pmac;
12532
12533 if (!h_hal) {
12534 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12535 FL("hHal is not valid"));
12536 return QDF_STATUS_E_INVAL;
12537 }
12538 pmac = PMAC_STRUCT(h_hal);
12539
12540 status = sme_acquire_global_lock(&pmac->sme);
12541 if (QDF_IS_STATUS_SUCCESS(status)) {
12542 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12543 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012544 } else
12545 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12546 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012547
12548 return status;
12549}
12550
Zhang Qian73c348a2017-03-13 16:15:55 +080012551/**
12552 * sme_ll_stats_set_thresh - set threshold for mac counters
12553 * @hal, hal layer handle
12554 * @threshold, threshold for mac counters
12555 *
12556 * Return: QDF_STATUS Enumeration
12557 */
12558QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12559 struct sir_ll_ext_stats_threshold *threshold)
12560{
12561 QDF_STATUS status;
12562 tpAniSirGlobal mac;
12563 struct scheduler_msg message;
12564 struct sir_ll_ext_stats_threshold *thresh;
12565
12566 if (!threshold) {
12567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12568 FL("threshold is not valid"));
12569 return QDF_STATUS_E_INVAL;
12570 }
12571
12572 if (!hal) {
12573 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12574 FL("hal is not valid"));
12575 return QDF_STATUS_E_INVAL;
12576 }
12577 mac = PMAC_STRUCT(hal);
12578
12579 thresh = qdf_mem_malloc(sizeof(*thresh));
12580 if (!thresh) {
12581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12582 "%s: Fail to alloc mem", __func__);
12583 return QDF_STATUS_E_NOMEM;
12584 }
12585 *thresh = *threshold;
12586
12587 status = sme_acquire_global_lock(&mac->sme);
12588 if (QDF_IS_STATUS_SUCCESS(status)) {
12589 /* Serialize the req through MC thread */
12590 message.bodyptr = thresh;
12591 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12592 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12593 NO_SESSION, message.type));
12594 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12595 if (!QDF_IS_STATUS_SUCCESS(status)) {
12596 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12597 "%s: not able to post WDA_LL_STATS_GET_REQ",
12598 __func__);
12599 qdf_mem_free(thresh);
12600 }
12601 sme_release_global_lock(&mac->sme);
12602 } else {
12603 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12604 FL("sme_acquire_global_lock error"));
12605 qdf_mem_free(thresh);
12606 }
12607 return status;
12608}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012610#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12611
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012612#ifdef WLAN_POWER_DEBUGFS
12613/**
12614 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12615 * @callback_fn: Pointer to the callback function for Power stats event
12616 * @power_stats_context: Pointer to context
12617 *
12618 * Return: QDF_STATUS
12619 */
12620QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12621 (struct power_stats_response *response,
12622 void *context), void *power_stats_context)
12623{
12624 QDF_STATUS status = QDF_STATUS_SUCCESS;
12625 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012626 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012627
12628 status = sme_acquire_global_lock(&mac_ctx->sme);
12629 if (QDF_IS_STATUS_SUCCESS(status)) {
12630 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012631 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012632 sme_release_global_lock(&mac_ctx->sme);
12633 return QDF_STATUS_E_FAILURE;
12634 }
12635
12636 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12637 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12638 msg.bodyptr = NULL;
12639 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012640 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012641 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012642 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012643 sme_release_global_lock(&mac_ctx->sme);
12644 }
12645 return status;
12646}
12647#endif
12648
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012649/**
12650 * sme_fw_mem_dump_register_cb() - Register fw memory dump callback
12651 *
12652 * @hal - MAC global handle
12653 * @callback_routine - callback routine from HDD
12654 *
12655 * This API is invoked by HDD to register its callback in SME
12656 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012657 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012658 */
12659#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012660QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012661 void (*callback_routine)(void *cb_context,
12662 struct fw_dump_rsp *rsp))
12663{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012664 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012665 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12666
12667 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012668 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012669 pmac->sme.fw_dump_callback = callback_routine;
12670 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012671 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012672 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012674
12675 return status;
12676}
12677#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012678QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012679 void (*callback_routine)(void *cb_context,
12680 struct fw_dump_rsp *rsp))
12681{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012682 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012683}
12684#endif /* WLAN_FEATURE_MEMDUMP */
12685
12686/**
12687 * sme_fw_mem_dump_unregister_cb() - Unregister fw memory dump callback
12688 *
12689 * @hHal - MAC global handle
12690 *
12691 * This API is invoked by HDD to unregister its callback in SME
12692 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012693 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012694 */
12695#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012696QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012697{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012698 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012699 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12700
12701 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012702 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012703 pmac->sme.fw_dump_callback = NULL;
12704 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012705 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012706 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012707 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012708
12709 return status;
12710}
12711#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012712QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012714 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012715}
12716#endif /* WLAN_FEATURE_MEMDUMP */
12717
12718#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012719/*
12720 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12721 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12722 *
12723 * hHal - The handle returned by mac_open.
12724 * nRoamOffloadEnabled - The bool to update with
12725 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12726 * Other status means SME is failed to update.
12727 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012728
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012729QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012730 bool nRoamOffloadEnabled)
12731{
12732 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012733 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012734
12735 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012736 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012737 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012738 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12739 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12740 nRoamOffloadEnabled);
12741 pMac->roam.configParam.isRoamOffloadEnabled =
12742 nRoamOffloadEnabled;
12743 sme_release_global_lock(&pMac->sme);
12744 }
12745
12746 return status;
12747}
12748
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012749/**
12750 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12751 * This is a synchronous call
12752 * @hal_ctx: The handle returned by mac_open.
12753 * @session_id: Session Identifier
12754 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012755 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012756 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12757 * Other status means SME is failed to update.
12758 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012759
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012760QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012761 uint8_t session_id,
12762 bool key_mgmt_offload_enabled,
12763 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012764{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012765 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012766 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012767
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012768 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012769 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012770 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012772 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12773 __func__, key_mgmt_offload_enabled);
12774 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12775 session_id,
12776 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012777 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012778 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012779 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012780 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012781 }
12782
12783 return status;
12784}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012785#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012787/*
12788 * sme_get_temperature() -
12789 * SME API to get the pdev temperature
12790 *
12791 * hHal
12792 * temperature context
12793 * pCallbackfn: callback fn with response (temperature)
12794 * Return QDF_STATUS
12795 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012796QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012797 void *tempContext,
12798 void (*pCallbackfn)(int temperature,
12799 void *pContext))
12800{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012801 QDF_STATUS status = QDF_STATUS_SUCCESS;
12802 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012803 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012804 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012805
12806 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012807 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012808 if ((NULL == pCallbackfn) &&
12809 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012811 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012812 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012813 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012814 } else if (NULL != pCallbackfn) {
12815 pMac->sme.pTemperatureCbContext = tempContext;
12816 pMac->sme.pGetTemperatureCb = pCallbackfn;
12817 }
12818 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012819 message.bodyptr = NULL;
12820 message.type = WMA_GET_TEMPERATURE_REQ;
12821 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12822 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012823 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012824 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012825 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012826 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012827 }
12828 sme_release_global_lock(&pMac->sme);
12829 }
12830 return status;
12831}
12832
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012833/*
12834 * sme_set_scanning_mac_oui() -
12835 * SME API to set scanning mac oui
12836 *
12837 * hHal
12838 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12839 * Return QDF_STATUS
12840 */
12841QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12842 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012843{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012844 QDF_STATUS status = QDF_STATUS_SUCCESS;
12845 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012846 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012847 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012848
12849 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012850 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012851 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012852 message.bodyptr = pScanMacOui;
12853 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12854 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12855 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012856 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012857 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012858 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012859 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012860 }
12861 sme_release_global_lock(&pMac->sme);
12862 }
12863 return status;
12864}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012865
12866#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012867/*
12868 * sme_set_dhcp_srv_offload() -
12869 * SME API to set DHCP server offload info
12870 *
12871 * hHal
12872 * pDhcpSrvInfo : DHCP server offload info struct
12873 * Return QDF_STATUS
12874 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012875QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012876 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12877{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012878 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012879 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012880 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012881 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12882
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012883 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012884
12885 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012887 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12888 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012889 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012890 }
12891
12892 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12893
12894 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012895 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012896 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012897 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12898 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012899
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012900 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012901 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12902 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012903 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012904 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012905 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012906 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012907 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012908 }
12909 sme_release_global_lock(&pMac->sme);
12910 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012911 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012912 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012913 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012914 }
12915
12916 return status;
12917}
12918#endif /* DHCP_SERVER_OFFLOAD */
12919
Krunal Soniaadaa272017-10-04 16:42:55 -070012920QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12921 uint32_t arg_count, uint32_t *arg)
12922{
12923 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12924 arg_count, arg);
12925}
12926
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012927#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012928/*
12929 * sme_set_led_flashing() -
12930 * API to set the Led flashing parameters.
12931 *
12932 * hHal - The handle returned by mac_open.
12933 * x0, x1 - led flashing parameters
12934 * Return QDF_STATUS
12935 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012936QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012937 uint32_t x0, uint32_t x1)
12938{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012939 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012940 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012941 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012942 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012943
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012944 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012945 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012947 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012948 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012949 }
12950
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012951 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012952 ledflashing->pattern_id = type;
12953 ledflashing->led_x0 = x0;
12954 ledflashing->led_x1 = x1;
12955
12956 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012957 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012958 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012959 message.bodyptr = ledflashing;
12960 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012961 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012962 sme_release_global_lock(&pMac->sme);
12963 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012964 if (!QDF_IS_STATUS_SUCCESS(status))
12965 qdf_mem_free(ledflashing);
12966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012967 return status;
12968}
12969#endif
12970
12971/**
12972 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12973 * @h_hal: corestack handler
12974 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012975 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012976 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012977QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012978{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012979 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012980 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12981
12982 status = sme_acquire_global_lock(&mac->sme);
12983
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012984 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012985
12986 mac->scan.fEnableDFSChnlScan = dfs_flag;
12987
12988 /* update the channel list to the firmware */
12989 status = csr_update_channel_list(mac);
12990
12991 sme_release_global_lock(&mac->sme);
12992 }
12993
12994 return status;
12995}
12996
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012997#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12998/**
12999 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
13000 * concurreny rules set to avoid channel interference.
13001 * @hal - Hal context
13002 * @sap_ch - channel to switch
13003 * @sap_phy_mode - phy mode of SAP
13004 * @cc_switch_mode - concurreny switch mode
13005 * @session_id - sme session id.
13006 *
13007 * Return: true if there is no channel interference else return false
13008 */
13009bool sme_validate_sap_channel_switch(tHalHandle hal,
13010 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
13011 uint8_t session_id)
13012{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013013 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013014 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013015 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013016 uint16_t intf_channel = 0;
13017
13018 if (!session)
13019 return false;
13020
13021 session->ch_switch_in_progress = true;
13022 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013023 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013024 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
13025 sap_phy_mode,
13026 cc_switch_mode);
13027 sme_release_global_lock(&mac->sme);
13028 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013029 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053013030 FL("sme_acquire_global_lock error!"));
13031 session->ch_switch_in_progress = false;
13032 return false;
13033 }
13034
13035 session->ch_switch_in_progress = false;
13036 return (intf_channel == 0) ? true : false;
13037}
13038#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013039
13040/**
13041 * sme_configure_stats_avg_factor() - function to config avg. stats factor
13042 * @hal: hal
13043 * @session_id: session ID
13044 * @stats_avg_factor: average stats factor
13045 *
13046 * This function configures the stats avg factor in firmware
13047 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013048 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013049 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013050QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013051 uint16_t stats_avg_factor)
13052{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013053 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013055 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13056 struct sir_stats_avg_factor *stats_factor;
13057
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013058 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013059
13060 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013061 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013062 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
13063 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013064 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013065 }
13066
13067 status = sme_acquire_global_lock(&mac->sme);
13068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013069 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013070
13071 stats_factor->vdev_id = session_id;
13072 stats_factor->stats_avg_factor = stats_avg_factor;
13073
13074 /* serialize the req through MC thread */
13075 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
13076 msg.bodyptr = stats_factor;
13077
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013078 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013079 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013080 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013081 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
13082 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013083 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013084 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013085 }
13086 sme_release_global_lock(&mac->sme);
13087 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013088 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013089 "%s: sme_acquire_global_lock error!",
13090 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013091 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013092 }
13093
13094 return status;
13095}
13096
13097/**
13098 * sme_configure_guard_time() - function to configure guard time
13099 * @hal: hal
13100 * @session_id: session id
13101 * @guard_time: guard time
13102 *
13103 * This function configures the guard time in firmware
13104 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013105 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013106 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013107QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013108 uint32_t guard_time)
13109{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013110 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013111 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013112 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13113 struct sir_guard_time_request *g_time;
13114
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013115 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013116
13117 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013118 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013119 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
13120 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013121 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122 }
13123
13124 status = sme_acquire_global_lock(&mac->sme);
13125
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013126 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013127
13128 g_time->vdev_id = session_id;
13129 g_time->guard_time = guard_time;
13130
13131 /* serialize the req through MC thread */
13132 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
13133 msg.bodyptr = g_time;
13134
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013135 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013136 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013137 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013138 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
13139 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013140 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013141 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142 }
13143 sme_release_global_lock(&mac->sme);
13144 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013145 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013146 "%s: sme_acquire_global_lock error!",
13147 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013148 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013149 }
13150
13151 return status;
13152}
13153
13154/**
13155 * sme_configure_modulated_dtim() - function to configure modulated dtim
13156 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
13157 * @session_id: session ID
13158 * @modulated_dtim: modulated dtim value
13159 *
13160 * This function configures the modulated dtim in firmware
13161 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013162 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013163 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013164QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013165 uint32_t modulated_dtim)
13166{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013167 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013168 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013169 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13170 wma_cli_set_cmd_t *iwcmd;
13171
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013172 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013173 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013174 QDF_TRACE(QDF_MODULE_ID_SME,
13175 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013176 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013177 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013178 }
13179
13180 status = sme_acquire_global_lock(&mac->sme);
13181
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013182 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013184 iwcmd->param_value = modulated_dtim;
13185 iwcmd->param_vdev_id = session_id;
13186 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
13187 iwcmd->param_vp_dev = GEN_CMD;
13188 msg.type = WMA_CLI_SET_CMD;
13189 msg.reserved = 0;
13190 msg.bodyptr = (void *)iwcmd;
13191
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013192 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013193 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013195 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
13196 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013197 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013198 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013199 }
13200 sme_release_global_lock(&mac->sme);
13201 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013203 "%s: sme_acquire_global_lock error!",
13204 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013205 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013206 }
13207
13208 return status;
13209}
13210
Mukul Sharma6398b252017-05-01 17:58:12 +053013211/**
13212 * sme_override_listen_interval() - function to override static LI
13213 * @h_hal: SME API to override listen interval
13214 * @session_id: session ID
13215 * @override_li: new LI value passed by user
13216 *
13217 * This function override (enable/disable) static a.k.a ini based LI
13218 *
13219 * Return: QDF_STATUS
13220 */
13221QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
13222 uint32_t override_li)
13223{
13224 struct scheduler_msg msg = {0};
13225 QDF_STATUS status = QDF_STATUS_SUCCESS;
13226 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
13227 wma_cli_set_cmd_t *iwcmd;
13228
13229 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
13230 if (!iwcmd) {
13231 QDF_TRACE(QDF_MODULE_ID_SME,
13232 QDF_TRACE_LEVEL_FATAL,
13233 "%s: qdf_mem_malloc failed", __func__);
13234 return QDF_STATUS_E_NOMEM;
13235 }
13236
13237 status = sme_acquire_global_lock(&mac->sme);
13238
13239 if (status == QDF_STATUS_SUCCESS) {
13240
13241 iwcmd->param_value = override_li;
13242 iwcmd->param_vdev_id = session_id;
13243 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
13244 iwcmd->param_vp_dev = GEN_CMD;
13245 msg.type = WMA_CLI_SET_CMD;
13246 msg.reserved = 0;
13247 msg.bodyptr = (void *)iwcmd;
13248
13249 if (!QDF_IS_STATUS_SUCCESS(
13250 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
13251 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13252 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
13253 __func__);
13254 qdf_mem_free(iwcmd);
13255 status = QDF_STATUS_E_FAILURE;
13256 }
13257 sme_release_global_lock(&mac->sme);
13258 } else {
13259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13260 "%s: sme_acquire_global_lock error!",
13261 __func__);
13262 qdf_mem_free(iwcmd);
13263 }
13264
13265 return status;
13266}
13267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013268/*
13269 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
13270 * to either start/stop logging
13271 * @hal: HAL context
13272 * @start_log: Structure containing the wifi start logger params
13273 *
13274 * This function sends the start/stop logging command to WMA
13275 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013276 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013278QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013279 struct sir_wifi_start_log start_log)
13280{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013281 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013282 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013283 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013284 struct sir_wifi_start_log *req_msg;
13285 uint32_t len;
13286
13287 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013288 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013289 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013290 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013291 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013292 }
13293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053013295 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013296 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080013297 req_msg->ini_triggered = start_log.ini_triggered;
13298 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053013299 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053013300 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013301
13302 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013303 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013304 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013305 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013306 return status;
13307 }
13308
13309 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013310 message.bodyptr = req_msg;
13311 message.type = SIR_HAL_START_STOP_LOGGING;
13312 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013313 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013314 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013315 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013316 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013317 }
13318 sme_release_global_lock(&mac->sme);
13319
13320 return status;
13321}
13322
13323/**
13324 * sme_neighbor_middle_of_roaming() - Function to know if
13325 * STA is in the middle of roaming states
13326 * @hal: Handle returned by macOpen
13327 * @sessionId: sessionId of the STA session
13328 *
13329 * This function is a wrapper to call
13330 * csr_neighbor_middle_of_roaming to know STA is in the
13331 * middle of roaming states
13332 *
13333 * Return: True or False
13334 *
13335 */
13336bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
13337{
Sandeep Puligillaca631612016-11-08 11:53:52 -080013338 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
13339 bool val = false;
13340
13341 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
13342 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
13343 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013344 sme_err("Invalid Session: %d", sessionId);
13345
Sandeep Puligillaca631612016-11-08 11:53:52 -080013346 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013347}
13348
13349/*
13350 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
13351 * @mac: MAC handle
13352 *
13353 * This function is used to send the command that will
13354 * be used to flush the logs in the firmware
13355 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070013356 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013357 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013358QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013360 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013361 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013363 /* Serialize the req through MC thread */
13364 message.bodyptr = NULL;
13365 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013366 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013367 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013368 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013369 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013371 return status;
13372}
13373
Jeff Johnsona1e92612017-09-24 15:33:44 -070013374QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013375 sme_ac_enum_type ac, uint8_t tid,
13376 uint8_t pri, uint32_t srvc_int,
13377 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053013378 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013379 uint8_t psb, uint32_t sessionId,
13380 uint32_t delay_interval)
13381{
13382 void *wma_handle;
13383 t_wma_trigger_uapsd_params uapsd_params;
13384 enum uapsd_ac access_category;
13385
13386 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013387 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013388 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013389 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013390 }
13391
Anurag Chouhan6d760662016-02-20 16:05:43 +053013392 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013393 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013395 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013396 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013397 }
13398
13399 switch (ac) {
13400 case SME_AC_BK:
13401 access_category = UAPSD_BK;
13402 break;
13403 case SME_AC_BE:
13404 access_category = UAPSD_BE;
13405 break;
13406 case SME_AC_VI:
13407 access_category = UAPSD_VI;
13408 break;
13409 case SME_AC_VO:
13410 access_category = UAPSD_VO;
13411 break;
13412 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013413 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013414 }
13415
13416 uapsd_params.wmm_ac = access_category;
13417 uapsd_params.user_priority = pri;
13418 uapsd_params.service_interval = srvc_int;
13419 uapsd_params.delay_interval = delay_interval;
13420 uapsd_params.suspend_interval = sus_int;
13421
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013422 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013423 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013424 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013425 "Failed to Trigger Uapsd params for sessionId %d",
13426 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013427 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013428 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013429 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013430}
13431
Jeff Johnsona1e92612017-09-24 15:33:44 -070013432QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013433 sme_ac_enum_type ac,
13434 uint32_t sessionId)
13435{
13436 void *wma_handle;
13437 enum uapsd_ac access_category;
13438
13439 switch (ac) {
13440 case SME_AC_BK:
13441 access_category = UAPSD_BK;
13442 break;
13443 case SME_AC_BE:
13444 access_category = UAPSD_BE;
13445 break;
13446 case SME_AC_VI:
13447 access_category = UAPSD_VI;
13448 break;
13449 case SME_AC_VO:
13450 access_category = UAPSD_VO;
13451 break;
13452 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013453 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013454 }
13455
Anurag Chouhan6d760662016-02-20 16:05:43 +053013456 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013457 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013458 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013459 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013460 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013461 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013462 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013463 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013465 "Failed to disable uapsd for ac %d for sessionId %d",
13466 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013467 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013468 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013469 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013470}
13471
13472/**
13473 * sme_update_nss() - SME API to change the number for spatial streams
13474 * (1 or 2)
13475 * @hal: Handle returned by mac open
13476 * @nss: Number of spatial streams
13477 *
13478 * This function is used to update the number of spatial streams supported.
13479 *
13480 * Return: Success upon successfully changing nss else failure
13481 *
13482 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013483QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013484{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013485 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013486 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13487 uint32_t i, value = 0;
13488 union {
13489 uint16_t cfg_value16;
13490 tSirMacHTCapabilityInfo ht_cap_info;
13491 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013492 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013493
13494 status = sme_acquire_global_lock(&mac_ctx->sme);
13495
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013496 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013497 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13498
13499 /* get the HT capability info*/
13500 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13501 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13502
13503 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13504 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13505 csr_session = &mac_ctx->roam.roamSession[i];
13506 csr_session->htConfig.ht_tx_stbc =
13507 uHTCapabilityInfo.ht_cap_info.txSTBC;
13508 }
13509 }
13510
13511 sme_release_global_lock(&mac_ctx->sme);
13512 }
13513 return status;
13514}
13515
13516/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013517 * sme_update_user_configured_nss() - sets the nss based on user request
13518 * @hal: Pointer to HAL
13519 * @nss: number of streams
13520 *
13521 * Return: None
13522 */
13523void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13524{
13525 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13526
13527 mac_ctx->user_configured_nss = nss;
13528}
13529
13530/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013531 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13532 * @hal: global hal handle
13533 * @cb: callback function pointer
13534 *
13535 * This function stores nud debug stats callback function.
13536 *
13537 * Return: QDF_STATUS enumeration.
13538 */
13539QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13540 void (*cb)(void *, struct rsp_stats *))
13541{
13542 QDF_STATUS status = QDF_STATUS_SUCCESS;
13543 tpAniSirGlobal mac;
13544
13545 if (!hal) {
13546 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13547 FL("hal is not valid"));
13548 return QDF_STATUS_E_INVAL;
13549 }
13550 mac = PMAC_STRUCT(hal);
13551
13552 status = sme_acquire_global_lock(&mac->sme);
13553 if (!QDF_IS_STATUS_SUCCESS(status)) {
13554 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13555 FL("sme_acquire_global_lock failed!(status=%d)"),
13556 status);
13557 return status;
13558 }
13559
13560 mac->sme.get_arp_stats_cb = cb;
13561 sme_release_global_lock(&mac->sme);
13562 return status;
13563}
13564
13565/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013566 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013567 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013568 * @cb: callback function pointer
13569 *
13570 * This function stores the rssi threshold breached callback function.
13571 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013572 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013573 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013574QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013575 void (*cb)(void *, struct rssi_breach_event *))
13576{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013577 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013578 tpAniSirGlobal mac;
13579
13580 if (!h_hal) {
13581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13582 FL("hHal is not valid"));
13583 return QDF_STATUS_E_INVAL;
13584 }
13585 mac = PMAC_STRUCT(h_hal);
13586
13587 status = sme_acquire_global_lock(&mac->sme);
13588 if (!QDF_IS_STATUS_SUCCESS(status)) {
13589 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13590 FL("sme_acquire_global_lock failed!(status=%d)"),
13591 status);
13592 return status;
13593 }
13594
13595 mac->sme.rssi_threshold_breached_cb = cb;
13596 sme_release_global_lock(&mac->sme);
13597 return status;
13598}
13599
13600/**
13601 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13602 * @hal: global hal handle
13603 *
13604 * This function de-registers the rssi threshold breached callback function.
13605 *
13606 * Return: QDF_STATUS enumeration.
13607 */
13608QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13609{
13610 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013611 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13612
13613 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013614 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013615 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013616 return status;
13617 }
13618
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013619 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013620 sme_release_global_lock(&mac->sme);
13621 return status;
13622}
13623
13624/**
13625 * sme_is_any_session_in_connected_state() - SME wrapper API to
13626 * check if any session is in connected state or not.
13627 *
13628 * @hal: Handle returned by mac open
13629 *
13630 * This function is used to check if any valid sme session is in
13631 * connected state or not.
13632 *
13633 * Return: true if any session is connected, else false.
13634 *
13635 */
13636bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13637{
13638 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013639 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013640 bool ret = false;
13641
13642 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013643 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013644 ret = csr_is_any_session_in_connect_state(mac_ctx);
13645 sme_release_global_lock(&mac_ctx->sme);
13646 }
13647 return ret;
13648}
13649
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013650QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13651 void (*cb)(void *,
13652 struct chip_pwr_save_fail_detected_params *)) {
13653
13654 QDF_STATUS status = QDF_STATUS_SUCCESS;
13655 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13656
13657 status = sme_acquire_global_lock(&mac->sme);
13658 if (status != QDF_STATUS_SUCCESS) {
13659 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13660 return status;
13661 }
13662 mac->sme.chip_power_save_fail_cb = cb;
13663 sme_release_global_lock(&mac->sme);
13664 return status;
13665}
13666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013667/**
13668 * sme_set_rssi_monitoring() - set rssi monitoring
13669 * @hal: global hal handle
13670 * @input: request message
13671 *
13672 * This function constructs the vos message and fill in message type,
13673 * bodyptr with @input and posts it to WDA queue.
13674 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013675 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013676 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013677QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678 struct rssi_monitor_req *input)
13679{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013680 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013681 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013682 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013683 struct rssi_monitor_req *req_msg;
13684
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013685 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013686 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013687 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013688 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013689 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013690 }
13691
13692 *req_msg = *input;
13693
13694 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013695 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013696 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013697 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013698 return status;
13699 }
13700
13701 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013702 message.bodyptr = req_msg;
13703 message.type = WMA_SET_RSSI_MONITOR_REQ;
13704 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013705 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013706 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013707 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013708 }
13709 sme_release_global_lock(&mac->sme);
13710
13711 return status;
13712}
13713
13714/**
13715 * sme_fw_mem_dump() - Get FW memory dump
13716 * @hHal: hal handle
13717 * @recvd_req: received memory dump request.
13718 *
13719 * This API is invoked by HDD to indicate FW to start
13720 * dumping firmware memory.
13721 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013722 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013723 */
13724#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013725QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013726{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013727 QDF_STATUS status = QDF_STATUS_SUCCESS;
13728 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013729 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013730 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013731 struct fw_dump_req *send_req;
13732 struct fw_dump_seg_req seg_req;
13733 int loop;
13734
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013735 send_req = qdf_mem_malloc(sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013736 if (!send_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013737 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013738 FL("Memory allocation failed for WDA_FW_MEM_DUMP"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013739 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013740 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013741 qdf_mem_copy(send_req, recvd_req, sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013742
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013743 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013744 FL("request_id:%d num_seg:%d"),
13745 send_req->request_id, send_req->num_seg);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013747 FL("Segment Information"));
13748 for (loop = 0; loop < send_req->num_seg; loop++) {
13749 seg_req = send_req->segment[loop];
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("seg_number:%d"), loop);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013752 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013753 FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
13754 seg_req.seg_id, seg_req.seg_start_addr_lo,
13755 seg_req.seg_start_addr_hi);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013756 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013757 FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
13758 seg_req.seg_length, seg_req.dst_addr_lo,
13759 seg_req.dst_addr_hi);
13760 }
13761
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013762 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013763 msg.bodyptr = send_req;
13764 msg.type = WMA_FW_MEM_DUMP_REQ;
13765 msg.reserved = 0;
13766
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013767 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013768 if (QDF_STATUS_SUCCESS != qdf_status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013769 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013770 FL("Not able to post WMA_FW_MEM_DUMP"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013771 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013772 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013773 }
13774 sme_release_global_lock(&pMac->sme);
13775 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013777 FL("Failed to acquire SME Global Lock"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013778 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013779 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013780 }
13781
13782 return status;
13783}
13784#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013785QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013786{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013787 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013788}
13789#endif /* WLAN_FEATURE_MEMDUMP */
13790
13791/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013792 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013793 * @hal: Handle returned by macOpen
13794 * @msg: PCL channel list and length structure
13795 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013796 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013797 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013798 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013799QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013800{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013801 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013802 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013803 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013804 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013805 uint32_t len, i;
13806
13807 len = sizeof(*req_msg);
13808
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013809 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013810 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013811 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013812 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013813 }
13814
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013815 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013816 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013817 req_msg->weight_list[i] = msg.weight_list[i];
13818 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013819
13820 req_msg->pcl_len = msg.pcl_len;
13821
13822 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013823 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013824 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013825 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013826 return status;
13827 }
13828
13829 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013830 message.bodyptr = req_msg;
13831 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13832 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013833 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013834 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013835 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013836 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013837 }
13838 sme_release_global_lock(&mac->sme);
13839
13840 return status;
13841}
13842
13843/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013844 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013845 * @hal: Handle returned by macOpen
13846 * @msg: HW mode structure containing hw mode and callback details
13847 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013848 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013849 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013850 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013851QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013852{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013853 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013854 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013855 tSmeCmd *cmd = NULL;
13856
13857 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013858 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013859 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013860 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013861 }
13862
Krunal Soni78618d92017-02-14 21:46:31 -080013863 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013864 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013865 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013866 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013867 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013868 }
13869
13870 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013871 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013872 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13873 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013874 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13875 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013876 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013877
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013878 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013879 cmd->u.set_hw_mode_cmd.session_id,
13880 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013881 csr_queue_sme_command(mac, cmd, false);
13882
13883 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013884 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013885}
13886
13887/**
13888 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13889 * @hal: Handle returned by macOpen
13890 * @callback: HDD callback to be registered
13891 *
13892 * Registers the HDD callback with SME. This callback will be invoked when
13893 * HW mode transition event is received from the FW
13894 *
13895 * Return: None
13896 */
13897void sme_register_hw_mode_trans_cb(tHalHandle hal,
13898 hw_mode_transition_cb callback)
13899{
13900 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13901
13902 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013903}
13904
13905/**
13906 * sme_nss_update_request() - Send beacon templete update to FW with new
13907 * nss value
13908 * @hal: Handle returned by macOpen
13909 * @vdev_id: the session id
13910 * @new_nss: the new nss value
13911 * @cback: hdd callback
13912 * @next_action: next action to happen at policy mgr after beacon update
13913 *
13914 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013915 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013916 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013917QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13918 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13919 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13920 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013921{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013922 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013923 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013924 tSmeCmd *cmd = NULL;
13925
13926 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013927 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013928 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013929 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013930 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013931 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013932 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013933 }
13934 cmd->command = e_sme_command_nss_update;
13935 /* Sessionized modules may require this info */
13936 cmd->sessionId = vdev_id;
13937 cmd->u.nss_update_cmd.new_nss = new_nss;
13938 cmd->u.nss_update_cmd.session_id = vdev_id;
13939 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013940 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013941 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013942 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013943
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013944 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013945 csr_queue_sme_command(mac, cmd, false);
13946 sme_release_global_lock(&mac->sme);
13947 }
13948 return status;
13949}
13950
13951/**
13952 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13953 * @hal: Handle returned by macOpen
13954 * @msg: Structure containing the dual mac config parameters
13955 *
13956 * Queues configuration information to CSR to configure
13957 * WLAN firmware for the dual MAC features
13958 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013959 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013960 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013961QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013962{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013963 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013964 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013965 tSmeCmd *cmd;
13966
13967 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013968 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013969 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013970 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013971 }
13972
Krunal Soni78618d92017-02-14 21:46:31 -080013973 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013974 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013975 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013976 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013977 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013978 }
13979
13980 cmd->command = e_sme_command_set_dual_mac_config;
13981 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13982 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13983 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13984
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013985 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013986 cmd->u.set_dual_mac_cmd.scan_config,
13987 cmd->u.set_dual_mac_cmd.fw_mode_config);
13988 csr_queue_sme_command(mac, cmd, false);
13989
13990 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013991 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013992}
13993
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013994#ifdef FEATURE_LFR_SUBNET_DETECTION
13995/**
13996 * sme_gateway_param_update() - to update gateway parameters with WMA
13997 * @Hal: hal handle
13998 * @gw_params: request parameters from HDD
13999 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014000 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014001 *
14002 * This routine will update gateway parameters to WMA
14003 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014004QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014005 struct gateway_param_update_req *gw_params)
14006{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014007 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014008 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014009 struct gateway_param_update_req *request_buf;
14010
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014011 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014012 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014013 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014014 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014015 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014016 }
14017
14018 *request_buf = *gw_params;
14019
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014020 message.type = WMA_GW_PARAM_UPDATE_REQ;
14021 message.reserved = 0;
14022 message.bodyptr = request_buf;
14023 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014024 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014025 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014026 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014027 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014028 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014029 }
14030
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014031 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080014032}
14033#endif /* FEATURE_LFR_SUBNET_DETECTION */
14034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014035/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014036 * sme_soc_set_antenna_mode() - set antenna mode
14037 * @hal: Handle returned by macOpen
14038 * @msg: Structure containing the antenna mode parameters
14039 *
14040 * Send the command to CSR to send
14041 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
14042 *
14043 * Return: QDF_STATUS
14044 */
14045QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
14046 struct sir_antenna_mode_param *msg)
14047{
14048 QDF_STATUS status = QDF_STATUS_SUCCESS;
14049 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14050 tSmeCmd *cmd;
14051
14052 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014053 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014054 return QDF_STATUS_E_FAILURE;
14055 }
14056
14057 status = sme_acquire_global_lock(&mac->sme);
14058 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014059 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014060 return QDF_STATUS_E_RESOURCES;
14061 }
14062
Krunal Soni78618d92017-02-14 21:46:31 -080014063 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014064 if (!cmd) {
14065 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014066 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014067 return QDF_STATUS_E_NULL_VALUE;
14068 }
14069
14070 cmd->command = e_sme_command_set_antenna_mode;
14071 cmd->u.set_antenna_mode_cmd = *msg;
14072
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014073 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080014074 cmd->u.set_antenna_mode_cmd.num_rx_chains,
14075 cmd->u.set_antenna_mode_cmd.num_tx_chains);
14076
14077 csr_queue_sme_command(mac, cmd, false);
14078 sme_release_global_lock(&mac->sme);
14079
14080 return QDF_STATUS_SUCCESS;
14081}
14082
14083/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014084 * sme_set_peer_authorized() - call peer authorized callback
14085 * @peer_addr: peer mac address
14086 * @auth_cb: auth callback
14087 * @vdev_id: vdev id
14088 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053014089 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014090 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014091QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014092 sme_peer_authorized_fp auth_cb,
14093 uint32_t vdev_id)
14094{
14095 void *wma_handle;
14096
Anurag Chouhan6d760662016-02-20 16:05:43 +053014097 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014098 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014100 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014101 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014102 }
14103
14104 wma_set_peer_authorized_cb(wma_handle, auth_cb);
14105 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
14106 1, vdev_id);
14107}
14108
14109/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070014110 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014111 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070014112 * @fcc_constraint: flag to enable/disable the constraint
14113 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014114 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014115 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014116 */
Amar Singhal83a047a2016-05-19 15:56:11 -070014117QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
14118 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014119{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014120 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014121 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
14122
14123 status = sme_acquire_global_lock(&mac_ptr->sme);
14124
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014125 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014126
14127 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
14128 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070014129 if (scan_pending)
14130 mac_ptr->scan.defer_update_channel_list = true;
14131 else
14132 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014133 }
14134
14135 sme_release_global_lock(&mac_ptr->sme);
14136 }
14137
14138 return status;
14139}
14140/**
14141 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
14142 * @hal: Global MAC pointer
14143 *
14144 * Return: NULL.
14145 */
14146void sme_setdef_dot11mode(tHalHandle hal)
14147{
14148 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014150 csr_set_default_dot11_mode(mac_ctx);
14151}
14152
14153/**
14154 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
14155 * params
14156 * @hal_handle - The handle returned by macOpen.
14157 * @session_id - Session Identifier
14158 * @notify_id - Identifies 1 of the 4 parameters to be modified
14159 * @val New value of the parameter
14160 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014161 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014162 * Other status means SME failed to update
14163 */
14164
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014165QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014166 uint8_t session_id,
14167 uint32_t notify_id,
14168 int32_t val)
14169{
14170 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014171 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014172 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014173 tpCsrNeighborRoamControlInfo nr_info = NULL;
14174 uint32_t reason = 0;
14175
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080014176 if (session_id >= CSR_ROAM_SESSION_MAX) {
14177 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14178 FL("Invalid sme session id: %d"), session_id);
14179 return QDF_STATUS_E_INVAL;
14180 }
14181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014182 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014183 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014184 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
14185 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
14186 switch (notify_id) {
14187 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014188 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014189 "%s: gRoamScanHirssiMaxCount %d => %d",
14190 __func__, nr_config->nhi_rssi_scan_max_count,
14191 val);
14192 nr_config->nhi_rssi_scan_max_count = val;
14193 nr_info->cfgParams.hi_rssi_scan_max_count = val;
14194 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
14195 break;
14196
14197 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014198 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014199 FL("gRoamScanHiRssiDelta %d => %d"),
14200 nr_config->nhi_rssi_scan_rssi_delta,
14201 val);
14202 nr_config->nhi_rssi_scan_rssi_delta = val;
14203 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
14204 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
14205 break;
14206
14207 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014208 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014209 FL("gRoamScanHiRssiDelay %d => %d"),
14210 nr_config->nhi_rssi_scan_delay,
14211 val);
14212 nr_config->nhi_rssi_scan_delay = val;
14213 nr_info->cfgParams.hi_rssi_scan_delay = val;
14214 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
14215 break;
14216
14217 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014218 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014219 FL("gRoamScanHiRssiUpperBound %d => %d"),
14220 nr_config->nhi_rssi_scan_rssi_ub,
14221 val);
14222 nr_config->nhi_rssi_scan_rssi_ub = val;
14223 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
14224 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
14225 break;
14226
14227 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014228 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014229 FL("invalid parameter notify_id %d"),
14230 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014231 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014232 break;
14233 }
14234 sme_release_global_lock(&mac_ctx->sme);
14235 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014236 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014237 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014238 csr_roam_offload_scan(mac_ctx, session_id,
14239 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
14240 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014241
14242 return status;
14243}
14244
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014245/**
14246 * sme_update_tgt_services() - update the target services config.
14247 * @hal: HAL pointer.
14248 * @cfg: wma_tgt_services parameters.
14249 *
14250 * update the target services config.
14251 *
14252 * Return: None.
14253 */
14254void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
14255{
14256 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14257
Krunal Sonie6a1cda2017-09-27 15:23:02 -070014258 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014259 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053014260 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053014261 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053014262 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014263
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070014264}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014265
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014266/**
14267 * sme_is_session_id_valid() - Check if the session id is valid
14268 * @hal: Pointer to HAL
14269 * @session_id: Session id
14270 *
14271 * Checks if the session id is valid or not
14272 *
14273 * Return: True is the session id is valid, false otherwise
14274 */
14275bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
14276{
14277 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014278
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014279 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053014280 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14281 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014282 return false;
14283 }
14284
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014285 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014286 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014287
14288 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053014289}
14290
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014291#ifdef FEATURE_WLAN_TDLS
14292
14293/**
14294 * sme_get_opclass() - determine operating class
14295 * @hal: Pointer to HAL
14296 * @channel: channel id
14297 * @bw_offset: bandwidth offset
14298 * @opclass: pointer to operating class
14299 *
14300 * Function will determine operating class from regdm_get_opclass_from_channel
14301 *
14302 * Return: none
14303 */
14304void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
14305 uint8_t *opclass)
14306{
14307 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14308
14309 /* redgm opclass table contains opclass for 40MHz low primary,
14310 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
14311 * first we will check if bit for 40MHz is set and if so find
14312 * matching opclass either with low primary or high primary
14313 * (a channel would never be in both) and then search for opclass
14314 * matching 20MHz, else for any BW.
14315 */
14316 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014317 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014318 mac_ctx->scan.countryCodeCurrent,
14319 channel, BW40_LOW_PRIMARY);
14320 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014321 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014322 mac_ctx->scan.countryCodeCurrent,
14323 channel, BW40_HIGH_PRIMARY);
14324 }
14325 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014326 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014327 mac_ctx->scan.countryCodeCurrent,
14328 channel, BW20);
14329 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014330 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053014331 mac_ctx->scan.countryCodeCurrent,
14332 channel, BWALL);
14333 }
14334}
14335#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014336
14337#ifdef FEATURE_GREEN_AP
14338/**
14339 * sme_send_egap_conf_params() - set the enhanced green ap configuration params
14340 * @enable: enable/disable the enhanced green ap feature
14341 * @inactivity_time: inactivity timeout value
14342 * @wait_time: wait timeout value
14343 * @flag: feature flag in bitmasp
14344 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014345 * Return: Return QDF_STATUS, otherwise appropriate failure code
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014347QDF_STATUS sme_send_egap_conf_params(uint32_t enable, uint32_t inactivity_time,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014348 uint32_t wait_time, uint32_t flags)
14349{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014350 struct scheduler_msg message = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014351 QDF_STATUS status;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014352 struct egap_conf_params *egap_params;
14353
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014354 egap_params = qdf_mem_malloc(sizeof(*egap_params));
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014355 if (NULL == egap_params) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014356 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014357 "%s: fail to alloc egap_params", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014358 return QDF_STATUS_E_NOMEM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014359 }
14360
14361 egap_params->enable = enable;
14362 egap_params->inactivity_time = inactivity_time;
14363 egap_params->wait_time = wait_time;
14364 egap_params->flags = flags;
14365
14366 message.type = WMA_SET_EGAP_CONF_PARAMS;
14367 message.bodyptr = egap_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014368 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014369 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014370 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014371 "%s: Not able to post msg to WMA!", __func__);
14372
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014373 qdf_mem_free(egap_params);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080014374 }
14375 return status;
14376}
14377#endif
Sandeep Puligillae0875662016-02-12 16:09:21 -080014378
14379/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053014380 * sme_set_fw_test() - set fw test
14381 * @fw_test: fw test param
14382 *
14383 * Return: Return QDF_STATUS, otherwise appropriate failure code
14384 */
14385QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
14386{
14387 void *wma_handle;
14388
14389 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14390 if (!wma_handle) {
14391 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14392 "wma handle is NULL");
14393 return QDF_STATUS_E_FAILURE;
14394 }
14395 wma_process_fw_test_cmd(wma_handle, fw_test);
14396 return QDF_STATUS_SUCCESS;
14397}
14398
14399/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080014400 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
14401 * @hal: mac handel
14402 * @vdev_id: vdev identifier
14403 *
14404 * Return: Return QDF_STATUS, otherwise appropriate failure code
14405 */
14406QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
14407{
14408 void *wma_handle;
14409
14410 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14411 if (!wma_handle) {
14412 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14413 "wma handle is NULL");
14414 return QDF_STATUS_E_FAILURE;
14415 }
14416 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
14417 return QDF_STATUS_SUCCESS;
14418}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014419
14420/**
14421 * sme_update_mimo_power_save() - Update MIMO power save
14422 * configuration
14423 * @hal: The handle returned by macOpen
14424 * @is_ht_smps_enabled: enable/disable ht smps
14425 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080014426 * @send_smps_action: flag to send smps force mode command
14427 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014428 *
14429 * Return: QDF_STATUS if SME update mimo power save
14430 * configuration sucsess else failue status
14431 */
14432QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
14433 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080014434 uint8_t ht_smps_mode,
14435 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014436{
14437 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080014438
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014439 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080014440 is_ht_smps_enabled, ht_smps_mode,
14441 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014442 mac_ctx->roam.configParam.enableHtSmps =
14443 is_ht_smps_enabled;
14444 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080014445 mac_ctx->roam.configParam.send_smps_action =
14446 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014447
14448 return QDF_STATUS_SUCCESS;
14449}
14450
14451/**
14452 * sme_is_sta_smps_allowed() - check if the supported nss for
14453 * the session is greater than 1x1 to enable sta SMPS
14454 * @hal: The handle returned by macOpen
14455 * @session_id: session id
14456 *
14457 * Return: bool returns true if supported nss is greater than
14458 * 1x1 else false
14459 */
14460bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
14461{
14462 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014463 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014464
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014465 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
14466 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014467 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053014468 return false;
14469 }
14470
14471 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014472 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014473 return false;
14474 }
14475
14476 return (csr_session->supported_nss_1x1 == true) ? false : true;
14477}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014478
14479/**
14480 * sme_add_beacon_filter() - set the beacon filter configuration
14481 * @hal: The handle returned by macOpen
14482 * @session_id: session id
14483 * @ie_map: bitwise array of IEs
14484 *
14485 * Return: Return QDF_STATUS, otherwise appropriate failure code
14486 */
14487QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
14488 uint32_t session_id,
14489 uint32_t *ie_map)
14490{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014491 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014492 QDF_STATUS qdf_status;
14493 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14494 struct beacon_filter_param *filter_param;
14495
14496 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014497 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014498 return QDF_STATUS_E_FAILURE;
14499 }
14500
14501 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14502 if (NULL == filter_param) {
14503 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14504 "%s: fail to alloc filter_param", __func__);
14505 return QDF_STATUS_E_FAILURE;
14506 }
14507
14508 filter_param->vdev_id = session_id;
14509
14510 qdf_mem_copy(filter_param->ie_map, ie_map,
14511 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14512
14513 message.type = WMA_ADD_BCN_FILTER_CMDID;
14514 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014515 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014516 &message);
14517 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14518 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14519 "%s: Not able to post msg to WDA!",
14520 __func__);
14521
14522 qdf_mem_free(filter_param);
14523 }
14524 return qdf_status;
14525}
14526
14527/**
14528 * sme_remove_beacon_filter() - set the beacon filter configuration
14529 * @hal: The handle returned by macOpen
14530 * @session_id: session id
14531 *
14532 * Return: Return QDF_STATUS, otherwise appropriate failure code
14533 */
14534QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14535{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014536 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014537 QDF_STATUS qdf_status;
14538 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14539 struct beacon_filter_param *filter_param;
14540
14541 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014542 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014543 return QDF_STATUS_E_FAILURE;
14544 }
14545
14546 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14547 if (NULL == filter_param) {
14548 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14549 "%s: fail to alloc filter_param", __func__);
14550 return QDF_STATUS_E_FAILURE;
14551 }
14552
14553 filter_param->vdev_id = session_id;
14554
14555 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14556 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014557 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014558 &message);
14559 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14560 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14561 "%s: Not able to post msg to WDA!",
14562 __func__);
14563
14564 qdf_mem_free(filter_param);
14565 }
14566 return qdf_status;
14567}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014568
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014569/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014570 * sme_send_disassoc_req_frame - send disassoc req
14571 * @hal: handler to hal
14572 * @session_id: session id
14573 * @peer_mac: peer mac address
14574 * @reason: reason for disassociation
14575 * wait_for_ack: wait for acknowledgment
14576 *
14577 * function to send disassoc request to lim
14578 *
14579 * return: none
14580 */
14581void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14582 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14583{
14584 struct sme_send_disassoc_frm_req *msg;
14585 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14586 A_UINT8 *buf;
14587 A_UINT16 tmp;
14588
14589 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14590
14591 if (NULL == msg)
14592 qdf_status = QDF_STATUS_E_FAILURE;
14593 else
14594 qdf_status = QDF_STATUS_SUCCESS;
14595
14596 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14597 return;
14598
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014599 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14600
14601 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14602
14603 buf = &msg->session_id;
14604
14605 /* session id */
14606 *buf = (A_UINT8) session_id;
14607 buf += sizeof(A_UINT8);
14608
14609 /* transaction id */
14610 *buf = 0;
14611 *(buf + 1) = 0;
14612 buf += sizeof(A_UINT16);
14613
14614 /* Set the peer MAC address before sending the message to LIM */
14615 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14616
14617 buf += QDF_MAC_ADDR_SIZE;
14618
14619 /* reasoncode */
14620 tmp = (uint16_t) reason;
14621 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14622 buf += sizeof(uint16_t);
14623
14624 *buf = wait_for_ack;
14625 buf += sizeof(uint8_t);
14626
Rajeev Kumard138ac52017-01-30 18:38:37 -080014627 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014628
14629 if (qdf_status != QDF_STATUS_SUCCESS)
14630 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14631 FL("cds_send_mb_message Failed"));
14632}
14633
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014634QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14635 bpf_get_offload_cb callback,
14636 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014637{
14638 QDF_STATUS status = QDF_STATUS_SUCCESS;
14639 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014640 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014641
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014642 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014643
14644 status = sme_acquire_global_lock(&mac_ctx->sme);
14645 if (QDF_STATUS_SUCCESS == status) {
14646 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014647 mac_ctx->sme.bpf_get_offload_cb = callback;
14648 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014649 cds_msg.bodyptr = NULL;
14650 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014651 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014652 if (!QDF_IS_STATUS_SUCCESS(status)) {
14653 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14654 FL("Post bpf get offload msg fail"));
14655 status = QDF_STATUS_E_FAILURE;
14656 }
14657 sme_release_global_lock(&mac_ctx->sme);
14658 } else {
14659 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14660 FL("sme_acquire_global_lock error"));
14661 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014662 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014663 return status;
14664}
14665
14666
14667/**
14668 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14669 * @hal: HAL handle
14670 * @bpf_set_offload: struct to set bpf filter instructions.
14671 *
14672 * Return: QDF_STATUS enumeration.
14673 */
14674QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14675 struct sir_bpf_set_offload *req)
14676{
14677 QDF_STATUS status = QDF_STATUS_SUCCESS;
14678 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014679 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014680 struct sir_bpf_set_offload *set_offload;
14681
Arun Khandavallica198b52016-04-26 20:53:35 +053014682 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14683 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014684
14685 if (NULL == set_offload) {
14686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14687 FL("Failed to alloc set_offload"));
14688 return QDF_STATUS_E_NOMEM;
14689 }
14690
14691 set_offload->session_id = req->session_id;
14692 set_offload->filter_id = req->filter_id;
14693 set_offload->current_offset = req->current_offset;
14694 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014695 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014696 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014697 set_offload->program = ((uint8_t *)set_offload) +
14698 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014699 qdf_mem_copy(set_offload->program, req->program,
14700 set_offload->current_length);
14701 }
14702 status = sme_acquire_global_lock(&mac_ctx->sme);
14703 if (QDF_STATUS_SUCCESS == status) {
14704 /* Serialize the req through MC thread */
14705 cds_msg.bodyptr = set_offload;
14706 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014707 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014708
14709 if (!QDF_IS_STATUS_SUCCESS(status)) {
14710 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14711 FL("Post BPF set offload msg fail"));
14712 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014713 qdf_mem_free(set_offload);
14714 }
14715 sme_release_global_lock(&mac_ctx->sme);
14716 } else {
14717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14718 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014719 qdf_mem_free(set_offload);
14720 }
14721 return status;
14722}
14723
14724/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014725 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14726 * @hal: hal pointer
14727 *
14728 * Return: wni dot11 mode.
14729 */
14730uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14731{
14732 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14733
14734 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14735 mac_ctx->roam.configParam.uCfgDot11Mode);
14736}
14737
14738/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014739 * sme_create_mon_session() - post message to create PE session for monitormode
14740 * operation
14741 * @hal_handle: Handle to the HAL
14742 * @bssid: pointer to bssid
14743 *
14744 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14745 */
14746QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14747{
14748 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14749 struct sir_create_session *msg;
14750
14751 msg = qdf_mem_malloc(sizeof(*msg));
14752 if (NULL != msg) {
14753 msg->type = eWNI_SME_MON_INIT_SESSION;
14754 msg->msg_len = sizeof(*msg);
14755 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014756 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014757 }
14758 return status;
14759}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014760
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014761void sme_set_chan_info_callback(tHalHandle hal_handle,
14762 void (*callback)(struct scan_chan_info *chan_info))
14763{
14764 tpAniSirGlobal mac;
14765
14766 if (hal_handle == NULL) {
14767 QDF_ASSERT(0);
14768 return;
14769 }
14770 mac = PMAC_STRUCT(hal_handle);
14771 mac->chan_info_cb = callback;
14772}
14773
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014774/**
14775 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14776 * @hal: The handle returned by macOpen
14777 * @params: adaptive_dwelltime_params config
14778 *
14779 * Return: QDF_STATUS if adaptive dwell time update
14780 * configuration sucsess else failure status
14781 */
14782QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14783 struct adaptive_dwelltime_params *params)
14784{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014785 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014786 QDF_STATUS status;
14787 struct adaptive_dwelltime_params *dwelltime_params;
14788
14789 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14790 if (NULL == dwelltime_params) {
14791 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14792 "%s: fail to alloc dwelltime_params", __func__);
14793 return QDF_STATUS_E_NOMEM;
14794 }
14795
14796 dwelltime_params->is_enabled = params->is_enabled;
14797 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14798 dwelltime_params->lpf_weight = params->lpf_weight;
14799 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14800 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14801
14802 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14803 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014804 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014805 if (!QDF_IS_STATUS_SUCCESS(status)) {
14806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14807 "%s: Not able to post msg to WMA!", __func__);
14808
14809 qdf_mem_free(dwelltime_params);
14810 }
14811 return status;
14812}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014813
14814/**
14815 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14816 * @hal: Pointer to HAL
14817 * @vdev_id: vdev_id for which IE is targeted
14818 *
14819 * Return: None
14820 */
14821void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14822{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014823 struct sir_set_vdev_ies_per_band *p_msg;
14824 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14825
14826 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14827 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014828 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014829 return;
14830 }
14831
14832 p_msg->vdev_id = vdev_id;
14833 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14834 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014835 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014836 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014837 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014838 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014839 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014840}
14841
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014842/**
14843 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14844 * @hal: Pointer to HAL
14845 * @enable2x2: 1x1 or 2x2 mode.
14846 *
14847 * Sends the set pdev IE req with Nss value.
14848 *
14849 * Return: None
14850 */
14851void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14852{
14853 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14854 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14855 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14856
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014857 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14858 eCSR_CFG_DOT11_MODE_AUTO) ||
14859 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14860 eCSR_CFG_DOT11_MODE_11N) ||
14861 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14862 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14863 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14864 eCSR_CFG_DOT11_MODE_11AC) ||
14865 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14866 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14867 return;
14868
14869 status = sme_acquire_global_lock(&mac_ctx->sme);
14870 if (QDF_STATUS_SUCCESS == status) {
14871 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14872 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014873 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014874 sme_release_global_lock(&mac_ctx->sme);
14875 return;
14876 }
14877
14878 ht_vht_cfg->pdev_id = 0;
14879 if (enable2x2)
14880 ht_vht_cfg->nss = 2;
14881 else
14882 ht_vht_cfg->nss = 1;
14883 ht_vht_cfg->dot11mode =
14884 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14885 mac_ctx->roam.configParam.uCfgDot11Mode);
14886
14887 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14888 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014889 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14890 ht_vht_cfg->nss,
14891 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014892 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014893 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014894 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014895
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014896 sme_release_global_lock(&mac_ctx->sme);
14897 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014898}
14899
14900/**
14901 * sme_update_vdev_type_nss() - sets the nss per vdev type
14902 * @hal: Pointer to HAL
14903 * @max_supp_nss: max_supported Nss
14904 * @band: 5G or 2.4G band
14905 *
14906 * Sets the per band Nss for each vdev type based on INI and configured
14907 * chain mask value.
14908 *
14909 * Return: None
14910 */
14911void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
14912 uint32_t vdev_type_nss, eCsrBand band)
14913{
14914 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14915 struct vdev_type_nss *vdev_nss;
14916
14917 if (eCSR_BAND_5G == band)
14918 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14919 else
14920 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14921
14922 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14923 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14924 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14925 CFG_P2P_GO_NSS(vdev_type_nss));
14926 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14927 CFG_P2P_CLI_NSS(vdev_type_nss));
14928 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14929 CFG_P2P_DEV_NSS(vdev_type_nss));
14930 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14931 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14932 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14933
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014934 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 -070014935 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14936 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14937 vdev_nss->tdls, vdev_nss->ocb);
14938}
Peng Xu8fdaa492016-06-22 10:20:47 -070014939
14940/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014941 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14942 * @hal: Pointer to HAL
14943 * @hw_dbs_capable: HW DBS capability
14944 *
14945 * Sets HW DBS capability based on INI and fw capability.
14946 *
14947 * Return: None
14948 */
14949void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14950{
14951 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014952
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014953 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14954}
14955
14956/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014957 * sme_register_p2p_lo_event() - Register for the p2p lo event
14958 * @hHal: reference to the HAL
14959 * @context: the context of the call
14960 * @callback: the callback to hdd
14961 *
14962 * This function registers the callback function for P2P listen
14963 * offload stop event.
14964 *
14965 * Return: none
14966 */
14967void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14968 p2p_lo_callback callback)
14969{
14970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14971 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14972
14973 status = sme_acquire_global_lock(&pMac->sme);
14974 pMac->sme.p2p_lo_event_callback = callback;
14975 pMac->sme.p2p_lo_event_context = context;
14976 sme_release_global_lock(&pMac->sme);
14977}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014978
14979/**
14980 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14981 * @hal: The handle returned by macOpen
14982 * @session_id: session id
14983 * @dbg_args: args for mac pwr debug command
14984 * Return: Return QDF_STATUS, otherwise appropriate failure code
14985 */
14986QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14987 struct sir_mac_pwr_dbg_cmd*
14988 dbg_args)
14989{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014990 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014991 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14992 struct sir_mac_pwr_dbg_cmd *req;
14993 int i;
14994
14995 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014996 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014997 return QDF_STATUS_E_FAILURE;
14998 }
14999
15000 req = qdf_mem_malloc(sizeof(*req));
15001 if (NULL == req) {
15002 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15003 "%s: fail to alloc mac_pwr_dbg_args", __func__);
15004 return QDF_STATUS_E_FAILURE;
15005 }
15006 req->module_id = dbg_args->module_id;
15007 req->pdev_id = dbg_args->pdev_id;
15008 req->num_args = dbg_args->num_args;
15009 for (i = 0; i < req->num_args; i++)
15010 req->args[i] = dbg_args->args[i];
15011
15012 message.type = SIR_HAL_POWER_DBG_CMD;
15013 message.bodyptr = req;
15014
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015015 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053015016 (QDF_MODULE_ID_WMA, &message))) {
15017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15018 "%s: Not able to post msg to WDA!",
15019 __func__);
15020 qdf_mem_free(req);
15021 }
15022 return QDF_STATUS_SUCCESS;
15023}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070015024/**
15025 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070015026 * @dev_mode: connection type.
15027 * @nss2g: Pointer to the 2G Nss parameter.
15028 * @nss5g: Pointer to the 5G Nss parameter.
15029 *
15030 * Fills the 2G and 5G Nss values based on connection type.
15031 *
15032 * Return: None
15033 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015034void sme_get_vdev_type_nss(enum tQDF_ADAPTER_MODE dev_mode,
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070015035 uint8_t *nss_2g, uint8_t *nss_5g)
15036{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015037 tpAniSirGlobal mac_ctx = sme_get_mac_context();
15038
15039 if (NULL == mac_ctx) {
15040 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15041 FL("Invalid MAC context"));
15042 return;
15043 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070015044 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
15045}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015046
15047/**
15048 * sme_update_sta_roam_policy() - update sta roam policy for
15049 * unsafe and DFS channels.
15050 * @hal_handle: hal handle for getting global mac struct
15051 * @dfs_mode: dfs mode which tell if dfs channel needs to be
15052 * skipped or not
15053 * @skip_unsafe_channels: Param to tell if driver needs to
15054 * skip unsafe channels or not.
15055 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053015056 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015057 *
15058 * sme_update_sta_roam_policy update sta rome policies to csr
15059 * this function will call csrUpdateChannelList as well
15060 * to include/exclude DFS channels and unsafe channels.
15061 *
15062 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
15063 */
15064QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
15065 enum sta_roam_policy_dfs_mode dfs_mode,
15066 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053015067 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015068{
15069 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
15070 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015071 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015072
15073 if (!mac_ctx) {
15074 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
15075 "%s: mac_ctx is null", __func__);
15076 return QDF_STATUS_E_FAILURE;
15077 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015078
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015079 sme_config = qdf_mem_malloc(sizeof(*sme_config));
15080 if (!sme_config) {
15081 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15082 FL("failed to allocate memory for sme_config"));
15083 return QDF_STATUS_E_FAILURE;
15084 }
15085 qdf_mem_zero(sme_config, sizeof(*sme_config));
15086 sme_get_config_param(hal_handle, sme_config);
15087
15088 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015089 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015090 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015091 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015092 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053015093 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015094
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015095 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015096
15097 status = csr_update_channel_list(mac_ctx);
15098 if (QDF_STATUS_SUCCESS != status) {
15099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15100 FL("failed to update the supported channel list"));
15101 }
15102 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
15103 csr_roam_offload_scan(mac_ctx, session_id,
15104 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
15105 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053015106
15107 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053015108 return status;
15109}
15110
15111/**
15112 * sme_enable_disable_chanavoidind_event - configure ca event ind
15113 * @hal: handler to hal
15114 * @set_value: enable/disable
15115 *
15116 * function to enable/disable chan avoidance indication
15117 *
15118 * Return: QDF_STATUS
15119 */
15120QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
15121 uint8_t set_value)
15122{
15123 QDF_STATUS status;
15124 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015125 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053015126
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015127 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053015128 status = sme_acquire_global_lock(&mac_ctx->sme);
15129 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015130 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053015131 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
15132 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015133 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053015134 sme_release_global_lock(&mac_ctx->sme);
15135 return status;
15136 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053015137 return status;
15138}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015139
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053015140/*
15141 * sme_set_default_scan_ie() - API to send default scan IE to LIM
15142 * @hal: reference to the HAL
15143 * @session_id: current session ID
15144 * @ie_data: Pointer to Scan IE data
15145 * @ie_len: Length of @ie_data
15146 *
15147 * Return: QDF_STATUS
15148 */
15149QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
15150 uint8_t *ie_data, uint16_t ie_len)
15151{
15152 QDF_STATUS status;
15153 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15154 struct hdd_default_scan_ie *set_ie_params;
15155
15156 status = sme_acquire_global_lock(&mac_ctx->sme);
15157 if (QDF_IS_STATUS_SUCCESS(status)) {
15158 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
15159 if (!set_ie_params)
15160 status = QDF_STATUS_E_NOMEM;
15161 else {
15162 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
15163 set_ie_params->length = sizeof(*set_ie_params);
15164 set_ie_params->session_id = session_id;
15165 set_ie_params->ie_len = ie_len;
15166 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080015167 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053015168 }
15169 sme_release_global_lock(&mac_ctx->sme);
15170 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053015171 return status;
15172}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015173
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080015174QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
15175 struct sar_limit_cmd_params *sar_limit_cmd)
15176{
15177 void *wma_handle;
15178
15179 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15180 if (!wma_handle) {
15181 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15182 "wma handle is NULL");
15183 return QDF_STATUS_E_FAILURE;
15184 }
15185
15186 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
15187}
15188
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053015189#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015190/**
15191 * sme_encrypt_decrypt_msg() - handles encrypt/decrypt mesaage
15192 * @hal: HAL handle
15193 * @encrypt_decrypt_params: struct to set encryption/decryption params.
15194 *
15195 * Return: QDF_STATUS enumeration.
15196 */
15197QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
Jeff Johnsone8216e82017-01-26 15:54:51 -080015198 struct encrypt_decrypt_req_params *encrypt_decrypt_params,
15199 sme_encrypt_decrypt_callback callback,
15200 void *context)
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015201{
15202 QDF_STATUS status = QDF_STATUS_SUCCESS;
15203 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015204 struct scheduler_msg cds_msg = {0};
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015205 struct encrypt_decrypt_req_params *params;
15206 uint8_t *ptr;
15207
15208 ptr = qdf_mem_malloc(sizeof(*params) +
15209 encrypt_decrypt_params->data_len);
15210 if (ptr == NULL) {
15211 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015212 "Failed to alloc memory for encrypt/decrypt params");
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015213 return QDF_STATUS_E_NOMEM;
15214 }
15215
15216 params = (struct encrypt_decrypt_req_params *)ptr;
15217
15218 *params = *encrypt_decrypt_params;
15219
15220 if (params->data_len) {
15221 params->data = ptr + sizeof(*params);
15222
15223 qdf_mem_copy(params->data, encrypt_decrypt_params->data,
15224 params->data_len);
15225 }
15226
15227 status = sme_acquire_global_lock(&mac_ctx->sme);
15228 if (status == QDF_STATUS_SUCCESS) {
15229 /* Serialize the req through MC thread */
Jeff Johnsone8216e82017-01-26 15:54:51 -080015230 mac_ctx->sme.encrypt_decrypt_cb = callback;
15231 mac_ctx->sme.encrypt_decrypt_context = context;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015232 cds_msg.bodyptr = params;
15233 cds_msg.type = WMA_ENCRYPT_DECRYPT_MSG;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015234 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053015235
15236 if (!QDF_IS_STATUS_SUCCESS(status)) {
15237 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15238 FL("Post encrypt/decrypt msg fail"));
15239 status = QDF_STATUS_E_FAILURE;
15240 qdf_mem_free(params);
15241 }
15242 sme_release_global_lock(&mac_ctx->sme);
15243 } else {
15244 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15245 FL("sme_acquire_global_lock failed"));
15246 qdf_mem_free(params);
15247 }
15248 return status;
15249
15250}
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053015251#endif
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053015252
Jeff Johnson6136fb92017-03-30 15:21:49 -070015253#ifdef WLAN_FEATURE_FIPS
15254QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
15255 wma_fips_cb callback, void *context)
15256{
15257 void *wma_handle;
15258
15259 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15260 if (!wma_handle) {
15261 sme_err("wma handle is NULL");
15262 return QDF_STATUS_E_FAILURE;
15263 }
15264
15265 return wma_fips_request(wma_handle, param, callback, context);
15266}
15267#endif
15268
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053015269QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
15270{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053015271 void *wma_handle;
15272
15273 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15274 if (!wma_handle) {
15275 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15276 "wma_handle is NULL");
15277 return QDF_STATUS_E_FAILURE;
15278 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053015279 if (QDF_STATUS_SUCCESS !=
15280 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
15281 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15282 "%s: Failed to set cts2self for p2p GO to firmware",
15283 __func__);
15284 return QDF_STATUS_E_FAILURE;
15285 }
15286 return QDF_STATUS_SUCCESS;
15287}
Yingying Tang95409972016-10-20 15:16:15 +080015288
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015289/**
15290 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
15291 * @hal: Handle returned by mac_open
15292 * @session_id: Session ID on which tx fail count needs to be updated to FW
15293 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
15294 *
15295 * This function is used to set tx fail count threshold to firmware.
15296 * firmware will issue disocnnect with peer device once this threshold is
15297 * reached.
15298 *
15299 * Return: Return QDF_STATUS, otherwise appropriate failure code
15300 */
15301QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
15302 uint8_t session_id, uint32_t tx_fail_count)
15303{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015304 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15305 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015306 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015307
15308 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
15309 if (NULL == tx_fail_cnt) {
15310 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15311 "%s: fail to alloc filter_param", __func__);
15312 return QDF_STATUS_E_FAILURE;
15313 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015314 sme_debug("session_id: %d tx_fail_count: %d",
15315 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015316 tx_fail_cnt->session_id = session_id;
15317 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
15318
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015319 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015320 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
15321 msg.reserved = 0;
15322 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015323 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015324
15325 if (!QDF_IS_STATUS_SUCCESS(status)) {
15326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015327 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015328 qdf_mem_free(tx_fail_cnt);
15329 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015330 return status;
15331}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015332
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015333QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
15334 void (*cb)(void *, struct sir_lost_link_info *))
15335{
15336 QDF_STATUS status = QDF_STATUS_SUCCESS;
15337 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15338
15339 status = sme_acquire_global_lock(&mac->sme);
15340 if (QDF_IS_STATUS_SUCCESS(status)) {
15341 mac->sme.lost_link_info_cb = cb;
15342 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015343 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015344 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053015345 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015346
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053015347 return status;
15348}
Yingying Tang95409972016-10-20 15:16:15 +080015349
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015350#ifdef FEATURE_WLAN_ESE
15351bool sme_roam_is_ese_assoc(tCsrRoamInfo *roam_info)
15352{
15353 return roam_info->isESEAssoc;
15354}
Manjeet Singh2f785062017-03-08 18:14:18 +053015355#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053015356/**
Manjeet Singh2f785062017-03-08 18:14:18 +053015357 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053015358 * params from ini.
15359 * @hal_handle: Handle returned by mac_open
15360 * @5g_pref_params: pref params from ini.
15361 *
15362 * Returns: None
15363 */
15364void sme_set_5g_band_pref(tHalHandle hal_handle,
15365 struct sme_5g_band_pref_params *pref_params)
15366{
15367
15368 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
15369 struct roam_ext_params *roam_params;
15370 QDF_STATUS status = QDF_STATUS_SUCCESS;
15371
15372 if (!pref_params) {
15373 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15374 "Invalid 5G pref params!");
15375 return;
15376 }
15377 status = sme_acquire_global_lock(&mac_ctx->sme);
15378 if (QDF_STATUS_SUCCESS == status) {
15379 roam_params = &mac_ctx->roam.configParam.roam_params;
15380 roam_params->raise_rssi_thresh_5g =
15381 pref_params->rssi_boost_threshold_5g;
15382 roam_params->raise_factor_5g =
15383 pref_params->rssi_boost_factor_5g;
15384 roam_params->max_raise_rssi_5g =
15385 pref_params->max_rssi_boost_5g;
15386 roam_params->drop_rssi_thresh_5g =
15387 pref_params->rssi_penalize_threshold_5g;
15388 roam_params->drop_factor_5g =
15389 pref_params->rssi_penalize_factor_5g;
15390 roam_params->max_drop_rssi_5g =
15391 pref_params->max_rssi_penalize_5g;
15392
15393 sme_release_global_lock(&mac_ctx->sme);
15394 } else
15395 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15396 "Unable to acquire global sme lock");
15397}
15398
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015399
15400bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
15401{
15402 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015403
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015404 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
15405}
Yingying Tang95409972016-10-20 15:16:15 +080015406
15407#ifdef WLAN_FEATURE_WOW_PULSE
15408/**
15409 * sme_set_wow_pulse() - set wow pulse info
15410 * @wow_pulse_set_info: wow_pulse_mode structure pointer
15411 *
15412 * Return: QDF_STATUS
15413 */
15414QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
15415{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015416 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080015417 QDF_STATUS status;
15418 struct wow_pulse_mode *wow_pulse_set_cmd;
15419
15420 if (!wow_pulse_set_info) {
15421 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15422 "%s: invalid wow_pulse_set_info pointer", __func__);
15423 return QDF_STATUS_E_FAILURE;
15424 }
15425
15426 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
15427 if (NULL == wow_pulse_set_cmd) {
15428 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15429 "%s: fail to alloc wow_pulse_set_cmd", __func__);
15430 return QDF_STATUS_E_NOMEM;
15431 }
15432
15433 *wow_pulse_set_cmd = *wow_pulse_set_info;
15434
15435 message.type = WMA_SET_WOW_PULSE_CMD;
15436 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015437 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080015438 &message);
15439 if (!QDF_IS_STATUS_SUCCESS(status)) {
15440 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15441 "%s: Not able to post msg to WDA!",
15442 __func__);
15443 qdf_mem_free(wow_pulse_set_cmd);
15444 status = QDF_STATUS_E_FAILURE;
15445 }
15446
15447 return status;
15448}
15449#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015450
15451/**
15452 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
15453 * different fields and IEs from bss descriptor.
15454 * @frame_buf: frame buffer to populate
15455 * @bss_descp: bss descriptor
15456 * @bssid: bssid of the beacon frame to populate
15457 * @ie_len: length of IE fields
15458 *
15459 * Return: None
15460 */
15461static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
15462 tSirBssDescription *bss_descp,
15463 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080015464 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015465{
15466 tDot11fBeacon1 *bcn_fixed;
15467 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
15468
15469 /* populate mac header first to indicate beacon */
15470 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15471 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
15472 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
15473 qdf_mem_copy((uint8_t *) mac_hdr->da,
15474 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
15475 sizeof(struct qdf_mac_addr));
15476 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15477 sizeof(struct qdf_mac_addr));
15478 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15479 sizeof(struct qdf_mac_addr));
15480
15481 /* now populate fixed params */
15482 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15483 /* populate timestamp */
15484 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15485 sizeof(bss_descp->timeStamp));
15486 /* populate beacon interval */
15487 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15488 /* populate capability */
15489 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15490 sizeof(bss_descp->capabilityInfo));
15491
15492 /* copy IEs now */
15493 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15494 + SIR_MAC_B_PR_SSID_OFFSET,
15495 &bss_descp->ieFields, ie_len);
15496}
15497
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015498QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
15499 tCsrRoamProfile *profile,
15500 const uint8_t *bssid,
15501 int8_t *rssi, int8_t *snr)
15502{
15503 tSirBssDescription *bss_descp;
15504 tCsrScanResultFilter *scan_filter;
15505 struct scan_result_list *bss_list;
15506 tScanResultHandle result_handle = NULL;
15507 QDF_STATUS status = QDF_STATUS_SUCCESS;
15508 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15509
15510 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15511 if (NULL == scan_filter) {
15512 sme_err("memory allocation failed");
15513 status = QDF_STATUS_E_NOMEM;
15514 goto free_scan_flter;
15515 }
15516
15517 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15518 profile, scan_filter);
15519 if (QDF_STATUS_SUCCESS != status) {
15520 sme_err("prepare_filter failed");
15521 goto free_scan_flter;
15522 }
15523
15524 /* update filter to get scan result with just target BSSID */
15525 if (NULL == scan_filter->BSSIDs.bssid) {
15526 scan_filter->BSSIDs.bssid =
15527 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15528 if (scan_filter->BSSIDs.bssid == NULL) {
15529 sme_err("malloc failed");
15530 status = QDF_STATUS_E_NOMEM;
15531 goto free_scan_flter;
15532 }
15533 }
15534
15535 scan_filter->BSSIDs.numOfBSSIDs = 1;
15536 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15537 bssid, sizeof(struct qdf_mac_addr));
15538
15539 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15540 if (QDF_STATUS_SUCCESS != status) {
15541 sme_err("parse_scan_result failed");
15542 goto free_scan_flter;
15543 }
15544
15545 bss_list = (struct scan_result_list *)result_handle;
15546 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15547 if (!bss_descp) {
15548 sme_err("unable to fetch bss descriptor");
15549 status = QDF_STATUS_E_FAULT;
15550 goto free_scan_flter;
15551 }
15552
15553 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15554 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15555
15556 if (rssi)
15557 *rssi = bss_descp->rssi;
15558 if (snr)
15559 *snr = bss_descp->sinr;
15560
15561free_scan_flter:
15562 /* free scan filter and exit */
15563 if (scan_filter) {
15564 csr_free_scan_filter(mac_ctx, scan_filter);
15565 qdf_mem_free(scan_filter);
15566 }
15567
15568 if (result_handle)
15569 csr_scan_result_purge(mac_ctx, result_handle);
15570
15571 return status;
15572}
15573
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015574QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15575 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015576 uint8_t **frame_buf, uint32_t *frame_len,
15577 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015578{
15579 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015580 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015581 tCsrScanResultFilter *scan_filter;
15582 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15583 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015584 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015585 uint32_t ie_len;
15586
15587 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15588 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015589 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015590 status = QDF_STATUS_E_NOMEM;
15591 goto free_scan_flter;
15592 }
15593 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15594 profile, scan_filter);
15595 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015596 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015597 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015598 goto free_scan_flter;
15599 }
15600
15601 /* update filter to get scan result with just target BSSID */
15602 if (NULL == scan_filter->BSSIDs.bssid) {
15603 scan_filter->BSSIDs.bssid =
15604 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15605 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015606 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015607 status = QDF_STATUS_E_NOMEM;
15608 goto free_scan_flter;
15609 }
15610 }
15611 scan_filter->BSSIDs.numOfBSSIDs = 1;
15612 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15613 bssid, sizeof(struct qdf_mac_addr));
15614
15615 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15616 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015617 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015618 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015619 goto free_scan_flter;
15620 }
15621
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015622 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015623 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015624 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015625 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015626 status = QDF_STATUS_E_FAULT;
15627 goto free_scan_flter;
15628 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015629
Naveen Rawat81f058c2017-06-02 16:02:39 -070015630 /**
15631 * Length of BSS descriptor is without length of
15632 * length itself and length of pointer that holds ieFields.
15633 *
15634 * tSirBssDescription
15635 * +--------+---------------------------------+---------------+
15636 * | length | other fields | pointer to IEs|
15637 * +--------+---------------------------------+---------------+
15638 * ^
15639 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015640 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015641 ie_len = bss_descp->length + sizeof(bss_descp->length)
15642 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015643 sme_debug("found bss_descriptor ie_len: %d channel %d",
15644 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015645
15646 /* include mac header and fixed params along with IEs in frame */
15647 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15648 *frame_buf = qdf_mem_malloc(*frame_len);
15649 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015650 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015651 status = QDF_STATUS_E_NOMEM;
15652 goto free_scan_flter;
15653 }
15654
15655 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15656
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015657 if (!*channel)
15658 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015659free_scan_flter:
15660 /* free scan filter and exit */
15661 if (scan_filter) {
15662 csr_free_scan_filter(mac_ctx, scan_filter);
15663 qdf_mem_free(scan_filter);
15664 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015665 if (result_handle)
15666 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015667
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015668 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015669}
15670
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015671QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15672 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015673 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015674{
15675 QDF_STATUS status;
15676 struct wma_roam_invoke_cmd *fastreassoc;
15677 struct scheduler_msg msg = {0};
15678
15679 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15680 if (NULL == fastreassoc) {
15681 sme_err("qdf_mem_malloc failed for fastreassoc");
15682 return QDF_STATUS_E_NOMEM;
15683 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015684 /* if both are same then set the flag */
15685 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15686 fastreassoc->is_same_bssid = true;
15687 sme_debug("bssid same, bssid[%pM]", bssid);
15688 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015689 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015690 fastreassoc->bssid[0] = bssid[0];
15691 fastreassoc->bssid[1] = bssid[1];
15692 fastreassoc->bssid[2] = bssid[2];
15693 fastreassoc->bssid[3] = bssid[3];
15694 fastreassoc->bssid[4] = bssid[4];
15695 fastreassoc->bssid[5] = bssid[5];
15696
15697 status = sme_get_beacon_frm(hal, profile, bssid,
15698 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015699 &fastreassoc->frame_len,
15700 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015701
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015702 if (!channel) {
15703 sme_err("channel retrieval from BSS desc fails!");
15704 qdf_mem_free(fastreassoc);
15705 return QDF_STATUS_E_FAULT;
15706 }
15707
15708 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015709 if (QDF_STATUS_SUCCESS != status) {
15710 sme_warn("sme_get_beacon_frm failed");
15711 fastreassoc->frame_buf = NULL;
15712 fastreassoc->frame_len = 0;
15713 }
15714
15715 msg.type = SIR_HAL_ROAM_INVOKE;
15716 msg.reserved = 0;
15717 msg.bodyptr = fastreassoc;
15718 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15719 if (QDF_STATUS_SUCCESS != status) {
15720 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15721 qdf_mem_free(fastreassoc);
15722 }
15723
15724 return status;
15725}
15726
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015727/* ARP DEBUG STATS */
15728
15729/**
15730 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15731 * @hal: handle to hal
15732 * @set_stats_param: pointer to set stats param
15733 *
15734 * Return: Return QDF_STATUS.
15735 */
15736QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15737 struct set_arp_stats_params
15738 *set_stats_param)
15739{
15740 struct set_arp_stats_params *arp_set_param;
15741 struct scheduler_msg msg;
15742
15743 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15744 if (arp_set_param == NULL) {
15745 sme_err("Memory allocation failure");
15746 return QDF_STATUS_E_NOMEM;
15747 }
15748
15749 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15750
15751 msg.type = WMA_SET_ARP_STATS_REQ;
15752 msg.reserved = 0;
15753 msg.bodyptr = arp_set_param;
15754
15755 if (QDF_STATUS_SUCCESS !=
15756 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15757 sme_err("Not able to post message to WDA");
15758 qdf_mem_free(arp_set_param);
15759 return QDF_STATUS_E_FAILURE;
15760 }
15761
15762 return QDF_STATUS_SUCCESS;
15763}
15764
15765/**
15766 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15767 * @hal: handle to hal
15768 * @get_stats_param: pointer to set stats param
15769 *
15770 * Return: Return QDF_STATUS.
15771 */
15772QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15773 struct get_arp_stats_params
15774 *get_stats_param)
15775{
15776 struct get_arp_stats_params *arp_get_param;
15777 struct scheduler_msg msg;
15778
15779 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15780 if (arp_get_param == NULL) {
15781 sme_err("Memory allocation failure");
15782 return QDF_STATUS_E_NOMEM;
15783 }
15784
15785 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15786
15787 msg.type = WMA_GET_ARP_STATS_REQ;
15788 msg.reserved = 0;
15789 msg.bodyptr = arp_get_param;
15790
15791 if (QDF_STATUS_SUCCESS !=
15792 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15793 sme_err("Not able to post message to WDA");
15794 qdf_mem_free(arp_get_param);
15795 return QDF_STATUS_E_FAILURE;
15796 }
15797
15798 return QDF_STATUS_SUCCESS;
15799}
15800
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015801QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15802 uint32_t param_value, uint32_t vdev_id)
15803{
15804 void *wma_handle;
15805
15806 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15807 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015808 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015809 return QDF_STATUS_E_FAILURE;
15810 }
15811
15812 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15813 param_value, vdev_id);
15814}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015815
15816QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015817 bool (*set_connection_info_cb)(bool),
15818 bool (*get_connection_info_cb)(uint8_t *session_id,
15819 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015820{
15821 QDF_STATUS status = QDF_STATUS_SUCCESS;
15822 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15823
15824 status = sme_acquire_global_lock(&pMac->sme);
15825 if (QDF_IS_STATUS_SUCCESS(status)) {
15826 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015827 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015828 sme_release_global_lock(&pMac->sme);
15829 }
15830 return status;
15831}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015832
15833QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15834 void (*cb)(void *, struct rso_cmd_status *))
15835{
15836 QDF_STATUS status = QDF_STATUS_SUCCESS;
15837 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15838
15839 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015840 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015841 return status;
15842}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015843
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015844QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15845 struct wmi_dbs_scan_sel_params *params)
15846{
15847 struct scheduler_msg message = {0};
15848 QDF_STATUS status;
15849 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15850 uint32_t i;
15851
15852 if (0 == params->num_clients) {
15853 sme_err("Num of clients is 0");
15854 return QDF_STATUS_E_FAILURE;
15855 }
15856
15857 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15858 if (!dbs_scan_params) {
15859 sme_err("fail to alloc dbs_scan_params");
15860 return QDF_STATUS_E_NOMEM;
15861 }
15862
15863 dbs_scan_params->num_clients = params->num_clients;
15864 dbs_scan_params->pdev_id = params->pdev_id;
15865 for (i = 0; i < params->num_clients; i++) {
15866 dbs_scan_params->module_id[i] = params->module_id[i];
15867 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15868 dbs_scan_params->num_non_dbs_scans[i] =
15869 params->num_non_dbs_scans[i];
15870 }
15871 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15872 message.bodyptr = dbs_scan_params;
15873 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15874 if (!QDF_IS_STATUS_SUCCESS(status)) {
15875 sme_err("Not able to post msg to WMA!");
15876 qdf_mem_free(dbs_scan_params);
15877 }
15878
15879 return status;
15880}
15881
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015882void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15883{
15884 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15885 void *wma_handle;
15886 QDF_STATUS status;
15887
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015888 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015889 if (QDF_STATUS_SUCCESS != status) {
15890 mac_ctx->pdev = NULL;
15891 return;
15892 }
15893 mac_ctx->pdev = pdev;
15894 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15895 if (!wma_handle) {
15896 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015897 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015898 return;
15899 }
15900 wma_store_pdev(wma_handle, pdev);
15901}
15902
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015903QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15904 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15905{
15906 QDF_STATUS status;
15907 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15908
15909 status = sme_acquire_global_lock(&mac->sme);
15910 if (QDF_IS_STATUS_SUCCESS(status)) {
15911 mac->sme.congestion_cb = congestion_cb;
15912 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015913 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015914 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015915 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015916 }
15917
15918 return status;
15919}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015920
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015921QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15922 uint32_t param_val)
15923{
15924 return wma_configure_smps_params(vdev_id, param_id, param_val);
15925}
15926
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015927QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15928 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15929{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015930 wma_cli_set_cmd_t *iwcmd;
15931 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015932
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015933 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15934 if (!iwcmd) {
15935 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015936 return QDF_STATUS_E_NOMEM;
15937 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015938
15939 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15940 iwcmd->param_sec_value = 0;
15941 iwcmd->param_vdev_id = vdev_id;
15942 iwcmd->param_id = param_id;
15943 iwcmd->param_vp_dev = req_cat;
15944 iwcmd->param_value = param_val;
15945 wma_ipa_uc_stat_request(iwcmd);
15946 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015947
15948 return status;
15949}
lifeng66831662017-05-19 16:01:35 +080015950
15951QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15952 struct sir_set_rx_reorder_timeout_val *req)
15953{
15954 QDF_STATUS status;
15955
15956 status = wma_set_rx_reorder_timeout_val(hal, req);
15957
15958 return status;
15959}
15960
15961QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15962 struct sir_peer_set_rx_blocksize *req)
15963{
15964 QDF_STATUS status;
15965
15966 status = wma_set_rx_blocksize(hal, req);
15967
15968 return status;
15969}
Naveen Rawat247a8682017-06-05 15:00:31 -070015970
15971int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15972{
15973 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15974}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015975
15976QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15977 void (*cb)(void *, uint32_t bt_activity))
15978{
15979 QDF_STATUS status;
15980 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15981
15982 status = sme_acquire_global_lock(&mac->sme);
15983 if (QDF_IS_STATUS_SUCCESS(status)) {
15984 mac->sme.bt_activity_info_cb = cb;
15985 sme_release_global_lock(&mac->sme);
15986 sme_debug("bt activity info callback set");
15987 } else {
15988 sme_debug("sme_acquire_global_lock failed %d", status);
15989 }
15990
15991 return status;
15992}
lifengd217d192017-05-09 19:44:16 +080015993
15994QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15995 struct get_chain_rssi_req_params *input,
15996 get_chain_rssi_callback callback,
15997 void *context)
15998{
15999 QDF_STATUS status = QDF_STATUS_SUCCESS;
16000 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16001
16002 SME_ENTER();
16003
16004 if (NULL == input) {
16005 sme_err("Invalid req params");
16006 return QDF_STATUS_E_INVAL;
16007 }
16008
16009 mac_ctx->sme.get_chain_rssi_cb = callback;
16010 mac_ctx->sme.get_chain_rssi_context = context;
16011 wma_get_chain_rssi(hal, input);
16012
16013 SME_EXIT();
16014 return status;
16015}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016016
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016017QDF_STATUS sme_process_msg_callback(tHalHandle hal,
16018 struct scheduler_msg *msg)
16019{
16020 QDF_STATUS status = QDF_STATUS_E_FAILURE;
16021
16022 if (msg == NULL) {
16023 sme_err("Empty message for SME Msg callback");
16024 return status;
16025 }
16026 status = sme_process_msg(hal, msg);
16027 return status;
16028}
16029
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016030void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
16031{
16032 struct csr_roam_session *session;
16033 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16034
16035 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16036 sme_err("%s Invalid session id: %d", __func__, session_id);
16037 return;
16038 }
16039
16040 session = CSR_GET_SESSION(mac_ctx, session_id);
16041 if (!session) {
16042 sme_err("%s Failed to get session for id: %d",
16043 __func__, session_id);
16044 return;
16045 }
16046
16047 sme_debug("Total No. of Disconnections: %d",
16048 session->disconnect_stats.disconnection_cnt);
16049
16050 sme_debug("No. of Diconnects Triggered by Application: %d",
16051 session->disconnect_stats.disconnection_by_app);
16052
16053 sme_debug("No. of Disassoc Sent by Peer: %d",
16054 session->disconnect_stats.disassoc_by_peer);
16055
16056 sme_debug("No. of Deauth Sent by Peer: %d",
16057 session->disconnect_stats.deauth_by_peer);
16058
16059 sme_debug("No. of Disconnections due to Beacon Miss: %d",
16060 session->disconnect_stats.bmiss);
16061
16062 sme_debug("No. of Disconnections due to Peer Kickout: %d",
16063 session->disconnect_stats.peer_kickout);
16064}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053016065
16066/**
16067 * sme_set_bmiss_bcnt() - set bmiss config parameters
16068 * @vdev_id: virtual device for the command
16069 * @first_cnt: bmiss first value
16070 * @final_cnt: bmiss final value
16071 *
16072 * Return: QDF_STATUS_SUCCESS or non-zero on failure
16073 */
16074QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
16075 uint32_t final_cnt)
16076{
16077 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
16078}