blob: fb8a8c2a126ced3f27d483bebfcdf6371cc0b485 [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"
Naveen Rawatd2657be2017-10-10 14:31:23 -070065#include "wifi_pos_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053069static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053071static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
72 void *pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053074static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053076static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 void *pMsgBuf);
78
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053079static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053082QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
84#endif
85
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053087static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 uint16_t msg_type, void *pMsgBuf);
89
90/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053091QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053093 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094
95 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053096 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053097 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053098 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099 }
100
101 return status;
102}
103
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530104QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530106 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107
108 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530109 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530110 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530111 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 }
113
114 return status;
115}
116
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700117tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700118{
119 tpAniSirGlobal mac_ctx;
120 tHalHandle h_hal;
121
122 h_hal = cds_get_context(QDF_MODULE_ID_SME);
123 if (NULL == h_hal) {
124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
125 FL("invalid h_hal"));
126 return NULL;
127 }
128
129 mac_ctx = PMAC_STRUCT(h_hal);
130 if (NULL == mac_ctx) {
131 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
132 FL("Invalid MAC context"));
133 return NULL;
134 }
135
136 return mac_ctx;
137}
138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139/**
140 * sme_process_set_hw_mode_resp() - Process set HW mode response
141 * @mac: Global MAC pointer
142 * @msg: HW mode response
143 *
144 * Processes the HW mode response and invokes the HDD callback
145 * to process further
146 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530147static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148{
Krunal Sonia8270f52017-02-23 19:51:25 -0800149 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 tSmeCmd *command = NULL;
151 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800152 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530154 enum sir_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530155 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800156 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 param = (struct sir_set_hw_mode_resp *)msg;
159 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700160 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 /* Not returning. Need to check if active command list
162 * needs to be freed
163 */
164 }
165
Krunal Sonia8270f52017-02-23 19:51:25 -0800166 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700168 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800169 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 }
171
172 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
173 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700174 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800175 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 }
177
178 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700179 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800180 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 }
182
183 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530184 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800185 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530186
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700187 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530188 command->u.set_hw_mode_cmd.reason,
189 command->u.set_hw_mode_cmd.session_id);
190
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700191 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700192 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700193 goto end;
194 }
195
196 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700197 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700198 goto end;
199 }
200
201 /* Irrespective of the reason for which the hw mode change request
202 * was issued, the policy manager connection table needs to be updated
203 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
204 * set hw mode was successful.
205 */
206 callback(param->status,
207 param->cfgd_hw_mode_index,
208 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800209 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800210 command->u.set_hw_mode_cmd.next_action,
211 command->u.set_hw_mode_cmd.reason,
212 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800213 command->u.set_hw_mode_cmd.context);
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800214 session = CSR_GET_SESSION(mac, session_id);
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700215 if (reason == SIR_UPDATE_REASON_HIDDEN_STA) {
216 /* In the case of hidden SSID, connection update
217 * (set hw mode) is done after the scan with reason
218 * code eCsrScanForSsid completes. The connect/failure
219 * needs to be handled after the response of set hw
220 * mode
221 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800222 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700223 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800224 csr_scan_handle_search_for_ssid(mac,
225 session_id);
226 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700227 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800228 csr_scan_handle_search_for_ssid_failure(mac,
229 session_id);
230 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800231 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232 }
233
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530234end:
Krunal Soni72dba662017-02-15 20:13:17 -0800235 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530237 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800239 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530241 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242}
243
244/**
245 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
246 * @mac: Global MAC pointer
247 * @msg: HW mode transition response
248 *
249 * Processes the HW mode transition indication and invoke the HDD callback
250 * to process further
251 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530252static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 uint8_t *msg)
254{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 struct sir_hw_mode_trans_ind *param;
256
257 param = (struct sir_hw_mode_trans_ind *)msg;
258 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700259 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530260 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 }
262
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800263 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800264 param->new_hw_mode_index,
265 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800266 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530268 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269}
270
Naveen Rawate7d86052015-11-13 12:01:43 -0800271/**
272 * free_sme_cmds() - This function frees memory allocated for SME commands
273 * @mac_ctx: Pointer to Global MAC structure
274 *
275 * This function frees memory allocated for SME commands
276 *
277 * @Return: void
278 */
279static void free_sme_cmds(tpAniSirGlobal mac_ctx)
280{
281 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530282
Naveen Rawate7d86052015-11-13 12:01:43 -0800283 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
284 return;
285
286 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530287 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800288
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530289 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800290 mac_ctx->sme.pSmeCmdBufAddr = NULL;
291}
292
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530293static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530295 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 tSmeCmd *pCmd;
297 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800298 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
301
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530304 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 goto end;
306
Naveen Rawate7d86052015-11-13 12:01:43 -0800307 /* following pointer contains array of pointers for tSmeCmd* */
308 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530309 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800310 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530311 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800312 goto end;
313 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530315 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800316 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
317 /*
318 * Since total size of all commands together can be huge chunk
319 * of memory, allocate SME cmd individually. These SME CMDs are
320 * moved between pending and active queues. And these freeing of
321 * these queues just manipulates the list but does not actually
322 * frees SME CMD pointers. Hence store each SME CMD address in
323 * the array, sme.pSmeCmdBufAddr. This will later facilitate
324 * freeing up of all SME CMDs with just a for loop.
325 */
326 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530327 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800328 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530329 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800330 free_sme_cmds(pMac);
331 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800333 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
334 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
335 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 }
337
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530339 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700340 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341
342 return status;
343}
344
Krunal Sonia8270f52017-02-23 19:51:25 -0800345void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346{
Krunal Sonia8270f52017-02-23 19:51:25 -0800347 sme_cmd->command = eSmeNoCommand;
348 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530349 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350}
351
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530352static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530354 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 csr_ll_close(&pMac->sme.smeCmdFreeList);
357
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530358 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530359 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700360 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 goto done;
362 }
363
Naveen Rawate7d86052015-11-13 12:01:43 -0800364 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530366 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530367 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700368 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369done:
370 return status;
371}
372
Jeff Johnson49c02f92016-10-07 10:29:09 -0700373static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374{
375 switch (pCmd->command) {
376 case eSmeCommandScan:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700377 sme_debug("scan command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 pCmd->u.scanCmd.reason);
379 break;
380
381 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700382 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 pCmd->u.roamCmd.roamReason);
384 break;
385
386 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700387 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 pCmd->u.wmStatusChangeCmd.Type);
389 break;
390
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700392 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 pCmd->command);
394 break;
395 }
396}
397
398tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
399{
400 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
401 tListElem *pEntry;
402 static int sme_command_queue_full;
403
404 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
405
406 /* If we can get another MS Msg buffer, then we are ok. Just link */
407 /* the entry onto the linked list. (We are using the linked list */
408 /* to keep track of tfhe message buffers). */
409 if (pEntry) {
410 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
411 /* reset when free list is available */
412 sme_command_queue_full = 0;
413 } else {
414 int idx = 1;
415
416 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800417 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530418 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530420
421 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
423 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530424 if (eSmeCsrCommandMask & pTempCmd->command)
425 /* CSR command is stuck. See what the reason
426 * code is for that command
427 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 } /* if(pTempCmd) */
430
431 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800432 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800434 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 LL_ACCESS_NOLOCK);
436 while (pEntry && !sme_command_queue_full) {
437 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
438 /* Print only 1st five commands from pending queue. */
439 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530440 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441 idx, pTempCmd->command);
442 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530443 if (eSmeCsrCommandMask & pTempCmd->command)
444 /* CSR command is stuck. See what the reason
445 * code is for that command
446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800448 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 LL_ACCESS_NOLOCK);
450 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800451 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452
Abhishek Singh5ea86532016-04-27 14:10:53 +0530453 if (pMac->roam.configParam.enable_fatal_event)
454 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
455 WLAN_LOG_INDICATOR_HOST_DRIVER,
456 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
457 false,
458 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530459 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530460 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 }
462
463 /* memset to zero */
464 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530465 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530467 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530469 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
471
472 return pRetCmd;
473}
474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800476 * sme_ser_handle_active_cmd() - handle command activation callback from
477 * new serialization module
478 * @cmd: pointer to new serialization command
479 *
480 * This API is to handle command activation callback from new serialization
481 * callback
482 *
483 * Return: QDF_STATUS_SUCCESS
484 */
485static
486QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
487{
488 tSmeCmd *sme_cmd;
489 tHalHandle hal;
490 tpAniSirGlobal mac_ctx;
491 QDF_STATUS status = QDF_STATUS_SUCCESS;
492 bool do_continue;
493
494 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700495 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800496 return QDF_STATUS_E_FAILURE;
497 }
498
499 hal = cds_get_context(QDF_MODULE_ID_SME);
500 mac_ctx = PMAC_STRUCT(hal);
501 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700502 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800503 return QDF_STATUS_E_FAILURE;
504 }
505 sme_cmd = cmd->umac_cmd;
506 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700507 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800508 return QDF_STATUS_E_FAILURE;
509 }
510
511 switch (sme_cmd->command) {
512 case eSmeCommandRoam:
513 status = csr_roam_process_command(mac_ctx, sme_cmd);
514 break;
515 case eSmeCommandWmStatusChange:
516 csr_roam_process_wm_status_change_command(mac_ctx,
517 sme_cmd);
518 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800519 case eSmeCommandNdpInitiatorRequest:
520 status = csr_process_ndp_initiator_request(mac_ctx, sme_cmd);
521 break;
522 case eSmeCommandNdpResponderRequest:
523 status = csr_process_ndp_responder_request(mac_ctx, sme_cmd);
524 break;
525 case eSmeCommandNdpDataEndInitiatorRequest:
526 status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
527 break;
Krunal Soni81f068c2017-02-23 19:51:55 -0800528 case eSmeCommandScan:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700529 sme_debug("Processing scan offload cmd");
Krunal Soni81f068c2017-02-23 19:51:55 -0800530 qdf_mc_timer_start(&sme_cmd->u.scanCmd.csr_scan_timer,
531 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
532 status = csr_process_scan_command(mac_ctx, sme_cmd);
533 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800534 /*
535 * Treat standby differently here because caller may not be able
536 * to handle the failure so we do our best here
537 */
538 case eSmeCommandEnterStandby:
539 break;
540 case eSmeCommandAddTs:
541 case eSmeCommandDelTs:
542#ifndef WLAN_MDM_CODE_REDUCTION_OPT
543 do_continue = qos_process_command(mac_ctx, sme_cmd);
544 if (do_continue)
545 status = QDF_STATUS_E_FAILURE;
546#endif
547 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800548 case e_sme_command_set_hw_mode:
549 csr_process_set_hw_mode(mac_ctx, sme_cmd);
550 break;
551 case e_sme_command_nss_update:
552 csr_process_nss_update_req(mac_ctx, sme_cmd);
553 break;
554 case e_sme_command_set_dual_mac_config:
555 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
556 break;
557 case e_sme_command_set_antenna_mode:
558 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
559 break;
560 default:
561 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700562 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800563 status = QDF_STATUS_E_FAILURE;
564 break;
565 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800566 return status;
567}
568
569QDF_STATUS sme_ser_cmd_callback(void *buf,
570 enum wlan_serialization_cb_reason reason)
571{
572 struct wlan_serialization_command *cmd = buf;
573 tHalHandle hal;
574 tpAniSirGlobal mac_ctx;
575 QDF_STATUS status = QDF_STATUS_SUCCESS;
576 tSmeCmd *sme_cmd;
577
578 hal = cds_get_context(QDF_MODULE_ID_SME);
579 mac_ctx = PMAC_STRUCT(hal);
580 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700581 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800582 return QDF_STATUS_E_FAILURE;
583 }
584 /*
585 * Do not acquire lock here as sme global lock is already acquired in
586 * caller or MC thread context
587 */
588 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700589 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800590 return QDF_STATUS_E_FAILURE;
591 }
592
593 switch (reason) {
594 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700595 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800596 status = sme_ser_handle_active_cmd(cmd);
597 break;
598 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700599 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800600 sme_cmd = cmd->umac_cmd;
601 csr_cancel_command(mac_ctx, sme_cmd);
Krunal Sonia8270f52017-02-23 19:51:25 -0800602 break;
603 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700604 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800605 sme_cmd = cmd->umac_cmd;
606 csr_release_command_buffer(mac_ctx, sme_cmd);
607 break;
608 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700609 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800610 break;
611 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700612 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800613 return QDF_STATUS_E_FAILURE;
614 }
615 return status;
616}
617
618/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530619 * sme_get_sessionid_from_activelist() - gets session id
620 * @mac: mac context
621 *
622 * This function is used to get session id from sme command
623 * active list
624 *
625 * Return: returns session id
626 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700627static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530628{
629 tListElem *entry;
630 tSmeCmd *command;
631 uint32_t session_id = CSR_SESSION_ID_INVALID;
632
Krunal Sonia8270f52017-02-23 19:51:25 -0800633 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530634 if (entry) {
635 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
636 session_id = command->sessionId;
637 }
638
639 return session_id;
640}
641
642/**
643 * sme_state_info_dump() - prints state information of sme layer
644 * @buf: buffer pointer
645 * @size: size of buffer to be filled
646 *
647 * This function is used to dump state information of sme layer
648 *
649 * Return: None
650 */
651static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
652{
653 uint32_t session_id, active_session_id;
654 tHalHandle hal;
655 tpAniSirGlobal mac;
656 uint16_t len = 0;
657 char *buf = *buf_ptr;
658 eCsrConnectState connect_state;
659
660 hal = cds_get_context(QDF_MODULE_ID_SME);
661 if (hal == NULL) {
662 QDF_ASSERT(0);
663 return;
664 }
665
666 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530667
668 active_session_id = sme_get_sessionid_from_activelist(mac);
669 if (active_session_id != CSR_SESSION_ID_INVALID) {
670 len += qdf_scnprintf(buf + len, *size - len,
671 "\n active command sessionid %d", active_session_id);
672 }
673
674 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
675 if (CSR_IS_SESSION_VALID(mac, session_id)) {
676 connect_state =
677 mac->roam.roamSession[session_id].connectState;
678 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
679 connect_state)
680 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
681 connect_state)) {
682 len += qdf_scnprintf(buf + len, *size - len,
683 "\n NeighborRoamState: %d",
684 mac->roam.neighborRoamInfo[session_id].
685 neighborRoamState);
686 len += qdf_scnprintf(buf + len, *size - len,
687 "\n RoamState: %d", mac->roam.
688 curState[session_id]);
689 len += qdf_scnprintf(buf + len, *size - len,
690 "\n RoamSubState: %d", mac->roam.
691 curSubState[session_id]);
692 len += qdf_scnprintf(buf + len, *size - len,
693 "\n ConnectState: %d",
694 connect_state);
695 }
696 }
697 }
698
699 *size -= len;
700 *buf_ptr += len;
701}
702
703/**
704 * sme_register_debug_callback() - registration function sme layer
705 * to print sme state information
706 *
707 * Return: None
708 */
709static void sme_register_debug_callback(void)
710{
711 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
712}
713
714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800715/* Global APIs */
716
717/**
718 * sme_open() - Initialze all SME modules and put them at idle state
719 * @hHal: The handle returned by mac_open
720 *
721 * The function initializes each module inside SME, PMC, CSR, etc. Upon
722 * successfully return, all modules are at idle state ready to start.
723 * smeOpen must be called before any other SME APIs can be involved.
724 * smeOpen must be called after mac_open.
725 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530726 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 * Other status means SME is failed to be initialized
728 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530729QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530731 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733
734 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530735 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530736 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700738 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530739 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 }
741 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530742 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700743 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 return status;
745 }
746
747 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530748 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700749 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 return status;
751 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752
753#ifndef WLAN_MDM_CODE_REDUCTION_OPT
754 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530755 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700756 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 return status;
758 }
759#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530761 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530765 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700766 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 return status;
768 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530770 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700771 wlan_serialization_legacy_init_callback();
772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 return status;
774}
775
776/*
777 * sme_init_chan_list, triggers channel setup based on country code.
778 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530779QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700780 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781{
782 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
783
Amar Singhala297bfa2015-10-15 15:07:29 -0700784 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
786 pmac->roam.configParam.Is11dSupportEnabled = false;
787 }
788
789 return csr_init_chan_list(pmac, alpha2);
790}
791
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530792/*
793 * sme_set11dinfo() - Set the 11d information about valid channels
794 * and there power using information from nvRAM
795 * This function is called only for AP.
796 *
797 * This is a synchronous call
798 *
799 * hHal - The handle returned by mac_open.
800 * pSmeConfigParams - a pointer to a caller allocated object of
801 * typedef struct _smeConfigParams.
802 *
803 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
804 *
805 * Other status means SME is failed to update the config parameters.
806 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530808QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530810 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530812 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
814 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700815 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 return status;
817 }
818
819 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700820 if (!QDF_IS_STATUS_SUCCESS(status))
821 sme_err("csr_set_channels failed with status: %d", status);
822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 return status;
824}
825
826/**
827 * sme_set_scan_disable() - Dynamically enable/disable scan
828 * @h_hal: Handle to HAL
829 *
830 * This command gives the user an option to dynamically
831 * enable or disable scans.
832 *
833 * Return: None
834 */
835void sme_set_scan_disable(tHalHandle h_hal, int value)
836{
837 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530838
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700839 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530840 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530842/*
843 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
844 * This is a synchronous call
845 *
846 * hHal - The handle returned by HostapdAdapter.
847 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
848 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
849 * Other status means, failed to get the current regulatory domain.
850 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530852QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
853 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530855 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
857
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530858 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
860 NO_SESSION, 0));
861 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700862 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 return status;
864 }
865
866 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530867 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869 return status;
870}
871
Krunal Sonie3531942016-04-12 17:43:53 -0700872/**
873 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
874 * incoming val
875 * @hal: Handle for Hal layer
876 * @val: New FTM capability value
877 *
878 * Return: None
879 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530880void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
881 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700882{
883 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530884
Naveen Rawatd2657be2017-10-10 14:31:23 -0700885 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700886
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530887 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700888 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
889 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
890 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
891 } else {
892 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
893 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
894 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
895 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530896
897 /* Inform this RRM IE change to FW */
898 csr_roam_offload_scan(mac_ctx, session_id,
899 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
900 REASON_CONNECT_IES_CHANGED);
Krunal Sonie3531942016-04-12 17:43:53 -0700901}
902
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530903/*
904 * sme_update_config() - Change configurations for all SME moduels
905 * The function updates some configuration for modules in SME, CSR, etc
906 * during SMEs close open sequence.
907 * Modules inside SME apply the new configuration at the next transaction.
908 * This is a synchronous call
909 *
910 * hHal - The handle returned by mac_open.
911 * pSmeConfigParams - a pointer to a caller allocated object of
912 * typedef struct _smeConfigParams.
913 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
914 * Other status means SME is failed to update the config parameters.
915 */
916QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
917 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530919 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
921
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530922 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
924 0));
925 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700926 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 return status;
928 }
929
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530930 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
931 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530933 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700934 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530937 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
938 rrmConfig);
939
940 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700941 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530943
944 /* For SOC, CFG is set before start We don't want to apply global CFG
945 * in connect state because that may cause some side affect
946 */
947 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949
950 /*
951 * If scan offload is enabled then lim has allow the sending of
952 * scan request to firmware even in powersave mode. The firmware has
953 * to take care of exiting from power save mode
954 */
955 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
956
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530957 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530960
961 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 return status;
964}
965
966/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530967 * sme_update_scan_roam_params() - Update the scan roaming params
968 * @mac_ctx: mac ctx
969 *
970 * Return: void.
971 */
972static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
973{
974 struct roam_filter_params scan_params = {0};
975 struct roam_ext_params *roam_params_src;
976 uint8_t i;
977 QDF_STATUS status;
978
979 roam_params_src = &mac_ctx->roam.configParam.roam_params;
980
981 scan_params.num_bssid_avoid_list =
982 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530983
984 if (scan_params.num_bssid_avoid_list >
985 MAX_AVOID_LIST_BSSID)
986 scan_params.num_bssid_avoid_list =
987 MAX_AVOID_LIST_BSSID;
988
989 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
990 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
991 &roam_params_src->bssid_avoid_list[i]);
992 }
993
994 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
995 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700996 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530997 status);
998}
999
1000/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 * sme_update_roam_params() - Store/Update the roaming params
1002 * @hal: Handle for Hal layer
1003 * @session_id: SME Session ID
1004 * @roam_params_src: The source buffer to copy
1005 * @update_param: Type of parameter to be updated
1006 *
1007 * Return: Return the status of the updation.
1008 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301009QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001010 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 int update_param)
1012{
1013 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1014 struct roam_ext_params *roam_params_dst;
1015 uint8_t i;
1016
1017 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1018 switch (update_param) {
1019 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1020 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001021 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001023 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001025 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001027 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001029 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001031 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001033 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 roam_params_dst->is_5g_pref_enabled = true;
1035 break;
1036 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301037 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1039 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001040 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1042 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001043 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301044 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001045 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 roam_params_dst->ssid_allowed_list[i].length);
1047 }
1048 break;
1049 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1052 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001053 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301055 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001056 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 sizeof(tSirMacAddr));
1058 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001059 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 }
1061 break;
1062 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301063 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301064 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001066 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301068 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001069 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 }
1071 break;
1072 case REASON_ROAM_GOOD_RSSI_CHANGED:
1073 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001074 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 break;
1076 default:
1077 break;
1078 }
1079 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1080 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301081
1082 sme_update_scan_roam_params(mac_ctx);
1083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 return 0;
1085}
1086
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301087/*
1088 * sme_process_ready_to_suspend() -
1089 * On getting ready to suspend indication, this function calls
1090 * callback registered (HDD callbacks) with SME to inform ready
1091 * to suspend indication.
1092 *
1093 * hHal - Handle returned by mac_open.
1094 * pReadyToSuspend - Parameter received along with ready to suspend
1095 * indication from WMA.
1096 * Return: None
1097 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001098static void sme_process_ready_to_suspend(tHalHandle hHal,
1099 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100{
1101 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1102
1103 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 "%s: pMac is null", __func__);
1106 return;
1107 }
1108
1109 if (NULL != pMac->readyToSuspendCallback) {
1110 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1111 pReadyToSuspend->suspended);
1112 pMac->readyToSuspendCallback = NULL;
1113 }
1114}
1115
1116#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001118/**
1119 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1120 * @hHal - Handle returned by mac_open.
1121 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1122 * indication from WMA.
1123 *
1124 * On getting ready to Ext WoW indication, this function calls callback
1125 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1126 *
1127 * Return: None
1128 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001129static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1130 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131{
1132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1133
1134 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 "%s: pMac is null", __func__);
1137 return;
1138 }
1139
1140 if (NULL != pMac->readyToExtWoWCallback) {
1141 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1142 pReadyToExtWoW->status);
1143 pMac->readyToExtWoWCallback = NULL;
1144 pMac->readyToExtWoWContext = NULL;
1145 }
1146
1147}
1148#endif
1149
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301150/*
1151 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1152 * that the NIC is ready tio run.
1153 * The function is called by HDD at the end of initialization stage so PE/HAL
1154 * can enable the NIC to running state.
1155 * This is a synchronous call
1156 *
1157 * @hHal - The handle returned by mac_open.
1158 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1159 * successfully.
1160 * Other status means SME failed to send the message to PE.
1161 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301162QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163{
Abhishek Singhde410b72017-05-22 15:25:39 +05301164 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301165 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1167
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301168 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1170 do {
1171
Abhishek Singhde410b72017-05-22 15:25:39 +05301172 msg = qdf_mem_malloc(sizeof(*msg));
1173 if (!msg) {
1174 sme_err("Memory allocation failed! for msg");
1175 return QDF_STATUS_E_NOMEM;
1176 }
1177 msg->messageType = eWNI_SME_SYS_READY_IND;
1178 msg->length = sizeof(*msg);
1179 msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
1180 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001181 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301183 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1184 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301185 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001187 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 break;
1189 }
1190
1191 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301192 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001193 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 break;
1195 }
1196
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 pMac->sme.state = SME_STATE_READY;
1198 } while (0);
1199
1200 return status;
1201}
1202
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001203QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1204{
1205 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1206 QDF_STATUS status = QDF_STATUS_SUCCESS;
1207
1208 if (NULL == mac_ctx) {
1209 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1210 FL("Invalid MAC context"));
1211 return QDF_STATUS_E_FAILURE;
1212 }
1213
1214 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1215 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1216 status = QDF_STATUS_E_INVAL;
1217
1218 return status;
1219}
1220
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301221/*
1222 * sme_start() - Put all SME modules at ready state.
1223 * The function starts each module in SME, PMC, CSR, etc. . Upon
1224 * successfully return, all modules are ready to run.
1225 * This is a synchronous call
1226 *
1227 * hHal - The handle returned by mac_open.
1228 * Return QDF_STATUS_SUCCESS - SME is ready.
1229 * Other status means SME is failed to start
1230 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301231QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001235 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236
1237 do {
1238 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301239 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001240 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 break;
1242 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001243 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001244 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001245 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1246 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1247 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1248 sme_cbacks.sme_soc_set_dual_mac_config =
1249 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001250 sme_cbacks.sme_change_mcc_beacon_interval =
1251 sme_change_mcc_beacon_interval;
1252 sme_cbacks.sme_get_ap_channel_from_scan =
1253 sme_get_ap_channel_from_scan;
1254 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001255 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1256 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001257 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001258 status);
1259 break;
1260 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001263 /* START RRM */
1264 status = rrm_start(pMac);
1265 if (!QDF_IS_STATUS_SUCCESS(status)) {
1266 sme_err("Failed to start RRM");
1267 break;
1268 }
1269 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 return status;
1271}
1272
Arif Hussaincd151632017-02-11 16:57:19 -08001273static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1274 struct scheduler_msg *msg)
1275{
1276 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001277 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001278 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1279 uint32_t session_id = 0;
1280 eRoamCmdStatus roam_status;
1281 eCsrRoamResult roam_result;
1282
1283 switch (msg->type) {
1284 case eWNI_SME_DFS_RADAR_FOUND:
1285 {
1286 session_id = msg->bodyval;
1287 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1288 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301289 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001290 "sapdfs: Radar indication event occurred");
1291 break;
1292 }
1293 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1294 {
1295 csa_ie_tx_complete_rsp =
1296 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1297 if (!csa_ie_tx_complete_rsp) {
1298 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1299 return QDF_STATUS_E_FAILURE;
1300 }
1301 session_id = csa_ie_tx_complete_rsp->sessionId;
1302 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1303 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301304 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001305 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1306 session_id);
1307 break;
1308 }
1309 case eWNI_SME_DFS_CAC_COMPLETE:
1310 {
1311 session_id = msg->bodyval;
1312 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1313 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301314 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001315 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1316 session_id);
1317 break;
1318 }
1319 default:
1320 {
1321 sme_err("Invalid DFS message: 0x%x", msg->type);
1322 status = QDF_STATUS_E_FAILURE;
1323 return status;
1324 }
1325 }
1326
1327 /* Indicate Radar Event to SAP */
1328 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1329 roam_status, roam_result);
1330 return status;
1331}
1332
1333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301335/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 * Handle the unprotected management frame indication from LIM and
1337 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301338 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1341{
1342 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301343 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001344 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1346
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001347 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1348 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1349 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350
1351 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001352 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1354
1355 return status;
1356}
1357#endif
1358
Kapil Gupta8878ad92017-02-13 11:56:04 +05301359QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1360{
1361 QDF_STATUS status = QDF_STATUS_SUCCESS;
1362 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001363 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301364 eRoamCmdStatus roamStatus;
1365 eCsrRoamResult roamResult;
1366
1367 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
1368 roamInfo->dfs_event.sessionId = session_id;
1369
1370 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1371 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301372 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301373 "sapdfs: Updated new channel event");
1374
1375 /* Indicate channel Event to SAP */
1376 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1377 roamStatus, roamResult);
1378
1379 qdf_mem_free(roamInfo);
1380 return status;
1381}
1382
1383
Abhishek Singh518323d2015-10-19 17:42:01 +05301384/**
1385 * sme_extended_change_channel_ind()- function to indicate ECSA
1386 * action frame is received in lim to SAP
1387 * @mac_ctx: pointer to global mac structure
1388 * @msg_buf: contain new channel and session id.
1389 *
1390 * This function is called to post ECSA action frame
1391 * receive event to SAP.
1392 *
1393 * Return: success if msg indicated to SAP else return failure
1394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301395static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301396 void *msg_buf)
1397{
1398 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301399 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301400 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001401 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301402 eRoamCmdStatus roam_status;
1403 eCsrRoamResult roam_result;
1404
Abhishek Singh518323d2015-10-19 17:42:01 +05301405 ext_chan_ind = msg_buf;
1406 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001407 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301408 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301409 }
1410 session_id = ext_chan_ind->session_id;
1411 roamInfo.target_channel = ext_chan_ind->new_channel;
1412 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1413 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001414 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1415 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301416
1417 /* Indicate Ext Channel Change event to SAP */
1418 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1419 roam_status, roam_result);
1420 return status;
1421}
1422
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001423/**
1424 * sme_process_fw_mem_dump_rsp - process fw memory dump response from WMA
1425 *
1426 * @mac_ctx: pointer to MAC handle.
1427 * @msg: pointer to received SME msg.
1428 *
1429 * This function process the received SME message and calls the corresponding
1430 * callback which was already registered with SME.
1431 *
1432 * Return: None
1433 */
1434#ifdef WLAN_FEATURE_MEMDUMP
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001435static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1436 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001437{
1438 if (msg->bodyptr) {
1439 if (mac_ctx->sme.fw_dump_callback)
1440 mac_ctx->sme.fw_dump_callback(mac_ctx->hHdd,
1441 (struct fw_dump_rsp *) msg->bodyptr);
1442 qdf_mem_free(msg->bodyptr);
1443 }
1444}
1445#else
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001446static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1447 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001448{
1449}
1450#endif
1451
1452#ifdef FEATURE_WLAN_ESE
1453/**
1454 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1455 * @hHal: HAL handle
1456 * @sessionId: session id
1457 * @isEseIniFeatureEnabled: ese ini enabled
1458 *
1459 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1460 * isEseIniFeatureEnabled. This is a synchronous call
1461 *
1462 * Return: QDF_STATUS enumeration
1463 */
1464QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1465 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1466{
1467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1468
1469 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1470 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001472 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1473 __func__,
1474 pMac->roam.configParam.isEseIniFeatureEnabled,
1475 isEseIniFeatureEnabled);
1476 return QDF_STATUS_SUCCESS;
1477 }
1478
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301479 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001480 "%s: EseEnabled is changed from %d to %d", __func__,
1481 pMac->roam.configParam.isEseIniFeatureEnabled,
1482 isEseIniFeatureEnabled);
1483 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001484 csr_neighbor_roam_update_fast_roaming_enabled(
1485 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001486
1487 if (true == isEseIniFeatureEnabled)
1488 sme_update_fast_transition_enabled(hHal, true);
1489
1490 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1491 csr_roam_offload_scan(pMac, sessionId,
1492 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1493 REASON_ESE_INI_CFG_CHANGED);
1494
1495 return QDF_STATUS_SUCCESS;
1496}
1497
1498/**
1499 * sme_set_plm_request() - set plm request
1500 * @hHal: HAL handle
1501 * @pPlmReq: Pointer to input plm request
1502 *
1503 * Return: QDF_STATUS enumeration
1504 */
1505QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1506{
1507 QDF_STATUS status;
1508 bool ret = false;
1509 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001510 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001511 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001512 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301513 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1514 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001515
1516 status = sme_acquire_global_lock(&pMac->sme);
1517 if (!QDF_IS_STATUS_SUCCESS(status))
1518 return status;
1519
1520 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001521 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001522 sme_release_global_lock(&pMac->sme);
1523 return QDF_STATUS_E_FAILURE;
1524 }
1525
1526 if (!pSession->sessionActive) {
1527 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1528 FL("Invalid Sessionid"));
1529 sme_release_global_lock(&pMac->sme);
1530 return QDF_STATUS_E_FAILURE;
1531 }
1532
1533 if (!pPlmReq->enable)
1534 goto send_plm_start;
1535 /* validating channel numbers */
1536 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1537 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1538 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001539 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1540 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001541 pPlmReq->plmChList[count])) {
1542 /* DFS channel is provided, no PLM bursts can be
1543 * transmitted. Ignoring these channels.
1544 */
1545 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301546 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001547 FL("DFS channel %d ignored for PLM"),
1548 pPlmReq->plmChList[count]);
1549 continue;
1550 }
1551 } else if (!ret) {
1552 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301553 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001554 FL("Unsupported channel %d ignored for PLM"),
1555 pPlmReq->plmChList[count]);
1556 continue;
1557 }
1558 ch_list[valid_count] = pPlmReq->plmChList[count];
1559 valid_count++;
1560 } /* End of for () */
1561
1562 /* Copying back the valid channel list to plm struct */
1563 qdf_mem_set((void *)pPlmReq->plmChList,
1564 pPlmReq->plmNumCh, 0);
1565 if (valid_count)
1566 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1567 valid_count);
1568 /* All are invalid channels, FW need to send the PLM
1569 * report with "incapable" bit set.
1570 */
1571 pPlmReq->plmNumCh = valid_count;
1572
1573send_plm_start:
1574 /* PLM START */
1575 msg.type = WMA_SET_PLM_REQ;
1576 msg.reserved = 0;
1577 msg.bodyptr = pPlmReq;
1578
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001579 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001580 &msg))) {
1581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1582 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1583 sme_release_global_lock(&pMac->sme);
1584 return QDF_STATUS_E_FAILURE;
1585 }
1586
1587 sme_release_global_lock(&pMac->sme);
1588 return status;
1589}
1590
1591/**
1592 * sme_tsm_ie_ind() - sme tsm ie indication
1593 * @hHal: HAL handle
1594 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 *
1596 * Handle the tsm ie indication from LIM and forward it to HDD.
1597 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001598 * Return: QDF_STATUS enumeration
1599 */
1600static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601{
1602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301603 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001604 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301606
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001607 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1608 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1609 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001611 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301612 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 return status;
1614}
1615
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001616/**
1617 * sme_set_cckm_ie() - set cckm ie
1618 * @hHal: HAL handle
1619 * @sessionId: session id
1620 * @pCckmIe: Pointer to CCKM Ie
1621 * @cckmIeLen: Length of @pCckmIe
1622 *
1623 * Function to store the CCKM IE passed from supplicant and use
1624 * it while packing reassociation request.
1625 *
1626 * Return: QDF_STATUS enumeration
1627 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301628QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 uint8_t *pCckmIe, uint8_t cckmIeLen)
1630{
1631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301632 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301635 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1637 sme_release_global_lock(&pMac->sme);
1638 }
1639 return status;
1640}
1641
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001642/**
1643 * sme_set_ese_beacon_request() - set ese beacon request
1644 * @hHal: HAL handle
1645 * @sessionId: session id
1646 * @pEseBcnReq: Ese beacon report
1647 *
1648 * function to set ESE beacon request parameters
1649 *
1650 * Return: QDF_STATUS enumeration
1651 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301652QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 const tCsrEseBeaconReq *pEseBcnReq)
1654{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001655 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1657 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1658 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1659 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301660 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1662
1663 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001664 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301665 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 }
1667
1668 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301669 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 sizeof(tCsrEseBeaconReq));
1671
1672 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301673 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001675 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301676 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 }
1678
1679 pSmeRrmContext->eseBcnReqInProgress = true;
1680
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001681 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682
1683 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1684 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301685 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 pSession->connectedProfile.bssid.bytes,
1687 sizeof(tSirMacAddr));
1688 pSmeBcnReportReq->channelInfo.channelNum = 255;
1689 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1690 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1691
1692 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1693 pBeaconReq =
1694 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1695 pSmeBcnReportReq->fMeasurementtype[counter] =
1696 pBeaconReq->scanMode;
1697 pSmeBcnReportReq->measurementDuration[counter] =
1698 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1699 pSmeBcnReportReq->channelList.channelNumber[counter] =
1700 pBeaconReq->channel;
1701 }
1702
1703 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1704
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301705 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 pSmeRrmContext->eseBcnReqInProgress = false;
1707
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301708 qdf_mem_free(pSmeBcnReportReq);
1709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 return status;
1711}
1712
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001713/**
1714 * sme_get_tsm_stats() - SME get tsm stats
1715 * @hHal: HAL handle
1716 * @callback: SME sends back the requested stats using the callback
1717 * @staId: The station ID for which the stats is requested for
1718 * @bssId: bssid
1719 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001720 * @tid: Traffic id
1721 *
1722 * API register a callback to get TSM Stats.
1723 *
1724 * Return: QDF_STATUS enumeration
1725 */
1726QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1727 tCsrTsmStatsCallback callback,
1728 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001729 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001730{
1731 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1732 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1733
1734 status = sme_acquire_global_lock(&pMac->sme);
1735 if (QDF_IS_STATUS_SUCCESS(status)) {
1736 status = csr_get_tsm_stats(pMac, callback,
1737 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001738 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001739 sme_release_global_lock(&pMac->sme);
1740 }
1741 return status;
1742}
1743
1744/**
1745 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1746 * @hHal: pointer HAL handle returned by mac_open
1747 * @sessionId: sme session id
1748 * @pChannelList: Output channel list
1749 * @numChannels: Output number of channels
1750 *
1751 * This routine is called to set ese roam scan channel list.
1752 * This is a synchronous call
1753 *
1754 * Return: QDF_STATUS
1755 */
1756QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1757 uint8_t sessionId,
1758 uint8_t *pChannelList,
1759 uint8_t numChannels)
1760{
1761 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1762 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001763 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1764 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001765 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1766 uint8_t newChannelList[128] = { 0 };
1767 uint8_t i = 0, j = 0;
1768
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001769 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1771 FL("Invalid sme session id: %d"), sessionId);
1772 return QDF_STATUS_E_INVAL;
1773 }
1774
1775 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1776 curchnl_list_info =
1777 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1778
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001779 status = sme_acquire_global_lock(&pMac->sme);
1780 if (!QDF_IS_STATUS_SUCCESS(status)) {
1781 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1782 csr_roam_offload_scan(pMac, sessionId,
1783 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1784 REASON_CHANNEL_LIST_CHANGED);
1785 return status;
1786 }
1787 if (NULL != curchnl_list_info->ChannelList) {
1788 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1789 j += snprintf(oldChannelList + j,
1790 sizeof(oldChannelList) - j, "%d",
1791 curchnl_list_info->ChannelList[i]);
1792 }
1793 }
1794 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1795 pChannelList, numChannels,
1796 csr_get_current_band(hHal));
1797 if (QDF_IS_STATUS_SUCCESS(status)) {
1798 if (NULL != curchnl_list_info->ChannelList) {
1799 j = 0;
1800 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1801 j += snprintf(newChannelList + j,
1802 sizeof(newChannelList) - j, "%d",
1803 curchnl_list_info->ChannelList[i]);
1804 }
1805 }
1806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1807 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1808 newChannelList, oldChannelList,
1809 pNeighborRoamInfo->neighborRoamState);
1810 }
1811 sme_release_global_lock(&pMac->sme);
1812 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1813 csr_roam_offload_scan(pMac, sessionId,
1814 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1815 REASON_CHANNEL_LIST_CHANGED);
1816 return status;
1817}
1818
1819#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820
Jeff Johnson49c02f92016-10-07 10:29:09 -07001821static
1822QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1823 tpSirIbssGetPeerInfoRspParams
1824 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001825{
1826 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1827
1828 if (NULL == pMac) {
1829 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1830 "%s: pMac is null", __func__);
1831 return QDF_STATUS_E_FAILURE;
1832 }
1833 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1835 "%s: HDD callback is null", __func__);
1836 return QDF_STATUS_E_FAILURE;
1837 }
1838 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1839 &pIbssPeerInfoParams->
1840 ibssPeerInfoRspParams);
1841 return QDF_STATUS_SUCCESS;
1842}
1843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1846 * @mac: Global MAC pointer
1847 * @msg: Dual mac config response
1848 *
1849 * Processes the dual mac configuration response and invokes the HDD callback
1850 * to process further
1851 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301852static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 uint8_t *msg)
1854{
1855 tListElem *entry = NULL;
1856 tSmeCmd *command = NULL;
1857 bool found;
1858 dual_mac_cb callback = NULL;
1859 struct sir_dual_mac_config_resp *param;
1860
1861 param = (struct sir_dual_mac_config_resp *)msg;
1862 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001863 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 /* Not returning. Need to check if active command list
1865 * needs to be freed
1866 */
1867 }
1868
Krunal Sonia8270f52017-02-23 19:51:25 -08001869 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001871 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301872 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 }
1874
1875 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1876 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001877 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301878 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 }
1880
1881 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001882 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301883 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 }
1885
1886 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1887 if (callback) {
1888 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001889 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001891 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 callback(param->status,
1893 command->u.set_dual_mac_cmd.scan_config,
1894 command->u.set_dual_mac_cmd.fw_mode_config);
1895 }
1896 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001897 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 }
1899
Krunal Soni72dba662017-02-15 20:13:17 -08001900 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 if (found)
1902 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001903 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301905 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906}
1907
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001908/**
1909 * sme_process_antenna_mode_resp() - Process set antenna mode
1910 * response
1911 * @mac: Global MAC pointer
1912 * @msg: antenna mode response
1913 *
1914 * Processes the antenna mode response and invokes the HDD
1915 * callback to process further
1916 */
1917static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1918 uint8_t *msg)
1919{
1920 tListElem *entry;
1921 tSmeCmd *command;
1922 bool found;
1923 antenna_mode_cb callback;
1924 struct sir_antenna_mode_resp *param;
1925
1926 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301927 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001928 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001929 /* Not returning. Need to check if active command list
1930 * needs to be freed
1931 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001932
Krunal Sonia8270f52017-02-23 19:51:25 -08001933 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001934 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001935 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001936 return QDF_STATUS_E_FAILURE;
1937 }
1938
1939 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1940 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001941 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001942 return QDF_STATUS_E_FAILURE;
1943 }
1944
1945 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001946 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001947 return QDF_STATUS_E_FAILURE;
1948 }
1949
1950 callback =
1951 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1952 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301953 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001954 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301955 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001956 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001957 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001958 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001959 }
1960
Krunal Soni72dba662017-02-15 20:13:17 -08001961 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001962 if (found)
1963 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001964 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001965
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001966 return QDF_STATUS_SUCCESS;
1967}
1968
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301969/*
1970 * sme_process_msg() - The main message processor for SME.
1971 * The function is called by a message dispatcher when to process a message
1972 * targeted for SME.
1973 * This is a synchronous call
1974 *
1975 * hHal - The handle returned by mac_open.
1976 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1977 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1978 * Other status means SME failed to process the message to HAL.
1979 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001980QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1984
1985 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001986 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 return status;
1988 }
1989 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301990 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001991 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301993 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 return status;
1995 }
1996 if (!SME_IS_START(pMac)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001997 sme_warn("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301999 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 goto release_lock;
2001 }
2002 switch (pMsg->type) {
2003#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302005 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
2007 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302008 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 break;
2010#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 case WNI_CFG_SET_CNF:
2012 case WNI_CFG_DNLD_CNF:
2013 case WNI_CFG_GET_RSP:
2014 case WNI_CFG_ADD_GRP_ADDR_CNF:
2015 case WNI_CFG_DEL_GRP_ADDR_CNF:
2016 break;
2017 case eWNI_SME_ADDTS_RSP:
2018 case eWNI_SME_DELTS_RSP:
2019 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 /* QoS */
2022 if (pMsg->bodyptr) {
2023#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2024 status = sme_qos_msg_processor(pMac, pMsg->type,
2025 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302026 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027#endif
2028 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002029 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 }
2031 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 case eWNI_SME_NEIGHBOR_REPORT_IND:
2033 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 if (pMsg->bodyptr) {
2035 status = sme_rrm_msg_processor(pMac, pMsg->type,
2036 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302039 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 }
2041 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 case eWNI_SME_ADD_STA_SELF_RSP:
2043 if (pMsg->bodyptr) {
2044 status = csr_process_add_sta_session_rsp(pMac,
2045 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302046 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002048 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050 break;
2051 case eWNI_SME_DEL_STA_SELF_RSP:
2052 if (pMsg->bodyptr) {
2053 status = csr_process_del_sta_session_rsp(pMac,
2054 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302055 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002057 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 }
2059 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 case eWNI_SME_CHANGE_COUNTRY_CODE:
2061 if (pMsg->bodyptr) {
2062 status = sme_handle_change_country_code((void *)pMac,
2063 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302064 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002066 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 }
2068 break;
2069 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2070 if (pMsg->bodyptr) {
2071 status = sme_handle_generic_change_country_code(
2072 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302073 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002075 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 }
2077 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079#ifdef WLAN_FEATURE_11W
2080 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2081 if (pMsg->bodyptr) {
2082 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302083 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002085 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 }
2087 break;
2088#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002089#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 case eWNI_SME_TSM_IE_IND:
2091 if (pMsg->bodyptr) {
2092 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302093 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002095 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 }
2097 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002098#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2100 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2101 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302102 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002104 case eWNI_SME_IBSS_PEER_INFO_RSP:
2105 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002106 sme_ibss_peer_info_response_handler(pMac,
2107 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002108 qdf_mem_free(pMsg->bodyptr);
2109 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002110 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002111 }
2112 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 case eWNI_SME_READY_TO_SUSPEND_IND:
2114 if (pMsg->bodyptr) {
2115 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302116 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002118 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 }
2120 break;
2121#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2122 case eWNI_SME_READY_TO_EXTWOW_IND:
2123 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002124 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302125 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002127 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 }
2129 break;
2130#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2132 case eWNI_SME_AUTO_SHUTDOWN_IND:
2133 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302134 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 FL("Auto shutdown notification"));
2136 pMac->sme.pAutoShutdownNotificationCb();
2137 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302138 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 break;
2140#endif
2141 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002142 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002144 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302145 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 break;
2147 case eWNI_SME_CHANNEL_CHANGE_RSP:
2148 if (pMsg->bodyptr) {
2149 status = sme_process_channel_change_resp(pMac,
2150 pMsg->type,
2151 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302152 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002154 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 }
2156 break;
2157#ifdef WLAN_FEATURE_STATS_EXT
2158 case eWNI_SME_STATS_EXT_EVENT:
2159 if (pMsg->bodyptr) {
2160 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302161 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002163 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 }
2165 break;
2166#endif
Will Huang558f8082017-05-31 16:22:24 +08002167 case eWNI_SME_GET_PEER_INFO_IND:
2168 if (pMac->sme.pget_peer_info_ind_cb)
2169 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2170 pMac->sme.pget_peer_info_cb_context);
2171 qdf_mem_free(pMsg->bodyptr);
2172 break;
2173 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2174 if (pMac->sme.pget_peer_info_ext_ind_cb)
2175 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2176 pMac->sme.pget_peer_info_ext_cb_context);
2177 qdf_mem_free(pMsg->bodyptr);
2178 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 case eWNI_SME_CSA_OFFLOAD_EVENT:
2180 if (pMsg->bodyptr) {
2181 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302182 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 }
2184 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002185 case eWNI_SME_TSF_EVENT:
2186 if (pMac->sme.get_tsf_cb) {
2187 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2188 (struct stsf *)pMsg->bodyptr);
2189 }
2190 if (pMsg->bodyptr)
2191 qdf_mem_free(pMsg->bodyptr);
2192 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193#ifdef WLAN_FEATURE_NAN
2194 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302195 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2196 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 if (pMsg->bodyptr) {
2198 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 }
2201 break;
2202#endif /* WLAN_FEATURE_NAN */
2203 case eWNI_SME_LINK_STATUS_IND:
2204 {
2205 tAniGetLinkStatus *pLinkStatus =
2206 (tAniGetLinkStatus *) pMsg->bodyptr;
2207 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302208 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 pMac->sme.linkStatusCallback(
2210 pLinkStatus->linkStatus,
2211 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 pMac->sme.linkStatusCallback = NULL;
2214 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302215 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 }
2217 break;
2218 }
2219 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302220 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2222 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 break;
2224 case eWNI_SME_SNR_IND:
2225 {
2226 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 if (pSnrReq) {
2229 if (pSnrReq->snrCallback) {
2230 ((tCsrSnrCallback)
2231 (pSnrReq->snrCallback))
2232 (pSnrReq->snr, pSnrReq->staId,
2233 pSnrReq->pDevContext);
2234 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 }
2237 break;
2238 }
2239#ifdef FEATURE_WLAN_EXTSCAN
2240 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2241 if (pMac->sme.pExtScanIndCb)
2242 pMac->sme.pExtScanIndCb(pMac->hHdd,
2243 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2244 pMsg->bodyptr);
2245 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002246 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 pMsg->type);
2248
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302249 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 break;
2251 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2252 if (pMac->sme.pExtScanIndCb)
2253 pMac->sme.pExtScanIndCb(pMac->hHdd,
2254 eSIR_EPNO_NETWORK_FOUND_IND,
2255 pMsg->bodyptr);
2256 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002257 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 pMsg->type);
2259
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302260 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 break;
2262#endif
2263 case eWNI_SME_FW_DUMP_IND:
2264 sme_process_fw_mem_dump_rsp(pMac, pMsg);
2265 break;
2266 case eWNI_SME_SET_HW_MODE_RESP:
2267 if (pMsg->bodyptr) {
2268 status = sme_process_set_hw_mode_resp(pMac,
2269 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302270 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002272 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 }
2274 break;
2275 case eWNI_SME_HW_MODE_TRANS_IND:
2276 if (pMsg->bodyptr) {
2277 status = sme_process_hw_mode_trans_ind(pMac,
2278 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302279 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002281 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 }
2283 break;
2284 case eWNI_SME_NSS_UPDATE_RSP:
2285 if (pMsg->bodyptr) {
2286 status = sme_process_nss_update_resp(pMac,
2287 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302288 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002290 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 }
2292 break;
2293 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302294 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 pMac->sme.ocb_set_config_callback(
2296 pMac->sme.ocb_set_config_context,
2297 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302298 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002299 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 pMac->sme.ocb_set_config_callback = NULL;
2301 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302302 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 break;
2304 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302305 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 pMac->sme.ocb_get_tsf_timer_callback(
2307 pMac->sme.ocb_get_tsf_timer_context,
2308 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302309 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002310 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2312 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302313 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314 break;
2315 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302316 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 pMac->sme.dcc_get_stats_callback(
2318 pMac->sme.dcc_get_stats_context,
2319 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302320 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002321 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 pMac->sme.dcc_get_stats_callback = NULL;
2323 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302324 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 break;
2326 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302327 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 pMac->sme.dcc_update_ndl_callback(
2329 pMac->sme.dcc_update_ndl_context,
2330 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302331 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002332 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 pMac->sme.dcc_update_ndl_callback = NULL;
2334 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 break;
2337 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302338 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 pMac->sme.dcc_stats_event_callback(
2340 pMac->sme.dcc_stats_event_context,
2341 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302342 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002343 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302344 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 break;
2346 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2347 if (pMsg->bodyptr) {
2348 status = sme_process_dual_mac_config_resp(pMac,
2349 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002352 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 }
2354 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2355 if (pMac->sme.set_thermal_level_cb)
2356 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2357 pMsg->bodyval);
2358 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302359 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2360 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302361 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302362 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002363 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2364 if (pMsg->bodyptr) {
2365 status = sme_process_antenna_mode_resp(pMac,
2366 pMsg->bodyptr);
2367 qdf_mem_free(pMsg->bodyptr);
2368 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002369 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002370 }
2371 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002372 case eWNI_SME_NDP_CONFIRM_IND:
2373 case eWNI_SME_NDP_NEW_PEER_IND:
2374 case eWNI_SME_NDP_INITIATOR_RSP:
Abhishek Singh4fef7472016-06-06 11:36:03 -07002375 case eWNI_SME_NDP_INDICATION:
2376 case eWNI_SME_NDP_RESPONDER_RSP:
Naveen Rawatf28315c2016-06-29 18:06:02 -07002377 case eWNI_SME_NDP_END_RSP:
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07002378 case eWNI_SME_NDP_END_IND:
2379 case eWNI_SME_NDP_PEER_DEPARTED_IND:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002380 sme_ndp_msg_processor(pMac, pMsg);
2381 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302382 case eWNI_SME_LOST_LINK_INFO_IND:
2383 if (pMac->sme.lost_link_info_cb)
2384 pMac->sme.lost_link_info_cb(pMac->hHdd,
2385 (struct sir_lost_link_info *)pMsg->bodyptr);
2386 qdf_mem_free(pMsg->bodyptr);
2387 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302388 case eWNI_SME_RSO_CMD_STATUS_IND:
2389 if (pMac->sme.rso_cmd_status_cb)
2390 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002391 qdf_mem_free(pMsg->bodyptr);
2392 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002393 case eWMI_SME_LL_STATS_IND:
2394 if (pMac->sme.link_layer_stats_ext_cb)
2395 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2396 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302397 qdf_mem_free(pMsg->bodyptr);
2398 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302399 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2400 if (pMac->sme.bt_activity_info_cb)
2401 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2402 pMsg->bodyval);
2403 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 default:
2405
2406 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2407 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2408 /* CSR */
2409 if (pMsg->bodyptr) {
2410 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302411 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302412 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002413 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002415 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302417 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 }
2419 } /* switch */
2420release_lock:
2421 sme_release_global_lock(&pMac->sme);
2422 return status;
2423}
2424
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002425QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2426{
2427 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2428
2429 if (mac_ctx == NULL) {
2430 QDF_ASSERT(0);
2431 return QDF_STATUS_E_FAILURE;
2432 }
2433
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002434 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002435}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437/**
2438 * sme_process_nss_update_resp() - Process nss update response
2439 * @mac: Global MAC pointer
2440 * @msg: nss update response
2441 *
2442 * Processes the nss update response and invokes the HDD
2443 * callback to process further
2444 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302445static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446{
2447 tListElem *entry = NULL;
2448 tSmeCmd *command = NULL;
2449 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002450 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 struct sir_beacon_tx_complete_rsp *param;
2452
2453 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302454 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002455 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 /* Not returning. Need to check if active command list
2457 * needs to be freed
2458 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459
Krunal Sonia8270f52017-02-23 19:51:25 -08002460 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002462 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302463 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 }
2465
2466 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2467 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002468 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302469 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 }
2471
2472 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002473 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302474 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 }
2476
2477 callback = command->u.nss_update_cmd.nss_update_cb;
2478 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302479 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002480 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302481 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 callback(command->u.nss_update_cmd.context,
2483 param->tx_status,
2484 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302485 command->u.nss_update_cmd.next_action,
2486 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002488 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 }
2490
Krunal Soni72dba662017-02-15 20:13:17 -08002491 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 if (found) {
2493 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002494 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002496
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302497 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498}
2499
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302500/* No need to hold the global lock here because this function can only be
2501 * called after sme_stop.
2502 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002503void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504{
2505 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302506 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302507 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 }
2509
2510}
2511
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302512/*
2513 * sme_stop() - Stop all SME modules and put them at idle state
2514 *
2515 * The function stops each module in SME, PMC, CSR, etc. . Upon
2516 * return, all modules are at idle state ready to start.
2517 * This is a synchronous call
2518 *
2519 * hHal - The handle returned by mac_open
2520 * tHalStopType - reason for stopping
2521 * Return QDF_STATUS_SUCCESS - SME is stopped.
2522 * Other status means SME is failed to stop but caller should still
2523 * consider SME is stopped.
2524 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302525QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302527 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2528 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2530
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002531 status = rrm_stop(pMac);
2532 if (!QDF_IS_STATUS_SUCCESS(status)) {
2533 sme_err("rrm_stop failed with status: %d", status);
2534 }
2535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302537 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002538 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 fail_status = status;
2540 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302542 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544
2545 pMac->sme.state = SME_STATE_STOP;
2546
2547 return status;
2548}
2549
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302550/*
2551 * sme_close() - Release all SME modules and their resources.
2552 * The function release each module in SME, PMC, CSR, etc. . Upon
2553 * return, all modules are at closed state.
2554 *
2555 * No SME APIs can be involved after smeClose except smeOpen.
2556 * smeClose must be called before mac_close.
2557 * This is a synchronous call
2558 *
2559 * hHal - The handle returned by mac_open
2560 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2561 *
2562 * Other status means SME is failed to be closed but caller still cannot
2563 * call any other SME functions except smeOpen.
2564 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302565QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302567 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2568 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2570
2571 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302572 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573
2574 /* Note: pSession will be invalid from here on, do not access */
2575 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302576 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002577 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 fail_status = status;
2579 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2581 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302582 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002583 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 fail_status = status;
2585 }
2586#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302588 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002589 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 fail_status = status;
2591 }
2592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302594 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002595 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 fail_status = status;
2597 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 free_sme_cmd_list(pMac);
2600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302601 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302602 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302603 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302605 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607
2608 pMac->sme.state = SME_STATE_STOP;
2609
2610 return status;
2611}
2612
2613/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302614 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2615 * scan list
2616 * @hal: hal context.
2617 * @bssid: bssid to be removed
2618 *
2619 * This function remove the given bssid from scan list.
2620 *
2621 * Return: QDF status.
2622 */
2623QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2624 tSirMacAddr bssid)
2625{
2626 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2627 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2628
2629 status = sme_acquire_global_lock(&mac_ctx->sme);
2630 if (QDF_IS_STATUS_SUCCESS(status)) {
2631 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2632 sme_release_global_lock(&mac_ctx->sme);
2633 }
2634
2635 return status;
2636}
2637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302639/*
2640 * sme_scan_get_result
2641 * A wrapper function to request scan results from CSR.
2642 * This is a synchronous call
2643 *
2644 * pFilter - If pFilter is NULL, all cached results are returned
2645 * phResult - an object for the result.
2646 * Return QDF_STATUS
2647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302648QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 tCsrScanResultFilter *pFilter,
2650 tScanResultHandle *phResult)
2651{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302652 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2654
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302655 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2657 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302659 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 status = csr_scan_get_result(hHal, pFilter, phResult);
2661 sme_release_global_lock(&pMac->sme);
2662 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
2664 return status;
2665}
2666
2667/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002668 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002669 * AP's channel id from
2670 * CSR by filtering the
2671 * result which matches
2672 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002673 * @profile: SAP profile
2674 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2675 * best ap from scan cache.
2676 *
2677 * This function is written to get AP's channel id from CSR by filtering
2678 * the result which matches our roam profile. This is a synchronous call.
2679 *
2680 * Return: QDF_STATUS.
2681 */
2682QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2683 tScanResultHandle *scan_cache,
2684 uint8_t *ap_chnl_id)
2685{
2686 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2687 profile,
2688 scan_cache,
2689 ap_chnl_id);
2690}
2691
2692/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2694 * channel id from CSR by filtering the
2695 * result which matches our roam profile.
2696 * @profile: SAP adapter
2697 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2698 * best ap from scan cache.
2699 *
2700 * This function is written to get AP's channel id from CSR by filtering
2701 * the result which matches our roam profile. This is a synchronous call.
2702 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002705QDF_STATUS sme_get_ap_channel_from_scan_cache(
2706 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2707 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302709 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002710 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 tCsrScanResultFilter *scan_filter = NULL;
2712 tScanResultHandle filtered_scan_result = NULL;
2713 tSirBssDescription first_ap_profile;
2714
2715 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302716 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302718 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302720 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302724 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302725 }
2726 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2727 if (NULL == profile) {
2728 scan_filter->EncryptionType.numEntries = 1;
2729 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302731 } else {
2732 /* Here is the profile we need to connect to */
2733 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 profile,
2735 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302736 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302738 if (QDF_STATUS_SUCCESS == status) {
2739 /* Save the WPS info */
2740 if (NULL != profile) {
2741 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302743 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302746 scan_filter->bWPSAssociation = 0;
2747 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302749 } else {
2750 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2751 FL("Preparing the profile filter failed"));
2752 qdf_mem_free(scan_filter);
2753 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 }
2755 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302756 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002757 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302759 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2761 &first_ap_profile);
2762 *scan_cache = filtered_scan_result;
2763 if (0 != first_ap_profile.channelId) {
2764 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302765 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302766 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 FL("Found best AP & its on chnl[%d]"),
2768 first_ap_profile.channelId);
2769 } else {
2770 /*
2771 * This means scan result is empty
2772 * so set the channel to zero, caller should
2773 * take of zero channel id case.
2774 */
2775 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302776 QDF_TRACE(QDF_MODULE_ID_SME,
2777 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302779 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 }
2781 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302782 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302784 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 }
2786 csr_free_scan_filter(mac_ctx, scan_filter);
2787 sme_release_global_lock(&mac_ctx->sme);
2788 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302789 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002791 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302792 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302794 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 return status;
2796}
2797
2798/**
2799 * sme_store_joinreq_param() - This function will pass station's join
2800 * request to store to csr.
2801 * @hal_handle: pointer to hal context.
2802 * @profile: pointer to station's roam profile.
2803 * @scan_cache: pointer to station's scan cache.
2804 * @roam_id: reference to roam_id variable being passed.
2805 * @session_id: station's session id.
2806 *
2807 * This function will pass station's join request further down to csr
2808 * to store it. this stored parameter will be used later.
2809 *
2810 * Return: true or false based on function's overall success.
2811 **/
2812bool sme_store_joinreq_param(tHalHandle hal_handle,
2813 tCsrRoamProfile *profile,
2814 tScanResultHandle scan_cache,
2815 uint32_t *roam_id,
2816 uint32_t session_id)
2817{
2818 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302819 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 bool ret_status = true;
2821
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302822 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2824 session_id, 0));
2825 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302826 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302828 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 sme_release_global_lock(&mac_ctx->sme);
2831 } else {
2832 ret_status = false;
2833 }
2834
2835 return ret_status;
2836}
2837
2838/**
2839 * sme_clear_joinreq_param() - This function will pass station's clear
2840 * the join request to csr.
2841 * @hal_handle: pointer to hal context.
2842 * @session_id: station's session id.
2843 *
2844 * This function will pass station's clear join request further down to csr
2845 * to cleanup.
2846 *
2847 * Return: true or false based on function's overall success.
2848 **/
2849bool sme_clear_joinreq_param(tHalHandle hal_handle,
2850 uint32_t session_id)
2851{
2852 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302853 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 bool ret_status = true;
2855
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302856 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2858 session_id, 0));
2859 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302860 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302862 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 sme_release_global_lock(&mac_ctx->sme);
2865 } else {
2866 ret_status = false;
2867 }
2868
2869 return ret_status;
2870}
2871
2872/**
2873 * sme_issue_stored_joinreq() - This function will issues station's stored
2874 * the join request to csr.
2875 * @hal_handle: pointer to hal context.
2876 * @roam_id: reference to roam_id variable being passed.
2877 * @session_id: station's session id.
2878 *
2879 * This function will issue station's stored join request further down to csr
2880 * to proceed forward.
2881 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302882 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302884QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 uint32_t *roam_id,
2886 uint32_t session_id)
2887{
2888 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302889 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2890 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891
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_ISSUE_JOIN_REQ,
2894 session_id, 0));
2895 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 if (QDF_STATUS_SUCCESS == status) {
2897 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 roam_id,
2899 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302900 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 }
2902 sme_release_global_lock(&mac_ctx->sme);
2903 } else {
2904 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302905 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 }
2907 return ret_status;
2908}
2909
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302910/*
2911 * sme_scan_flush_result() -
2912 * A wrapper function to request CSR to clear scan results.
2913 * This is a synchronous call
2914 *
2915 * Return QDF_STATUS
2916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302917QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302919 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2921
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302922 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2924 0, 0));
2925 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302926 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 status = csr_scan_flush_result(hHal);
2928 sme_release_global_lock(&pMac->sme);
2929 }
2930
2931 return status;
2932}
2933
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302934/*
2935 * sme_filter_scan_results() -
2936 * A wrapper function to request CSR to clear scan results.
2937 * This is a synchronous call
2938 *
2939 * tHalHandle - HAL context handle
2940 * sessionId - session id
2941 * Return QDF_STATUS
2942 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302943QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302945 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2947
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302948 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2950 sessionId, 0));
2951 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302952 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 csr_scan_filter_results(pMac);
2954 sme_release_global_lock(&pMac->sme);
2955 }
2956
2957 return status;
2958}
2959
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302960QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302962 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2964
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302965 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2967 sessionId, 0));
2968 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302969 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 status = csr_scan_flush_selective_result(hHal, true);
2971 sme_release_global_lock(&pMac->sme);
2972 }
2973
2974 return status;
2975}
2976
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302977/*
2978 * sme_scan_result_get_first() -
2979 * A wrapper function to request CSR to returns the first element of
2980 * scan result.
2981 * This is a synchronous call
2982 *
2983 * hScanResult - returned from csr_scan_get_result
2984 * Return tCsrScanResultInfo * - NULL if no result
2985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2987 tScanResultHandle hScanResult)
2988{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2991 tCsrScanResultInfo *pRet = NULL;
2992
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302993 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2995 NO_SESSION, 0));
2996 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 pRet = csr_scan_result_get_first(pMac, hScanResult);
2999 sme_release_global_lock(&pMac->sme);
3000 }
3001
3002 return pRet;
3003}
3004
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303005/*
3006 * sme_scan_result_get_next() -
3007 * A wrapper function to request CSR to returns the next element of
3008 * scan result. It can be called without calling csr_scan_result_get_first first
3009 * This is a synchronous call
3010 *
3011 * hScanResult - returned from csr_scan_get_result
3012 * Return Null if no result or reach the end
3013 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3015 tScanResultHandle hScanResult)
3016{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303017 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3019 tCsrScanResultInfo *pRet = NULL;
3020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303022 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 pRet = csr_scan_result_get_next(pMac, hScanResult);
3024 sme_release_global_lock(&pMac->sme);
3025 }
3026
3027 return pRet;
3028}
3029
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303030/*
3031 * sme_scan_result_purge() -
3032 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3033 * in the list and free memory for each item
3034 * This is a synchronous call
3035 *
3036 * hScanResult - returned from csr_scan_get_result. hScanResult is
3037 * considered gone by
3038 * calling this function and even before this function reutrns.
3039 * Return QDF_STATUS
3040 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003041QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003044 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303046 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3048 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003049 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303050 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003051 status = csr_scan_result_purge(mac_ctx, hScanResult);
3052 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 }
3054
3055 return status;
3056}
3057
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303058/*
3059 * sme_scan_get_pmkid_candidate_list() -
3060 * A wrapper function to return the PMKID candidate list
3061 * This is a synchronous call
3062 *
3063 * pPmkidList - caller allocated buffer point to an array of
3064 * tPmkidCandidateInfo
3065 * pNumItems - pointer to a variable that has the number of
3066 * tPmkidCandidateInfo allocated when retruning, this is
3067 * either the number needed or number of items put into
3068 * pPmkidList
3069 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3070 * big enough and pNumItems
3071 * has the number of tPmkidCandidateInfo.
3072 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3073 * not sizeof(tPmkidCandidateInfo) * something
3074 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 tPmkidCandidateInfo *pPmkidList,
3077 uint32_t *pNumItems)
3078{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303079 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3081
3082 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303083 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 status =
3085 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3086 pPmkidList,
3087 pNumItems);
3088 sme_release_global_lock(&pMac->sme);
3089 }
3090
3091 return status;
3092}
3093
3094eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3095{
3096 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 return pMac->roam.configParam.phyMode;
3099}
3100
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303101/*
3102 * sme_get_channel_bonding_mode5_g() -
3103 * get the channel bonding mode for 5G band
3104 *
3105 * hHal - HAL handle
3106 * Return channel bonding mode for 5G
3107 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3109{
3110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3111 tSmeConfigParams smeConfig;
3112
3113 sme_get_config_param(pMac, &smeConfig);
3114
3115 return smeConfig.csrConfig.channelBondingMode5GHz;
3116}
3117
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303118/*
3119 * sme_get_channel_bonding_mode24_g() -
3120 * get the channel bonding mode for 2.4G band
3121 *
3122 * hHal - HAL handle
3123 * Return channel bonding mode for 2.4G
3124 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3126{
3127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3128 tSmeConfigParams smeConfig;
3129
3130 sme_get_config_param(pMac, &smeConfig);
3131
3132 return smeConfig.csrConfig.channelBondingMode24GHz;
3133}
3134
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303135/*
3136 * sme_roam_connect() -
3137 * A wrapper function to request CSR to inititiate an association
3138 * This is an asynchronous call.
3139 *
3140 * sessionId - the sessionId returned by sme_open_session.
3141 * pProfile - description of the network to which to connect
3142 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3143 * from csr_scan_get_result
3144 * pRoamId - to get back the request ID
3145 * Return QDF_STATUS
3146 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303147QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303150 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3152
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303153 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303154 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303156 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303159 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3161 status =
3162 csr_roam_connect(pMac, sessionId, pProfile,
3163 pRoamId);
3164 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003165 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303166 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 }
3168 sme_release_global_lock(&pMac->sme);
3169 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003170 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 }
3172
3173 return status;
3174}
3175
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303176/*
3177 * sme_set_phy_mode() -
3178 * Changes the PhyMode.
3179 *
3180 * hHal - The handle returned by mac_open.
3181 * phyMode new phyMode which is to set
3182 * Return QDF_STATUS SUCCESS.
3183 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303184QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185{
3186 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3187
3188 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303189 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 }
3193
3194 pMac->roam.configParam.phyMode = phyMode;
3195 pMac->roam.configParam.uCfgDot11Mode =
3196 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303197 pMac->roam.configParam.phyMode,
3198 pMac->roam.configParam.
3199 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303201 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202}
3203
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303204/*
3205 * sme_roam_reassoc() -
3206 * A wrapper function to request CSR to inititiate a re-association
3207 *
3208 * pProfile - can be NULL to join the currently connected AP. In that
3209 * case modProfileFields should carry the modified field(s) which could trigger
3210 * reassoc
3211 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3212 * that might need modification dynamically once STA is up & running and this
3213 * could trigger a reassoc
3214 * pRoamId - to get back the request ID
3215 * Return QDF_STATUS
3216 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 tCsrRoamProfile *pProfile,
3219 tCsrRoamModifyProfileFields modProfileFields,
3220 uint32_t *pRoamId, bool fForce)
3221{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303222 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3224
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303225 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303228 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303230 if ((NULL == pProfile) && (fForce == 1))
3231 status = csr_reassoc(pMac, sessionId,
3232 &modProfileFields, pRoamId,
3233 fForce);
3234 else
3235 status = csr_roam_reassoc(pMac, sessionId,
3236 pProfile,
3237 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303239 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 }
3241 sme_release_global_lock(&pMac->sme);
3242 }
3243
3244 return status;
3245}
3246
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303247/*
3248 * sme_roam_connect_to_last_profile() -
3249 * A wrapper function to request CSR to disconnect and reconnect with
3250 * the same profile
3251 * This is an asynchronous call.
3252 *
3253 * Return QDF_STATUS. It returns fail if currently connected
3254 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303255QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303257 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3259
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303260 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3262 sessionId, 0));
3263 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303265 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3266 status = csr_roam_connect_to_last_profile(pMac,
3267 sessionId);
3268 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 sme_release_global_lock(&pMac->sme);
3271 }
3272
3273 return status;
3274}
3275
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303276/*
3277 * sme_roam_disconnect() -
3278 * A wrapper function to request CSR to disconnect from a network
3279 * This is an asynchronous call.
3280 *
3281 * reason -- To indicate the reason for disconnecting. Currently, only
3282 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3283 * Return QDF_STATUS
3284 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303285QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 eCsrRoamDisconnectReason reason)
3287{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303288 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3290
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303291 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3293 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303296 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303298 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303299 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 sme_release_global_lock(&pMac->sme);
3301 }
3302
3303 return status;
3304}
3305
Abhishek Singhca408032016-09-13 15:26:12 +05303306/* sme_dhcp_done_ind() - send dhcp done ind
3307 * @hal: hal context
3308 * @session_id: session id
3309 *
3310 * Return: void.
3311 */
3312void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3313{
3314 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303315 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303316
3317 if (!mac_ctx)
3318 return;
3319
3320 session = CSR_GET_SESSION(mac_ctx, session_id);
3321 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003322 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303323 return;
3324 }
3325 session->dhcp_done = true;
3326}
3327
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303328/*
3329 * sme_roam_stop_bss() -
3330 * To stop BSS for Soft AP. This is an asynchronous API.
3331 *
3332 * hHal - Global structure
3333 * sessionId - sessionId of SoftAP
3334 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3335 * actual results
3336 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303337QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303339 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303344 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3345 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
3346 true);
3347 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303348 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 sme_release_global_lock(&pMac->sme);
3350 }
3351
3352 return status;
3353}
3354
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303355/**
3356 * sme_roam_disconnect_sta() - disassociate a station
3357 * @hHal: Global structure
3358 * @sessionId: SessionId of SoftAP
3359 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3360 *
3361 * To disassociate a station. This is an asynchronous API.
3362 *
3363 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3364 * be called to indicate actual result.
3365 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303366QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003367 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303369 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3371
3372 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303373 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 return status;
3375 }
3376
3377 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303378 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303379 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303381 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303382 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303383 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 sme_release_global_lock(&pMac->sme);
3385 }
3386
3387 return status;
3388}
3389
3390/**
3391 * sme_roam_deauth_sta() - deauthenticate a station
3392 * @hHal: Global structure
3393 * @sessionId: SessionId of SoftAP
3394 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3395 *
3396 * To disassociate a station. This is an asynchronous API.
3397 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303398 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 * code on error. Roam callback will be called to indicate actual
3400 * result
3401 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303402QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003403 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303405 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3407
3408 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303409 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 return status;
3411 }
3412
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303413 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303414 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3415 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303417 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303418 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 status =
3420 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3421 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303422 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 sme_release_global_lock(&pMac->sme);
3425 }
3426
3427 return status;
3428}
3429
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303430/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303431 * sme_roam_get_associated_stas() -
3432 * To probe the list of associated stations from various modules
3433 * of CORE stack.
3434 * This is an asynchronous API.
3435 *
3436 * sessionId - sessionId of SoftAP
3437 * modId - Module from whom list of associtated stations is
3438 * to be probed. If an invalid module is passed then
3439 * by default QDF_MODULE_ID_PE will be probed.
3440 * pUsrContext - Opaque HDD context
3441 * pfnSapEventCallback - Sap event callback in HDD
3442 * pAssocBuf - Caller allocated memory to be filled with associatd
3443 * stations info
3444 * Return QDF_STATUS
3445 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303446QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303447 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 void *pfnSapEventCallback,
3449 uint8_t *pAssocStasBuf)
3450{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3453
3454 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303455 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 return status;
3457 }
3458
3459 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303460 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303461 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303463 csr_roam_get_associated_stas(pMac, sessionId,
3464 modId,
3465 pUsrContext,
3466 pfnSapEventCallback,
3467 pAssocStasBuf);
3468 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303469 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 sme_release_global_lock(&pMac->sme);
3471 }
3472
3473 return status;
3474}
3475
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303476/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303477 * sme_roam_get_connect_state() -
3478 * A wrapper function to request CSR to return the current connect state
3479 * of Roaming
3480 * This is a synchronous call.
3481 *
3482 * Return QDF_STATUS
3483 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 eCsrConnectState *pState)
3486{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303487 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3489
3490 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303491 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303492 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3493 status = csr_roam_get_connect_state(pMac, sessionId,
3494 pState);
3495 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303496 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497 sme_release_global_lock(&pMac->sme);
3498 }
3499
3500 return status;
3501}
3502
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303503/*
3504 * sme_roam_get_connect_profile() -
3505 * A wrapper function to request CSR to return the current connect
3506 * profile. Caller must call csr_roam_free_connect_profile after it is done
3507 * and before reuse for another csr_roam_get_connect_profile call.
3508 * This is a synchronous call.
3509 *
3510 * pProfile - pointer to a caller allocated structure
3511 * tCsrRoamConnectedProfile
3512 * eturn QDF_STATUS. Failure if not connected
3513 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 tCsrRoamConnectedProfile *pProfile)
3516{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3519
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303520 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3522 sessionId, 0));
3523 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303525 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3526 status = csr_roam_get_connect_profile(pMac, sessionId,
3527 pProfile);
3528 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303529 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 sme_release_global_lock(&pMac->sme);
3531 }
3532
3533 return status;
3534}
3535
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003536/**
3537 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3538 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3539 *
3540 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3541 *
3542 * Return: none
3543 */
3544void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303546 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3548 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003549 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550}
3551
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303552/*
3553 * sme_roam_set_pmkid_cache() -
3554 * A wrapper function to request CSR to return the PMKID candidate list
3555 * This is a synchronous call.
3556
3557 * pPMKIDCache - caller allocated buffer point to an array of
3558 * tPmkidCacheInfo
3559 * numItems - a variable that has the number of tPmkidCacheInfo
3560 * allocated when retruning, this is either the number needed
3561 * or number of items put into pPMKIDCache
3562 * update_entire_cache - this bool value specifies if the entire pmkid
3563 * cache should be overwritten or should it be
3564 * updated entry by entry.
3565 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3566 * big enough and pNumItems has the number of
3567 * tPmkidCacheInfo.
3568 * \Note: pNumItems is a number of tPmkidCacheInfo,
3569 * not sizeof(tPmkidCacheInfo) * something
3570 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303571QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 tPmkidCacheInfo *pPMKIDCache,
3573 uint32_t numItems, bool update_entire_cache)
3574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303575 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3577
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303578 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3580 numItems));
3581 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303583 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3584 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3585 pPMKIDCache,
3586 numItems, update_entire_cache);
3587 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303588 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 sme_release_global_lock(&pMac->sme);
3590 }
3591
3592 return status;
3593}
3594
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303595QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303596 tPmkidCacheInfo *pmksa,
3597 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303599 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303601
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303602 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303603 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3604 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303607 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303609 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303610 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303611 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 sme_release_global_lock(&pMac->sme);
3613 }
3614 return status;
3615}
3616
3617#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303618/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 * \fn sme_roam_set_psk_pmk
3620 * \brief a wrapper function to request CSR to save PSK/PMK
3621 * This is a synchronous call.
3622 * \param hHal - Global structure
3623 * \param sessionId - SME sessionId
3624 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3625 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3626 * connections. Need to pass this information to
3627 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303630QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 uint8_t *pPSK_PMK, size_t pmk_len)
3632{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303633 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303638 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3639 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303641 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303642 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 sme_release_global_lock(&pMac->sme);
3644 }
3645 return status;
3646}
3647#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303648/*
3649 * sme_roam_get_security_req_ie() -
3650 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3651 * passes to PE to JOIN request or START_BSS request
3652 * This is a synchronous call.
3653 *
3654 * pLen - caller allocated memory that has the length of pBuf as input.
3655 * Upon returned, *pLen has the needed or IE length in pBuf.
3656 * pBuf - Caller allocated memory that contain the IE field, if any,
3657 * upon return
3658 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3659 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3660 * big enough
3661 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303662QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 uint32_t *pLen, uint8_t *pBuf,
3664 eCsrSecurityType secType)
3665{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303666 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3668
3669 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303670 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303671 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3672 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3673 pLen, pBuf);
3674 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303675 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 sme_release_global_lock(&pMac->sme);
3677 }
3678
3679 return status;
3680}
3681
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303682/*
3683 * sme_roam_get_security_rsp_ie() -
3684 * A wrapper function to request CSR to return the WPA or RSN or
3685 * WAPI IE from the beacon or probe rsp if connected
3686 * This is a synchronous call.
3687 *
3688 * pLen - caller allocated memory that has the length of pBuf as input.
3689 * Upon returned, *pLen has the needed or IE length in pBuf.
3690 * pBuf - Caller allocated memory that contain the IE field, if any,
3691 * upon return
3692 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3693 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3694 * big enough
3695 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303696QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 uint32_t *pLen, uint8_t *pBuf,
3698 eCsrSecurityType secType)
3699{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303700 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3702
3703 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303705 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3706 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3707 pLen, pBuf);
3708 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303709 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 sme_release_global_lock(&pMac->sme);
3711 }
3712
3713 return status;
3714
3715}
3716
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303717/*
3718 * sme_roam_get_num_pmkid_cache() -
3719 * A wrapper function to request CSR to return number of PMKID cache
3720 * entries
3721 * This is a synchronous call.
3722 *
3723 * Return uint32_t - the number of PMKID cache entries
3724 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3726{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3729 uint32_t numPmkidCache = 0;
3730
3731 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303732 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3734 numPmkidCache =
3735 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303736 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303737 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303738 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 sme_release_global_lock(&pMac->sme);
3740 }
3741
3742 return numPmkidCache;
3743}
3744
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303745/*
3746 * sme_roam_get_pmkid_cache() -
3747 * A wrapper function to request CSR to return PMKID cache from CSR
3748 * This is a synchronous call.
3749 *
3750 * pNum - caller allocated memory that has the space of the number of
3751 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3752 * needed or actually number in tPmkidCacheInfo.
3753 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3754 * any, upon return
3755 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3756 * big enough
3757 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303758QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303759 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003760{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303761 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3763
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303764 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3766 0));
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_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303772 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_get_config_param() -
3782 * A wrapper function that HDD calls to get the global settings
3783 * currently maintained by CSR.
3784 * This is a synchronous call.
3785 *
3786 * pParam - caller allocated memory
3787 * Return QDF_STATUS
3788 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303791 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3793
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303794 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3796 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303797 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003800 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 sme_release_global_lock(&pMac->sme);
3802 return status;
3803 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303804 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003805 &pMac->rrm.rrmSmeContext.rrmConfig,
3806 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303807 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 sme_release_global_lock(&pMac->sme);
3809 }
3810
3811 return status;
3812}
3813
3814/**
3815 * sme_cfg_set_int() - Sets the cfg parameter value.
3816 * @hal: Handle to hal.
3817 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003818 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 *
3820 * This function sets the string value in cfg parameter.
3821 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303822 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303824QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825{
3826 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303827 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828
3829 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303830 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
3832 return status;
3833}
3834
3835/**
3836 * sme_cfg_set_str() - Sets the cfg parameter string.
3837 * @hal: Handle to hal.
3838 * @cfg_id: Configuration parameter ID.
3839 * @str: Pointer to the string buffer.
3840 * @length: Length of the string.
3841 *
3842 * This function sets the string value in cfg parameter.
3843 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303844 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303846QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 uint32_t length)
3848{
3849 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303850 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851
3852 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854
3855 return status;
3856}
3857
3858/**
3859 * sme_cfg_get_int() - Gets the cfg parameter value.
3860 * @hal: Handle to hal.
3861 * @cfg_id: Configuration parameter ID.
3862 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003863 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 *
3865 * This function gets the value of the cfg parameter.
3866 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303867 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303869QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870{
3871 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873
3874 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303875 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
3877 return status;
3878}
3879
3880/**
3881 * sme_cfg_get_str() - Gets the cfg parameter string.
3882 * @hal: Handle to hal.
3883 * @cfg_id: Configuration parameter ID.
3884 * @str: Pointer to the string buffer.
3885 * @length: Pointer to length of the string.
3886 *
3887 * This function gets the string value of the cfg parameter.
3888 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303889 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303891QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 uint32_t *length)
3893{
3894 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303895 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896
3897 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899
3900 return status;
3901}
3902
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303903/*
3904 * sme_get_modify_profile_fields() -
3905 * HDD or SME - QOS calls this function to get the current values of
3906 * connected profile fields, changing which can cause reassoc.
3907 * This function must be called after CFG is downloaded and STA is in connected
3908 * state. Also, make sure to call this function to get the current profile
3909 * fields before calling the reassoc. So that pModifyProfileFields will have
3910 * all the latest values plus the one(s) has been updated as part of reassoc
3911 * request.
3912 *
3913 * pModifyProfileFields - pointer to the connected profile fields
3914 * changing which can cause reassoc
3915 * Return QDF_STATUS
3916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303917QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 tCsrRoamModifyProfileFields *
3919 pModifyProfileFields)
3920{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303921 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3923
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303924 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3926 0));
3927 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303928 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303929 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3930 status = csr_get_modify_profile_fields(pMac, sessionId,
3931 pModifyProfileFields);
3932 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303933 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 sme_release_global_lock(&pMac->sme);
3935 }
3936
3937 return status;
3938}
3939
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303940/*
3941 * sme_set_dhcp_till_power_active_flag() -
3942 * Sets/Clears DHCP related flag to disable/enable auto PS
3943 *
3944 * hal - The handle returned by mac_open.
3945 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3947{
3948 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3949 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3950
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303951 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3953 flag));
3954 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3955 ps_global_info->remain_in_power_active_till_dhcp = flag;
3956}
3957
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303958/*
3959 * sme_register11d_scan_done_callback() -
3960 * Register a routine of type csr_scan_completeCallback which is
3961 * called whenever an 11d scan is done
3962 *
3963 * hHal - The handle returned by mac_open.
3964 * callback - 11d scan complete routine to be registered
3965 * Return QDF_STATUS
3966 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303967QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303968 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303970 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3972
3973 pMac->scan.callback11dScanDone = callback;
3974
3975 return status;
3976}
3977
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303978/**
3979 * sme_deregister11d_scan_done_callback() - De-register scandone callback
3980 * @h_hal: Handler return by mac_open
3981 *
3982 * This function De-registers the scandone callback to SME
3983 *
3984 * Return: None
3985 */
3986void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
3987{
3988 tpAniSirGlobal pmac;
3989
3990 if (!h_hal) {
3991 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3992 FL("hHal is not valid"));
3993 return;
3994 }
3995
3996 pmac = PMAC_STRUCT(h_hal);
3997 pmac->scan.callback11dScanDone = NULL;
3998}
3999
4000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001#ifdef FEATURE_OEM_DATA_SUPPORT
4002/**
4003 * sme_register_oem_data_rsp_callback() - Register a routine of
4004 * type send_oem_data_rsp_msg
4005 * @h_hal: Handle returned by mac_open.
4006 * @callback: Callback to send response
4007 * to oem application.
4008 *
4009 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4010 * callback function.
4011 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304012 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304014QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 sme_send_oem_data_rsp_msg callback)
4016{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304017 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4019
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004020 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021
4022 return status;
4023
4024}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304025
4026/**
4027 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4028 * @h_hal: Handler return by mac_open
4029 * This function De-registers the OEM data response callback to SME
4030 *
4031 * Return: None
4032 */
4033void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4034{
4035 tpAniSirGlobal pmac;
4036
4037 if (!h_hal) {
4038 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4039 FL("hHal is not valid"));
4040 return;
4041 }
4042 pmac = PMAC_STRUCT(h_hal);
4043
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004044 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304045}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046
4047/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004048 * sme_oem_update_capability() - update UMAC's oem related capability.
4049 * @hal: Handle returned by mac_open
4050 * @oem_cap: pointer to oem_capability
4051 *
4052 * This function updates OEM capability to UMAC. Currently RTT
4053 * related capabilities are updated. More capabilities can be
4054 * added in future.
4055 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304056 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004057 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304058QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004059 struct sme_oem_capability *cap)
4060{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304061 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004062 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4063 uint8_t *bytes;
4064
4065 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4066
4067 if (cap->ftm_rr)
4068 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4069 if (cap->lci_capability)
4070 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4071
4072 return status;
4073}
4074
4075/**
4076 * sme_oem_get_capability() - get oem capability
4077 * @hal: Handle returned by mac_open
4078 * @oem_cap: pointer to oem_capability
4079 *
4080 * This function is used to get the OEM capability from UMAC.
4081 * Currently RTT related capabilities are received. More
4082 * capabilities can be added in future.
4083 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004085 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304086QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004087 struct sme_oem_capability *cap)
4088{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304089 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004090 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4091 uint8_t *bytes;
4092
4093 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4094
4095 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4096 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4097
4098 return status;
4099}
Naveen Rawat910726a2017-03-06 11:42:51 -08004100#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004101
4102/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4104 * function to MAC/SYS
4105 *
4106 * @hal: hal handle
4107 * @callback: hdd function that has to be registered
4108 *
4109 * Return: void
4110 */
4111void sme_register_ftm_msg_processor(tHalHandle hal,
4112 hdd_ftm_msg_processor callback)
4113{
4114 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4115
4116 if (mac_ctx == NULL) {
Naveen Rawatcf684762016-06-27 15:30:24 -07004117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4118 FL("mac ctx is NULL"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 return;
4120 }
Naveen Rawatcf684762016-06-27 15:30:24 -07004121
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 mac_ctx->ftm_msg_processor_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123}
4124
4125/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4127 * @hal_ctx - The handle returned by mac_open.
4128 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4129 * Used for success/failure notification by SME
4130 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4131 * back to HDD at the time of callback.
4132 * @wake_reason_ind_cb - Callback routine provided by HDD.
4133 * Used for Wake Reason Indication by SME
4134 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4135 * back to HDD at the time of callback.
4136 *
4137 * WoWLAN works on top of BMPS mode.
4138 * If the device is not in BMPS mode,
4139 * SME will will cache the information that
4140 * WOWL has been enabled and attempt to put the device
4141 * in BMPS. On entry into BMPS, SME will enable the
4142 * WOWL mode.
4143 * Note 1: If we exit BMPS mode (someone requests full power),
4144 * we will NOT resume WOWL when we go back to BMPS again.
4145 * Request for full power (while in WOWL mode) means disable
4146 * WOWL and go to full power.
4147 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4148 * On entry into BMPS, SME will give priority to UAPSD and
4149 * enable only UAPSD if both UAPSD and WOWL are required.
4150 * Currently there is no requirement or use case to support
4151 * UAPSD and WOWL at the same time.
4152 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304153 * Return: QDF_STATUS
4154 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4155 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4156 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 * WOWL after BMPS mode is entered.
4158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304159QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 void (*enter_wowl_callback_routine)(void
4161 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304162 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 void *enter_wowl_callback_context,
4164#ifdef WLAN_WAKEUP_EVENTS
4165 void (*wakeIndicationCB)(void *callback_context,
4166 tpSirWakeReasonInd
4167 wake_reason_ind),
4168 void *wakeIndicationCBContext,
4169#endif /* WLAN_WAKEUP_EVENTS */
4170 tpSirSmeWowlEnterParams wowl_enter_params,
4171 uint8_t session_id)
4172{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304173 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4175 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304176
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304177 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004178 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4179
4180 /* cache the WOWL information */
4181 ps_global_info->ps_params[session_id].wowl_enter_params =
4182 *wowl_enter_params;
4183 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4184 enter_wowl_callback_routine;
4185 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4186 enter_wowl_callback_context;
4187#ifdef WLAN_WAKEUP_EVENTS
4188 /* Cache the Wake Reason Indication callback information */
4189 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4190 wakeIndicationCB;
4191 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4192 wakeIndicationCBContext;
4193#endif /* WLAN_WAKEUP_EVENTS */
4194
4195 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4196 return status;
4197}
4198/**
4199 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4200 * @hal_ctx - The handle returned by mac_open.
4201 * @wowl_exit_params - Carries info on which smesession
4202 * wowl exit is requested.
4203 *
4204 * SME will initiate exit from WoWLAN mode and device will be
4205 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304206 * Return QDF_STATUS
4207 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4208 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304210QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 tpSirSmeWowlExitParams wowl_exit_params)
4212{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304213 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4215 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304216
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304217 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4219 session_id = wowl_exit_params->sessionId;
4220 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4221 return status;
4222}
4223
4224/**
4225 * sme_roam_set_key() - To set encryption key.
4226 * @hal: hal global context
4227 * @session_id: session id
4228 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4229 * @ptr_roam_id: Upon success return, this is the id caller can use to
4230 * identify the request in roamcallback
4231 *
4232 * This function should be called only when connected. This is an asynchronous
4233 * API.
4234 *
4235 * Return: Status of operation
4236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304237QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4239{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304240 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4242 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304243 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4245
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304246 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 session_id, 0));
4248 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004249 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304250 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 }
4252 /*Once Setkey is done, we can go in BMPS */
4253 if (set_key->keyLength)
4254 ps_global_info->remain_in_power_active_till_dhcp = false;
4255
4256 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304257 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 return status;
4259
4260 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4261 if (ptr_roam_id)
4262 *ptr_roam_id = roam_id;
4263
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004264 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004266 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 session = CSR_GET_SESSION(mac_ctx, session_id);
4268 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004269 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304271 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 }
4273 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4274 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4275 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4276 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4277 set_key->encType)) {
4278 session->pCurRoamProfile->negotiatedUCEncryptionType =
4279 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4280 }
4281 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4282 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4283 set_key->encType)) {
4284 session->pCurRoamProfile->negotiatedUCEncryptionType =
4285 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4286 }
4287 }
4288 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4289 sme_release_global_lock(&mac_ctx->sme);
4290 return status;
4291}
4292
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304293/**
4294 * sme_roam_set_default_key_index - To set default wep key idx
4295 * @hal: pointer to hal handler
4296 * @session_id: session id
4297 * @default_idx: default wep key index
4298 *
4299 * This function prepares a message and post to WMA to set wep default
4300 * key index
4301 *
4302 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4303 */
4304QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4305 uint8_t default_idx)
4306{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004307 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304308 struct wep_update_default_key_idx *update_key;
4309
4310 update_key = qdf_mem_malloc(sizeof(*update_key));
4311 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004312 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304313 return QDF_STATUS_E_NOMEM;
4314 }
4315
4316 update_key->session_id = session_id;
4317 update_key->default_idx = default_idx;
4318
4319 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4320 msg.reserved = 0;
4321 msg.bodyptr = (void *)update_key;
4322
4323 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004324 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004325 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304326 qdf_mem_free(update_key);
4327 return QDF_STATUS_E_FAILURE;
4328 }
4329
4330 return QDF_STATUS_SUCCESS;
4331}
4332
4333
Jeff Johnson8bd23352017-09-26 11:39:24 -07004334/**
4335 * sme_get_rssi() - API to retrieve current RSSI
4336 * @hHal: HAL handle for device
4337 * @callback: SME sends back the requested stats using the callback
4338 * @staId: The station ID for which the RSSI is requested for
4339 * @bssid: The bssid of the connected session
4340 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4341 * RSSI, do not hold up but return this value.
4342 * @pContext: user context to be passed back along with the callback
4343 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304344 * A wrapper function that client calls to register a callback to get RSSI
4345 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004346 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304347 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304348QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304349 tCsrRssiCallback callback, uint8_t staId,
4350 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004351 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304353 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4355
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304356 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4358 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304359 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 status = csr_get_rssi(pMac, callback,
4361 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004362 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 sme_release_global_lock(&pMac->sme);
4364 }
4365 return status;
4366}
4367
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304368/*
4369 * sme_get_snr() -
4370 * A wrapper function that client calls to register a callback to get SNR
4371 *
4372 * callback - SME sends back the requested stats using the callback
4373 * staId - The station ID for which the stats is requested for
4374 * pContext - user context to be passed back along with the callback
4375 * p_cds_context - cds context
4376 * \return QDF_STATUS
4377 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304378QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304380 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304382 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4384
4385 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304386 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004387 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4388 sme_release_global_lock(&pMac->sme);
4389 }
4390 return status;
4391}
4392
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304393/*
4394 * sme_get_statistics() -
4395 * A wrapper function that client calls to register a callback to get
4396 * different PHY level statistics from CSR.
4397 *
4398 * requesterId - different client requesting for statistics,
4399 * HDD, UMA/GAN etc
4400 * statsMask - The different category/categories of stats requester
4401 * is looking for
4402 * callback - SME sends back the requested stats using the callback
4403 * periodicity - If requester needs periodic update in millisec, 0 means
4404 * it's an one time request
4405 * cache - If requester is happy with cached stats
4406 * staId - The station ID for which the stats is requested for
4407 * pContext - user context to be passed back along with the callback
4408 * sessionId - sme session interface
4409 * Return QDF_STATUS
4410 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304411QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 eCsrStatsRequesterType requesterId,
4413 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004414 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304416 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304420 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304421 status = csr_get_statistics(pMac, requesterId, statsMask,
4422 callback, staId, pContext,
4423 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 sme_release_global_lock(&pMac->sme);
4425 }
4426
4427 return status;
4428
4429}
4430
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304431QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 tCsrLinkStatusCallback callback,
4433 void *pContext, uint8_t sessionId)
4434{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304435 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4437 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004438 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439
4440 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304441 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304442 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304444 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 "%s: Not able to allocate memory for link status",
4446 __func__);
4447 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304448 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 }
4450
4451 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4452 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4453 pMsg->sessionId = sessionId;
4454 pMac->sme.linkStatusContext = pContext;
4455 pMac->sme.linkStatusCallback = callback;
4456
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004457 message.type = WMA_LINK_STATUS_GET_REQ;
4458 message.bodyptr = pMsg;
4459 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304461 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004462 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4463 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304464 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304466 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 pMac->sme.linkStatusContext = NULL;
4468 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304469 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 }
4471
4472 sme_release_global_lock(&pMac->sme);
4473 }
4474
4475 return status;
4476}
4477
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304478/*
4479 * sme_get_country_code() -
4480 * To return the current country code. If no country code is applied,
4481 * default country code is used to fill the buffer.
4482 * If 11d supported is turned off, an error is return and the last
4483 * applied/default country code is used.
4484 * This is a synchronous API.
4485 *
4486 * pBuf - pointer to a caller allocated buffer for returned country code.
4487 * pbLen For input, this parameter indicates how big is the buffer.
4488 * Upon return, this parameter has the number of bytes for
4489 * country. If pBuf doesn't have enough space, this function
4490 * returns fail status and this parameter contains the number
4491 * that is needed.
4492 *
4493 * Return QDF_STATUS SUCCESS.
4494 *
4495 * FAILURE or RESOURCES The API finished and failed.
4496 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304497QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498{
4499 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4500
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304501 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4503
4504 return csr_get_country_code(pMac, pBuf, pbLen);
4505}
4506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507/* some support functions */
4508bool sme_is11d_supported(tHalHandle hHal)
4509{
4510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4511
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004512 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513}
4514
4515bool sme_is11h_supported(tHalHandle hHal)
4516{
4517 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4518
4519 return csr_is11h_supported(pMac);
4520}
4521
4522bool sme_is_wmm_supported(tHalHandle hHal)
4523{
4524 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4525
4526 return csr_is_wmm_supported(pMac);
4527}
4528
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304529/*
4530 * sme_change_country_code() -
4531 * Change Country code from upperlayer during WLAN driver operation.
4532 * This is a synchronous API.
4533 *
4534 * hHal - The handle returned by mac_open.
4535 * pCountry New Country Code String
4536 * sendRegHint If we want to send reg hint to nl80211
4537 * Return QDF_STATUS SUCCESS.
4538 * FAILURE or RESOURCES The API finished and failed.
4539 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304540QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541 tSmeChangeCountryCallback callback,
4542 uint8_t *pCountry,
4543 void *pContext,
4544 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004545 bool countryFromUserSpace,
4546 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004547{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304548 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004550 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 tAniChangeCountryCodeReq *pMsg;
4552
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304553 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4555 0));
4556 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304557 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4559 && (!pMac->roam.configParam.
4560 fSupplicantCountryCodeHasPriority)) {
4561
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004562 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004563
4564 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304565 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 return status;
4567 }
4568
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304569 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004571 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304573 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 }
4575
4576 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4577 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304578 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 pMsg->countryFromUserSpace = countryFromUserSpace;
4580 pMsg->sendRegHint = sendRegHint;
4581 pMsg->changeCCCallback = callback;
4582 pMsg->pDevContext = pContext;
4583 pMsg->p_cds_context = p_cds_context;
4584
4585 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4586 msg.bodyptr = pMsg;
4587 msg.reserved = 0;
4588
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304589 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004590 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004591 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304592 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304593 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 sme_release_global_lock(&pMac->sme);
4596 }
4597
4598 return status;
4599}
4600
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304601/*
4602 * sme_generic_change_country_code() -
4603 * Change Country code from upperlayer during WLAN driver operation.
4604 * This is a synchronous API.
4605 *
4606 * hHal - The handle returned by mac_open.
4607 * pCountry New Country Code String
4608 * reg_domain regulatory domain
4609 * Return QDF_STATUS SUCCESS.
4610 * FAILURE or RESOURCES The API finished and failed.
4611 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304612QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004613 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004617 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 tAniGenericChangeCountryCodeReq *pMsg;
4619
4620 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304621 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 "%s: pMac is null", __func__);
4623 return status;
4624 }
4625
4626 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304627 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304628 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629
4630 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004631 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304633 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 }
4635
4636 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4637 pMsg->msgLen =
4638 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304639 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004640 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641
4642 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4643 msg.bodyptr = pMsg;
4644 msg.reserved = 0;
4645
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004647 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004648 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304649 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 sme_release_global_lock(&pMac->sme);
4653 }
4654
4655 return status;
4656}
4657
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304658/*
4659 * sme_dhcp_start_ind() -
4660 * API to signal the FW about the DHCP Start event.
4661 *
4662 * hHal - HAL handle for device.
4663 * device_mode - mode(AP,SAP etc) of the device.
4664 * macAddr - MAC address of the adapter.
4665 * sessionId - session ID.
4666 * Return QDF_STATUS SUCCESS.
4667 * FAILURE or RESOURCES The API finished and failed.
4668 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304669QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 uint8_t device_mode,
4671 uint8_t *macAddr, uint8_t sessionId)
4672{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304673 QDF_STATUS status;
4674 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004676 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304678 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679
4680 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304681 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 pSession = CSR_GET_SESSION(pMac, sessionId);
4683
4684 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004685 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304687 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 }
Arif Hussain3316f402016-11-10 13:08:03 -08004689 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304691 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 "%s: Not able to allocate memory for dhcp start",
4695 __func__);
4696 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304697 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 }
4699 pMsg->msgType = WMA_DHCP_START_IND;
4700 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4701 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304702 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304703 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304704 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004705 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004706
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004707 message.type = WMA_DHCP_START_IND;
4708 message.bodyptr = pMsg;
4709 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304710 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004711 sessionId, message.type));
4712 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4713 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304714 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304717 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304718 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 }
4720 sme_release_global_lock(&pMac->sme);
4721 }
4722 return status;
4723}
4724
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304725/*
4726 * sme_dhcp_stop_ind() -
4727 * API to signal the FW about the DHCP complete event.
4728 *
4729 * hHal - HAL handle for device.
4730 * device_mode - mode(AP, SAP etc) of the device.
4731 * macAddr - MAC address of the adapter.
4732 * sessionId - session ID.
4733 * Return QDF_STATUS SUCCESS.
4734 * FAILURE or RESOURCES The API finished and failed.
4735 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304736QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 uint8_t device_mode,
4738 uint8_t *macAddr, uint8_t sessionId)
4739{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740 QDF_STATUS status;
4741 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004743 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304745 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746
4747 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304748 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 pSession = CSR_GET_SESSION(pMac, sessionId);
4750
4751 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004752 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304754 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 }
Arif Hussain3316f402016-11-10 13:08:03 -08004756 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304758 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 "%s: Not able to allocate memory for dhcp stop",
4762 __func__);
4763 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304764 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 }
4766
4767 pMsg->msgType = WMA_DHCP_STOP_IND;
4768 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4769 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304770 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304771 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304772 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004773 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004774
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004775 message.type = WMA_DHCP_STOP_IND;
4776 message.bodyptr = pMsg;
4777 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304778 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004779 sessionId, message.type));
4780 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4781 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304782 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304783 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304785 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304786 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 }
4788
4789 sme_release_global_lock(&pMac->sme);
4790 }
4791 return status;
4792}
4793
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304794/*
4795 * sme_TXFailMonitorStopInd() -
4796 * API to signal the FW to start monitoring TX failures
4797 *
4798 * Return QDF_STATUS SUCCESS.
4799 * FAILURE or RESOURCES The API finished and failed.
4800 */
4801QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4802 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004803 void *txFailIndCallback)
4804{
4805 QDF_STATUS status;
4806 QDF_STATUS qdf_status;
4807 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004808 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004809 tAniTXFailMonitorInd *pMsg;
4810
4811 status = sme_acquire_global_lock(&pMac->sme);
4812 if (QDF_STATUS_SUCCESS == status) {
4813 pMsg = (tAniTXFailMonitorInd *)
4814 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4815 if (NULL == pMsg) {
4816 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4817 "%s: Failed to allocate memory", __func__);
4818 sme_release_global_lock(&pMac->sme);
4819 return QDF_STATUS_E_NOMEM;
4820 }
4821
4822 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4823 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4824
4825 /* tx_fail_count = 0 should disable the Monitoring in FW */
4826 pMsg->tx_fail_count = tx_fail_count;
4827 pMsg->txFailIndCallback = txFailIndCallback;
4828
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004829 message.type = WMA_TX_FAIL_MONITOR_IND;
4830 message.bodyptr = pMsg;
4831 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004832
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004833 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4834 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004835 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4836 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4837 "%s: Post TX Fail monitor Start MSG fail",
4838 __func__);
4839 qdf_mem_free(pMsg);
4840 status = QDF_STATUS_E_FAILURE;
4841 }
4842 sme_release_global_lock(&pMac->sme);
4843 }
4844 return status;
4845}
4846
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304847/*
4848 * sme_set_cfg_privacy() -
4849 * API to set configure privacy parameters
4850 *
4851 * hHal - The handle returned by mac_open.
4852 * pProfile - Pointer CSR Roam profile.
4853 * fPrivacy - This parameter indicates status of privacy
4854 * Return void
4855 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856void sme_set_cfg_privacy(tHalHandle hHal,
4857 tCsrRoamProfile *pProfile, bool fPrivacy)
4858{
4859 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304860
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304861 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304863 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4865 sme_release_global_lock(&pMac->sme);
4866 }
4867}
4868
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304869/*
4870 * sme_neighbor_report_request() -
4871 * API to request neighbor report.
4872 *
4873 * hHal - The handle returned by mac_open.
4874 * pRrmNeighborReq - Pointer to a caller allocated object of type
4875 * tRrmNeighborReq. Caller owns the memory and is
4876 * responsible for freeing it.
4877 * Return QDF_STATUS
4878 * QDF_STATUS_E_FAILURE - failure
4879 * QDF_STATUS_SUCCESS success
4880 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304881QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304883 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304885 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304887
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304888 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4890 0));
4891
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304892 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 status =
4894 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304895 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 sme_release_global_lock(&pMac->sme);
4897 }
4898
4899 return status;
4900}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304902/*
4903 * sme_get_wcnss_wlan_compiled_version() -
4904 * This API returns the version of the WCNSS WLAN API with
4905 * which the HOST driver was built
4906 *
4907 * hHal - The handle returned by mac_open.
4908 * pVersion - Points to the Version structure to be filled
4909 * Return QDF_STATUS
4910 * QDF_STATUS_E_INVAL - failure
4911 * QDF_STATUS_SUCCESS success
4912 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304913QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 tSirVersionType *pVersion)
4915{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304916 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4918
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304919 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304921 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924
4925 sme_release_global_lock(&pMac->sme);
4926 }
4927
4928 return status;
4929}
4930
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304931/*
4932 * sme_get_wcnss_wlan_reported_version() -
4933 * This API returns the version of the WCNSS WLAN API with
4934 * which the WCNSS driver reports it was built
4935 * hHal - The handle returned by mac_open.
4936 * pVersion - Points to the Version structure to be filled
4937 * Return QDF_STATUS
4938 * QDF_STATUS_E_INVAL - failure
4939 * QDF_STATUS_SUCCESS success
4940 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304941QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 tSirVersionType *pVersion)
4943{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304944 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004945 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4946
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304947 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304949 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304951 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952
4953 sme_release_global_lock(&pMac->sme);
4954 }
4955
4956 return status;
4957}
4958
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304959/*
4960 * sme_get_wcnss_software_version() -
4961 * This API returns the version string of the WCNSS driver
4962 *
4963 * hHal - The handle returned by mac_open.
4964 * pVersion - Points to the Version string buffer to be filled
4965 * versionBufferSize - THe size of the Version string buffer
4966 * Return QDF_STATUS
4967 * QDF_STATUS_E_INVAL - failure
4968 * QDF_STATUS_SUCCESS success
4969 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304970QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 uint8_t *pVersion,
4972 uint32_t versionBufferSize)
4973{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304974 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304978 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004980 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 pVersion,
4982 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304983 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304984 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 sme_release_global_lock(&pMac->sme);
4986 }
4987
4988 return status;
4989}
4990
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304991/*
4992 * sme_get_wcnss_hardware_version() -
4993 * This API returns the version string of the WCNSS hardware
4994 *
4995 * hHal - The handle returned by mac_open.
4996 * pVersion - Points to the Version string buffer to be filled
4997 * versionBufferSize - THe size of the Version string buffer
4998 * Return QDF_STATUS
4999 * QDF_STATUS_E_INVAL - failure
5000 * QDF_STATUS_SUCCESS success
5001 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305002QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 uint8_t *pVersion,
5004 uint32_t versionBufferSize)
5005{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305006 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5008
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305009 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305011 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014
5015 sme_release_global_lock(&pMac->sme);
5016 }
5017
5018 return status;
5019}
5020
5021#ifdef FEATURE_WLAN_WAPI
5022
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305023/*
5024 * sme_scan_get_bkid_candidate_list() -
5025 * A wrapper function to return the BKID candidate list
5026 *
5027 * pBkidList - caller allocated buffer point to an array of
5028 * tBkidCandidateInfo
5029 * pNumItems - pointer to a variable that has the number of
5030 * tBkidCandidateInfo allocated when retruning, this is
5031 * either the number needed or number of items put into
5032 * pPmkidList
5033 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5034 * big enough and pNumItems
5035 * has the number of tBkidCandidateInfo.
5036 * Note: pNumItems is a number of tBkidCandidateInfo,
5037 * not sizeof(tBkidCandidateInfo) * something
5038 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305039QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 tBkidCandidateInfo *pBkidList,
5041 uint32_t *pNumItems)
5042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305043 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5045
5046 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305047 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305049 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5050 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 sme_release_global_lock(&pMac->sme);
5052 }
5053
5054 return status;
5055}
5056#endif /* FEATURE_WLAN_WAPI */
5057
5058#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005059/**
5060 * sme_oem_data_req() - send oem data request to WMA
5061 * @hal: HAL handle
5062 * @hdd_oem_req: OEM data request from HDD
5063 *
5064 * Return: QDF_STATUS
5065 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005066QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305068 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005069 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005070 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005072 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005073 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5074 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005075 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005076 return QDF_STATUS_E_FAILURE;
5077 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005079 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5080 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005081 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005082 return QDF_STATUS_E_NOMEM;
5083 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005085 oem_data_req->data_len = hdd_oem_req->data_len;
5086 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5087 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005088 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005089 return QDF_STATUS_E_NOMEM;
5090 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005092 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5093 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005095 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305097 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005098 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305099 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005100 sme_debug("OEM request(length: %d) sent to WMA",
5101 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005102
5103 if (oem_data_req->data_len)
5104 qdf_mem_free(oem_data_req->data);
5105 qdf_mem_free(oem_data_req);
5106
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005107 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108 return status;
5109}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110#endif /*FEATURE_OEM_DATA_SUPPORT */
5111
Krunal Soni8d184fa2017-11-20 21:52:05 -08005112QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113{
Arif Hussainee677012017-01-26 17:50:13 -08005114 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005115 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08005116 struct cdp_pdev *pdev;
5117 ol_txrx_peer_handle peer;
5118 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005119 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005120
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305121 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005122 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08005123 __func__, params->type_of_persona,
5124 params->sme_session_id, params->subtype_of_persona,
5125 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126
Arif Hussainee677012017-01-26 17:50:13 -08005127 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5128
5129 if (NULL == pdev) {
5130 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5131 "%s: Failed to get pdev handler", __func__);
5132 return status;
5133 }
5134
Krunal Soni8d184fa2017-11-20 21:52:05 -08005135 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005136 if (QDF_IS_STATUS_ERROR(status))
5137 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138
Krunal Soni8d184fa2017-11-20 21:52:05 -08005139 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
5140 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005141 if (peer) {
5142 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5143 "%s: Peer=%d exist with same MAC",
5144 __func__, peer_id);
5145 status = QDF_STATUS_E_INVAL;
5146 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005147 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08005148 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08005149 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005150
5151 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005152 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153
5154 return status;
5155}
5156
Krunal Soni8d184fa2017-11-20 21:52:05 -08005157QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305159 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005160 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305162 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005163 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305165 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005166 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 sme_release_global_lock(&pMac->sme);
5168 }
5169
5170 return status;
5171}
5172
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305173/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305174 * sme_change_mcc_beacon_interval() -
5175 * To update P2P-GO beaconInterval. This function should be called after
5176 * disassociating all the station is done
5177 * This is an asynchronous API.
5178 *
5179 * @sessionId: Session Identifier
5180 * Return QDF_STATUS SUCCESS
5181 * FAILURE or RESOURCES
5182 * The API finished and failed.
5183 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005184QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305186 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005187 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005189 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305190 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005191 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5192 sessionId);
5193 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 }
5195 return status;
5196}
5197
5198/**
5199 * sme_set_host_offload(): API to set the host offload feature.
5200 * @hHal: The handle returned by mac_open.
5201 * @sessionId: Session Identifier
5202 * @request: Pointer to the offload request.
5203 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305204 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305206QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 tpSirHostOffloadReq request)
5208{
5209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305210 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305212 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5214 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305215 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216#ifdef WLAN_NS_OFFLOAD
5217 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5218 status = sme_set_ps_ns_offload(hHal, request,
5219 sessionId);
5220 } else
5221#endif /* WLAN_NS_OFFLOAD */
5222 {
5223 status = sme_set_ps_host_offload(hHal, request,
5224 sessionId);
5225 }
5226 sme_release_global_lock(&pMac->sme);
5227 }
5228
5229 return status;
5230}
5231
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305232/*
5233 * sme_set_keep_alive() -
5234 * API to set the Keep Alive feature.
5235 *
5236 * hHal - The handle returned by mac_open.
5237 * request - Pointer to the Keep Alive request.
5238 * Return QDF_STATUS
5239 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305240QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 tpSirKeepAliveReq request)
5242{
5243 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005244 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305246 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 FL("WMA_SET_KEEP_ALIVE message"));
5250
5251 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305256 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305258 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305259 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305260 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261 }
5262
Anurag Chouhanc5548422016-02-24 18:33:27 +05305263 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305264 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305266 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267 "buff TP %d input TP %d ", request_buf->timePeriod,
5268 request->timePeriod);
5269 request_buf->sessionId = session_id;
5270
5271 msg.type = WMA_SET_KEEP_ALIVE;
5272 msg.reserved = 0;
5273 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305274 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5275 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305276 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005277 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305279 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305280 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305281 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 }
5283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305284 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005285}
5286
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305287/*
5288 * sme_get_operation_channel() -
5289 * API to get current channel on which STA is parked his function gives
5290 * channel information only of infra station or IBSS station
5291 *
5292 * hHal, pointer to memory location and sessionId
5293 * Returns QDF_STATUS_SUCCESS
5294 * QDF_STATUS_E_FAILURE
5295 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305296QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 uint8_t sessionId)
5298{
5299 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305300 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301
5302 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5303 pSession = CSR_GET_SESSION(pMac, sessionId);
5304
5305 if ((pSession->connectedProfile.BSSType ==
5306 eCSR_BSS_TYPE_INFRASTRUCTURE)
5307 || (pSession->connectedProfile.BSSType ==
5308 eCSR_BSS_TYPE_IBSS)
5309 || (pSession->connectedProfile.BSSType ==
5310 eCSR_BSS_TYPE_INFRA_AP)
5311 || (pSession->connectedProfile.BSSType ==
5312 eCSR_BSS_TYPE_START_IBSS)) {
5313 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305314 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 }
5316 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305317 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318} /* sme_get_operation_channel ends here */
5319
Abhishek Singh7996eb72015-12-30 17:24:02 +05305320/**
5321 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5322 * management frame indication to PE.
5323 *
5324 * @hal: hal pointer
5325 * @callback: callback pointer to be registered
5326 *
5327 * This function is used to register a callback for management
5328 * frame indication to PE.
5329 *
5330 * Return: Success if msg is posted to PE else Failure.
5331 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305332QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305333 sir_mgmt_frame_ind_callback callback)
5334{
5335 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5336 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305337 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305338
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305339 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305340 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305341 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305342 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005343 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305344 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305345 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305346 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305347 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5348 msg->length = sizeof(*msg);
5349
5350 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005351 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305352 sme_release_global_lock(&mac_ctx->sme);
5353 return status;
5354 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305355 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305356}
5357
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305358/*
5359 * sme_RegisterMgtFrame() -
5360 * To register managment frame of specified type and subtype.
5361 *
5362 * frameType - type of the frame that needs to be passed to HDD.
5363 * matchData - data which needs to be matched before passing frame
5364 * to HDD.
5365 * matchDataLen - Length of matched data.
5366 * Return QDF_STATUS
5367 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305368QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005369 uint16_t frameType, uint8_t *matchData,
5370 uint16_t matchLen)
5371{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305372 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305376 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377 tSirRegisterMgmtFrame *pMsg;
5378 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305379 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5380 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381
5382 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005383 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305385 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 }
5387
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305388 if (!CSR_IS_SESSION_ANY(sessionId) &&
5389 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305390 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 "%s Invalid Sessionid", __func__);
5392 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 }
5395
5396 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5397
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305398 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305400 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5403 pMsg->length = len;
5404 pMsg->sessionId = sessionId;
5405 pMsg->registerFrame = true;
5406 pMsg->frameType = frameType;
5407 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305408 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005409 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 }
5411 sme_release_global_lock(&pMac->sme);
5412 }
5413 return status;
5414}
5415
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305416/*
5417 * sme_DeregisterMgtFrame() -
5418 * To De-register managment frame of specified type and subtype.
5419 *
5420 * frameType - type of the frame that needs to be passed to HDD.
5421 * matchData - data which needs to be matched before passing frame
5422 * to HDD.
5423 * matchDataLen - Length of matched data.
5424 * Return QDF_STATUS
5425 */
5426QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427 uint16_t frameType, uint8_t *matchData,
5428 uint16_t matchLen)
5429{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305430 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5432
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305433 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5435 0));
5436 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305437 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 tSirRegisterMgmtFrame *pMsg;
5439 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305440 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5441 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442
5443 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005444 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305446 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 }
5448
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305449 if (!CSR_IS_SESSION_ANY(sessionId) &&
5450 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305451 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 "%s Invalid Sessionid", __func__);
5453 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455 }
5456
5457 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5458
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305459 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305461 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5464 pMsg->length = len;
5465 pMsg->registerFrame = false;
5466 pMsg->frameType = frameType;
5467 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305468 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005469 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 }
5471 sme_release_global_lock(&pMac->sme);
5472 }
5473 return status;
5474}
5475
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005477/**
5478 * sme_configure_ext_wow() - configure Extr WoW
5479 * @hHal - The handle returned by mac_open.
5480 * @wlanExtParams - Depicts the wlan Ext params.
5481 * @callback - ext_wow callback to be registered.
5482 * @callback_context - ext_wow callback context
5483 *
5484 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305485 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005486 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305487QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 tpSirExtWoWParams wlanExtParams,
5489 csr_readyToExtWoWCallback callback,
5490 void *callback_context)
5491{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305492 QDF_STATUS status = QDF_STATUS_SUCCESS;
5493 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005495 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305496 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497
5498 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305499 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305501 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5503
5504 pMac->readyToExtWoWCallback = callback;
5505 pMac->readyToExtWoWContext = callback_context;
5506
5507 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305508 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509
5510 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305511 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005512 message.bodyptr = MsgPtr;
5513 message.type = WMA_WLAN_EXT_WOW;
5514 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5515 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305516 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 pMac->readyToExtWoWCallback = NULL;
5518 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305519 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305520 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 }
5522 sme_release_global_lock(&pMac->sme);
5523 } else {
5524 pMac->readyToExtWoWCallback = NULL;
5525 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305526 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 }
5528
5529 return status;
5530}
5531
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305532/*
5533 * sme_configure_app_type1_params() -
5534 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5535 *
5536 * hHal - The handle returned by mac_open.
5537 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5538 * Return QDF_STATUS
5539 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305540QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 tpSirAppType1Params wlanAppType1Params)
5542{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305543 QDF_STATUS status = QDF_STATUS_SUCCESS;
5544 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005546 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305547 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548
5549 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305550 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305552 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5554 0));
5555
5556 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305557 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305559 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005560 message.bodyptr = MsgPtr;
5561 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5562 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5563 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305564 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305565 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305566 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 }
5568 sme_release_global_lock(&pMac->sme);
5569 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305570 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571 }
5572
5573 return status;
5574}
5575
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305576/*
5577 * sme_configure_app_type2_params() -
5578 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5579 *
5580 * hHal - The handle returned by mac_open.
5581 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5582 * Return QDF_STATUS
5583 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305584QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305585 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305587 QDF_STATUS status = QDF_STATUS_SUCCESS;
5588 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005590 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305591 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592
5593 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305594 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305596 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5598 0));
5599
5600 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305601 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305603 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005604 message.bodyptr = MsgPtr;
5605 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5606 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5607 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305608 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305609 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305610 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 }
5612 sme_release_global_lock(&pMac->sme);
5613 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 }
5616
5617 return status;
5618}
5619#endif
5620
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305621/*
5622 * sme_get_infra_session_id
5623 * To get the session ID for infra session, if connected
5624 * This is a synchronous API.
5625 *
5626 * hHal - The handle returned by mac_open.
5627 * sessionid, -1 if infra session is not connected
5628 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629int8_t sme_get_infra_session_id(tHalHandle hHal)
5630{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305631 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 int8_t sessionid = -1;
5633 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5634
5635 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305636 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637
5638 sessionid = csr_get_infra_session_id(pMac);
5639
5640 sme_release_global_lock(&pMac->sme);
5641 }
5642
5643 return sessionid;
5644}
5645
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305646/*
5647 * sme_get_infra_operation_channel() -
5648 * To get the operating channel for infra session, if connected
5649 * This is a synchronous API.
5650 *
5651 * hHal - The handle returned by mac_open.
5652 * sessionId - the sessionId returned by sme_open_session.
5653 * Return operating channel, 0 if infra session is not connected
5654 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5656{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305657 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5659 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305662 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663
5664 channel = csr_get_infra_operation_channel(pMac, sessionId);
5665
5666 sme_release_global_lock(&pMac->sme);
5667 }
5668
5669 return channel;
5670}
5671
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305672/* This routine will return poerating channel on which other BSS is operating
5673 * to be used for concurrency mode. If other BSS is not up or not connected it
5674 * will return 0
5675 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5677{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305678 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5680 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305681
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305683 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684
5685 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5687 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005688 sme_release_global_lock(&pMac->sme);
5689 }
5690
5691 return channel;
5692}
5693
5694#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5695uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5696 eCsrPhyMode sapPhyMode,
5697 uint8_t cc_switch_mode)
5698{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305699 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5701 uint16_t channel = 0;
5702
5703 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305704 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005705 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305706 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5707 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005708 cc_switch_mode);
5709 sme_release_global_lock(&pMac->sme);
5710 }
5711
5712 return channel;
5713}
5714#endif
5715
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305716/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005717 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005718 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005719 * @cb_fn: Callback function pointer
5720 * @db_ctx: Callback data
5721 *
5722 * Return: QDF_STATUS
5723 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005724QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005725 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5726{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005727 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005728 QDF_STATUS status;
5729
Manikandan Mohan976e7562016-03-15 16:33:31 -07005730 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005731 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005732 mac->sme.get_tsf_cb = cb_fn;
5733 mac->sme.get_tsf_cxt = cb_ctx;
5734 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005735 }
5736 return status;
5737}
5738
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305739/**
5740 * sme_reset_tsfcb() - Reset callback for TSF capture
5741 * @h_hal: Handler return by mac_open
5742 *
5743 * This function reset the tsf capture callback to SME
5744 *
5745 * Return: QDF_STATUS
5746 */
5747QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5748{
5749 tpAniSirGlobal mac;
5750 QDF_STATUS status;
5751
5752 if (!h_hal) {
5753 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5754 FL("h_hal is not valid"));
5755 return QDF_STATUS_E_INVAL;
5756 }
5757 mac = PMAC_STRUCT(h_hal);
5758
5759 status = sme_acquire_global_lock(&mac->sme);
5760 if (QDF_IS_STATUS_SUCCESS(status)) {
5761 mac->sme.get_tsf_cb = NULL;
5762 mac->sme.get_tsf_cxt = NULL;
5763 sme_release_global_lock(&mac->sme);
5764 }
5765 return status;
5766}
5767
Manikandan Mohan976e7562016-03-15 16:33:31 -07005768#ifdef WLAN_FEATURE_TSF
5769/*
5770 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5771 * @h_hal: Handler return by mac_open
5772 * @pinvalue: gpio pin id
5773 *
5774 * Return: QDF_STATUS
5775 */
5776QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5777{
5778 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005779 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005780 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5781
5782 status = sme_acquire_global_lock(&mac->sme);
5783 if (QDF_IS_STATUS_SUCCESS(status)) {
5784 tsf_msg.type = WMA_TSF_GPIO_PIN;
5785 tsf_msg.reserved = 0;
5786 tsf_msg.bodyval = pinvalue;
5787
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005788 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005789 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005790 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005791 status = QDF_STATUS_E_FAILURE;
5792 }
5793 sme_release_global_lock(&mac->sme);
5794 }
5795 return status;
5796}
5797#endif
5798
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005799QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 uint32_t *len)
5801{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305802 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005803 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005805 if (NULL == mac_ctx) {
5806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5807 FL("Invalid MAC context"));
5808 return QDF_STATUS_E_FAILURE;
5809 }
5810
5811 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305812 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005813 status = csr_get_cfg_valid_channels(mac_ctx,
5814 aValidChannels, len);
5815 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 }
5817
5818 return status;
5819}
5820
Amar Singhal6edf9732016-11-20 21:43:40 -08005821void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5822{
5823 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5824
5825 mac_ctx->reg_hint_src = cc_src;
5826}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305827/*
5828 * sme_handle_change_country_code() -
5829 * Change Country code, Reg Domain and channel list
5830 *
5831 * Details Country Code Priority
5832 * If Supplicant country code is priority than 11d is disabled.
5833 * If 11D is enabled, we update the country code after every scan.
5834 * Hence when Supplicant country code is priority, we don't need 11D info.
5835 * Country code from Supplicant is set as current courtry code.
5836 * User can send reset command XX (instead of country code) to reset the
5837 * country code to default values. If 11D is priority,
5838 * Than Supplicant country code code is set to default code. But 11D code
5839 * is set as current country code
5840 *
5841 * pMac - The handle returned by mac_open.
5842 * pMsgBuf - MSG Buffer
5843 * Return QDF_STATUS
5844 */
5845static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5846 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305848 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849 tAniChangeCountryCodeReq *pMsg;
5850 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305851 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005852 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305854 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855 /*
5856 * if the reset Supplicant country code command is triggered,
5857 * enable 11D, reset the country code and return
5858 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005859 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860 pMac->roam.configParam.Is11dSupportEnabled =
5861 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5862
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005863 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5864 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865
5866 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305867 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305868 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869 default_country,
5870 WNI_CFG_COUNTRY_CODE_LEN);
5871 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305872 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 return status;
5874 }
5875 /*
5876 * Update the 11d country to default country so that when
5877 * callback is received for this default country, driver will
5878 * not disable the 11d taking it as valid country by user.
5879 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005880 sme_debug(
5881 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305883 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005884 pMsg->countryCode,
5885 WNI_CFG_COUNTRY_CODE_LEN);
5886 } else {
5887 /* if Supplicant country code has priority, disable 11d */
5888 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305889 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 }
5892
5893 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305894 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005895
5896 /* Set Current Country code and Current Regulatory domain */
5897 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305898 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 /* Supplicant country code failed. So give 11D priority */
5900 pMac->roam.configParam.Is11dSupportEnabled =
5901 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005902 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 return status;
5904 }
5905
5906 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305907 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
5909
5910 /* Get Domain ID from country code */
5911 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305912 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005913 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07005914 domainIdIoctl,
5915 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305916 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005917 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 return status;
5919 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305920 /* Supplicant country code is invalid, so we are on world mode
5921 * now. So give 11D chance to update
5922 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 pMac->roam.configParam.Is11dSupportEnabled =
5924 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005925 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 }
5927
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005928 if (domainIdIoctl >= REGDOMAIN_COUNT) {
5929 sme_err("Invalid regId %d", domainIdIoctl);
5930 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 } else {
5932 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
5933 /* set again if we find AP with 11d info during scan */
5934 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005935 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305936 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305937 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305938 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 sizeof(pMac->scan.countryCode11d));
5940 }
5941 }
5942
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305943 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305945 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305947 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948}
5949
5950/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005951 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 * @mac_ctx: mac global context
5953 * @msg: request msg packet
5954 *
5955 * If Supplicant country code is priority than 11d is disabled.
5956 * If 11D is enabled, we update the country code after every scan.
5957 * Hence when Supplicant country code is priority, we don't need 11D info.
5958 * Country code from Supplicant is set as current country code.
5959 *
5960 * Return: status of operation
5961 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305962static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005963sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5964 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005965{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305966 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005967 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005968 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005970 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971
Amar Singhal6edf9732016-11-20 21:43:40 -08005972 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5973 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5974 if (user_ctry_priority)
5975 mac_ctx->roam.configParam.Is11dSupportEnabled =
5976 false;
5977 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305978 if (mac_ctx->roam.configParam.
5979 Is11dSupportEnabled &&
5980 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005982 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005983
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305984 status =
5985 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005986 mac_ctx,
5987 mac_ctx->scan.countryCode11d,
5988 &reg_domain_id,
5989 SOURCE_11D);
5990 return QDF_STATUS_E_FAILURE;
5991 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005992 }
5993 }
5994 } else {
5995 /* if kernel gets invalid country code; it
5996 * resets the country code to world
5997 */
5998 if (('0' != msg->countryCode[0]) ||
5999 ('0' != msg->countryCode[1]))
6000 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6001 msg->countryCode,
6002 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006004
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006005 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6006 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 /* get the channels based on new cc */
6010 status = csr_get_channel_and_power_list(mac_ctx);
6011
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306012 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006013 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 return status;
6015 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006016
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 /* reset info based on new cc, and we are done */
6018 csr_apply_channel_power_info_wrapper(mac_ctx);
6019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006021
6022 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 * Country IE
6024 */
6025 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006026
Amar Singhal6edf9732016-11-20 21:43:40 -08006027 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6028
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006030
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306031 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032}
6033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034static bool
6035sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6036{
6037 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306038 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 ch_lst_info = &mac_ctx->scan.base_channels;
6041 for (i = 0; i < ch_lst_info->numChannels; i++) {
6042 if (ch_lst_info->channelList[i] == curr_ch)
6043 return true;
6044 }
6045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 return false;
6047}
6048/**
6049 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6050 * if channel is not supported
6051 * @mac_ctx: mac global context
6052 *
6053 * If new country code does not support the channel on which STA/P2P client
6054 * is connetced, it sends the disconnect to the AP/P2P GO
6055 *
6056 * Return: void
6057 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306058static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059{
6060 uint8_t session_id, found = false;
6061 uint8_t curr_ch;
6062
6063 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6064 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6065 continue;
6066 found = false;
6067 /* Session is connected.Check the channel */
6068 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6069 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006070 sme_debug("Current Operating channel : %d, session :%d",
6071 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006072 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6073 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006074 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 csr_roam_disconnect(mac_ctx, session_id,
6076 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6077 }
6078 }
6079}
6080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306082QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 tpSirRcvFltMcAddrList pMulticastAddrs)
6084{
6085 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006086 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306088 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006089
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306090 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6091 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006093 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006094
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006095 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006096 pSession = CSR_GET_SESSION(pMac, sessionId);
6097 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6098 (!csr_is_conn_state_infra(pMac, sessionId) &&
6099 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306100 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006101 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306103 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 }
6105
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306106 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306108 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306109 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306111 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 }
6113
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006114 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6115 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006117 "%s: Request ignored, session %d is not connected or started",
6118 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306119 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306120 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 }
6122
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306123 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 sizeof(tSirRcvFltMcAddrList));
6125
Anurag Chouhanc5548422016-02-24 18:33:27 +05306126 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6127 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006128 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129
6130 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6131 msg.reserved = 0;
6132 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306133 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6134 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006135 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006136 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306137 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306138 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306140 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306141 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 }
6143
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306144 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146#endif /* WLAN_FEATURE_PACKET_FILTERING */
6147
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306148/*
6149 * sme_is_channel_valid() -
6150 * To check if the channel is valid for currently established domain
6151 * This is a synchronous API.
6152 *
6153 * hHal - The handle returned by mac_open.
6154 * channel - channel to verify
6155 * Return true/false, true if channel is valid
6156 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6158{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306159 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160 bool valid = false;
6161 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6162
6163 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306164 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006165
6166 valid = csr_roam_is_channel_valid(pMac, channel);
6167
6168 sme_release_global_lock(&pMac->sme);
6169 }
6170
6171 return valid;
6172}
6173
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306174/*
6175 * sme_set_freq_band() -
6176 * Used to set frequency band.
6177 *
6178 * hHal
6179 * sessionId - Session Identifier
6180 * band value to be configured
6181 * Return QDF_STATUS
6182 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306183QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306185 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6187
6188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306189 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190 status = csr_set_band(hHal, sessionId, eBand);
6191 sme_release_global_lock(&pMac->sme);
6192 }
6193 return status;
6194}
6195
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306196/*
6197 * sme_get_freq_band() -
6198 * Used to get the current band settings.
6199 *
6200 * hHal
6201 * pBand pointer to hold band value
6202 * Return QDF_STATUS
6203 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306204QDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306206 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6208
6209 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306210 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006211 *pBand = csr_get_current_band(hHal);
6212 sme_release_global_lock(&pMac->sme);
6213 }
6214 return status;
6215}
6216
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306217/*
6218 * sme_set_max_tx_power_per_band() -
6219 * Set the Maximum Transmit Power specific to band dynamically.
6220 * Note: this setting will not persist over reboots.
6221 *
6222 * band
6223 * power to set in dB
6224 * Return QDF_STATUS
6225 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306226QDF_STATUS sme_set_max_tx_power_per_band(eCsrBand band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006228 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6230
6231 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306232 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306234 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6236 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306237 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006238 }
6239
6240 pMaxTxPowerPerBandParams->power = dB;
6241 pMaxTxPowerPerBandParams->bandInfo = band;
6242
6243 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6244 msg.reserved = 0;
6245 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306246 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6247 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006248 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006249 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306250 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6252 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306253 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255 }
6256
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306257 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006258}
6259
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306260/*
6261 * sme_set_max_tx_power() -
6262 * Set the Maximum Transmit Power dynamically. Note: this setting will
6263 * not persist over reboots.
6264 *
6265 * hHal
6266 * pBssid BSSID to set the power cap for
6267 * pBssid pSelfMacAddress self MAC Address
6268 * pBssid power to set in dB
6269 * Return QDF_STATUS
6270 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306271QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6272 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006274 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 tpMaxTxPowerParams pMaxTxParams = NULL;
6276
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306277 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306279 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006280 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306281 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 "%s: Not able to allocate memory for pMaxTxParams",
6283 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306284 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285 }
6286
Anurag Chouhanc5548422016-02-24 18:33:27 +05306287 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6288 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289 pMaxTxParams->power = dB;
6290
6291 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6292 msg.reserved = 0;
6293 msg.bodyptr = pMaxTxParams;
6294
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006295 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006296 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006298 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6299 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306300 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306301 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302 }
6303
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306304 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305}
6306
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306307/*
6308 * sme_set_custom_mac_addr() -
6309 * Set the customer Mac Address.
6310 *
6311 * customMacAddr customer MAC Address
6312 * Return QDF_STATUS
6313 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306314QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006316 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006317 tSirMacAddr *pBaseMacAddr;
6318
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306319 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006322 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306323 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 }
6325
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306326 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327
6328 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6329 msg.reserved = 0;
6330 msg.bodyptr = pBaseMacAddr;
6331
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006332 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006333 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306334 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306335 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306336 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306337 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006338 }
6339
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306340 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341}
6342
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306343/*
6344 * sme_set_tx_power() -
6345 * Set Transmit Power dynamically.
6346 *
6347 * hHal
6348 * sessionId Target Session ID
6349 * BSSID
6350 * dev_mode dev_mode such as station, P2PGO, SAP
6351 * dBm power to set
6352 * Return QDF_STATUS
6353 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306354QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306355 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006356 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006358 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 tpMaxTxPowerParams pTxParams = NULL;
6360 int8_t power = (int8_t) dBm;
6361
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306362 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006363 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6364
6365 /* make sure there is no overflow */
6366 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006368 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306369 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 }
6371
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306372 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006373 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306374 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006375 "%s: Not able to allocate memory for pTxParams",
6376 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306377 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006378 }
6379
Anurag Chouhanc5548422016-02-24 18:33:27 +05306380 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 pTxParams->power = power; /* unit is dBm */
6382 pTxParams->dev_mode = dev_mode;
6383 msg.type = WMA_SET_TX_POWER_REQ;
6384 msg.reserved = 0;
6385 msg.bodyptr = pTxParams;
6386
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006387 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006388 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306389 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6391 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306392 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 }
6395
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306396 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397}
6398
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306399QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6400 uint8_t param_val)
6401{
6402 QDF_STATUS status;
6403 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6404
6405 pMac->roam.configParam.is_fils_enabled = !param_val;
6406
6407 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6408 status = wma_cli_set_command((int)session_id,
6409 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6410 !param_val, VDEV_CMD);
6411 if (status)
6412 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6413 "%s: Failed to set enable bcast probe setting",
6414 __func__);
6415
6416 return status;
6417}
6418
6419QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306420 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006421{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306422 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306423 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 uint16_t len;
6425
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306426 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306427 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306428 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306429 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6430 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006431
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306432 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006433 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306434 sme_release_global_lock(&mac_ctx->sme);
6435 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006436 }
6437
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306438 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6439 mac_ctx->ignore_assoc_disallowed = param_val;
6440
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306441 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306442 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006443
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306444 len = sizeof(*msg);
6445 msg = qdf_mem_malloc(len);
6446 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306447 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306449 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6450 msg->length = len;
6451 msg->session_id = session_id;
6452 msg->param_type = param_type;
6453 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006454 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006455 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306456 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006457 }
6458 return status;
6459}
6460
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306461/*
6462 * sme_set_tm_level() -
6463 * Set Thermal Mitigation Level to RIVA
6464 *
6465 * hHal - The handle returned by mac_open.
6466 * newTMLevel - new Thermal Mitigation Level
6467 * tmMode - Thermal Mitigation handle mode, default 0
6468 * Return QDF_STATUS
6469 */
6470QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6471 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006472{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306473 QDF_STATUS status = QDF_STATUS_SUCCESS;
6474 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006475 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006476 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 tAniSetTmLevelReq *setTmLevelReq = NULL;
6478
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306479 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6481 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306482 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 setTmLevelReq =
6484 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306485 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306487 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006488 "%s: Not able to allocate memory for sme_set_tm_level",
6489 __func__);
6490 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306491 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006492 }
6493
6494 setTmLevelReq->tmMode = tmMode;
6495 setTmLevelReq->newTmLevel = newTMLevel;
6496
6497 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006498 message.bodyptr = setTmLevelReq;
6499 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306500 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006501 NO_SESSION, message.type));
6502 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6503 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306504 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306505 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006506 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306507 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306508 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006509 }
6510 sme_release_global_lock(&pMac->sme);
6511 }
6512 return status;
6513}
6514
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306515/*
6516 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6517 * Host and FW.
6518 *
6519 * hHal - HAL handle for device
6520 * Return NONE
6521 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006522void sme_feature_caps_exchange(tHalHandle hHal)
6523{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306524 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306525 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6526 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527}
6528
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306529/*
6530 * sme_disable_feature_capablity() - SME interface to disable Active mode
6531 * offload capablity in Host.
6532 *
6533 * hHal - HAL handle for device
6534 * Return NONE
6535 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006536void sme_disable_feature_capablity(uint8_t feature_index)
6537{
6538}
6539
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306540/*
6541 * sme_reset_power_values_for5_g
6542 * Reset the power values for 5G band with default power values.
6543 *
6544 * hHal - HAL handle for device
6545 * Return NONE
6546 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547void sme_reset_power_values_for5_g(tHalHandle hHal)
6548{
6549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306550
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306551 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6553 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306554 /* Store the channel+power info in the global place: Cfg */
6555 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556}
6557
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306558/*
6559 * sme_update_roam_prefer5_g_hz() -
6560 * Enable/disable Roam prefer 5G runtime option
6561 * This function is called through dynamic setConfig callback function
6562 * to configure the Roam prefer 5G runtime option
6563 *
6564 * hHal - HAL handle for device
6565 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6566 * Return Success or failure
6567 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006568
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306569QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6570 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571{
6572 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306573 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006574
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306575 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6577 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306578 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 "%s: gRoamPrefer5GHz is changed from %d to %d",
6581 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6582 nRoamPrefer5GHz);
6583 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6584 sme_release_global_lock(&pMac->sme);
6585 }
6586
6587 return status;
6588}
6589
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306590/*
6591 * sme_set_roam_intra_band() -
6592 * enable/disable Intra band roaming
6593 * This function is called through dynamic setConfig callback function
6594 * to configure the intra band roaming
6595 * hHal - HAL handle for device
6596 * nRoamIntraBand Enable/Disable Intra band roaming
6597 * Return Success or failure
6598 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306599QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006600{
6601 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306602 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306604 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6606 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306607 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306608 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006609 "%s: gRoamIntraBand is changed from %d to %d",
6610 __func__, pMac->roam.configParam.nRoamIntraBand,
6611 nRoamIntraBand);
6612 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6613 sme_release_global_lock(&pMac->sme);
6614 }
6615
6616 return status;
6617}
6618
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306619/*
6620 * sme_update_roam_scan_n_probes() -
6621 * Function to update roam scan N probes
6622 * This function is called through dynamic setConfig callback function
6623 * to update roam scan N probes
6624 * hHal - HAL handle for device
6625 * sessionId - Session Identifier
6626 * nProbes number of probe requests to be sent out
6627 * Return Success or failure
6628 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306629QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630 const uint8_t nProbes)
6631{
6632 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306633 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306635 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006636 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6637 NO_SESSION, 0));
6638 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306639 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306640 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641 "%s: gRoamScanNProbes is changed from %d to %d",
6642 __func__, pMac->roam.configParam.nProbes, nProbes);
6643 pMac->roam.configParam.nProbes = nProbes;
6644 sme_release_global_lock(&pMac->sme);
6645 }
6646 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6647 csr_roam_offload_scan(pMac, sessionId,
6648 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6649 REASON_NPROBES_CHANGED);
6650 }
6651 return status;
6652}
6653
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306654/*
6655 * sme_update_roam_scan_home_away_time() -
6656 * Function to update roam scan Home away time
6657 * This function is called through dynamic setConfig callback function
6658 * to update roam scan home away time
6659 *
6660 * hHal - HAL handle for device
6661 * sessionId - Session Identifier
6662 * nRoamScanAwayTime Scan home away time
6663 * bSendOffloadCmd If true then send offload command to firmware
6664 * If false then command is not sent to firmware
6665 * Return Success or failure
6666 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306667QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306669 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006670 const bool bSendOffloadCmd)
6671{
6672 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306673 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306675 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6677 NO_SESSION, 0));
6678 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306679 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306680 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006681 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6682 __func__,
6683 pMac->roam.configParam.nRoamScanHomeAwayTime,
6684 nRoamScanHomeAwayTime);
6685 pMac->roam.configParam.nRoamScanHomeAwayTime =
6686 nRoamScanHomeAwayTime;
6687 sme_release_global_lock(&pMac->sme);
6688 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306689 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6690 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 csr_roam_offload_scan(pMac, sessionId,
6692 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6693 REASON_HOME_AWAY_TIME_CHANGED);
6694 }
6695 return status;
6696}
6697
Abhishek Singh518323d2015-10-19 17:42:01 +05306698/**
6699 * sme_ext_change_channel()- function to post send ECSA
6700 * action frame to csr.
6701 * @hHal: Hal context
6702 * @channel: new channel to switch
6703 * @session_id: senssion it should be sent on.
6704 *
6705 * This function is called to post ECSA frame to csr.
6706 *
6707 * Return: success if msg is sent else return failure
6708 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306709QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306710 uint8_t session_id)
6711{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306712 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306713 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6714 uint8_t channel_state;
6715
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006716 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306717 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006718 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306719
6720 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006721 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306722 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306723 }
6724
6725 status = sme_acquire_global_lock(&mac_ctx->sme);
6726
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306727 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306728 /* update the channel list to the firmware */
6729 status = csr_send_ext_change_channel(mac_ctx,
6730 channel, session_id);
6731 sme_release_global_lock(&mac_ctx->sme);
6732 }
6733
6734 return status;
6735}
6736
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306737/*
6738 * sme_get_roam_intra_band() -
6739 * get Intra band roaming
6740 *
6741 * hHal - HAL handle for device
6742 * Return Success or failure
6743 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006744bool sme_get_roam_intra_band(tHalHandle hHal)
6745{
6746 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306747
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306748 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006749 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6750 return pMac->roam.configParam.nRoamIntraBand;
6751}
6752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306753/*
6754 * sme_get_roam_scan_n_probes() -
6755 * get N Probes
6756 *
6757 * hHal - HAL handle for device
6758 * Return Success or failure
6759 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006760uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6761{
6762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006764 return pMac->roam.configParam.nProbes;
6765}
6766
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306767/*
6768 * sme_get_roam_scan_home_away_time() -
6769 * get Roam scan home away time
6770 *
6771 * hHal - HAL handle for device
6772 * Return Success or failure
6773 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6775{
6776 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6779}
6780
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306781/*
6782 * sme_update_roam_rssi_diff() -
6783 * Update RoamRssiDiff
6784 * This function is called through dynamic setConfig callback function
6785 * to configure RoamRssiDiff
6786 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6787 *
6788 * hHal - HAL handle for device
6789 * sessionId - Session Identifier
6790 * RoamRssiDiff - minimum rssi difference between potential
6791 * candidate and current AP.
6792 * Return Success or failure
6793 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306795QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006796 uint8_t RoamRssiDiff)
6797{
6798 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306799 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006801 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6803 FL("Invalid sme session id: %d"), sessionId);
6804 return QDF_STATUS_E_INVAL;
6805 }
6806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306808 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306809 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6811 RoamRssiDiff,
6812 pMac->roam.configParam.RoamRssiDiff,
6813 mac_trace_get_neighbour_roam_state(pMac->roam.
6814 neighborRoamInfo
6815 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306816 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006817 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6818 sme_release_global_lock(&pMac->sme);
6819 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006820
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306821 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006822 csr_roam_offload_scan(pMac, sessionId,
6823 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6824 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006825 return status;
6826}
6827
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306828#ifdef WLAN_FEATURE_FILS_SK
6829QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6830 tCsrRoamProfile *src_profile)
6831{
6832 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6833 QDF_STATUS status = QDF_STATUS_SUCCESS;
6834 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6835 &mac->roam.neighborRoamInfo[session_id];
6836
6837 if (session_id >= CSR_ROAM_SESSION_MAX) {
6838 sme_err("Invalid sme session id: %d", session_id);
6839 return QDF_STATUS_E_INVAL;
6840 }
6841
6842 if (!src_profile) {
6843 sme_err("src roam profile NULL");
6844 return QDF_STATUS_E_INVAL;
6845 }
6846
6847 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6848 (neighbor_roam_info->neighborRoamState !=
6849 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6850 sme_info("Fast roam is disabled or not connected(%d)",
6851 neighbor_roam_info->neighborRoamState);
6852 return QDF_STATUS_E_PERM;
6853 }
6854
6855 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306856 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306857 sme_debug("Updating fils config to fw");
6858 csr_roam_offload_scan(mac, session_id,
6859 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6860 REASON_FILS_PARAMS_CHANGED);
6861 } else {
6862 sme_info("LFR3 not enabled");
6863 return QDF_STATUS_E_INVAL;
6864 }
6865
6866 return status;
6867}
6868
6869void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6870 tCsrRoamProfile *profile, uint32_t if_addr)
6871{
6872 int i;
6873 struct scheduler_msg msg;
6874 QDF_STATUS status;
6875 struct hlp_params *params;
6876 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6877 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6878 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6879 &mac->roam.neighborRoamInfo[session_id];
6880
6881 if (!session) {
6882 sme_err("session NULL");
6883 return;
6884 }
6885
6886 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6887 (neighbor_roam_info->neighborRoamState !=
6888 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6889 sme_debug("Fast roam is disabled or not connected(%d)",
6890 neighbor_roam_info->neighborRoamState);
6891 return;
6892 }
6893
6894 params = qdf_mem_malloc(sizeof(*params));
6895 if (!params) {
6896 sme_err("Mem alloc for HLP IE fails");
6897 return;
6898 }
6899 if ((profile->hlp_ie_len +
6900 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6901 sme_err("HLP IE len exceeds %d",
6902 profile->hlp_ie_len);
6903 qdf_mem_free(params);
6904 return;
6905 }
6906
6907 params->vdev_id = session_id;
6908 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6909
6910 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6911 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6912
6913 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6914 profile->hlp_ie, profile->hlp_ie_len);
6915
6916 msg.type = SIR_HAL_HLP_IE_INFO;
6917 msg.reserved = 0;
6918 msg.bodyptr = params;
6919 status = sme_acquire_global_lock(&mac->sme);
6920 if (status != QDF_STATUS_SUCCESS) {
6921 sme_err("sme lock acquire fails");
6922 qdf_mem_free(params);
6923 return;
6924 }
6925
6926 if (!QDF_IS_STATUS_SUCCESS
6927 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6928 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6929 sme_release_global_lock(&mac->sme);
6930 qdf_mem_free(params);
6931 return;
6932 }
6933
6934 sme_release_global_lock(&mac->sme);
6935}
6936
Jeff Johnson172237b2017-11-07 15:32:59 -08006937void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306938{
6939 struct fils_join_rsp_params *roam_fils_params;
6940
6941 if (!roam_info) {
6942 sme_err("FILS Roam Info NULL");
6943 return;
6944 }
6945
6946 roam_fils_params = roam_info->fils_join_rsp;
6947 if (!roam_fils_params) {
6948 sme_err("FILS Roam Param NULL");
6949 return;
6950 }
6951
6952 if (roam_fils_params->fils_pmk)
6953 qdf_mem_free(roam_fils_params->fils_pmk);
6954
6955 qdf_mem_free(roam_fils_params);
6956
6957 roam_info->fils_join_rsp = NULL;
6958}
6959
6960#else
6961inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6962 tCsrRoamProfile *profile, uint32_t if_addr)
6963{}
6964#endif
6965
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306966/*
6967 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6968 * support at runtime
6969 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6970 * isFastTransitionEnabled.
6971 * This is a synchronous call
6972 *
6973 * hHal - The handle returned by mac_open.
6974 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
6975 * successfully.
6976 * Other status means SME is failed to update isFastTransitionEnabled.
6977 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306978QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006979 bool isFastTransitionEnabled)
6980{
6981 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306982 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006983
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306984 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006985 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
6986 0));
6987 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306988 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306989 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006990 "%s: FastTransitionEnabled is changed from %d to %d",
6991 __func__,
6992 pMac->roam.configParam.isFastTransitionEnabled,
6993 isFastTransitionEnabled);
6994 pMac->roam.configParam.isFastTransitionEnabled =
6995 isFastTransitionEnabled;
6996 sme_release_global_lock(&pMac->sme);
6997 }
6998
6999 return status;
7000}
7001
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307002/*
7003 * sme_update_wes_mode() -
7004 * Update WES Mode
7005 * This function is called through dynamic setConfig callback function
7006 * to configure isWESModeEnabled
7007 *
7008 * hHal - HAL handle for device
7009 * isWESModeEnabled - WES mode
7010 * sessionId - Session Identifier
7011 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7012 * Other status means SME is failed to update isWESModeEnabled.
7013 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307015QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007016 uint8_t sessionId)
7017{
7018 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307019 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007020
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007021 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7022 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7023 FL("Invalid sme session id: %d"), sessionId);
7024 return QDF_STATUS_E_INVAL;
7025 }
7026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007027 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307028 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307029 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007030 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7031 isWESModeEnabled,
7032 pMac->roam.configParam.isWESModeEnabled,
7033 mac_trace_get_neighbour_roam_state(pMac->roam.
7034 neighborRoamInfo
7035 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307036 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007037 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7038 sme_release_global_lock(&pMac->sme);
7039 }
7040
7041 return status;
7042}
7043
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307044/*
7045 * sme_set_roam_scan_control() -
7046 * Set roam scan control
7047 * This function is called to set roam scan control
7048 * if roam scan control is set to 0, roaming scan cache is cleared
7049 * any value other than 0 is treated as invalid value
7050 * hHal - HAL handle for device
7051 * sessionId - Session Identifier
7052 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7053 * Other status means SME failure to update
7054 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307055QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056 bool roamScanControl)
7057{
7058 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307059 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307061 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007063
7064 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7065 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7066 FL("Invalid sme session id: %d"), sessionId);
7067 return QDF_STATUS_E_INVAL;
7068 }
7069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307071 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307072 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007073 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7074 roamScanControl,
7075 pMac->roam.configParam.nRoamScanControl,
7076 mac_trace_get_neighbour_roam_state(pMac->roam.
7077 neighborRoamInfo
7078 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307079 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7081 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307084 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7085 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7087 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307088 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7089 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007090 }
7091 }
7092 sme_release_global_lock(&pMac->sme);
7093 }
7094 return status;
7095}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307097/*
7098 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7099 * support at runtime
7100 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7101 * isFastRoamIniFeatureEnabled.
7102 * This is a synchronous call
7103 *
7104 * hHal - The handle returned by mac_open.
7105 * sessionId - Session Identifier
7106 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7107 * successfully.
7108 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7109 */
7110QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7111 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7112{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7114
7115 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7116 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7119 __func__,
7120 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7121 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307122 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 }
7124
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007126 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7127 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7128 isFastRoamIniFeatureEnabled);
7129 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7130 isFastRoamIniFeatureEnabled;
7131 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307132 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007133
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307134 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007135}
7136
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307137/**
7138 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7139 * @hal - The handle returned by macOpen.
7140 * @session_id - Session Identifier
7141 * @is_fast_roam_enabled - flag to enable/disable roaming
7142 *
7143 * When Supplicant issues enabled/disable fast roaming on the basis
7144 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7145 *
7146 * Return: QDF_STATUS
7147 */
7148
7149QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7150 const bool is_fast_roam_enabled)
7151{
7152 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307153 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307154 QDF_STATUS status;
7155
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007156 /*
7157 * supplicant_disabled_roaming flag is set to true in
7158 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7159 * request with BSSID. This flag is reset when supplicant sends
7160 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007161 *
7162 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007163 * if roaming is disabled using driver command or INI and
7164 * supplicant_disabled_roaming flag remains set. So make sure to set
7165 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7166 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007167 */
7168 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007169 session->pCurRoamProfile->supplicant_disabled_roaming =
7170 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007171
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307172 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007173 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307174 if (!is_fast_roam_enabled)
7175 return QDF_STATUS_SUCCESS;
7176 return QDF_STATUS_E_FAILURE;
7177 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307178
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307179 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7180 session_id, is_fast_roam_enabled);
7181 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007182 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307183 return QDF_STATUS_E_FAILURE;
7184 }
7185
7186 return QDF_STATUS_SUCCESS;
7187}
7188
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307189/*
7190 * sme_update_is_mawc_ini_feature_enabled() -
7191 * Enable/disable LFR MAWC support at runtime
7192 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7193 * isMAWCIniFeatureEnabled.
7194 * This is a synchronous call
7195 *
7196 * hHal - The handle returned by mac_open.
7197 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7198 * Other status means SME is failed to update MAWCEnabled.
7199 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307200QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 const bool MAWCEnabled)
7202{
7203 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307204 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007205
7206 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307207 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307208 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007209 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007210 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7211 MAWCEnabled);
7212 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7213 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007214 sme_release_global_lock(&pMac->sme);
7215 }
7216
7217 return status;
7218
7219}
7220
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007221/**
7222 * sme_stop_roaming() - Stop roaming for a given sessionId
7223 * This is a synchronous call
7224 *
7225 * @hHal - The handle returned by mac_open
7226 * @sessionId - Session Identifier
7227 *
7228 * Return QDF_STATUS_SUCCESS on success
7229 * Other status on failure
7230 */
7231QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007232{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007233 struct scheduler_msg wma_msg = {0};
7234 tSirRetStatus status;
7235 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007236 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7237 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007238 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007239
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007240 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007241 sme_err("incorrect session/vdev ID");
7242 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007243 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007244
7245 session = CSR_GET_SESSION(mac_ctx, session_id);
7246 if (session->pCurRoamProfile &&
7247 !session->pCurRoamProfile->roaming_allowed_on_iface) {
7248 sme_debug("Roaming was never started on session %d",
7249 session_id);
7250 return QDF_STATUS_SUCCESS;
7251 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007252 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007253 req = qdf_mem_malloc(sizeof(*req));
7254 if (!req) {
7255 sme_err("failed to allocated memory");
7256 return QDF_STATUS_E_NOMEM;
7257 }
7258
7259 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307260 if (reason == eCsrForcedDisassoc)
7261 req->reason = REASON_ROAM_STOP_ALL;
7262 else
7263 req->reason = REASON_ROAM_SYNCH_FAILED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007264 req->sessionId = session_id;
7265 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007266 req->middle_of_roaming = 1;
7267 else
7268 csr_roam_reset_roam_params(mac_ctx);
7269
7270 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7271 wma_msg.bodyptr = req;
7272
7273 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7274 if (eSIR_SUCCESS != status) {
7275 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007276 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007277 qdf_mem_free(req);
7278 return QDF_STATUS_E_FAULT;
7279 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007280 roam_info->b_roam_scan_offload_started = false;
7281 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007282
7283 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007284}
7285
Abhishek Singhd5686472017-09-20 15:18:50 +05307286void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7287{
7288 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7289 QDF_STATUS status = QDF_STATUS_SUCCESS;
7290 struct csr_roam_session *session;
7291
7292 status = sme_acquire_global_lock(&mac_ctx->sme);
7293 if (QDF_IS_STATUS_SUCCESS(status)) {
7294 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7295 session = CSR_GET_SESSION(mac_ctx, session_id);
7296 if (session)
7297 session->discon_in_progress = true;
7298 }
7299 sme_release_global_lock(&mac_ctx->sme);
7300 }
7301}
7302
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307303/*
7304 * sme_start_roaming() - Start roaming for a given sessionId
7305 * This is a synchronous call
7306 *
7307 * hHal - The handle returned by mac_open
7308 * sessionId - Session Identifier
7309 * Return QDF_STATUS_SUCCESS on success
7310 * Other status on failure
7311 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307312QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007313{
7314 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307315 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316
7317 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307318 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7320 reason);
7321 sme_release_global_lock(&pMac->sme);
7322 }
7323
7324 return status;
7325}
7326
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307327/*
7328 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7329 * Concurrent session exists
7330 * This is a synchronuous call
7331 *
7332 * hHal - The handle returned by mac_open.
7333 * Return QDF_STATUS_SUCCESS
7334 * Other status means SME is failed
7335 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307336QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007337 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307338 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339{
7340
7341 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307342 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007343
7344 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307345 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007346 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7347 bFastRoamInConIniFeatureEnabled;
7348 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7349 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7350 0;
7351 }
7352 sme_release_global_lock(&pMac->sme);
7353 }
7354
7355 return status;
7356}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007357
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307358/*
7359 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7360 * Monitoring at runtime
7361 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7362 * fEnableFwRssiMonitoring.
7363 * This is a synchronous call
7364 *
7365 * hHal - The handle returned by mac_open.
7366 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7367 * config successfully.
7368 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7369 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307370QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 bool fEnableFwRssiMonitoring)
7372{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307373 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007374
7375 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307376 fEnableFwRssiMonitoring) ==
7377 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307378 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307379 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007380 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7381 }
7382
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307383 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007384}
7385
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307386/*
7387 * sme_set_roam_opportunistic_scan_threshold_diff() -
7388 * Update Opportunistic Scan threshold diff
7389 * This function is called through dynamic setConfig callback function
7390 * to configure nOpportunisticThresholdDiff
7391 *
7392 * hHal - HAL handle for device
7393 * sessionId - Session Identifier
7394 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7395 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7396 * successfully.
7397 * else SME is failed to update nOpportunisticThresholdDiff.
7398 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307399QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007400 uint8_t sessionId,
7401 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307402 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403{
7404 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307405 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007406
7407 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307408 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007409 status = csr_neighbor_roam_update_config(pMac, sessionId,
7410 nOpportunisticThresholdDiff,
7411 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307412 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007413 pMac->roam.configParam.neighborRoamConfig.
7414 nOpportunisticThresholdDiff =
7415 nOpportunisticThresholdDiff;
7416 }
7417 sme_release_global_lock(&pMac->sme);
7418 }
7419 return status;
7420}
7421
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307422/*
7423 * sme_get_roam_opportunistic_scan_threshold_diff()
7424 * gets Opportunistic Scan threshold diff
7425 * This is a synchronous call
7426 *
7427 * hHal - The handle returned by mac_open
7428 * Return uint8_t - nOpportunisticThresholdDiff
7429 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7431{
7432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007434 return pMac->roam.configParam.neighborRoamConfig.
7435 nOpportunisticThresholdDiff;
7436}
7437
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307438/*
7439 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7440 * This function is called through dynamic setConfig callback function
7441 * to configure nRoamRescanRssiDiff
7442 *
7443 * hHal - HAL handle for device
7444 * sessionId - Session Identifier
7445 * nRoamRescanRssiDiff - roam rescan rssi diff
7446 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7447 * successfully.
7448 * else SME is failed to update nRoamRescanRssiDiff.
7449 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307450QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007451 uint8_t sessionId,
7452 const uint8_t nRoamRescanRssiDiff)
7453{
7454 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307455 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456
7457 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307458 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007459 status = csr_neighbor_roam_update_config(pMac, sessionId,
7460 nRoamRescanRssiDiff,
7461 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307462 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007463 pMac->roam.configParam.neighborRoamConfig.
7464 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7465 }
7466 sme_release_global_lock(&pMac->sme);
7467 }
7468 return status;
7469}
7470
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307471/*
7472 * sme_get_roam_rescan_rssi_diff()
7473 * gets roam rescan rssi diff
7474 * This is a synchronous call
7475 *
7476 * hHal - The handle returned by mac_open
7477 * Return int8_t - nRoamRescanRssiDiff
7478 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007479uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7480{
7481 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007483 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7484}
7485
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307486/*
7487 * sme_set_roam_bmiss_first_bcnt() -
7488 * Update Roam count for first beacon miss
7489 * This function is called through dynamic setConfig callback function
7490 * to configure nRoamBmissFirstBcnt
7491 * hHal - HAL handle for device
7492 * sessionId - Session Identifier
7493 * nRoamBmissFirstBcnt - Roam first bmiss count
7494 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7495 * successfully.
7496 * else SME is failed to update nRoamBmissFirstBcnt
7497 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307498QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007499 uint8_t sessionId,
7500 const uint8_t nRoamBmissFirstBcnt)
7501{
7502 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307503 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007504
7505 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307506 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007507 status = csr_neighbor_roam_update_config(pMac, sessionId,
7508 nRoamBmissFirstBcnt,
7509 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307510 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007511 pMac->roam.configParam.neighborRoamConfig.
7512 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7513 }
7514 sme_release_global_lock(&pMac->sme);
7515 }
7516 return status;
7517}
7518
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307519/*
7520 * sme_get_roam_bmiss_first_bcnt() -
7521 * get neighbor roam beacon miss first count
7522 *
7523 * hHal - The handle returned by mac_open.
7524 * Return uint8_t - neighbor roam beacon miss first count
7525 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007526uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7527{
7528 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307529
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007530 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7531}
7532
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307533/*
7534 * sme_set_roam_bmiss_final_bcnt() -
7535 * Update Roam count for final beacon miss
7536 * This function is called through dynamic setConfig callback function
7537 * to configure nRoamBmissFinalBcnt
7538 * hHal - HAL handle for device
7539 * sessionId - Session Identifier
7540 * nRoamBmissFinalBcnt - Roam final bmiss count
7541 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7542 * successfully.
7543 * else SME is failed to update nRoamBmissFinalBcnt
7544 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307545QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007546 uint8_t sessionId,
7547 const uint8_t nRoamBmissFinalBcnt)
7548{
7549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307550 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551
7552 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307553 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007554 status = csr_neighbor_roam_update_config(pMac, sessionId,
7555 nRoamBmissFinalBcnt,
7556 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307557 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 pMac->roam.configParam.neighborRoamConfig.
7559 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7560 }
7561 sme_release_global_lock(&pMac->sme);
7562 }
7563 return status;
7564}
7565
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307566/*
7567 * sme_get_roam_bmiss_final_bcnt() -
7568 * gets Roam count for final beacon miss
7569 * This is a synchronous call
7570 *
7571 * hHal - The handle returned by mac_open
7572 * Return uint8_t - nRoamBmissFinalBcnt
7573 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7575{
7576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307577
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7579}
7580
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307581/*
7582 * sme_set_roam_beacon_rssi_weight() -
7583 * Update Roam beacon rssi weight
7584 * This function is called through dynamic setConfig callback function
7585 * to configure nRoamBeaconRssiWeight
7586 *
7587 * hHal - HAL handle for device
7588 * sessionId - Session Identifier
7589 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7590 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7591 * successfully.
7592 * else SME is failed to update nRoamBeaconRssiWeight
7593 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307594QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007595 uint8_t sessionId,
7596 const uint8_t nRoamBeaconRssiWeight)
7597{
7598 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307599 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007600
7601 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307602 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007603 status = csr_neighbor_roam_update_config(pMac, sessionId,
7604 nRoamBeaconRssiWeight,
7605 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307606 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007607 pMac->roam.configParam.neighborRoamConfig.
7608 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7609 }
7610 sme_release_global_lock(&pMac->sme);
7611 }
7612 return status;
7613}
7614
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307615/*
7616 * sme_get_roam_beacon_rssi_weight() -
7617 * gets Roam beacon rssi weight
7618 * This is a synchronous call
7619 *
7620 * hHal - The handle returned by mac_open
7621 * Return uint8_t - nRoamBeaconRssiWeight
7622 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007623uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7624{
7625 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007627 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7628}
7629
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307630/*
7631 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7632 * rssi threshold
7633 * This is a synchronous call
7634 *
7635 * hHal - The handle returned by mac_open.
7636 * sessionId - Session Identifier
7637 * Return QDF_STATUS_SUCCESS - SME update config successful.
7638 * Other status means SME is failed to update
7639 */
7640QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7641 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7642{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007643 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307644 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007645
7646 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307647 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007648 status = csr_neighbor_roam_update_config(pMac,
7649 sessionId, neighborLookupRssiThreshold,
7650 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307651 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 pMac->roam.configParam.neighborRoamConfig.
7653 nNeighborLookupRssiThreshold =
7654 neighborLookupRssiThreshold;
7655 }
7656 sme_release_global_lock(&pMac->sme);
7657 }
7658 return status;
7659}
7660
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307661/*
7662 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7663 * This is a synchronous call
7664 *
7665 * hal - The handle returned by macOpen.
7666 * session_id - Session Identifier
7667 * delay_before_vdev_stop - value to be set
7668 * Return QDF_STATUS_SUCCESS - SME update config successful.
7669 * Other status means SME is failed to update
7670 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307671QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007672 uint8_t session_id,
7673 uint8_t delay_before_vdev_stop)
7674{
7675 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307676 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007677
7678 if (session_id >= CSR_ROAM_SESSION_MAX) {
7679 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7680 FL("Invalid sme session id: %d"), session_id);
7681 return QDF_STATUS_E_INVAL;
7682 }
7683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307685 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7687 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007688 pMac->roam.configParam.neighborRoamConfig.
7689 delay_before_vdev_stop,
7690 delay_before_vdev_stop);
7691 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7692 delay_before_vdev_stop = delay_before_vdev_stop;
7693 pMac->roam.configParam.neighborRoamConfig.
7694 delay_before_vdev_stop = delay_before_vdev_stop;
7695 sme_release_global_lock(&pMac->sme);
7696 }
7697 return status;
7698}
7699
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307700/*
7701 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7702 * rssi threshold
7703 * This is a synchronous call
7704 *
7705 * hHal - The handle returned by mac_open.
7706 * Return QDF_STATUS_SUCCESS - SME update config successful.
7707 * Other status means SME is failed to update
7708 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7710{
7711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007713 return pMac->roam.configParam.neighborRoamConfig.
7714 nNeighborLookupRssiThreshold;
7715}
7716
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307717/*
7718 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7719 * refresh period
7720 * This is a synchronous call
7721 *
7722 * hHal - The handle returned by mac_open.
7723 * sessionId - Session Identifier
7724 * Return QDF_STATUS_SUCCESS - SME update config successful.
7725 * Other status means SME is failed to update
7726 */
7727QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7728 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7729{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007730 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307731 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307732 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007733 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7734
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007735 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7737 FL("Invalid sme session id: %d"), sessionId);
7738 return QDF_STATUS_E_INVAL;
7739 }
7740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007741 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307742 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 pNeighborRoamConfig =
7744 &pMac->roam.configParam.neighborRoamConfig;
7745 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007747 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7748 neighborScanResultsRefreshPeriod,
7749 pMac->roam.configParam.neighborRoamConfig.
7750 nNeighborResultsRefreshPeriod,
7751 mac_trace_get_neighbour_roam_state(pMac->roam.
7752 neighborRoamInfo
7753 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307754 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007755 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7756 neighborScanResultsRefreshPeriod;
7757 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7758 neighborScanResultsRefreshPeriod;
7759
7760 sme_release_global_lock(&pMac->sme);
7761 }
7762 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7763 csr_roam_offload_scan(pMac, sessionId,
7764 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307765 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007766 }
7767 return status;
7768}
7769
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307770/*
7771 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7772 * offload feaure
7773 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7774 * gRoamScanOffloadEnabled.
7775 * This is a synchronous call
7776 *
7777 * hHal - The handle returned by mac_open.
7778 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7779 * Other status means SME is failed to update.
7780 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307781QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007782 bool nRoamScanOffloadEnabled)
7783{
7784 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307785 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786
7787 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307788 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307789 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307790 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007791 pMac->roam.configParam.isRoamOffloadScanEnabled,
7792 nRoamScanOffloadEnabled);
7793 pMac->roam.configParam.isRoamOffloadScanEnabled =
7794 nRoamScanOffloadEnabled;
7795 sme_release_global_lock(&pMac->sme);
7796 }
7797
7798 return status;
7799}
7800
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307801/*
7802 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7803 * refresh period
7804 * This is a synchronous call
7805 *
7806 * \param hHal - The handle returned by mac_open.
7807 * \return uint16_t - Neighbor scan results refresh period value
7808 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007809uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7810{
7811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007813 return pMac->roam.configParam.neighborRoamConfig.
7814 nNeighborResultsRefreshPeriod;
7815}
7816
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307817/*
7818 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7819 * This is a synchronuous call
7820 *
7821 * hHal - The handle returned by mac_open.
7822 * Return QDF_STATUS_SUCCESS - SME update config successful.
7823 * Other status means SME is failed to update
7824 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007825uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7826{
7827 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007829 return pMac->roam.configParam.neighborRoamConfig.
7830 nEmptyScanRefreshPeriod;
7831}
7832
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307833/*
7834 * sme_update_empty_scan_refresh_period
7835 * Update nEmptyScanRefreshPeriod
7836 * This function is called through dynamic setConfig callback function
7837 * to configure nEmptyScanRefreshPeriod
7838 * Usage: adb shell iwpriv wlan0 setConfig
7839 * nEmptyScanRefreshPeriod=[0 .. 60]
7840 *
7841 * hHal - HAL handle for device
7842 * sessionId - Session Identifier
7843 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7844 * Return Success or failure
7845 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007846
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307847QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7848 sessionId, uint16_t
7849 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850{
7851 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307852 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307853 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7855
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007856 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7857 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7858 FL("Invalid sme session id: %d"), sessionId);
7859 return QDF_STATUS_E_INVAL;
7860 }
7861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007862 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307863 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 pNeighborRoamConfig =
7865 &pMac->roam.configParam.neighborRoamConfig;
7866 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307867 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007868 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7869 nEmptyScanRefreshPeriod,
7870 pMac->roam.configParam.neighborRoamConfig.
7871 nEmptyScanRefreshPeriod,
7872 mac_trace_get_neighbour_roam_state(pMac->roam.
7873 neighborRoamInfo
7874 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307875 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7877 nEmptyScanRefreshPeriod;
7878 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7879 nEmptyScanRefreshPeriod;
7880 sme_release_global_lock(&pMac->sme);
7881 }
7882 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7883 csr_roam_offload_scan(pMac, sessionId,
7884 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7885 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7886 }
7887 return status;
7888}
7889
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307890/*
7891 * sme_set_neighbor_scan_min_chan_time() -
7892 * Update nNeighborScanMinChanTime
7893 * This function is called through dynamic setConfig callback function
7894 * to configure gNeighborScanChannelMinTime
7895 * Usage: adb shell iwpriv wlan0 setConfig
7896 * gNeighborScanChannelMinTime=[0 .. 60]
7897 *
7898 * hHal - HAL handle for device
7899 * nNeighborScanMinChanTime - Channel minimum dwell time
7900 * sessionId - Session Identifier
7901 * Return Success or failure
7902 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307903QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007904 const uint16_t
7905 nNeighborScanMinChanTime,
7906 uint8_t sessionId)
7907{
7908 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307909 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007911 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7912 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7913 FL("Invalid sme session id: %d"), sessionId);
7914 return QDF_STATUS_E_INVAL;
7915 }
7916
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007917 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307918 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307919 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007920 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7921 nNeighborScanMinChanTime,
7922 pMac->roam.configParam.neighborRoamConfig.
7923 nNeighborScanMinChanTime,
7924 mac_trace_get_neighbour_roam_state(pMac->roam.
7925 neighborRoamInfo
7926 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307927 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007928
7929 pMac->roam.configParam.neighborRoamConfig.
7930 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7931 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7932 minChannelScanTime = nNeighborScanMinChanTime;
7933 sme_release_global_lock(&pMac->sme);
7934 }
7935
7936 return status;
7937}
7938
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307939/*
7940 * sme_set_neighbor_scan_max_chan_time() -
7941 * Update nNeighborScanMaxChanTime
7942 * This function is called through dynamic setConfig callback function
7943 * to configure gNeighborScanChannelMaxTime
7944 * Usage: adb shell iwpriv wlan0 setConfig
7945 * gNeighborScanChannelMaxTime=[0 .. 60]
7946 *
7947 * hHal - HAL handle for device
7948 * sessionId - Session Identifier
7949 * nNeighborScanMinChanTime - Channel maximum dwell time
7950 * Return Success or failure
7951 */
7952QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7953 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 const uint16_t
7955 nNeighborScanMaxChanTime)
7956{
7957 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307958 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307959 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007960 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7961
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007962 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7963 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7964 FL("Invalid sme session id: %d"), sessionId);
7965 return QDF_STATUS_E_INVAL;
7966 }
7967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007968 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307969 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007970 pNeighborRoamConfig =
7971 &pMac->roam.configParam.neighborRoamConfig;
7972 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307973 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
7975 nNeighborScanMaxChanTime,
7976 pMac->roam.configParam.neighborRoamConfig.
7977 nNeighborScanMaxChanTime,
7978 mac_trace_get_neighbour_roam_state(pMac->roam.
7979 neighborRoamInfo
7980 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307981 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007982 pNeighborRoamConfig->nNeighborScanMaxChanTime =
7983 nNeighborScanMaxChanTime;
7984 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
7985 nNeighborScanMaxChanTime;
7986 sme_release_global_lock(&pMac->sme);
7987 }
7988 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7989 csr_roam_offload_scan(pMac, sessionId,
7990 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7991 REASON_SCAN_CH_TIME_CHANGED);
7992 }
7993
7994 return status;
7995}
7996
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307997/*
7998 * sme_get_neighbor_scan_min_chan_time() -
7999 * get neighbor scan min channel time
8000 *
8001 * hHal - The handle returned by mac_open.
8002 * sessionId - Session Identifier
8003 * Return uint16_t - channel min time value
8004 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008005uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8006{
8007 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008008
8009 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8011 FL("Invalid sme session id: %d"), sessionId);
8012 return 0;
8013 }
8014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008015 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8016 minChannelScanTime;
8017}
8018
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308019/*
8020 * sme_get_neighbor_roam_state() -
8021 * get neighbor roam state
8022 *
8023 * hHal - The handle returned by mac_open.
8024 * sessionId - Session Identifier
8025 * Return uint32_t - neighbor roam state
8026 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8028{
8029 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008030
8031 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8033 FL("Invalid sme session id: %d"), sessionId);
8034 return 0;
8035 }
8036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8038}
8039
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308040/*
8041 * sme_get_current_roam_state() -
8042 * get current roam state
8043 *
8044 * hHal - The handle returned by mac_open.
8045 * sessionId - Session Identifier
8046 * Return uint32_t - current roam state
8047 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008048uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8049{
8050 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052 return pMac->roam.curState[sessionId];
8053}
8054
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308055/*
8056 * sme_get_current_roam_sub_state() -
8057 * \brief get neighbor roam sub state
8058 *
8059 * hHal - The handle returned by mac_open.
8060 * sessionId - Session Identifier
8061 * Return uint32_t - current roam sub state
8062 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8064{
8065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008067 return pMac->roam.curSubState[sessionId];
8068}
8069
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308070/*
8071 * sme_get_lim_sme_state() -
8072 * get Lim Sme state
8073 *
8074 * hHal - The handle returned by mac_open.
8075 * Return uint32_t - Lim Sme state
8076 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008077uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8078{
8079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008081 return pMac->lim.gLimSmeState;
8082}
8083
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308084/*
8085 * sme_get_lim_mlm_state() -
8086 * get Lim Mlm state
8087 *
8088 * hHal - The handle returned by mac_open.
8089 * Return uint32_t - Lim Mlm state
8090 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8092{
8093 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308094
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008095 return pMac->lim.gLimMlmState;
8096}
8097
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308098/*
8099 * sme_is_lim_session_valid() -
8100 * is Lim session valid
8101 *
8102 * hHal - The handle returned by mac_open.
8103 * sessionId - Session Identifier
8104 * Return bool - true or false
8105 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8107{
8108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308109
8110 if (sessionId > pMac->lim.maxBssId)
8111 return false;
8112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008113 return pMac->lim.gpSession[sessionId].valid;
8114}
8115
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308116/*
8117 * sme_get_lim_sme_session_state() -
8118 * get Lim Sme session state
8119 *
8120 * hHal - The handle returned by mac_open.
8121 * sessionId - Session Identifier
8122 * Return uint32_t - Lim Sme session state
8123 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008124uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8125{
8126 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008128 return pMac->lim.gpSession[sessionId].limSmeState;
8129}
8130
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308131/*
8132 * sme_get_lim_mlm_session_state() -
8133 * \brief get Lim Mlm session state
8134 *
8135 * hHal - The handle returned by mac_open.
8136 * sessionId - Session Identifier
8137 * Return uint32_t - Lim Mlm session state
8138 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8140{
8141 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008143 return pMac->lim.gpSession[sessionId].limMlmState;
8144}
8145
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308146/*
8147 * sme_get_neighbor_scan_max_chan_time() -
8148 * get neighbor scan max channel time
8149 *
8150 * hHal - The handle returned by mac_open.
8151 * sessionId - Session Identifier
8152 * Return uint16_t - channel max time value
8153 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8155{
8156 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008157
8158 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8159 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8160 FL("Invalid sme session id: %d"), sessionId);
8161 return 0;
8162 }
8163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008164 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8165 maxChannelScanTime;
8166}
8167
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308168/*
8169 * sme_set_neighbor_scan_period() -
8170 * Update nNeighborScanPeriod
8171 * This function is called through dynamic setConfig callback function
8172 * to configure nNeighborScanPeriod
8173 * Usage: adb shell iwpriv wlan0 setConfig
8174 * nNeighborScanPeriod=[0 .. 1000]
8175 *
8176 * hHal - HAL handle for device
8177 * sessionId - Session Identifier
8178 * nNeighborScanPeriod - neighbor scan period
8179 * Return Success or failure
8180 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308181QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 const uint16_t nNeighborScanPeriod)
8183{
8184 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308185 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308186 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008187 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8188
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008189 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8190 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8191 FL("Invalid sme session id: %d"), sessionId);
8192 return QDF_STATUS_E_INVAL;
8193 }
8194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008195 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308196 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008197 pNeighborRoamConfig =
8198 &pMac->roam.configParam.neighborRoamConfig;
8199 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308200 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308201 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008202 nNeighborScanPeriod,
8203 pMac->roam.configParam.neighborRoamConfig.
8204 nNeighborScanTimerPeriod,
8205 mac_trace_get_neighbour_roam_state(pMac->roam.
8206 neighborRoamInfo
8207 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308208 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008209 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8210 nNeighborScanPeriod;
8211 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8212 nNeighborScanPeriod;
8213 sme_release_global_lock(&pMac->sme);
8214 }
8215 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8216 csr_roam_offload_scan(pMac, sessionId,
8217 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8218 REASON_SCAN_HOME_TIME_CHANGED);
8219 }
8220
8221 return status;
8222}
8223
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308224/*
8225 * sme_get_neighbor_scan_period() -
8226 * get neighbor scan period
8227 *
8228 * hHal - The handle returned by mac_open.
8229 * sessionId - Session Identifier
8230 * Return uint16_t - neighbor scan period
8231 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8233{
8234 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008235
8236 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8237 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8238 FL("Invalid sme session id: %d"), sessionId);
8239 return 0;
8240 }
8241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008242 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8243 neighborScanPeriod;
8244}
8245
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308246/**
8247 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8248 * This function is called through dynamic setConfig callback function
8249 * to configure neighbor_scan_min_period
8250 *
8251 * @hal - HAL handle for device
8252 * @session_id - Session Identifier
8253 * @neighbor_scan_min_period - neighbor scan min period
8254 *
8255 * Return - QDF_STATUS
8256 */
8257QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8258 uint8_t session_id,
8259 const uint16_t
8260 neighbor_scan_min_period)
8261{
8262 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8263 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308264 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308265 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008266
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308267 if (session_id >= CSR_ROAM_SESSION_MAX) {
8268 sme_err("Invalid sme session id: %d", session_id);
8269 return QDF_STATUS_E_INVAL;
8270 }
8271
8272 status = sme_acquire_global_lock(&pmac->sme);
8273 if (QDF_IS_STATUS_SUCCESS(status)) {
8274 p_neighbor_roam_config =
8275 &pmac->roam.configParam.neighborRoamConfig;
8276 p_neighbor_roam_info = &pmac->
8277 roam.neighborRoamInfo[session_id];
8278 sme_debug("LFR:set neighbor scan min period, old:%d, "
8279 "new: %d, state: %s",
8280 pmac->roam.configParam.neighborRoamConfig.
8281 neighbor_scan_min_timer_period,
8282 neighbor_scan_min_period,
8283 mac_trace_get_neighbour_roam_state(pmac->roam.
8284 neighborRoamInfo[session_id].
8285 neighborRoamState));
8286 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8287 neighbor_scan_min_period;
8288 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8289 neighbor_scan_min_period;
8290 sme_release_global_lock(&pmac->sme);
8291 }
8292
8293 return status;
8294}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008295
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308296/*
8297 * sme_get_roam_rssi_diff() - get Roam rssi diff
8298 * This is a synchronous call
8299 *
8300 * hHal - The handle returned by mac_open.
8301 * Return uint16_t - Rssi diff value
8302 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8304{
8305 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008307 return pMac->roam.configParam.RoamRssiDiff;
8308}
8309
8310/**
8311 * sme_change_roam_scan_channel_list() - to change scan channel list
8312 * @hHal: pointer HAL handle returned by mac_open
8313 * @sessionId: sme session id
8314 * @pChannelList: Output channel list
8315 * @numChannels: Output number of channels
8316 *
8317 * This routine is called to Change roam scan channel list.
8318 * This is a synchronous call
8319 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308320 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008321 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308322QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008323 uint8_t *pChannelList,
8324 uint8_t numChannels)
8325{
8326 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308327 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008328 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008329 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8330 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8331 uint8_t i = 0, j = 0;
8332 tCsrChannelInfo *chan_info;
8333
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008334 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8335 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8336 FL("Invalid sme session id: %d"), sessionId);
8337 return QDF_STATUS_E_INVAL;
8338 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008340 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008341 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308342 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008343 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8344 csr_roam_offload_scan(pMac, sessionId,
8345 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8346 REASON_CHANNEL_LIST_CHANGED);
8347 return status;
8348 }
8349 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8350
8351 if (NULL != chan_info->ChannelList) {
8352 for (i = 0; i < chan_info->numOfChannels; i++) {
8353 if (j < sizeof(oldChannelList))
8354 j += snprintf(oldChannelList + j,
8355 sizeof(oldChannelList) -
8356 j, "%d",
8357 chan_info->ChannelList[i]);
8358 else
8359 break;
8360 }
8361 }
8362 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8363 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8364 numChannels);
8365 sme_set_roam_scan_control(hHal, sessionId, 1);
8366 if (NULL != chan_info->ChannelList) {
8367 j = 0;
8368 for (i = 0; i < chan_info->numOfChannels; i++) {
8369 if (j < sizeof(newChannelList))
8370 j += snprintf(newChannelList + j,
8371 sizeof(newChannelList) -
8372 j, " %d",
8373 chan_info->ChannelList[i]);
8374 else
8375 break;
8376 }
8377 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308378 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308379 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008380 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308381 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382 sme_release_global_lock(&pMac->sme);
8383
8384 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8385 csr_roam_offload_scan(pMac, sessionId,
8386 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8387 REASON_CHANNEL_LIST_CHANGED);
8388 return status;
8389}
8390
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008391/**
8392 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8393 * @hHal: HAL pointer
8394 * @pChannelList: Output channel list
8395 * @pNumChannels: Output number of channels
8396 * @sessionId: Session Identifier
8397 *
8398 * To get roam scan channel list This is a synchronous call
8399 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308400 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308402QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008403 uint8_t *pChannelList, uint8_t *pNumChannels,
8404 uint8_t sessionId)
8405{
8406 int i = 0;
8407 uint8_t *pOutPtr = pChannelList;
8408 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008409 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308410 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008411
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008412 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8413 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8414 FL("Invalid sme session id: %d"), sessionId);
8415 return QDF_STATUS_E_INVAL;
8416 }
8417
8418 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008419 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308420 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421 return status;
8422 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308423 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424 FL("Roam Scan channel list is NOT yet initialized"));
8425 *pNumChannels = 0;
8426 sme_release_global_lock(&pMac->sme);
8427 return status;
8428 }
8429
8430 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308431 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008432 pOutPtr[i] =
8433 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008435 pOutPtr[i] = '\0';
8436 sme_release_global_lock(&pMac->sme);
8437 return status;
8438}
8439
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308440/*
8441 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8442 * This is a synchronuous call
8443 *
8444 * hHal - The handle returned by mac_open.
8445 * Return true (1) - if the ESE feature is enabled
8446 * false (0) - if feature is disabled (compile or runtime)
8447 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8449{
8450#ifdef FEATURE_WLAN_ESE
8451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008453 return csr_roam_is_ese_ini_feature_enabled(pMac);
8454#else
8455 return false;
8456#endif
8457}
8458
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308459/*
8460 * sme_get_wes_mode() - get WES Mode
8461 * This is a synchronous call
8462 *
8463 * hHal - The handle returned by mac_open
8464 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8465 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008466bool sme_get_wes_mode(tHalHandle hHal)
8467{
8468 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470 return pMac->roam.configParam.isWESModeEnabled;
8471}
8472
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308473/*
8474 * sme_get_roam_scan_control() - get scan control
8475 * This is a synchronous call
8476 *
8477 * hHal - The handle returned by mac_open.
8478 * Return bool - Enabled(1)/Disabled(0)
8479 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008480bool sme_get_roam_scan_control(tHalHandle hHal)
8481{
8482 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008484 return pMac->roam.configParam.nRoamScanControl;
8485}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008486
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308487/*
8488 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8489 * This is a synchronuous call
8490 * hHal - The handle returned by mac_open.
8491 * Return true (1) - if the feature is enabled
8492 * false (0) - if feature is disabled (compile or runtime)
8493 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8495{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008498 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008499}
8500
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308501/*
8502 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8503 * This is a synchronuous call
8504 *
8505 * hHal - The handle returned by mac_open.
8506 * Return true (1) - if the feature is enabled
8507 * false (0) - if feature is disabled (compile or runtime)
8508 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008509bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8510{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008511 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308512
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008513 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008514}
8515
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008516/**
8517 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8518 * @feature: enum value of requested feature.
8519 *
8520 * Retrun: 1 if supported; 0 otherwise
8521 */
8522bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008523{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008524 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525}
8526
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308527QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008528 void *plsContext,
8529 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8530 void *pContext))
8531{
8532
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308533 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008534 tpAniSirGlobal pMac;
8535 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308536 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008537
Jeff Johnsona5317a62017-01-26 08:51:25 -08008538 if (!hHal || !pCallbackfn || !lsReq) {
8539 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8540 FL("Invalid parameter"));
8541 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008542 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008543
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308544 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8545 if (!wma_handle) {
8546 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8547 "wma handle is NULL");
8548 return QDF_STATUS_E_FAILURE;
8549 }
8550
Jeff Johnsona5317a62017-01-26 08:51:25 -08008551 pMac = PMAC_STRUCT(hHal);
8552 req = qdf_mem_malloc(sizeof(*req));
8553 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008554 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008555 return QDF_STATUS_E_NOMEM;
8556 }
8557 *req = *lsReq;
8558
8559 status = sme_acquire_global_lock(&pMac->sme);
8560 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008561 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008562 qdf_mem_free(req);
8563 return QDF_STATUS_E_FAILURE;
8564 }
8565
8566 pMac->sme.pLinkSpeedCbContext = plsContext;
8567 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308568 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008569 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008571 return status;
8572}
8573
Will Huang558f8082017-05-31 16:22:24 +08008574QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8575 void *context,
8576 void (*callbackfn)(struct sir_peer_info_resp *param,
8577 void *pcontext))
8578{
8579
8580 QDF_STATUS status;
8581 QDF_STATUS qdf_status;
8582 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8583 struct scheduler_msg message;
8584
8585 status = sme_acquire_global_lock(&mac->sme);
8586 if (QDF_STATUS_SUCCESS == status) {
8587 if (NULL == callbackfn) {
8588 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8589 "%s: Indication Call back is NULL",
8590 __func__);
8591 sme_release_global_lock(&mac->sme);
8592 return QDF_STATUS_E_FAILURE;
8593 }
8594
8595 mac->sme.pget_peer_info_ind_cb = callbackfn;
8596 mac->sme.pget_peer_info_cb_context = context;
8597
8598 /* serialize the req through MC thread */
8599 message.bodyptr = qdf_mem_malloc(sizeof(req));
8600 if (NULL == message.bodyptr) {
8601 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8602 "%s: Memory allocation failed.", __func__);
8603 sme_release_global_lock(&mac->sme);
8604 return QDF_STATUS_E_NOMEM;
8605 }
8606 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8607 message.type = WMA_GET_PEER_INFO;
8608 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8609 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8610 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8611 "%s: Post get peer info msg fail", __func__);
8612 qdf_mem_free(message.bodyptr);
8613 status = QDF_STATUS_E_FAILURE;
8614 }
8615 sme_release_global_lock(&mac->sme);
8616 }
8617 return status;
8618}
8619
8620QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8621 struct sir_peer_info_ext_req *req,
8622 void *context,
8623 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8624 void *pcontext))
8625{
8626 QDF_STATUS status;
8627 QDF_STATUS qdf_status;
8628 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8629 struct scheduler_msg message;
8630
8631 status = sme_acquire_global_lock(&mac->sme);
8632 if (QDF_STATUS_SUCCESS == status) {
8633 if (NULL == callbackfn) {
8634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8635 "%s: Indication Call back is NULL",
8636 __func__);
8637 sme_release_global_lock(&mac->sme);
8638 return QDF_STATUS_E_FAILURE;
8639 }
8640
8641 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8642 mac->sme.pget_peer_info_ext_cb_context = context;
8643
8644 /* serialize the req through MC thread */
8645 message.bodyptr =
8646 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8647 if (NULL == message.bodyptr) {
8648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8649 "%s: Memory allocation failed.", __func__);
8650 sme_release_global_lock(&mac->sme);
8651 return QDF_STATUS_E_NOMEM;
8652 }
8653 qdf_mem_copy(message.bodyptr,
8654 req,
8655 sizeof(struct sir_peer_info_ext_req));
8656 message.type = WMA_GET_PEER_INFO_EXT;
8657 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8658 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8659 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8660 "%s: Post get rssi msg fail", __func__);
8661 qdf_mem_free(message.bodyptr);
8662 status = QDF_STATUS_E_FAILURE;
8663 }
8664 sme_release_global_lock(&mac->sme);
8665 }
8666 return status;
8667}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008668
8669/*
8670 * SME API to enable/disable WLAN driver initiated SSR
8671 */
8672void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8673{
8674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308675 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008676
8677 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308678 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008679 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008680 /* not serializing this messsage, as this is only going
8681 * to set a variable in WMA/WDI
8682 */
8683 WMA_SetEnableSSR(enableSSR);
8684 sme_release_global_lock(&pMac->sme);
8685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008686}
8687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8689ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8690{
8691 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8692}
8693
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308694/*
8695 * sme_set_curr_device_mode() - Sets the current operating device mode.
8696 *
8697 * hHal - The handle returned by mac_open.
8698 * currDeviceMode - Current operating device mode.
8699 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008700void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008701 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008702{
8703 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008705 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008706}
8707
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308708/*
8709 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8710 * This is a synchronous call
8711 *
8712 * hHal - The handle returned by mac_open
8713 * sessionId - Session Identifier
8714 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8715 * BSSID, channel etc.)
8716 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8717 * Other status means SME is failed to send the request.
8718 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008719
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308720QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008721 uint8_t sessionId,
8722 tCsrHandoffRequest *pHandoffInfo)
8723{
8724 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308725 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008726
8727 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308728 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308729 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008730 "%s: invoked", __func__);
8731 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8732 sme_release_global_lock(&pMac->sme);
8733 }
8734
8735 return status;
8736}
8737
8738#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308739/*
8740 * sme_ipa_offload_enable_disable() -
8741 * API to enable/disable IPA offload
8742 *
8743 * hal - The handle returned by macOpen.
8744 * session_id - Session Identifier
8745 * request - Pointer to the offload request.
8746 * Return QDF_STATUS
8747 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308748QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 struct sir_ipa_offload_enable_disable *request)
8750{
8751 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308752 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008753 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008754 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755
8756 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308757 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308758 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308761 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008762 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308763 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 }
8765
8766 request_buf->offload_type = request->offload_type;
8767 request_buf->vdev_id = request->vdev_id;
8768 request_buf->enable = request->enable;
8769
8770 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8771 msg.reserved = 0;
8772 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308773 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008774 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308775 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308776 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308777 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008778 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308779 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 }
8781
8782 sme_release_global_lock(&pMac->sme);
8783 }
8784
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308785 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008786}
8787#endif /* IPA_OFFLOAD */
8788
8789/*
8790 * SME API to check if there is any infra station or
8791 * P2P client is connected
8792 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308793QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008794{
8795 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308796
8797 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308798 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308799
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308800 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008801}
8802
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803/**
8804 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8805 * @hal: global hal handle
8806 * @addPeriodicTxPtrnParams: request message
8807 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308808 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008809 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308810QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008811sme_add_periodic_tx_ptrn(tHalHandle hal,
8812 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8813{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308814 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008815 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8816 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008817 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008819 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008820
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308821 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008822 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008823 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308824 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008825 }
8826
8827 *req_msg = *addPeriodicTxPtrnParams;
8828
8829 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308830 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008831 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008832 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308833 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008834 return status;
8835 }
8836
8837 /* Serialize the req through MC thread */
8838 msg.bodyptr = req_msg;
8839 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308840 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8841 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008842 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308843 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008844 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008845 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308846 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 }
8848 sme_release_global_lock(&mac->sme);
8849 return status;
8850}
8851
8852/**
8853 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8854 * @hal: global hal handle
8855 * @delPeriodicTxPtrnParams: request message
8856 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308857 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008858 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308859QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008860sme_del_periodic_tx_ptrn(tHalHandle hal,
8861 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8862{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308863 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8865 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008866 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008867
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008868 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008869
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308870 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008871 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008872 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308873 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 }
8875
8876 *req_msg = *delPeriodicTxPtrnParams;
8877
8878 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308879 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008880 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308882 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 return status;
8884 }
8885
8886 /* Serialize the req through MC thread */
8887 msg.bodyptr = req_msg;
8888 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308889 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8890 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008891 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308892 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008893 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308895 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008896 }
8897 sme_release_global_lock(&mac->sme);
8898 return status;
8899}
8900
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308901/*
8902 * sme_enable_rmc() - enables RMC
8903 * @hHal : Pointer to global HAL handle
8904 * @sessionId : Session ID
8905 *
8906 * Return: QDF_STATUS
8907 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008908QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8909{
8910 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008912 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008913 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8914
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008915 SME_ENTER();
8916
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008917 status = sme_acquire_global_lock(&pMac->sme);
8918 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008919 message.bodyptr = NULL;
8920 message.type = WMA_RMC_ENABLE_IND;
8921 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8922 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008923 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8924 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8925 "%s: failed to post message to WMA",
8926 __func__);
8927 status = QDF_STATUS_E_FAILURE;
8928 }
8929 sme_release_global_lock(&pMac->sme);
8930 }
8931 return status;
8932}
8933
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308934/*
8935 * sme_disable_rmc() - disables RMC
8936 * @hHal : Pointer to global HAL handle
8937 * @sessionId : Session ID
8938 *
8939 * Return: QDF_STATUS
8940 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008941QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
8942{
8943 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8944 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008945 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008946 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8947
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008948 SME_ENTER();
8949
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008950 status = sme_acquire_global_lock(&pMac->sme);
8951 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008952 message.bodyptr = NULL;
8953 message.type = WMA_RMC_DISABLE_IND;
8954 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8955 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008956 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8957 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8958 "%s: failed to post message to WMA",
8959 __func__);
8960 status = QDF_STATUS_E_FAILURE;
8961 }
8962 sme_release_global_lock(&pMac->sme);
8963 }
8964 return status;
8965}
8966
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308967/*
8968 * sme_send_rmc_action_period() - sends RMC action period param to target
8969 * @hHal : Pointer to global HAL handle
8970 * @sessionId : Session ID
8971 *
8972 * Return: QDF_STATUS
8973 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008974QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
8975{
8976 QDF_STATUS status = QDF_STATUS_SUCCESS;
8977 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008979 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008980
8981 status = sme_acquire_global_lock(&pMac->sme);
8982 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008983 message.bodyptr = NULL;
8984 message.type = WMA_RMC_ACTION_PERIOD_IND;
8985 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8986 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008987 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8989 "%s: failed to post message to WMA",
8990 __func__);
8991 status = QDF_STATUS_E_FAILURE;
8992 }
8993 sme_release_global_lock(&pMac->sme);
8994 }
8995
8996 return status;
8997}
8998
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308999/*
9000 * sme_request_ibss_peer_info() - request ibss peer info
9001 * @hHal : Pointer to global HAL handle
9002 * @pUserData : Pointer to user data
9003 * @peerInfoCbk : Peer info callback
9004 * @allPeerInfoReqd : All peer info required or not
9005 * @staIdx : sta index
9006 *
9007 * Return: QDF_STATUS
9008 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009009QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9010 pIbssPeerInfoCb peerInfoCbk,
9011 bool allPeerInfoReqd, uint8_t staIdx)
9012{
9013 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9014 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9015 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009016 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009017 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9018
9019 status = sme_acquire_global_lock(&pMac->sme);
9020 if (QDF_STATUS_SUCCESS == status) {
9021 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9022 pMac->sme.peerInfoParams.pUserData = pUserData;
9023
9024 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309025 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009026 if (NULL == pIbssInfoReqParams) {
9027 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9028 "%s: Not able to allocate memory for dhcp start",
9029 __func__);
9030 sme_release_global_lock(&pMac->sme);
9031 return QDF_STATUS_E_NOMEM;
9032 }
9033 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9034 pIbssInfoReqParams->staIdx = staIdx;
9035
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009036 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9037 message.bodyptr = pIbssInfoReqParams;
9038 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009039
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009040 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9041 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009042 if (QDF_STATUS_SUCCESS != qdf_status) {
9043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9044 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9045 __func__);
9046 qdf_mem_free(pIbssInfoReqParams);
9047 qdf_status = QDF_STATUS_E_FAILURE;
9048 }
9049 sme_release_global_lock(&pMac->sme);
9050 }
9051
9052 return qdf_status;
9053}
9054
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309055/*
9056 * sme_send_cesium_enable_ind() -
9057 * Used to send proprietary cesium enable indication to fw
9058 *
9059 * hHal
9060 * sessionId
9061 * Return QDF_STATUS
9062 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009063QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9064{
9065 QDF_STATUS status = QDF_STATUS_SUCCESS;
9066 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9067 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009068 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009069
9070 status = sme_acquire_global_lock(&pMac->sme);
9071 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009072 message.bodyptr = NULL;
9073 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9074 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9075 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009076 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9078 "%s: failed to post message to WMA",
9079 __func__);
9080 status = QDF_STATUS_E_FAILURE;
9081 }
9082 sme_release_global_lock(&pMac->sme);
9083 }
9084
9085 return status;
9086}
9087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009088void sme_get_command_q_status(tHalHandle hHal)
9089{
9090 tSmeCmd *pTempCmd = NULL;
9091 tListElem *pEntry;
9092 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9093
9094 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309095 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009096 "%s: pMac is NULL", __func__);
9097 return;
9098 }
9099
Krunal Sonia8270f52017-02-23 19:51:25 -08009100 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309101 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009102 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309103
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009104 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009105 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9106 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309107 if (eSmeCsrCommandMask & pTempCmd->command)
9108 /* CSR command is stuck. See what the reason code is
9109 * for that command
9110 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009111 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009112 } /* if(pTempCmd) */
9113
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009114 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009115 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009117}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009118/**
9119 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9120 * @hal: The handle returned by macOpen
9121 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9122 */
9123void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9124 bool sta_prefer_80MHz_over_160MHz)
9125{
9126 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309127
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009128 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9129}
9130
Agrawal Ashishb141b092016-09-02 19:59:26 +05309131#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009132/**
9133 * sme_set_dot11p_config() - API to set the 802.11p config
9134 * @hHal: The handle returned by macOpen
9135 * @enable_dot11p: 802.11p config param
9136 */
9137void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9138{
9139 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009141 pMac->enable_dot11p = enable_dot11p;
9142}
9143
9144/**
9145 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9146 * @src: the source configuration
9147 *
9148 * Return: pointer to the copied OCB configuration
9149 */
9150static struct sir_ocb_config *sme_copy_sir_ocb_config(
9151 struct sir_ocb_config *src)
9152{
9153 struct sir_ocb_config *dst;
9154 uint32_t length;
9155 void *cursor;
9156
9157 length = sizeof(*src) +
9158 src->channel_count * sizeof(*src->channels) +
9159 src->schedule_size * sizeof(*src->schedule) +
9160 src->dcc_ndl_chan_list_len +
9161 src->dcc_ndl_active_state_list_len;
9162
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309163 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 if (!dst)
9165 return NULL;
9166
9167 *dst = *src;
9168
9169 cursor = dst;
9170 cursor += sizeof(*dst);
9171 dst->channels = cursor;
9172 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309173 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009174 src->channel_count * sizeof(*src->channels));
9175 dst->schedule = cursor;
9176 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309177 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009178 src->schedule_size * sizeof(*src->schedule));
9179 dst->dcc_ndl_chan_list = cursor;
9180 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309181 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009182 src->dcc_ndl_chan_list_len);
9183 dst->dcc_ndl_active_state_list = cursor;
9184 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309185 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009186 src->dcc_ndl_active_state_list,
9187 src->dcc_ndl_active_state_list_len);
9188 return dst;
9189}
9190
9191/**
9192 * sme_ocb_set_config() - Set the OCB configuration
9193 * @hHal: reference to the HAL
9194 * @context: the context of the call
9195 * @callback: the callback to hdd
9196 * @config: the OCB configuration
9197 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309198 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009199 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309200QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009201 ocb_callback callback,
9202 struct sir_ocb_config *config)
9203{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309204 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009205 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009206 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009207 struct sir_ocb_config *msg_body;
9208
9209 /* Lock the SME structure */
9210 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309211 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009212 return status;
9213
9214 /*
9215 * Check if there is a pending request and return an error if one
9216 * exists
9217 */
9218 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309219 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 goto end;
9221 }
9222
9223 msg_body = sme_copy_sir_ocb_config(config);
9224
9225 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309226 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227 goto end;
9228 }
9229
9230 msg.type = WMA_OCB_SET_CONFIG_CMD;
9231 msg.bodyptr = msg_body;
9232
9233 /* Set the request callback and context */
9234 pMac->sme.ocb_set_config_callback = callback;
9235 pMac->sme.ocb_set_config_context = context;
9236
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009237 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309238 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309239 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009240 FL("Error posting message to WDA: %d"), status);
9241 pMac->sme.ocb_set_config_callback = callback;
9242 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309243 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009244 goto end;
9245 }
9246
9247end:
9248 sme_release_global_lock(&pMac->sme);
9249
9250 return status;
9251}
9252
9253/**
9254 * sme_ocb_set_utc_time() - Set the OCB UTC time
9255 * @hHal: reference to the HAL
9256 * @utc: the UTC time struct
9257 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309258 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309260QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009261{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309262 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009263 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009264 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009265 struct sir_ocb_utc *sme_utc;
9266
9267 /* Lock the SME structure */
9268 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309269 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 return status;
9271
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309272 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009273 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309274 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309276 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009277 goto end;
9278 }
9279 *sme_utc = *utc;
9280
9281 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9282 msg.reserved = 0;
9283 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009284 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309285 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309286 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009287 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309288 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009289 goto end;
9290 }
9291
9292end:
9293 sme_release_global_lock(&pMac->sme);
9294
9295 return status;
9296}
9297
9298/**
9299 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9300 * @hHal: reference to the HAL
9301 * @timing_advert: the timing advertisement struct
9302 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309303 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009304 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309305QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009306 struct sir_ocb_timing_advert *timing_advert)
9307{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309308 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009310 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009311 void *buf;
9312 struct sir_ocb_timing_advert *sme_timing_advert;
9313
9314 /* Lock the SME structure */
9315 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309316 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009317 return status;
9318
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309319 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320 timing_advert->template_length);
9321 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309322 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009323 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309324 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325 goto end;
9326 }
9327
9328 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9329 *sme_timing_advert = *timing_advert;
9330 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309331 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 timing_advert->template_value, timing_advert->template_length);
9333
9334 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9335 msg.reserved = 0;
9336 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009337 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309338 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309339 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 FL("Not able to post msg to WDA"));
9341 goto end;
9342 }
9343
9344end:
9345 sme_release_global_lock(&pMac->sme);
9346
9347 return status;
9348}
9349
9350/**
9351 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9352 * @hHal: reference to the HAL
9353 * @timing_advert: the timing advertisement struct
9354 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309355 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009356 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309357QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009358 struct sir_ocb_timing_advert *timing_advert)
9359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309360 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009362 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 struct sir_ocb_timing_advert *sme_timing_advert;
9364
9365 /* Lock the SME structure */
9366 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309367 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 return status;
9369
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309370 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009371 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309372 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009373 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309374 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009375 goto end;
9376 }
9377 *sme_timing_advert = *timing_advert;
9378
9379 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9380 msg.reserved = 0;
9381 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009382 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309383 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309384 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 FL("Not able to post msg to WDA"));
9386 goto end;
9387 }
9388
9389end:
9390 sme_release_global_lock(&pMac->sme);
9391
9392 return status;
9393}
9394
9395/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009396 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9397 * @hal_handle: reference to the HAL
9398 * @self_addr: the self MAC address
9399 * @buf: the buffer that will contain the frame
9400 * @timestamp_offset: return for the offset of the timestamp field
9401 * @time_value_offset: return for the time_value field in the TA IE
9402 *
9403 * Return: the length of the buffer.
9404 */
9405int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9406 tSirMacAddr self_addr, uint8_t **buf,
9407 uint32_t *timestamp_offset,
9408 uint32_t *time_value_offset)
9409{
9410 int template_length;
9411 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9412
9413 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9414 timestamp_offset,
9415 time_value_offset);
9416 return template_length;
9417}
9418/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009419 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9420 * @hHal: reference to the HAL
9421 * @context: the context of the call
9422 * @callback: the callback to hdd
9423 * @request: the TSF timer request
9424 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309425 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009426 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309427QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009428 ocb_callback callback,
9429 struct sir_ocb_get_tsf_timer *request)
9430{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309431 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009433 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009434 struct sir_ocb_get_tsf_timer *msg_body;
9435
9436 /* Lock the SME structure */
9437 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309438 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009439 return status;
9440
9441 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309442 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009443 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309444 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009445 goto end;
9446 }
9447 *msg_body = *request;
9448
9449 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9450 msg.bodyptr = msg_body;
9451
9452 /* Set the request callback and the context */
9453 pMac->sme.ocb_get_tsf_timer_callback = callback;
9454 pMac->sme.ocb_get_tsf_timer_context = context;
9455
9456 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009457 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309458 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 FL("Error posting message to WDA: %d"), status);
9461 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9462 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309463 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009464 goto end;
9465 }
9466
9467end:
9468 sme_release_global_lock(&pMac->sme);
9469
9470 return status;
9471}
9472
9473/**
9474 * sme_dcc_get_stats() - Get the DCC stats
9475 * @hHal: reference to the HAL
9476 * @context: the context of the call
9477 * @callback: the callback to hdd
9478 * @request: the get DCC stats request
9479 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309480 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009481 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309482QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009483 ocb_callback callback,
9484 struct sir_dcc_get_stats *request)
9485{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309486 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009488 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009489 struct sir_dcc_get_stats *msg_body;
9490
9491 /* Lock the SME structure */
9492 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309493 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009494 return status;
9495
9496 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309497 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498 request->request_array_len);
9499 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309500 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 goto end;
9502 }
9503 *msg_body = *request;
9504 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309505 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009506 request->request_array_len);
9507
9508 msg.type = WMA_DCC_GET_STATS_CMD;
9509 msg.bodyptr = msg_body;
9510
9511 /* Set the request callback and context */
9512 pMac->sme.dcc_get_stats_callback = callback;
9513 pMac->sme.dcc_get_stats_context = context;
9514
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009515 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309516 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309517 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009518 FL("Error posting message to WDA: %d"), status);
9519 pMac->sme.dcc_get_stats_callback = callback;
9520 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309521 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 goto end;
9523 }
9524
9525end:
9526 sme_release_global_lock(&pMac->sme);
9527
9528 return status;
9529}
9530
9531/**
9532 * sme_dcc_clear_stats() - Clear the DCC stats
9533 * @hHal: reference to the HAL
9534 * @vdev_id: vdev id for OCB interface
9535 * @dcc_stats_bitmap: the entries in the stats to clear
9536 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309537 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309539QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 uint32_t dcc_stats_bitmap)
9541{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309542 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009543 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009544 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009545 struct sir_dcc_clear_stats *request;
9546
9547 /* Lock the SME structure */
9548 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309549 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009550 return status;
9551
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309552 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009553 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309554 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309556 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557 goto end;
9558 }
9559
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009560 request->vdev_id = vdev_id;
9561 request->dcc_stats_bitmap = dcc_stats_bitmap;
9562
9563 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9564 msg.bodyptr = request;
9565
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009566 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309567 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309568 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009569 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309570 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 goto end;
9572 }
9573
9574end:
9575 sme_release_global_lock(&pMac->sme);
9576
9577 return status;
9578}
9579
9580/**
9581 * sme_dcc_update_ndl() - Update the DCC settings
9582 * @hHal: reference to the HAL
9583 * @context: the context of the call
9584 * @callback: the callback to hdd
9585 * @request: the update DCC request
9586 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309587 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009588 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309589QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 ocb_callback callback,
9591 struct sir_dcc_update_ndl *request)
9592{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309593 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009594 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009595 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596 struct sir_dcc_update_ndl *msg_body;
9597
9598 /* Lock the SME structure */
9599 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309600 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009601 return status;
9602
9603 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309604 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009605 request->dcc_ndl_chan_list_len +
9606 request->dcc_ndl_active_state_list_len);
9607 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309608 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309610 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009611 goto end;
9612 }
9613
9614 *msg_body = *request;
9615
9616 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9617 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9618 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309619 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309621 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009622 request->dcc_ndl_active_state_list,
9623 request->dcc_ndl_active_state_list_len);
9624
9625 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9626 msg.bodyptr = msg_body;
9627
9628 /* Set the request callback and the context */
9629 pMac->sme.dcc_update_ndl_callback = callback;
9630 pMac->sme.dcc_update_ndl_context = context;
9631
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009632 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309633 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009635 FL("Error posting message to WDA: %d"), status);
9636 pMac->sme.dcc_update_ndl_callback = NULL;
9637 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309638 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 goto end;
9640 }
9641
9642end:
9643 sme_release_global_lock(&pMac->sme);
9644
9645 return status;
9646}
9647
9648/**
9649 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9650 * event
9651 * @hHal: reference to the HAL
9652 * @context: the context of the call
9653 * @callback: the callback to hdd
9654 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309655 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309657QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009658 ocb_callback callback)
9659{
9660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309661 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009662
9663 status = sme_acquire_global_lock(&pMac->sme);
9664 pMac->sme.dcc_stats_event_callback = callback;
9665 pMac->sme.dcc_stats_event_context = context;
9666 sme_release_global_lock(&pMac->sme);
9667
9668 return 0;
9669}
9670
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309671/**
9672 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9673 * event
9674 * @h_hal: Hal Handle
9675 *
9676 * This function de-registers the DCC perioc stats callback
9677 *
9678 * Return: QDF_STATUS Enumeration
9679 */
9680QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9681{
9682 tpAniSirGlobal mac;
9683 QDF_STATUS status;
9684
9685 if (!h_hal) {
9686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9687 FL("h_hal is not valid"));
9688 return QDF_STATUS_E_INVAL;
9689 }
9690 mac = PMAC_STRUCT(h_hal);
9691
9692 status = sme_acquire_global_lock(&mac->sme);
9693 if (!QDF_IS_STATUS_SUCCESS(status)) {
9694 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9695 FL("Failed to acquire global lock"));
9696 return status;
9697 }
9698 mac->sme.dcc_stats_event_callback = NULL;
9699 mac->sme.dcc_stats_event_context = NULL;
9700 sme_release_global_lock(&mac->sme);
9701
9702 return status;
9703}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309704#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009706void sme_get_recovery_stats(tHalHandle hHal)
9707{
9708 uint8_t i;
9709
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309710 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009711 "Self Recovery Stats");
9712 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9713 if (eSmeNoCommand !=
9714 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009716 "timestamp %llu: command 0x%0X: reason %d: session %d",
9717 g_self_recovery_stats.activeCmdStats[i].
9718 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309719 g_self_recovery_stats.activeCmdStats[i].command,
9720 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009721 g_self_recovery_stats.activeCmdStats[i].
9722 sessionId);
9723 }
9724 }
9725}
9726
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309727QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009728{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009729 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009730 tpSirModemPowerStateInd request_buf;
9731 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9732
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309733 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309734 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009735
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309736 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009737 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9740 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309741 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009742 }
9743
9744 request_buf->param = value;
9745
9746 msg.type = WMA_MODEM_POWER_STATE_IND;
9747 msg.reserved = 0;
9748 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309749 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009750 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309752 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9753 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309754 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309755 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009756 }
9757
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309758 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009759}
9760
9761#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309762QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309763 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009764 uint8_t sessionId,
9765 uint8_t channel_type)
9766{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009767 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009768 tUpdateVHTOpMode *pHtOpMode = NULL;
9769 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309771 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309772 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309774 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009775 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009777 "%s: Not able to allocate memory for setting OP mode",
9778 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309779 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009780 }
9781
9782 switch (channel_type) {
9783 case eHT_CHAN_HT20:
9784 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9785 break;
9786
9787 case eHT_CHAN_HT40MINUS:
9788 case eHT_CHAN_HT40PLUS:
9789 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9790 break;
9791
9792 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309793 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009794 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309795 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009796 }
9797
9798 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309799 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800 sizeof(tSirMacAddr));
9801 pHtOpMode->smesessionId = sessionId;
9802
9803 msg.type = WMA_UPDATE_OP_MODE;
9804 msg.reserved = 0;
9805 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309806 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009807 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309808 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309809 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9810 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309811 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309812 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813 }
9814
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009816 "%s: Notifed FW about OP mode: %d for staId=%d",
9817 __func__, pHtOpMode->opMode, staId);
9818
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309819 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009820}
9821
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309822/*
9823 * sme_set_ht2040_mode() -
9824 * To update HT Operation beacon IE.
9825 *
9826 * Return QDF_STATUS SUCCESS
9827 * FAILURE or RESOURCES
9828 * The API finished and failed.
9829 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309830QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 uint8_t channel_type, bool obssEnabled)
9832{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309833 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9835 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309836 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309838 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9839 sme_err("Session not valid for session id %d", sessionId);
9840 return QDF_STATUS_E_INVAL;
9841 }
9842 session = CSR_GET_SESSION(pMac, sessionId);
9843 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9844 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009845
9846 switch (channel_type) {
9847 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309848 if (!session->bssParams.cbMode)
9849 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009850 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9851 break;
9852 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309853 if (session->bssParams.cbMode)
9854 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009855 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9856 break;
9857 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309858 if (session->bssParams.cbMode)
9859 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009860 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9861 break;
9862 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309863 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309864 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009865 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309866 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009867 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309868 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009869 status = csr_set_ht2040_mode(pMac, sessionId,
9870 cbMode, obssEnabled);
9871 sme_release_global_lock(&pMac->sme);
9872 }
9873 return status;
9874}
9875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009876#endif
9877
9878/*
9879 * SME API to enable/disable idle mode powersave
9880 * This should be called only if powersave offload
9881 * is enabled
9882 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309883QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009884{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309885 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009886
9887 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309888 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009889 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309890 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009891 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309892 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009893 " Idle Ps Set Value %d", value);
9894
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309895 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309896 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009897 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309898 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009899 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309900
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309901 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009902}
9903
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309904int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9905 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009906{
9907 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309908 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009909
9910 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309911 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009912 "%s: pSession is NULL", __func__);
9913 return -EIO;
9914 }
9915 switch (ht_capab) {
9916 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9917 return pSession->htConfig.ht_rx_ldpc;
9918 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9919 return pSession->htConfig.ht_tx_stbc;
9920 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9921 return pSession->htConfig.ht_rx_stbc;
9922 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009923 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009924 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009925 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009926 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309927 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928 "invalid ht capability");
9929 return -EIO;
9930 }
9931}
9932
9933int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9934 int value)
9935{
9936 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309937 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009938
9939 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309940 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009941 "%s: pSession is NULL", __func__);
9942 return -EIO;
9943 }
9944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309945 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009947 "Failed to set ht capability in target");
9948 return -EIO;
9949 }
9950
9951 switch (htCapab) {
9952 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9953 pSession->htConfig.ht_rx_ldpc = value;
9954 break;
9955 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9956 pSession->htConfig.ht_tx_stbc = value;
9957 break;
9958 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9959 pSession->htConfig.ht_rx_stbc = value;
9960 break;
9961 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009962 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009963 pSession->htConfig.ht_sgi20 = value;
9964 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009965 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009966 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009967 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009968 break;
9969 }
9970
Naveen Rawat8029a402017-06-01 10:54:19 -07009971 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009972 return 0;
9973}
9974
9975#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309976/*
9977 * sme_send_rate_update_ind() -
9978 * API to Update rate
9979 *
9980 * hHal - The handle returned by mac_open
9981 * rateUpdateParams - Pointer to rate update params
9982 * Return QDF_STATUS
9983 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309984QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985 tSirRateUpdateInd *rateUpdateParams)
9986{
9987 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309988 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009989 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309990 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009991
9992 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009994 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309995 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009996 }
9997 *rate_upd = *rateUpdateParams;
9998
9999 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10000 rate_upd->mcastDataRate24GHzTxFlag =
10001 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10002 else if (rate_upd->reliableMcastDataRate ==
10003 HT20_SHORT_GI_MCS7_RATE)
10004 rate_upd->reliableMcastDataRateTxFlag =
10005 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10006
10007 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010008 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010009 msg.type = WMA_RATE_UPDATE_IND;
10010 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010011 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10012 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010013 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010014 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010016 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010017 __func__);
10018
10019 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010020 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010021 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010022 }
10023
10024 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010025 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010026 }
10027
10028 return status;
10029}
10030
10031/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010032 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10033 * @hal: Pointer to the mac context
10034 * @session_id: sme session id
10035 * @vendor_ie: vendor ie
10036 * @access_policy: vendor ie access policy
10037 *
10038 * This function updates the vendor ie and access policy to lim.
10039 *
10040 * Return: success or failure.
10041 */
10042QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10043 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10044{
10045 struct sme_update_access_policy_vendor_ie *msg;
10046 uint16_t msg_len;
10047 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010048
10049 msg_len = sizeof(*msg);
10050
10051 msg = qdf_mem_malloc(msg_len);
10052 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010053 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010054 return QDF_STATUS_E_FAILURE;
10055 }
10056
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010057 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10058 msg->length = (uint16_t)msg_len;
10059
10060 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10061
10062 msg->sme_session_id = session_id;
10063 msg->access_policy = access_policy;
10064
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010065 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10066 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010067
Rajeev Kumard138ac52017-01-30 18:38:37 -080010068 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010069
10070 return status;
10071}
10072
10073/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010074 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10075 * @hal: Handle returned by mac_open
10076 * @session_id: Session ID on which short frame retry limit needs to be
10077 * updated to FW
10078 * @short_limit_count_th: Retry count TH to retry short frame.
10079 *
10080 * This function is used to configure count to retry short frame.
10081 *
10082 * Return: QDF_STATUS
10083 */
10084QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10085 struct sme_short_retry_limit *short_retry_limit_th)
10086{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010087 QDF_STATUS status = QDF_STATUS_SUCCESS;
10088 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010089 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010090
10091 srl = qdf_mem_malloc(sizeof(*srl));
10092 if (NULL == srl) {
10093 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10094 "%s: fail to alloc short retry limit", __func__);
10095 return QDF_STATUS_E_FAILURE;
10096 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010097 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010098 short_retry_limit_th->session_id,
10099 short_retry_limit_th->short_retry_limit);
10100
10101 srl->session_id = short_retry_limit_th->session_id;
10102 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10103
10104 qdf_mem_zero(&msg, sizeof(msg));
10105 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10106 msg.reserved = 0;
10107 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010108 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010109 if (status != QDF_STATUS_SUCCESS) {
10110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10111 FL("Not able to post short retry limit count to WDA"));
10112 qdf_mem_free(srl);
10113 return QDF_STATUS_E_FAILURE;
10114 }
10115
10116 return status;
10117}
10118
10119/**
10120 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10121 * @hal: Handle returned by mac_open
10122 * @session_id: Session ID on which long frames retry TH needs to be updated
10123 * to FW
10124 * @long_limit_count_th: Retry count to retry long frame.
10125 *
10126 * This function is used to configure TH to retry long frame.
10127 *
10128 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010129 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010130QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10131 struct sme_long_retry_limit *long_retry_limit_th)
10132{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010133 QDF_STATUS status = QDF_STATUS_SUCCESS;
10134 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010135 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010136
10137 lrl = qdf_mem_malloc(sizeof(*lrl));
10138 if (NULL == lrl) {
10139 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10140 "%s: fail to alloc long retry limit", __func__);
10141 return QDF_STATUS_E_FAILURE;
10142 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010143 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010144 long_retry_limit_th->session_id,
10145 long_retry_limit_th->long_retry_limit);
10146
10147 lrl->session_id = long_retry_limit_th->session_id;
10148 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10149
10150 qdf_mem_zero(&msg, sizeof(msg));
10151 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10152 msg.reserved = 0;
10153 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010154 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010155
10156 if (status != QDF_STATUS_SUCCESS) {
10157 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10158 FL("Not able to post long retry limit count to WDA"));
10159 qdf_mem_free(lrl);
10160 return QDF_STATUS_E_FAILURE;
10161 }
10162
10163 return status;
10164}
10165
10166/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010167 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10168 * @hal: Handle returned by mac_open
10169 * @session_id: Session ID on which sta_inactivity_timeout needs
10170 * to be updated to FW
10171 * @sta_inactivity_timeout: sta inactivity timeout.
10172 *
10173 * If a station does not send anything in sta_inactivity_timeout seconds, an
10174 * empty data frame is sent to it in order to verify whether it is
10175 * still in range. If this frame is not ACKed, the station will be
10176 * disassociated and then deauthenticated.
10177 *
10178 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010179 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010180QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10181 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10182{
10183 struct sme_sta_inactivity_timeout *inactivity_time;
10184 void *wma_handle;
10185
10186 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10187 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10188 if (NULL == inactivity_time) {
10189 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10190 "%s: fail to alloc inactivity_time", __func__);
10191 return QDF_STATUS_E_FAILURE;
10192 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010193 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010194 FL("sta_inactivity_timeout: %d"),
10195 sta_inactivity_timer->sta_inactivity_timeout);
10196 inactivity_time->session_id = sta_inactivity_timer->session_id;
10197 inactivity_time->sta_inactivity_timeout =
10198 sta_inactivity_timer->sta_inactivity_timeout;
10199
10200 wma_update_sta_inactivity_timeout(wma_handle,
10201 inactivity_time);
10202 return QDF_STATUS_SUCCESS;
10203}
10204
10205/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010206 * sme_get_reg_info() - To get registration info
10207 * @hHal: HAL context
10208 * @chanId: channel id
10209 * @regInfo1: first reg info to fill
10210 * @regInfo2: second reg info to fill
10211 *
10212 * This routine will give you reg info
10213 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010214 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010216QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010217 uint32_t *regInfo1, uint32_t *regInfo2)
10218{
10219 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010220 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010221 uint8_t i;
10222 bool found = false;
10223
10224 status = sme_acquire_global_lock(&pMac->sme);
10225 *regInfo1 = 0;
10226 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010227 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010228 return status;
10229
10230 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010231 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010233 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010234
10235 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010236 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010237 found = true;
10238 break;
10239 }
10240 }
10241 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010242 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010243
10244 sme_release_global_lock(&pMac->sme);
10245 return status;
10246}
10247
10248#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010249/*
10250 * sme_auto_shutdown_cb() -
10251 * Used to plug in callback function for receiving auto shutdown evt
10252 *
10253 * hHal
10254 * pCallbackfn : callback function pointer should be plugged in
10255 * Return QDF_STATUS
10256 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010257QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010258 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010259 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010260 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10261
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010262 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263 "%s: Plug in Auto shutdown event callback", __func__);
10264
10265 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010266 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010267 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010268 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010269 sme_release_global_lock(&pMac->sme);
10270 }
10271
10272 return status;
10273}
10274
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010275/*
10276 * sme_set_auto_shutdown_timer() -
10277 * API to set auto shutdown timer value in FW.
10278 *
10279 * hHal - The handle returned by mac_open
10280 * timer_val - The auto shutdown timer value to be set
10281 * Return Configuration message posting status, SUCCESS or Fail
10282 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010283QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010284{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010285 QDF_STATUS status = QDF_STATUS_SUCCESS;
10286 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10288 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010289 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010290
10291 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010292 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010293 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010294 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010295 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010296 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010297 "%s Request Buffer Alloc Fail", __func__);
10298 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010299 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300 }
10301
10302 auto_sh_cmd->timer_val = timer_val;
10303
10304 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010305 message.bodyptr = auto_sh_cmd;
10306 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10307 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10308 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010309 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010310 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010311 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010312 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010313 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010314 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010315 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010317 "%s: Posted Auto shutdown MSG", __func__);
10318 sme_release_global_lock(&pMac->sme);
10319 }
10320
10321 return status;
10322}
10323#endif
10324
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010325/*
10326 * sme_ch_avoid_update_req() -
10327 * API to request channel avoidance update from FW.
10328 *
10329 * hHal - The handle returned by mac_open
10330 * update_type - The udpate_type parameter of this request call
10331 * Return Configuration message posting status, SUCCESS or Fail
10332 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010333QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010335 QDF_STATUS status = QDF_STATUS_SUCCESS;
10336 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10338 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010339 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010340
10341 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010342 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010343 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010344 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010346 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010347 "%s Request Buffer Alloc Fail", __func__);
10348 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010349 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010350 }
10351
10352 cauReq->reserved_param = 0;
10353
10354 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010355 message.bodyptr = cauReq;
10356 message.type = WMA_CH_AVOID_UPDATE_REQ;
10357 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10358 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010359 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010360 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010361 "%s: Post Ch Avoid Update MSG fail",
10362 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010363 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010364 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010365 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010366 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010368 "%s: Posted Ch Avoid Update MSG", __func__);
10369 sme_release_global_lock(&pMac->sme);
10370 }
10371
10372 return status;
10373}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010374
10375/**
10376 * sme_set_miracast() - Function to set miracast value to UMAC
10377 * @hal: Handle returned by macOpen
10378 * @filter_type: 0-Disabled, 1-Source, 2-sink
10379 *
10380 * This function passes down the value of miracast set by
10381 * framework to UMAC
10382 *
10383 * Return: Configuration message posting status, SUCCESS or Fail
10384 *
10385 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010386QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010387{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010388 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389 uint32_t *val;
10390 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10391
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010392 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010393 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010396 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010397 }
10398
10399 *val = filter_type;
10400
10401 msg.type = SIR_HAL_SET_MIRACAST;
10402 msg.reserved = 0;
10403 msg.bodyptr = val;
10404
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010405 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010406 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010407 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10409 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010410 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010411 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010412 }
10413
10414 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010415 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416}
10417
10418/**
10419 * sme_set_mas() - Function to set MAS value to UMAC
10420 * @val: 1-Enable, 0-Disable
10421 *
10422 * This function passes down the value of MAS to the UMAC. A
10423 * value of 1 will enable MAS and a value of 0 will disable MAS
10424 *
10425 * Return: Configuration message posting status, SUCCESS or Fail
10426 *
10427 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010428QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010429{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010430 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 uint32_t *ptr_val;
10432
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010433 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010435 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010436 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010437 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010438 }
10439
10440 *ptr_val = val;
10441
10442 msg.type = SIR_HAL_SET_MAS;
10443 msg.reserved = 0;
10444 msg.bodyptr = ptr_val;
10445
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010446 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010447 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10450 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010451 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010452 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010454 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010455}
10456
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010457/**
10458 * sme_roam_channel_change_req() - Channel change to new target channel
10459 * @hHal: handle returned by mac_open
10460 * @bssid: mac address of BSS
10461 * @ch_params: target channel information
10462 * @profile: CSR profile
10463 *
10464 * API to Indicate Channel change to new target channel
10465 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010466 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010467 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010468QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010469 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010470 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010471 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010473 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010474 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010475
10476 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010477 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010478
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010479 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010480 profile);
10481 sme_release_global_lock(&pMac->sme);
10482 }
10483 return status;
10484}
10485
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010486/*
10487 * sme_process_channel_change_resp() -
10488 * API to Indicate Channel change response message to SAP.
10489 *
10490 * Return QDF_STATUS
10491 */
10492static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 uint16_t msg_type, void *pMsgBuf)
10494{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010495 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010496 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 eCsrRoamResult roamResult;
10498 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10499 uint32_t SessionId = pChnlParams->peSessionId;
10500
10501 proam_info.channelChangeRespEvent =
10502 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010503 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010504 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010505 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010506 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010507 return status;
10508 }
10509 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10510 proam_info.channelChangeRespEvent->sessionId = SessionId;
10511 proam_info.channelChangeRespEvent->newChannelNumber =
10512 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010514 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010515 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010516 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10517 SessionId);
10518 proam_info.channelChangeRespEvent->channelChangeStatus =
10519 1;
10520 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10521 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010522 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010523 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10524 SessionId);
10525 proam_info.channelChangeRespEvent->channelChangeStatus =
10526 0;
10527 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10528 }
10529
10530 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10531 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10532
10533 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010534 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010535 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536 status);
10537 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010538 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010539
10540 return status;
10541}
10542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010543/*
10544 * sme_roam_start_beacon_req() -
10545 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10546 *
10547 * hHal - The handle returned by mac_open
10548 * sessionId - session ID
10549 * dfsCacWaitStatus - CAC WAIT status flag
10550 * Return QDF_STATUS
10551 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010552QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010553 uint8_t dfsCacWaitStatus)
10554{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010555 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010557
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010558 status = sme_acquire_global_lock(&pMac->sme);
10559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010560 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010561 status = csr_roam_start_beacon_req(pMac, bssid,
10562 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010563 sme_release_global_lock(&pMac->sme);
10564 }
10565 return status;
10566}
10567
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010568/**
10569 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10570 * @hHal: handle returned by mac_open
10571 * @bssid: SAP bssid
10572 * @targetChannel: target channel information
10573 * @csaIeReqd: CSA IE Request
10574 * @ch_params: channel information
10575 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010576 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010577 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010578QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010579 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010580 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010581{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010582 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010583 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010584
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010585 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010586 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010587 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10588 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010589 sme_release_global_lock(&pMac->sme);
10590 }
10591 return status;
10592}
10593
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010594/*
10595 * sme_init_thermal_info() -
10596 * SME API to initialize the thermal mitigation parameters
10597 *
10598 * hHal
10599 * thermalParam : thermal mitigation parameters
10600 * Return QDF_STATUS
10601 */
10602QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10603 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010604{
10605 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010606 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10608
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010609 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010610 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010611 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010612 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010613 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010614 }
10615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010616 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10617 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010618
10619 pWmaParam->throttle_duty_cycle_tbl[0] =
10620 thermalParam.sme_throttle_duty_cycle_tbl[0];
10621 pWmaParam->throttle_duty_cycle_tbl[1] =
10622 thermalParam.sme_throttle_duty_cycle_tbl[1];
10623 pWmaParam->throttle_duty_cycle_tbl[2] =
10624 thermalParam.sme_throttle_duty_cycle_tbl[2];
10625 pWmaParam->throttle_duty_cycle_tbl[3] =
10626 thermalParam.sme_throttle_duty_cycle_tbl[3];
10627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010628 pWmaParam->thermalLevels[0].minTempThreshold =
10629 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10630 pWmaParam->thermalLevels[0].maxTempThreshold =
10631 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10632 pWmaParam->thermalLevels[1].minTempThreshold =
10633 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10634 pWmaParam->thermalLevels[1].maxTempThreshold =
10635 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10636 pWmaParam->thermalLevels[2].minTempThreshold =
10637 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10638 pWmaParam->thermalLevels[2].maxTempThreshold =
10639 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10640 pWmaParam->thermalLevels[3].minTempThreshold =
10641 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10642 pWmaParam->thermalLevels[3].maxTempThreshold =
10643 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10644
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010645 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10647 msg.bodyptr = pWmaParam;
10648
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010649 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010650 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010651 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010652 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10653 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010654 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010655 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010656 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010657 }
10658 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010659 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010661 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010662 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010663}
10664
10665/**
10666 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10667 * @hal: Handle returned by macOpen
10668 * @callback: sme_set_thermal_level_callback
10669 *
10670 * Plug in set thermal level callback
10671 *
10672 * Return: none
10673 */
10674void sme_add_set_thermal_level_callback(tHalHandle hal,
10675 sme_set_thermal_level_callback callback)
10676{
10677 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10678
10679 pMac->sme.set_thermal_level_cb = callback;
10680}
10681
10682/**
10683 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10684 * @hal: Handler to HAL
10685 * @level: Thermal mitigation level
10686 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010687 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010688 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010689QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010690{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010691 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010692 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010693 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010694
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010695 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010696 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010697 msg.type = WMA_SET_THERMAL_LEVEL;
10698 msg.bodyval = level;
10699
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010700 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010701 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010702 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010703 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10704 __func__);
10705 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010706 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010707 }
10708 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010709 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010710 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010711 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010712}
10713
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010714/*
10715 * sme_txpower_limit() -
10716 * SME API to set txpower limits
10717 *
10718 * hHal
10719 * psmetx : power limits for 2g/5g
10720 * Return QDF_STATUS
10721 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010722QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010723{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010724 QDF_STATUS status = QDF_STATUS_SUCCESS;
10725 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010726 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010727 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010728 tSirTxPowerLimit *tx_power_limit;
10729
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010730 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010731 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010732 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010733 "%s: Memory allocation for TxPowerLimit failed!",
10734 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010735 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010736 }
10737
10738 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010739
10740 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010741 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010742 message.type = WMA_TX_POWER_LIMIT;
10743 message.reserved = 0;
10744 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010745
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010746 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10747 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010748 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010749 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010750 "%s: not able to post WMA_TX_POWER_LIMIT",
10751 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010752 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010753 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010754 }
10755 sme_release_global_lock(&pMac->sme);
10756 }
10757 return status;
10758}
10759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010760QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
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);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765 pMac->fEnableDebugLog = set_value;
10766 return status;
10767}
10768
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010769/*
10770 * sme_ap_disable_intra_bss_fwd() -
10771 * SME will send message to WMA to set Intra BSS in txrx
10772 *
10773 * hHal - The handle returned by mac_open
10774 * sessionId - session id ( vdev id)
10775 * disablefwd - bool value that indicate disable intrabss fwd disable
10776 * Return QDF_STATUS
10777 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010778QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010779 bool disablefwd)
10780{
10781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010782 int status = QDF_STATUS_SUCCESS;
10783 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010784 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010785 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10786
10787 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010788 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010789 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010790 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010791 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010792 }
10793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010794 pSapDisableIntraFwd->sessionId = sessionId;
10795 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10796
10797 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010798 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010800 message.bodyptr = pSapDisableIntraFwd;
10801 message.type = WMA_SET_SAP_INTRABSS_DIS;
10802 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10803 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010804 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10805 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010806 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 }
10808 sme_release_global_lock(&pMac->sme);
10809 }
10810 return status;
10811}
10812
10813#ifdef WLAN_FEATURE_STATS_EXT
10814
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010815/*
10816 * sme_stats_ext_register_callback() -
10817 * This function called to register the callback that send vendor event for
10818 * stats ext
10819 *
10820 * callback - callback to be registered
10821 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010822void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10823{
10824 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10825
10826 pMac->sme.StatsExtCallback = callback;
10827}
10828
lifeng66831662017-05-19 16:01:35 +080010829void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10830 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10831{
10832 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10833
10834 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10835}
10836
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010837/**
10838 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10839 * @h_hal: Hal Handle
10840 *
10841 * This function is called to de initialize the HDD NAN feature. Currently
10842 * the only operation required is to de-register a callback with SME.
10843 *
10844 * Return: None
10845 */
10846void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10847{
10848 tpAniSirGlobal pmac;
10849
10850 if (!h_hal) {
10851 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10852 FL("hHal is not valid"));
10853 return;
10854 }
10855
10856 pmac = PMAC_STRUCT(h_hal);
10857 pmac->sme.StatsExtCallback = NULL;
10858}
10859
10860
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010861/*
10862 * sme_stats_ext_request() -
10863 * Function called when HDD receives STATS EXT vendor command from userspace
10864 *
10865 * sessionID - vdevID for the stats ext request
10866 * input - Stats Ext Request structure ptr
10867 * Return QDF_STATUS
10868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010869QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010870{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010871 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872 tpStatsExtRequest data;
10873 size_t data_len;
10874
10875 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010876 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010878 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010879 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010881 data->vdev_id = session_id;
10882 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010883 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010884 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010885 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010886
10887 msg.type = WMA_STATS_EXT_REQUEST;
10888 msg.reserved = 0;
10889 msg.bodyptr = data;
10890
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010891 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010892 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010893 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010894 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10895 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010896 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010897 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898 }
10899
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010900 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010901}
10902
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010903/*
10904 * sme_stats_ext_event() -
10905 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10906 * response from WMA
10907 *
10908 * hHal - HAL handle for device
10909 * pMsg - Message body passed from WMA; includes NAN header
10910 * Return QDF_STATUS
10911 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010912QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010913{
10914 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010915 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916
10917 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010918 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010919 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010920 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010921 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010922 pMac->sme.StatsExtCallback(pMac->hHdd,
10923 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924 }
10925
10926 return status;
10927}
10928
10929#endif
10930
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010931/*
10932 * sme_update_dfs_scan_mode() -
10933 * Update DFS roam scan mode
10934 * This function is called through dynamic setConfig callback function
10935 * to configure allowDFSChannelRoam.
10936 * hHal - HAL handle for device
10937 * sessionId - Session Identifier
10938 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10939 * 1 (passive), 2 (active)
10940 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
10941 * successfully.
10942 * Other status means SME failed to update DFS roaming scan config.
10943 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010944QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945 uint8_t allowDFSChannelRoam)
10946{
10947 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010948 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010949
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080010950 if (sessionId >= CSR_ROAM_SESSION_MAX) {
10951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10952 FL("Invalid sme session id: %d"), sessionId);
10953 return QDF_STATUS_E_INVAL;
10954 }
10955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010956 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010957 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010959 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010960 allowDFSChannelRoam,
10961 pMac->roam.configParam.allowDFSChannelRoam,
10962 mac_trace_get_neighbour_roam_state(pMac->roam.
10963 neighborRoamInfo
10964 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010965 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010966 pMac->roam.configParam.allowDFSChannelRoam =
10967 allowDFSChannelRoam;
10968 sme_release_global_lock(&pMac->sme);
10969 }
10970 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
10971 csr_roam_offload_scan(pMac, sessionId,
10972 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10973 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
10974 }
10975
10976 return status;
10977}
10978
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010979/*
10980 * sme_get_dfs_scan_mode() - get DFS roam scan mode
10981 * This is a synchronous call
10982 *
10983 * hHal - The handle returned by mac_open.
10984 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
10985 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010986uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
10987{
10988 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010990 return pMac->roam.configParam.allowDFSChannelRoam;
10991}
10992
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010993/*
10994 * sme_modify_add_ie() -
10995 * This function sends msg to updates the additional IE buffers in PE
10996 *
10997 * hHal - global structure
10998 * pModifyIE - pointer to tModifyIE structure
10999 * updateType - type of buffer
11000 * Return Success or failure
11001 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011002QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011003 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11004{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011005 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011006 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011008 status = sme_acquire_global_lock(&pMac->sme);
11009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011010 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011011 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11012 sme_release_global_lock(&pMac->sme);
11013 }
11014 return status;
11015}
11016
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011017/*
11018 * sme_update_add_ie() -
11019 * This function sends msg to updates the additional IE buffers in PE
11020 *
11021 * hHal - global structure
11022 * pUpdateIE - pointer to structure tUpdateIE
11023 * updateType - type of buffer
11024 * Return Success or failure
11025 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011026QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11028{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011029 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011030 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011031
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011032 status = sme_acquire_global_lock(&pMac->sme);
11033
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011034 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011035 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11036 sme_release_global_lock(&pMac->sme);
11037 }
11038 return status;
11039}
11040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011041/**
11042 * sme_update_dsc_pto_up_mapping()
11043 * @hHal: HAL context
11044 * @dscpmapping: pointer to DSCP mapping structure
11045 * @sessionId: SME session id
11046 *
11047 * This routine is called to update dscp mapping
11048 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011049 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011050 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011051QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011052 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011053 uint8_t sessionId)
11054{
11055 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011056 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011057 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011058 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011059 tpPESession pSession = NULL;
11060
11061 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011062 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011063 return status;
11064 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11065 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011066 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011067 FL("Session lookup fails for CSR session"));
11068 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011069 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011070 }
11071 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011072 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011073 FL("Invalid session Id %u"), sessionId);
11074 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011075 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011076 }
11077
11078 pSession = pe_find_session_by_bssid(pMac,
11079 pCsrSession->connectedProfile.bssid.bytes,
11080 &peSessionId);
11081
11082 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011083 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011084 FL(" Session lookup fails for BSSID"));
11085 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011086 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011087 }
11088
11089 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011090 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011091 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011092 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011093 }
11094 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11095 for (j = pSession->QosMapSet.dscp_range[i][0];
11096 j <= pSession->QosMapSet.dscp_range[i][1];
11097 j++) {
11098 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11099 && (pSession->QosMapSet.dscp_range[i][1] ==
11100 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011101 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011102 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011103 FL("User Priority %d isn't used"), i);
11104 break;
11105 } else {
11106 dscpmapping[j] = i;
11107 }
11108 }
11109 }
11110 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11111 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11112 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11113 pSession->QosMapSet.dscp_exceptions[i][1];
11114
11115 sme_release_global_lock(&pMac->sme);
11116 return status;
11117}
11118
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011119/*
11120 * sme_abort_roam_scan() -
11121 * API to abort current roam scan cycle by roam scan offload module.
11122 *
11123 * hHal - The handle returned by mac_open.
11124 * sessionId - Session Identifier
11125 * Return QDF_STATUS
11126 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011127
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011128QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011130 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11132
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011133 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11134 /* acquire the lock for the sme object */
11135 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011136 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011137 csr_roam_offload_scan(pMac, sessionId,
11138 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11139 REASON_ROAM_ABORT_ROAM_SCAN);
11140 /* release the lock for the sme object */
11141 sme_release_global_lock(&pMac->sme);
11142 }
11143 }
11144
11145 return status;
11146}
11147
11148#ifdef FEATURE_WLAN_EXTSCAN
11149/**
11150 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11151 * @hHal: HAL context
11152 * @wifiBand: RF band information
11153 * @aValidChannels: output array to store channel info
11154 * @pNumChannels: output number of channels
11155 *
11156 * SME API to fetch all valid channels filtered by band
11157 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011158 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011160QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 uint8_t wifiBand,
11162 uint32_t *aValidChannels,
11163 uint8_t *pNumChannels)
11164{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011165 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011167 uint8_t numChannels = 0;
11168 uint8_t i = 0;
11169 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011170 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011171
11172 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011173 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011174 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175 }
11176
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011177 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011178 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011179 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011180 }
11181
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011182 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011183 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011184 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011185 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011186 return status;
11187 }
11188
11189 switch (wifiBand) {
11190 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011191 sme_debug("Unspec Band, return all %d valid channels",
11192 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011193 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011194 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 break;
11197
11198 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011199 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011200 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011201 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011202 aValidChannels[numChannels++] =
11203 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011204 }
11205 break;
11206
11207 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011208 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011209 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011210 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011211 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011212 aValidChannels[numChannels++] =
11213 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011214 }
11215 break;
11216
11217 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011218 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011219 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011220 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11221 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011222 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011223 aValidChannels[numChannels++] =
11224 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011225 }
11226 break;
11227
11228 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011229 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011230 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011231 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011232 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011233 aValidChannels[numChannels++] =
11234 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 }
11236 break;
11237
11238 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011239 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011240 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011241 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 aValidChannels[numChannels++] =
11243 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244 }
11245 break;
11246
11247 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011248 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011249 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011250 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011251 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011252 aValidChannels[numChannels++] =
11253 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011254 }
11255 break;
11256
11257 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011258 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011259 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260 }
11261 *pNumChannels = numChannels;
11262
11263 return status;
11264}
11265
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011266/*
11267 * sme_ext_scan_get_capabilities() -
11268 * SME API to fetch extscan capabilities
11269 *
11270 * hHal
11271 * pReq: extscan capabilities structure
11272 * Return QDF_STATUS
11273 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011274QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275 tSirGetExtScanCapabilitiesReqParams *
11276 pReq)
11277{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011278 QDF_STATUS status = QDF_STATUS_SUCCESS;
11279 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011280 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011281 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282
11283 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011284 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011286 message.bodyptr = pReq;
11287 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011288 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011289 NO_SESSION, message.type));
11290 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11291 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011292 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11293 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011294
11295 sme_release_global_lock(&pMac->sme);
11296 }
11297 return status;
11298}
11299
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011300/*
11301 * sme_ext_scan_start() -
11302 * SME API to issue extscan start
11303 *
11304 * hHal
11305 * pStartCmd: extscan start structure
11306 * Return QDF_STATUS
11307 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011308QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011309 tSirWifiScanCmdReqParams *pStartCmd)
11310{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011311 QDF_STATUS status = QDF_STATUS_SUCCESS;
11312 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011313 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011314 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011315
11316 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011317 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011318 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011319 message.bodyptr = pStartCmd;
11320 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011321 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011322 NO_SESSION, message.type));
11323 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11324 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011325 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11326 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327
11328 sme_release_global_lock(&pMac->sme);
11329 }
11330 return status;
11331}
11332
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011333/*
11334 * sme_ext_scan_stop() -
11335 * SME API to issue extscan stop
11336 *
11337 * hHal
11338 * pStopReq: extscan stop structure
11339 * Return QDF_STATUS
11340 */
11341QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11342 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011343{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011344 QDF_STATUS status = QDF_STATUS_SUCCESS;
11345 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011346 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011347 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011348
11349 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011350 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011352 message.bodyptr = pStopReq;
11353 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011354 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011355 NO_SESSION, message.type));
11356 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11357 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011358 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11359 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011360 sme_release_global_lock(&pMac->sme);
11361 }
11362 return status;
11363}
11364
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011365/*
11366 * sme_set_bss_hotlist() -
11367 * SME API to set BSSID hotlist
11368 *
11369 * hHal
11370 * pSetHotListReq: extscan set hotlist structure
11371 * Return QDF_STATUS
11372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011373QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011374 tSirExtScanSetBssidHotListReqParams *
11375 pSetHotListReq)
11376{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011377 QDF_STATUS status = QDF_STATUS_SUCCESS;
11378 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011379 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011380 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011381
11382 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011383 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011385 message.bodyptr = pSetHotListReq;
11386 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011387 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011388 NO_SESSION, message.type));
11389 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11390 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011391 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11392 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011393
11394 sme_release_global_lock(&pMac->sme);
11395 }
11396 return status;
11397}
11398
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011399/*
11400 * sme_reset_bss_hotlist() -
11401 * SME API to reset BSSID hotlist
11402 *
11403 * hHal
11404 * pSetHotListReq: extscan set hotlist structure
11405 * Return QDF_STATUS
11406 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011407QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 tSirExtScanResetBssidHotlistReqParams *
11409 pResetReq)
11410{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011411 QDF_STATUS status = QDF_STATUS_SUCCESS;
11412 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011414 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415
11416 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011417 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011418 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011419 message.bodyptr = pResetReq;
11420 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011421 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011422 NO_SESSION, message.type));
11423 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11424 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011425 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11426 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011427
11428 sme_release_global_lock(&pMac->sme);
11429 }
11430 return status;
11431}
11432
Manikandan Mohan80dea792016-04-28 16:36:48 -070011433/**
11434 * sme_send_wisa_params(): Pass WISA mode to WMA
11435 * @hal: HAL context
11436 * @wisa_params: pointer to WISA params struct
11437 * @sessionId: SME session id
11438 *
11439 * Pass WISA params to WMA
11440 *
11441 * Return: QDF_STATUS
11442 */
11443QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11444 struct sir_wisa_params *wisa_params)
11445{
11446 QDF_STATUS status = QDF_STATUS_SUCCESS;
11447 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011448 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011449 struct sir_wisa_params *cds_msg_wisa_params;
11450
11451 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11452 if (!cds_msg_wisa_params)
11453 return QDF_STATUS_E_NOMEM;
11454
11455 *cds_msg_wisa_params = *wisa_params;
11456 status = sme_acquire_global_lock(&mac->sme);
11457 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011458 message.bodyptr = cds_msg_wisa_params;
11459 message.type = WMA_SET_WISA_PARAMS;
11460 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011461 sme_release_global_lock(&mac->sme);
11462 }
11463 return status;
11464}
11465
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011466/*
11467 * sme_set_significant_change() -
11468 * SME API to set significant change
11469 *
11470 * hHal
11471 * pSetSignificantChangeReq: extscan set significant change structure
11472 * Return QDF_STATUS
11473 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011474QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011475 tSirExtScanSetSigChangeReqParams *
11476 pSetSignificantChangeReq)
11477{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011478 QDF_STATUS status = QDF_STATUS_SUCCESS;
11479 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011481 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011482
11483 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011484 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011485 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011486 message.bodyptr = pSetSignificantChangeReq;
11487 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011488 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011489 NO_SESSION, message.type));
11490 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11491 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011492 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11493 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494
11495 sme_release_global_lock(&pMac->sme);
11496 }
11497 return status;
11498}
11499
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011500/*
11501 * sme_reset_significant_change
11502 * SME API to reset significant change
11503 *
11504 * hHal
11505 * pResetReq: extscan reset significant change structure
11506 * Return QDF_STATUS
11507 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011508QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011509 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011510 *pResetReq)
11511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011512 QDF_STATUS status = QDF_STATUS_SUCCESS;
11513 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011514 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011515 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011516
11517 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011518 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011519 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011520 message.bodyptr = pResetReq;
11521 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011522 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011523 NO_SESSION, message.type));
11524 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11525 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011526 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11527 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011528
11529 sme_release_global_lock(&pMac->sme);
11530 }
11531 return status;
11532}
11533
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011534/*
11535 * sme_get_cached_results() -
11536 * SME API to get cached results
11537 *
11538 * hHal
11539 * pCachedResultsReq: extscan get cached results structure
11540 * Return QDF_STATUS
11541 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011542QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011543 tSirExtScanGetCachedResultsReqParams *
11544 pCachedResultsReq)
11545{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011546 QDF_STATUS status = QDF_STATUS_SUCCESS;
11547 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011548 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011549 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011550
11551 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011552 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011553 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011554 message.bodyptr = pCachedResultsReq;
11555 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011556 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011557 NO_SESSION, message.type));
11558 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11559 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011560 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11561 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011562
11563 sme_release_global_lock(&pMac->sme);
11564 }
11565 return status;
11566}
11567
11568/**
11569 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011570 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011571 * @input: request message
11572 *
11573 * This function constructs the cds message and fill in message type,
11574 * bodyptr with %input and posts it to WDA queue.
11575 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011576 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011577 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011578QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011579 struct wifi_epno_params *input)
11580{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011581 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011583 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011584 struct wifi_epno_params *req_msg;
11585 int len, i;
11586
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011587 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011588 len = sizeof(*req_msg) +
11589 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011590
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011591 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011592 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011593 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011594 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011595 }
11596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011597 req_msg->num_networks = input->num_networks;
11598 req_msg->request_id = input->request_id;
11599 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011600
11601 /* Fill only when num_networks are non zero */
11602 if (req_msg->num_networks) {
11603 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11604 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11605 req_msg->initial_score_max = input->initial_score_max;
11606 req_msg->same_network_bonus = input->same_network_bonus;
11607 req_msg->secure_bonus = input->secure_bonus;
11608 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11609 req_msg->current_connection_bonus =
11610 input->current_connection_bonus;
11611
11612 for (i = 0; i < req_msg->num_networks; i++) {
11613 req_msg->networks[i].flags = input->networks[i].flags;
11614 req_msg->networks[i].auth_bit_field =
11615 input->networks[i].auth_bit_field;
11616 req_msg->networks[i].ssid.length =
11617 input->networks[i].ssid.length;
11618 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11619 input->networks[i].ssid.ssId,
11620 req_msg->networks[i].ssid.length);
11621 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011622 }
11623
11624 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011625 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011626 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011627 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011628 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011629 return status;
11630 }
11631
11632 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011633 message.bodyptr = req_msg;
11634 message.type = WMA_SET_EPNO_LIST_REQ;
11635 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011636 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011637 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011638 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011639 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011640 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011641 }
11642 sme_release_global_lock(&mac->sme);
11643 return status;
11644}
11645
11646/**
11647 * sme_set_passpoint_list() - set passpoint network list
11648 * @hal: global hal handle
11649 * @input: request message
11650 *
11651 * This function constructs the cds message and fill in message type,
11652 * bodyptr with @input and posts it to WDA queue.
11653 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011654 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011655 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011656QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011657 struct wifi_passpoint_req *input)
11658{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011659 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011661 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011662 struct wifi_passpoint_req *req_msg;
11663 int len, i;
11664
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011665 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666 len = sizeof(*req_msg) +
11667 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011668 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011669 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011670 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011671 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011672 }
11673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674 req_msg->num_networks = input->num_networks;
11675 req_msg->request_id = input->request_id;
11676 req_msg->session_id = input->session_id;
11677 for (i = 0; i < req_msg->num_networks; i++) {
11678 req_msg->networks[i].id =
11679 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011680 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011681 input->networks[i].realm,
11682 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011683 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011684 input->networks[i].plmn,
11685 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011686 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 input->networks[i].roaming_consortium_ids,
11688 sizeof(req_msg->networks[i].roaming_consortium_ids));
11689 }
11690
11691 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011692 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011693 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011695 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011696 return status;
11697 }
11698
11699 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011700 message.bodyptr = req_msg;
11701 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11702 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011703 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011704 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011705 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011706 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011707 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011708 }
11709 sme_release_global_lock(&mac->sme);
11710 return status;
11711}
11712
11713/**
11714 * sme_reset_passpoint_list() - reset passpoint network list
11715 * @hHal: global hal handle
11716 * @input: request message
11717 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011718 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011719 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011720QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011721 struct wifi_passpoint_req *input)
11722{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011723 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011724 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011725 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 struct wifi_passpoint_req *req_msg;
11727
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011728 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011729 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011730 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011731 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011732 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 }
11734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735 req_msg->request_id = input->request_id;
11736 req_msg->session_id = input->session_id;
11737
11738 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011739 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011740 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011741 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011742 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743 return status;
11744 }
11745
11746 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011747 message.bodyptr = req_msg;
11748 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11749 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011750 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011751 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011752 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011753 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011754 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 }
11756 sme_release_global_lock(&mac->sme);
11757 return status;
11758}
11759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011760QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011761 void (*pExtScanIndCb)(void *,
11762 const uint16_t,
11763 void *))
11764{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011765 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11767
11768 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011769 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011770 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11771 sme_release_global_lock(&pMac->sme);
11772 }
11773 return status;
11774}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011775#endif /* FEATURE_WLAN_EXTSCAN */
11776
11777#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11778
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011779/*
11780 * sme_ll_stats_clear_req() -
11781 * SME API to clear Link Layer Statistics
11782 *
11783 * hHal
11784 * pclearStatsReq: Link Layer clear stats request params structure
11785 * Return QDF_STATUS
11786 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011787QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011788 tSirLLStatsClearReq *pclearStatsReq)
11789{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011790 QDF_STATUS status = QDF_STATUS_SUCCESS;
11791 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011792 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011793 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 tSirLLStatsClearReq *clear_stats_req;
11795
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011799 "statsClearReqMask = 0x%X",
11800 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011801 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011803 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11804 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11805 "%s: invalid staId %d",
11806 __func__, pclearStatsReq->staId);
11807 return QDF_STATUS_E_INVAL;
11808 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011810 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811
11812 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011814 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11815 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011816 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011817 }
11818
11819 *clear_stats_req = *pclearStatsReq;
11820
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011821 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011822 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011823 message.bodyptr = clear_stats_req;
11824 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011825 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011826 NO_SESSION, message.type));
11827 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11828 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011829 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011830 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011831 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11832 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011833 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011834 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011835 }
11836 sme_release_global_lock(&pMac->sme);
11837 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011838 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11839 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011840 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011841 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011842 }
11843
11844 return status;
11845}
11846
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011847/*
11848 * sme_ll_stats_set_req() -
11849 * SME API to set the Link Layer Statistics
11850 *
11851 * hHal
11852 * psetStatsReq: Link Layer set stats request params structure
11853 * Return QDF_STATUS
11854 */
11855QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11856 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011858 QDF_STATUS status = QDF_STATUS_SUCCESS;
11859 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011860 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011861 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011862 tSirLLStatsSetReq *set_stats_req;
11863
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011864 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011865 "%s: MPDU Size = %u", __func__,
11866 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011867 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 " Aggressive Stats Collections = %u",
11869 psetStatsReq->aggressiveStatisticsGathering);
11870
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011871 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011872
11873 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011874 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011875 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11876 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011877 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011878 }
11879
11880 *set_stats_req = *psetStatsReq;
11881
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011882 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011884 message.bodyptr = set_stats_req;
11885 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011886 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011887 NO_SESSION, message.type));
11888 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11889 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011890 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011891 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011892 "%s: not able to post WMA_LL_STATS_SET_REQ",
11893 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011894 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011895 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896 }
11897 sme_release_global_lock(&pMac->sme);
11898 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011899 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11900 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011901 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011902 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011903 }
11904
11905 return status;
11906}
11907
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011908/*
11909 * sme_ll_stats_get_req() -
11910 * SME API to get the Link Layer Statistics
11911 *
11912 * hHal
11913 * pgetStatsReq: Link Layer get stats request params structure
11914 * Return QDF_STATUS
11915 */
11916QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
11917 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011918{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011919 QDF_STATUS status = QDF_STATUS_SUCCESS;
11920 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011922 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011923 tSirLLStatsGetReq *get_stats_req;
11924
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011925 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011926
11927 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011928 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011929 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
11930 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011931 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011932 }
11933
11934 *get_stats_req = *pgetStatsReq;
11935
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011936 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011938 message.bodyptr = get_stats_req;
11939 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011940 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011941 NO_SESSION, message.type));
11942 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11943 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011944 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011945 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011946 "%s: not able to post WMA_LL_STATS_GET_REQ",
11947 __func__);
11948
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011949 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011950 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011951
11952 }
11953 sme_release_global_lock(&pMac->sme);
11954 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011955 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11956 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011957 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011958 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011959 }
11960
11961 return status;
11962}
11963
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011964/*
11965 * sme_set_link_layer_stats_ind_cb() -
11966 * SME API to trigger the stats are available after get request
11967 *
11968 * hHal
11969 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011970 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011971 * Return QDF_STATUS
11972 */
11973QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
11974 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
11975{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011976 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011977 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11978
11979 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011980 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011981 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
11982 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011983 } else
11984 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11985 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011986
11987 return status;
11988}
11989
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011990/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080011991 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
11992 * @hal: Mac global handle
11993 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
11994 * status notification from FW
11995 *
11996 * Return: eHalStatus
11997 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011998QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
11999 (tHddHandle callback_ctx, tSirLLStatsResults
12000 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012001{
12002 QDF_STATUS status;
12003 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12004
12005 status = sme_acquire_global_lock(&mac->sme);
12006 if (status == QDF_STATUS_SUCCESS) {
12007 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12008 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012009 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12011 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012012 return status;
12013}
12014
12015/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012016 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12017 * indication
12018 * @h_hal: Hal Handle
12019 *
12020 * This function reset's the link layer stats indication
12021 *
12022 * Return: QDF_STATUS Enumeration
12023 */
12024
12025QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12026{
12027 QDF_STATUS status;
12028 tpAniSirGlobal pmac;
12029
12030 if (!h_hal) {
12031 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12032 FL("hHal is not valid"));
12033 return QDF_STATUS_E_INVAL;
12034 }
12035 pmac = PMAC_STRUCT(h_hal);
12036
12037 status = sme_acquire_global_lock(&pmac->sme);
12038 if (QDF_IS_STATUS_SUCCESS(status)) {
12039 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12040 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012041 } else
12042 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12043 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012044
12045 return status;
12046}
12047
Zhang Qian73c348a2017-03-13 16:15:55 +080012048/**
12049 * sme_ll_stats_set_thresh - set threshold for mac counters
12050 * @hal, hal layer handle
12051 * @threshold, threshold for mac counters
12052 *
12053 * Return: QDF_STATUS Enumeration
12054 */
12055QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12056 struct sir_ll_ext_stats_threshold *threshold)
12057{
12058 QDF_STATUS status;
12059 tpAniSirGlobal mac;
12060 struct scheduler_msg message;
12061 struct sir_ll_ext_stats_threshold *thresh;
12062
12063 if (!threshold) {
12064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12065 FL("threshold is not valid"));
12066 return QDF_STATUS_E_INVAL;
12067 }
12068
12069 if (!hal) {
12070 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12071 FL("hal is not valid"));
12072 return QDF_STATUS_E_INVAL;
12073 }
12074 mac = PMAC_STRUCT(hal);
12075
12076 thresh = qdf_mem_malloc(sizeof(*thresh));
12077 if (!thresh) {
12078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12079 "%s: Fail to alloc mem", __func__);
12080 return QDF_STATUS_E_NOMEM;
12081 }
12082 *thresh = *threshold;
12083
12084 status = sme_acquire_global_lock(&mac->sme);
12085 if (QDF_IS_STATUS_SUCCESS(status)) {
12086 /* Serialize the req through MC thread */
12087 message.bodyptr = thresh;
12088 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12089 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12090 NO_SESSION, message.type));
12091 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12092 if (!QDF_IS_STATUS_SUCCESS(status)) {
12093 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12094 "%s: not able to post WDA_LL_STATS_GET_REQ",
12095 __func__);
12096 qdf_mem_free(thresh);
12097 }
12098 sme_release_global_lock(&mac->sme);
12099 } else {
12100 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12101 FL("sme_acquire_global_lock error"));
12102 qdf_mem_free(thresh);
12103 }
12104 return status;
12105}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012107#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12108
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012109#ifdef WLAN_POWER_DEBUGFS
12110/**
12111 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12112 * @callback_fn: Pointer to the callback function for Power stats event
12113 * @power_stats_context: Pointer to context
12114 *
12115 * Return: QDF_STATUS
12116 */
12117QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12118 (struct power_stats_response *response,
12119 void *context), void *power_stats_context)
12120{
12121 QDF_STATUS status = QDF_STATUS_SUCCESS;
12122 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012123 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012124
12125 status = sme_acquire_global_lock(&mac_ctx->sme);
12126 if (QDF_IS_STATUS_SUCCESS(status)) {
12127 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012128 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012129 sme_release_global_lock(&mac_ctx->sme);
12130 return QDF_STATUS_E_FAILURE;
12131 }
12132
12133 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12134 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12135 msg.bodyptr = NULL;
12136 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012137 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012138 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012139 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012140 sme_release_global_lock(&mac_ctx->sme);
12141 }
12142 return status;
12143}
12144#endif
12145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012146/**
12147 * sme_fw_mem_dump_register_cb() - Register fw memory dump callback
12148 *
12149 * @hal - MAC global handle
12150 * @callback_routine - callback routine from HDD
12151 *
12152 * This API is invoked by HDD to register its callback in SME
12153 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012154 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012155 */
12156#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012157QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 void (*callback_routine)(void *cb_context,
12159 struct fw_dump_rsp *rsp))
12160{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012161 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012162 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12163
12164 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012165 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166 pmac->sme.fw_dump_callback = callback_routine;
12167 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012168 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012170 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012171
12172 return status;
12173}
12174#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012175QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012176 void (*callback_routine)(void *cb_context,
12177 struct fw_dump_rsp *rsp))
12178{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012179 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012180}
12181#endif /* WLAN_FEATURE_MEMDUMP */
12182
12183/**
12184 * sme_fw_mem_dump_unregister_cb() - Unregister fw memory dump callback
12185 *
12186 * @hHal - MAC global handle
12187 *
12188 * This API is invoked by HDD to unregister its callback in SME
12189 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012190 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012191 */
12192#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012193QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012194{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012195 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012196 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12197
12198 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012199 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012200 pmac->sme.fw_dump_callback = NULL;
12201 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012202 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012203 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012204 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012205
12206 return status;
12207}
12208#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012209QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012210{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012211 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012212}
12213#endif /* WLAN_FEATURE_MEMDUMP */
12214
12215#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012216/*
12217 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12218 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12219 *
12220 * hHal - The handle returned by mac_open.
12221 * nRoamOffloadEnabled - The bool to update with
12222 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12223 * Other status means SME is failed to update.
12224 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012225
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012226QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012227 bool nRoamOffloadEnabled)
12228{
12229 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012230 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012231
12232 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012233 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012234 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012235 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12236 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12237 nRoamOffloadEnabled);
12238 pMac->roam.configParam.isRoamOffloadEnabled =
12239 nRoamOffloadEnabled;
12240 sme_release_global_lock(&pMac->sme);
12241 }
12242
12243 return status;
12244}
12245
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012246/**
12247 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12248 * This is a synchronous call
12249 * @hal_ctx: The handle returned by mac_open.
12250 * @session_id: Session Identifier
12251 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012252 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012253 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12254 * Other status means SME is failed to update.
12255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012256
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012257QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012258 uint8_t session_id,
12259 bool key_mgmt_offload_enabled,
12260 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012261{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012262 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012263 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012265 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012266 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012267 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012268 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012269 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12270 __func__, key_mgmt_offload_enabled);
12271 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12272 session_id,
12273 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012274 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012275 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012276 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012277 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012278 }
12279
12280 return status;
12281}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012282#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012283
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012284/*
12285 * sme_get_temperature() -
12286 * SME API to get the pdev temperature
12287 *
12288 * hHal
12289 * temperature context
12290 * pCallbackfn: callback fn with response (temperature)
12291 * Return QDF_STATUS
12292 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012293QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012294 void *tempContext,
12295 void (*pCallbackfn)(int temperature,
12296 void *pContext))
12297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012298 QDF_STATUS status = QDF_STATUS_SUCCESS;
12299 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012300 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012301 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012302
12303 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012304 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012305 if ((NULL == pCallbackfn) &&
12306 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012308 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012309 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012311 } else if (NULL != pCallbackfn) {
12312 pMac->sme.pTemperatureCbContext = tempContext;
12313 pMac->sme.pGetTemperatureCb = pCallbackfn;
12314 }
12315 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012316 message.bodyptr = NULL;
12317 message.type = WMA_GET_TEMPERATURE_REQ;
12318 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12319 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012320 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012322 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012323 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012324 }
12325 sme_release_global_lock(&pMac->sme);
12326 }
12327 return status;
12328}
12329
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012330/*
12331 * sme_set_scanning_mac_oui() -
12332 * SME API to set scanning mac oui
12333 *
12334 * hHal
12335 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12336 * Return QDF_STATUS
12337 */
12338QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12339 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012341 QDF_STATUS status = QDF_STATUS_SUCCESS;
12342 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012343 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012344 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012345
12346 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012347 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012348 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012349 message.bodyptr = pScanMacOui;
12350 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12351 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12352 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012353 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012354 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012355 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012356 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012357 }
12358 sme_release_global_lock(&pMac->sme);
12359 }
12360 return status;
12361}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012362
12363#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012364/*
12365 * sme_set_dhcp_srv_offload() -
12366 * SME API to set DHCP server offload info
12367 *
12368 * hHal
12369 * pDhcpSrvInfo : DHCP server offload info struct
12370 * Return QDF_STATUS
12371 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012372QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012373 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12374{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012375 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012376 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012377 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012378 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12379
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012380 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381
12382 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012383 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012384 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12385 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012386 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012387 }
12388
12389 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12390
12391 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012392 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012393 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012394 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12395 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012396
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012397 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012398 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12399 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012400 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012401 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012402 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012403 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012404 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012405 }
12406 sme_release_global_lock(&pMac->sme);
12407 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012408 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012409 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012410 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012411 }
12412
12413 return status;
12414}
12415#endif /* DHCP_SERVER_OFFLOAD */
12416
Krunal Soniaadaa272017-10-04 16:42:55 -070012417QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12418 uint32_t arg_count, uint32_t *arg)
12419{
12420 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12421 arg_count, arg);
12422}
12423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012424#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012425/*
12426 * sme_set_led_flashing() -
12427 * API to set the Led flashing parameters.
12428 *
12429 * hHal - The handle returned by mac_open.
12430 * x0, x1 - led flashing parameters
12431 * Return QDF_STATUS
12432 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012433QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012434 uint32_t x0, uint32_t x1)
12435{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012436 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012437 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012438 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012439 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012441 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012442 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012444 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012445 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012446 }
12447
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012448 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012449 ledflashing->pattern_id = type;
12450 ledflashing->led_x0 = x0;
12451 ledflashing->led_x1 = x1;
12452
12453 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012454 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012455 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012456 message.bodyptr = ledflashing;
12457 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012458 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 sme_release_global_lock(&pMac->sme);
12460 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012461 if (!QDF_IS_STATUS_SUCCESS(status))
12462 qdf_mem_free(ledflashing);
12463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 return status;
12465}
12466#endif
12467
12468/**
12469 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12470 * @h_hal: corestack handler
12471 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012472 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012474QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012475{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012476 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012477 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12478
12479 status = sme_acquire_global_lock(&mac->sme);
12480
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012481 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012482
12483 mac->scan.fEnableDFSChnlScan = dfs_flag;
12484
12485 /* update the channel list to the firmware */
12486 status = csr_update_channel_list(mac);
12487
12488 sme_release_global_lock(&mac->sme);
12489 }
12490
12491 return status;
12492}
12493
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012494#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12495/**
12496 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12497 * concurreny rules set to avoid channel interference.
12498 * @hal - Hal context
12499 * @sap_ch - channel to switch
12500 * @sap_phy_mode - phy mode of SAP
12501 * @cc_switch_mode - concurreny switch mode
12502 * @session_id - sme session id.
12503 *
12504 * Return: true if there is no channel interference else return false
12505 */
12506bool sme_validate_sap_channel_switch(tHalHandle hal,
12507 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12508 uint8_t session_id)
12509{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012510 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012511 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012512 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012513 uint16_t intf_channel = 0;
12514
12515 if (!session)
12516 return false;
12517
12518 session->ch_switch_in_progress = true;
12519 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012520 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012521 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12522 sap_phy_mode,
12523 cc_switch_mode);
12524 sme_release_global_lock(&mac->sme);
12525 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012527 FL("sme_acquire_global_lock error!"));
12528 session->ch_switch_in_progress = false;
12529 return false;
12530 }
12531
12532 session->ch_switch_in_progress = false;
12533 return (intf_channel == 0) ? true : false;
12534}
12535#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536
12537/**
12538 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12539 * @hal: hal
12540 * @session_id: session ID
12541 * @stats_avg_factor: average stats factor
12542 *
12543 * This function configures the stats avg factor in firmware
12544 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012545 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012546 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012547QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012548 uint16_t stats_avg_factor)
12549{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012550 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012551 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12553 struct sir_stats_avg_factor *stats_factor;
12554
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012555 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012556
12557 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012558 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012559 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12560 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012561 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562 }
12563
12564 status = sme_acquire_global_lock(&mac->sme);
12565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012566 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012567
12568 stats_factor->vdev_id = session_id;
12569 stats_factor->stats_avg_factor = stats_avg_factor;
12570
12571 /* serialize the req through MC thread */
12572 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12573 msg.bodyptr = stats_factor;
12574
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012575 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012576 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012577 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012578 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12579 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012580 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012581 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012582 }
12583 sme_release_global_lock(&mac->sme);
12584 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012585 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012586 "%s: sme_acquire_global_lock error!",
12587 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012588 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589 }
12590
12591 return status;
12592}
12593
12594/**
12595 * sme_configure_guard_time() - function to configure guard time
12596 * @hal: hal
12597 * @session_id: session id
12598 * @guard_time: guard time
12599 *
12600 * This function configures the guard time in firmware
12601 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012602 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012603 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012604QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012605 uint32_t guard_time)
12606{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012607 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012608 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012609 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12610 struct sir_guard_time_request *g_time;
12611
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012612 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012613
12614 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012615 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012616 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12617 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012618 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619 }
12620
12621 status = sme_acquire_global_lock(&mac->sme);
12622
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012623 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012624
12625 g_time->vdev_id = session_id;
12626 g_time->guard_time = guard_time;
12627
12628 /* serialize the req through MC thread */
12629 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12630 msg.bodyptr = g_time;
12631
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012632 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012633 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012634 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012635 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12636 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012637 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012638 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012639 }
12640 sme_release_global_lock(&mac->sme);
12641 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012643 "%s: sme_acquire_global_lock error!",
12644 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012645 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012646 }
12647
12648 return status;
12649}
12650
12651/**
12652 * sme_configure_modulated_dtim() - function to configure modulated dtim
12653 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12654 * @session_id: session ID
12655 * @modulated_dtim: modulated dtim value
12656 *
12657 * This function configures the modulated dtim in firmware
12658 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012659 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012661QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012662 uint32_t modulated_dtim)
12663{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012664 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012665 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012666 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12667 wma_cli_set_cmd_t *iwcmd;
12668
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012669 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012670 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012671 QDF_TRACE(QDF_MODULE_ID_SME,
12672 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012673 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012674 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012675 }
12676
12677 status = sme_acquire_global_lock(&mac->sme);
12678
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012679 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012681 iwcmd->param_value = modulated_dtim;
12682 iwcmd->param_vdev_id = session_id;
12683 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12684 iwcmd->param_vp_dev = GEN_CMD;
12685 msg.type = WMA_CLI_SET_CMD;
12686 msg.reserved = 0;
12687 msg.bodyptr = (void *)iwcmd;
12688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012689 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012690 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012691 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012692 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12693 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012694 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012695 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012696 }
12697 sme_release_global_lock(&mac->sme);
12698 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012699 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012700 "%s: sme_acquire_global_lock error!",
12701 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012702 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012703 }
12704
12705 return status;
12706}
12707
Mukul Sharma6398b252017-05-01 17:58:12 +053012708/**
12709 * sme_override_listen_interval() - function to override static LI
12710 * @h_hal: SME API to override listen interval
12711 * @session_id: session ID
12712 * @override_li: new LI value passed by user
12713 *
12714 * This function override (enable/disable) static a.k.a ini based LI
12715 *
12716 * Return: QDF_STATUS
12717 */
12718QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12719 uint32_t override_li)
12720{
12721 struct scheduler_msg msg = {0};
12722 QDF_STATUS status = QDF_STATUS_SUCCESS;
12723 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12724 wma_cli_set_cmd_t *iwcmd;
12725
12726 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12727 if (!iwcmd) {
12728 QDF_TRACE(QDF_MODULE_ID_SME,
12729 QDF_TRACE_LEVEL_FATAL,
12730 "%s: qdf_mem_malloc failed", __func__);
12731 return QDF_STATUS_E_NOMEM;
12732 }
12733
12734 status = sme_acquire_global_lock(&mac->sme);
12735
12736 if (status == QDF_STATUS_SUCCESS) {
12737
12738 iwcmd->param_value = override_li;
12739 iwcmd->param_vdev_id = session_id;
12740 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12741 iwcmd->param_vp_dev = GEN_CMD;
12742 msg.type = WMA_CLI_SET_CMD;
12743 msg.reserved = 0;
12744 msg.bodyptr = (void *)iwcmd;
12745
12746 if (!QDF_IS_STATUS_SUCCESS(
12747 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12748 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12749 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12750 __func__);
12751 qdf_mem_free(iwcmd);
12752 status = QDF_STATUS_E_FAILURE;
12753 }
12754 sme_release_global_lock(&mac->sme);
12755 } else {
12756 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12757 "%s: sme_acquire_global_lock error!",
12758 __func__);
12759 qdf_mem_free(iwcmd);
12760 }
12761
12762 return status;
12763}
12764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012765/*
12766 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12767 * to either start/stop logging
12768 * @hal: HAL context
12769 * @start_log: Structure containing the wifi start logger params
12770 *
12771 * This function sends the start/stop logging command to WMA
12772 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012773 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012774 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012775QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012776 struct sir_wifi_start_log start_log)
12777{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012778 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012779 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012780 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012781 struct sir_wifi_start_log *req_msg;
12782 uint32_t len;
12783
12784 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012785 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012787 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012788 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012789 }
12790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012791 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012792 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012793 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012794 req_msg->ini_triggered = start_log.ini_triggered;
12795 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012796 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012797 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012798
12799 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012800 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012801 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012802 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012803 return status;
12804 }
12805
12806 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012807 message.bodyptr = req_msg;
12808 message.type = SIR_HAL_START_STOP_LOGGING;
12809 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012810 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012811 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012812 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012813 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012814 }
12815 sme_release_global_lock(&mac->sme);
12816
12817 return status;
12818}
12819
12820/**
12821 * sme_neighbor_middle_of_roaming() - Function to know if
12822 * STA is in the middle of roaming states
12823 * @hal: Handle returned by macOpen
12824 * @sessionId: sessionId of the STA session
12825 *
12826 * This function is a wrapper to call
12827 * csr_neighbor_middle_of_roaming to know STA is in the
12828 * middle of roaming states
12829 *
12830 * Return: True or False
12831 *
12832 */
12833bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12834{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012835 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12836 bool val = false;
12837
12838 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12839 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12840 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012841 sme_err("Invalid Session: %d", sessionId);
12842
Sandeep Puligillaca631612016-11-08 11:53:52 -080012843 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012844}
12845
12846/*
12847 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12848 * @mac: MAC handle
12849 *
12850 * This function is used to send the command that will
12851 * be used to flush the logs in the firmware
12852 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012853 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012854 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012855QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012856{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012857 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012858 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012860 /* Serialize the req through MC thread */
12861 message.bodyptr = NULL;
12862 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012863 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012864 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012865 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012866 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012867 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012868 return status;
12869}
12870
Jeff Johnsona1e92612017-09-24 15:33:44 -070012871QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012872 sme_ac_enum_type ac, uint8_t tid,
12873 uint8_t pri, uint32_t srvc_int,
12874 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012875 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012876 uint8_t psb, uint32_t sessionId,
12877 uint32_t delay_interval)
12878{
12879 void *wma_handle;
12880 t_wma_trigger_uapsd_params uapsd_params;
12881 enum uapsd_ac access_category;
12882
12883 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012884 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012885 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012886 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012887 }
12888
Anurag Chouhan6d760662016-02-20 16:05:43 +053012889 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012890 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012891 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012892 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012893 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012894 }
12895
12896 switch (ac) {
12897 case SME_AC_BK:
12898 access_category = UAPSD_BK;
12899 break;
12900 case SME_AC_BE:
12901 access_category = UAPSD_BE;
12902 break;
12903 case SME_AC_VI:
12904 access_category = UAPSD_VI;
12905 break;
12906 case SME_AC_VO:
12907 access_category = UAPSD_VO;
12908 break;
12909 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012910 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012911 }
12912
12913 uapsd_params.wmm_ac = access_category;
12914 uapsd_params.user_priority = pri;
12915 uapsd_params.service_interval = srvc_int;
12916 uapsd_params.delay_interval = delay_interval;
12917 uapsd_params.suspend_interval = sus_int;
12918
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012919 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012920 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012921 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012922 "Failed to Trigger Uapsd params for sessionId %d",
12923 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012924 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012925 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012926 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012927}
12928
Jeff Johnsona1e92612017-09-24 15:33:44 -070012929QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012930 sme_ac_enum_type ac,
12931 uint32_t sessionId)
12932{
12933 void *wma_handle;
12934 enum uapsd_ac access_category;
12935
12936 switch (ac) {
12937 case SME_AC_BK:
12938 access_category = UAPSD_BK;
12939 break;
12940 case SME_AC_BE:
12941 access_category = UAPSD_BE;
12942 break;
12943 case SME_AC_VI:
12944 access_category = UAPSD_VI;
12945 break;
12946 case SME_AC_VO:
12947 access_category = UAPSD_VO;
12948 break;
12949 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012950 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012951 }
12952
Anurag Chouhan6d760662016-02-20 16:05:43 +053012953 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012954 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012955 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012956 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012957 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012958 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012959 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012960 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012961 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012962 "Failed to disable uapsd for ac %d for sessionId %d",
12963 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012965 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012966 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012967}
12968
12969/**
12970 * sme_update_nss() - SME API to change the number for spatial streams
12971 * (1 or 2)
12972 * @hal: Handle returned by mac open
12973 * @nss: Number of spatial streams
12974 *
12975 * This function is used to update the number of spatial streams supported.
12976 *
12977 * Return: Success upon successfully changing nss else failure
12978 *
12979 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012980QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012981{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012982 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012983 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
12984 uint32_t i, value = 0;
12985 union {
12986 uint16_t cfg_value16;
12987 tSirMacHTCapabilityInfo ht_cap_info;
12988 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012989 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012990
12991 status = sme_acquire_global_lock(&mac_ctx->sme);
12992
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012993 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012994 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
12995
12996 /* get the HT capability info*/
12997 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
12998 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
12999
13000 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13001 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13002 csr_session = &mac_ctx->roam.roamSession[i];
13003 csr_session->htConfig.ht_tx_stbc =
13004 uHTCapabilityInfo.ht_cap_info.txSTBC;
13005 }
13006 }
13007
13008 sme_release_global_lock(&mac_ctx->sme);
13009 }
13010 return status;
13011}
13012
13013/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013014 * sme_update_user_configured_nss() - sets the nss based on user request
13015 * @hal: Pointer to HAL
13016 * @nss: number of streams
13017 *
13018 * Return: None
13019 */
13020void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13021{
13022 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13023
13024 mac_ctx->user_configured_nss = nss;
13025}
13026
13027/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013028 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13029 * @hal: global hal handle
13030 * @cb: callback function pointer
13031 *
13032 * This function stores nud debug stats callback function.
13033 *
13034 * Return: QDF_STATUS enumeration.
13035 */
13036QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13037 void (*cb)(void *, struct rsp_stats *))
13038{
13039 QDF_STATUS status = QDF_STATUS_SUCCESS;
13040 tpAniSirGlobal mac;
13041
13042 if (!hal) {
13043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13044 FL("hal is not valid"));
13045 return QDF_STATUS_E_INVAL;
13046 }
13047 mac = PMAC_STRUCT(hal);
13048
13049 status = sme_acquire_global_lock(&mac->sme);
13050 if (!QDF_IS_STATUS_SUCCESS(status)) {
13051 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13052 FL("sme_acquire_global_lock failed!(status=%d)"),
13053 status);
13054 return status;
13055 }
13056
13057 mac->sme.get_arp_stats_cb = cb;
13058 sme_release_global_lock(&mac->sme);
13059 return status;
13060}
13061
13062/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013063 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013064 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013065 * @cb: callback function pointer
13066 *
13067 * This function stores the rssi threshold breached callback function.
13068 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013069 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013070 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013071QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013072 void (*cb)(void *, struct rssi_breach_event *))
13073{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013074 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013075 tpAniSirGlobal mac;
13076
13077 if (!h_hal) {
13078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13079 FL("hHal is not valid"));
13080 return QDF_STATUS_E_INVAL;
13081 }
13082 mac = PMAC_STRUCT(h_hal);
13083
13084 status = sme_acquire_global_lock(&mac->sme);
13085 if (!QDF_IS_STATUS_SUCCESS(status)) {
13086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13087 FL("sme_acquire_global_lock failed!(status=%d)"),
13088 status);
13089 return status;
13090 }
13091
13092 mac->sme.rssi_threshold_breached_cb = cb;
13093 sme_release_global_lock(&mac->sme);
13094 return status;
13095}
13096
13097/**
13098 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13099 * @hal: global hal handle
13100 *
13101 * This function de-registers the rssi threshold breached callback function.
13102 *
13103 * Return: QDF_STATUS enumeration.
13104 */
13105QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13106{
13107 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013108 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13109
13110 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013111 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013112 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013113 return status;
13114 }
13115
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013116 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013117 sme_release_global_lock(&mac->sme);
13118 return status;
13119}
13120
13121/**
13122 * sme_is_any_session_in_connected_state() - SME wrapper API to
13123 * check if any session is in connected state or not.
13124 *
13125 * @hal: Handle returned by mac open
13126 *
13127 * This function is used to check if any valid sme session is in
13128 * connected state or not.
13129 *
13130 * Return: true if any session is connected, else false.
13131 *
13132 */
13133bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13134{
13135 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013136 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013137 bool ret = false;
13138
13139 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013140 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013141 ret = csr_is_any_session_in_connect_state(mac_ctx);
13142 sme_release_global_lock(&mac_ctx->sme);
13143 }
13144 return ret;
13145}
13146
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013147QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13148 void (*cb)(void *,
13149 struct chip_pwr_save_fail_detected_params *)) {
13150
13151 QDF_STATUS status = QDF_STATUS_SUCCESS;
13152 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13153
13154 status = sme_acquire_global_lock(&mac->sme);
13155 if (status != QDF_STATUS_SUCCESS) {
13156 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13157 return status;
13158 }
13159 mac->sme.chip_power_save_fail_cb = cb;
13160 sme_release_global_lock(&mac->sme);
13161 return status;
13162}
13163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013164/**
13165 * sme_set_rssi_monitoring() - set rssi monitoring
13166 * @hal: global hal handle
13167 * @input: request message
13168 *
13169 * This function constructs the vos message and fill in message type,
13170 * bodyptr with @input and posts it to WDA queue.
13171 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013172 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013173 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013174QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013175 struct rssi_monitor_req *input)
13176{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013177 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013178 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013179 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013180 struct rssi_monitor_req *req_msg;
13181
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013182 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013183 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013184 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013185 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013186 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 }
13188
13189 *req_msg = *input;
13190
13191 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013192 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013193 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013194 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013195 return status;
13196 }
13197
13198 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013199 message.bodyptr = req_msg;
13200 message.type = WMA_SET_RSSI_MONITOR_REQ;
13201 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013202 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013203 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013204 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013205 }
13206 sme_release_global_lock(&mac->sme);
13207
13208 return status;
13209}
13210
13211/**
13212 * sme_fw_mem_dump() - Get FW memory dump
13213 * @hHal: hal handle
13214 * @recvd_req: received memory dump request.
13215 *
13216 * This API is invoked by HDD to indicate FW to start
13217 * dumping firmware memory.
13218 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013219 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013220 */
13221#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013222QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013224 QDF_STATUS status = QDF_STATUS_SUCCESS;
13225 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013226 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013227 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013228 struct fw_dump_req *send_req;
13229 struct fw_dump_seg_req seg_req;
13230 int loop;
13231
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013232 send_req = qdf_mem_malloc(sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013233 if (!send_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013234 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013235 FL("Memory allocation failed for WDA_FW_MEM_DUMP"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013236 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013237 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013238 qdf_mem_copy(send_req, recvd_req, sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013239
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013240 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013241 FL("request_id:%d num_seg:%d"),
13242 send_req->request_id, send_req->num_seg);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013243 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013244 FL("Segment Information"));
13245 for (loop = 0; loop < send_req->num_seg; loop++) {
13246 seg_req = send_req->segment[loop];
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013247 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013248 FL("seg_number:%d"), loop);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013249 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013250 FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
13251 seg_req.seg_id, seg_req.seg_start_addr_lo,
13252 seg_req.seg_start_addr_hi);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013253 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013254 FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
13255 seg_req.seg_length, seg_req.dst_addr_lo,
13256 seg_req.dst_addr_hi);
13257 }
13258
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013259 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013260 msg.bodyptr = send_req;
13261 msg.type = WMA_FW_MEM_DUMP_REQ;
13262 msg.reserved = 0;
13263
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013264 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013265 if (QDF_STATUS_SUCCESS != qdf_status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013266 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013267 FL("Not able to post WMA_FW_MEM_DUMP"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013268 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013269 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013270 }
13271 sme_release_global_lock(&pMac->sme);
13272 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013273 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013274 FL("Failed to acquire SME Global Lock"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013275 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013276 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277 }
13278
13279 return status;
13280}
13281#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013282QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013283{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013284 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013285}
13286#endif /* WLAN_FEATURE_MEMDUMP */
13287
13288/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013289 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290 * @hal: Handle returned by macOpen
13291 * @msg: PCL channel list and length structure
13292 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013293 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013294 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013295 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013296QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013298 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013299 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013300 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013301 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013302 uint32_t len, i;
13303
13304 len = sizeof(*req_msg);
13305
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013306 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013307 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013308 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013309 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013310 }
13311
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013312 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013313 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013314 req_msg->weight_list[i] = msg.weight_list[i];
13315 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013316
13317 req_msg->pcl_len = msg.pcl_len;
13318
13319 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013320 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013321 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013322 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013323 return status;
13324 }
13325
13326 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013327 message.bodyptr = req_msg;
13328 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13329 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013330 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013331 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013332 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013333 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013334 }
13335 sme_release_global_lock(&mac->sme);
13336
13337 return status;
13338}
13339
13340/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013341 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013342 * @hal: Handle returned by macOpen
13343 * @msg: HW mode structure containing hw mode and callback details
13344 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013345 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013346 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013347 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013348QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013349{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013351 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013352 tSmeCmd *cmd = NULL;
13353
13354 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013355 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013356 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013357 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013358 }
13359
Krunal Soni78618d92017-02-14 21:46:31 -080013360 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013362 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013363 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013364 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013365 }
13366
13367 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013368 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013369 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13370 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013371 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13372 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013373 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013374 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013375
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013376 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013377 cmd->u.set_hw_mode_cmd.session_id,
13378 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013379 csr_queue_sme_command(mac, cmd, false);
13380
13381 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013382 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013383}
13384
13385/**
13386 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13387 * @hal: Handle returned by macOpen
13388 * @callback: HDD callback to be registered
13389 *
13390 * Registers the HDD callback with SME. This callback will be invoked when
13391 * HW mode transition event is received from the FW
13392 *
13393 * Return: None
13394 */
13395void sme_register_hw_mode_trans_cb(tHalHandle hal,
13396 hw_mode_transition_cb callback)
13397{
13398 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13399
13400 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013401}
13402
13403/**
13404 * sme_nss_update_request() - Send beacon templete update to FW with new
13405 * nss value
13406 * @hal: Handle returned by macOpen
13407 * @vdev_id: the session id
13408 * @new_nss: the new nss value
13409 * @cback: hdd callback
13410 * @next_action: next action to happen at policy mgr after beacon update
13411 *
13412 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013413 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013414 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013415QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13416 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13417 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13418 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013419{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013420 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013421 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013422 tSmeCmd *cmd = NULL;
13423
13424 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013425 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013426 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013427 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013428 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013430 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013431 }
13432 cmd->command = e_sme_command_nss_update;
13433 /* Sessionized modules may require this info */
13434 cmd->sessionId = vdev_id;
13435 cmd->u.nss_update_cmd.new_nss = new_nss;
13436 cmd->u.nss_update_cmd.session_id = vdev_id;
13437 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013438 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013439 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013440 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013441
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013442 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013443 csr_queue_sme_command(mac, cmd, false);
13444 sme_release_global_lock(&mac->sme);
13445 }
13446 return status;
13447}
13448
13449/**
13450 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13451 * @hal: Handle returned by macOpen
13452 * @msg: Structure containing the dual mac config parameters
13453 *
13454 * Queues configuration information to CSR to configure
13455 * WLAN firmware for the dual MAC features
13456 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013457 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013458 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013459QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013461 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013462 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013463 tSmeCmd *cmd;
13464
13465 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013466 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013467 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013468 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013469 }
13470
Krunal Soni78618d92017-02-14 21:46:31 -080013471 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013472 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013473 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013474 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013475 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013476 }
13477
13478 cmd->command = e_sme_command_set_dual_mac_config;
13479 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13480 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13481 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13482
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013483 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013484 cmd->u.set_dual_mac_cmd.scan_config,
13485 cmd->u.set_dual_mac_cmd.fw_mode_config);
13486 csr_queue_sme_command(mac, cmd, false);
13487
13488 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013489 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013490}
13491
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013492#ifdef FEATURE_LFR_SUBNET_DETECTION
13493/**
13494 * sme_gateway_param_update() - to update gateway parameters with WMA
13495 * @Hal: hal handle
13496 * @gw_params: request parameters from HDD
13497 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013498 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013499 *
13500 * This routine will update gateway parameters to WMA
13501 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013502QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013503 struct gateway_param_update_req *gw_params)
13504{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013505 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013506 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013507 struct gateway_param_update_req *request_buf;
13508
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013509 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013510 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013511 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013512 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013513 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013514 }
13515
13516 *request_buf = *gw_params;
13517
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013518 message.type = WMA_GW_PARAM_UPDATE_REQ;
13519 message.reserved = 0;
13520 message.bodyptr = request_buf;
13521 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013522 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013523 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013524 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013525 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013526 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013527 }
13528
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013529 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013530}
13531#endif /* FEATURE_LFR_SUBNET_DETECTION */
13532
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013533/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013534 * sme_soc_set_antenna_mode() - set antenna mode
13535 * @hal: Handle returned by macOpen
13536 * @msg: Structure containing the antenna mode parameters
13537 *
13538 * Send the command to CSR to send
13539 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13540 *
13541 * Return: QDF_STATUS
13542 */
13543QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13544 struct sir_antenna_mode_param *msg)
13545{
13546 QDF_STATUS status = QDF_STATUS_SUCCESS;
13547 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13548 tSmeCmd *cmd;
13549
13550 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013551 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013552 return QDF_STATUS_E_FAILURE;
13553 }
13554
13555 status = sme_acquire_global_lock(&mac->sme);
13556 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013557 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013558 return QDF_STATUS_E_RESOURCES;
13559 }
13560
Krunal Soni78618d92017-02-14 21:46:31 -080013561 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013562 if (!cmd) {
13563 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013564 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013565 return QDF_STATUS_E_NULL_VALUE;
13566 }
13567
13568 cmd->command = e_sme_command_set_antenna_mode;
13569 cmd->u.set_antenna_mode_cmd = *msg;
13570
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013571 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013572 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13573 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13574
13575 csr_queue_sme_command(mac, cmd, false);
13576 sme_release_global_lock(&mac->sme);
13577
13578 return QDF_STATUS_SUCCESS;
13579}
13580
13581/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013582 * sme_set_peer_authorized() - call peer authorized callback
13583 * @peer_addr: peer mac address
13584 * @auth_cb: auth callback
13585 * @vdev_id: vdev id
13586 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013587 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013588 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013589QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013590 sme_peer_authorized_fp auth_cb,
13591 uint32_t vdev_id)
13592{
13593 void *wma_handle;
13594
Anurag Chouhan6d760662016-02-20 16:05:43 +053013595 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013596 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013598 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013599 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013600 }
13601
13602 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13603 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13604 1, vdev_id);
13605}
13606
13607/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013608 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013609 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013610 * @fcc_constraint: flag to enable/disable the constraint
13611 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013612 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013613 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013614 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013615QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13616 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013617{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013618 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013619 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13620
13621 status = sme_acquire_global_lock(&mac_ptr->sme);
13622
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013623 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013624
13625 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13626 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013627 if (scan_pending)
13628 mac_ptr->scan.defer_update_channel_list = true;
13629 else
13630 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013631 }
13632
13633 sme_release_global_lock(&mac_ptr->sme);
13634 }
13635
13636 return status;
13637}
13638/**
13639 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13640 * @hal: Global MAC pointer
13641 *
13642 * Return: NULL.
13643 */
13644void sme_setdef_dot11mode(tHalHandle hal)
13645{
13646 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013648 csr_set_default_dot11_mode(mac_ctx);
13649}
13650
13651/**
13652 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13653 * params
13654 * @hal_handle - The handle returned by macOpen.
13655 * @session_id - Session Identifier
13656 * @notify_id - Identifies 1 of the 4 parameters to be modified
13657 * @val New value of the parameter
13658 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013659 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013660 * Other status means SME failed to update
13661 */
13662
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013663QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013664 uint8_t session_id,
13665 uint32_t notify_id,
13666 int32_t val)
13667{
13668 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013669 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013670 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013671 tpCsrNeighborRoamControlInfo nr_info = NULL;
13672 uint32_t reason = 0;
13673
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013674 if (session_id >= CSR_ROAM_SESSION_MAX) {
13675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13676 FL("Invalid sme session id: %d"), session_id);
13677 return QDF_STATUS_E_INVAL;
13678 }
13679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013680 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013681 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013682 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13683 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13684 switch (notify_id) {
13685 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013686 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013687 "%s: gRoamScanHirssiMaxCount %d => %d",
13688 __func__, nr_config->nhi_rssi_scan_max_count,
13689 val);
13690 nr_config->nhi_rssi_scan_max_count = val;
13691 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13692 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13693 break;
13694
13695 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013697 FL("gRoamScanHiRssiDelta %d => %d"),
13698 nr_config->nhi_rssi_scan_rssi_delta,
13699 val);
13700 nr_config->nhi_rssi_scan_rssi_delta = val;
13701 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13702 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13703 break;
13704
13705 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013706 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013707 FL("gRoamScanHiRssiDelay %d => %d"),
13708 nr_config->nhi_rssi_scan_delay,
13709 val);
13710 nr_config->nhi_rssi_scan_delay = val;
13711 nr_info->cfgParams.hi_rssi_scan_delay = val;
13712 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13713 break;
13714
13715 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013716 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013717 FL("gRoamScanHiRssiUpperBound %d => %d"),
13718 nr_config->nhi_rssi_scan_rssi_ub,
13719 val);
13720 nr_config->nhi_rssi_scan_rssi_ub = val;
13721 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13722 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13723 break;
13724
13725 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013726 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013727 FL("invalid parameter notify_id %d"),
13728 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013729 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013730 break;
13731 }
13732 sme_release_global_lock(&mac_ctx->sme);
13733 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013734 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013735 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013736 csr_roam_offload_scan(mac_ctx, session_id,
13737 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013739
13740 return status;
13741}
13742
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013743/**
13744 * sme_update_tgt_services() - update the target services config.
13745 * @hal: HAL pointer.
13746 * @cfg: wma_tgt_services parameters.
13747 *
13748 * update the target services config.
13749 *
13750 * Return: None.
13751 */
13752void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13753{
13754 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13755
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013756 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013757 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013758 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013759 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013760 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013761 mac_ctx->is_fils_roaming_supported =
13762 cfg->is_fils_roaming_supported;
13763 sme_debug("mac_ctx->pmf_offload: %d fils_roam support %d",
13764 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013765
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013766}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013767
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013768/**
13769 * sme_is_session_id_valid() - Check if the session id is valid
13770 * @hal: Pointer to HAL
13771 * @session_id: Session id
13772 *
13773 * Checks if the session id is valid or not
13774 *
13775 * Return: True is the session id is valid, false otherwise
13776 */
13777bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13778{
13779 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013780
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013781 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013782 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13783 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013784 return false;
13785 }
13786
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013787 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013788 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013789
13790 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013791}
13792
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013793#ifdef FEATURE_WLAN_TDLS
13794
13795/**
13796 * sme_get_opclass() - determine operating class
13797 * @hal: Pointer to HAL
13798 * @channel: channel id
13799 * @bw_offset: bandwidth offset
13800 * @opclass: pointer to operating class
13801 *
13802 * Function will determine operating class from regdm_get_opclass_from_channel
13803 *
13804 * Return: none
13805 */
13806void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13807 uint8_t *opclass)
13808{
13809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13810
13811 /* redgm opclass table contains opclass for 40MHz low primary,
13812 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13813 * first we will check if bit for 40MHz is set and if so find
13814 * matching opclass either with low primary or high primary
13815 * (a channel would never be in both) and then search for opclass
13816 * matching 20MHz, else for any BW.
13817 */
13818 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013819 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013820 mac_ctx->scan.countryCodeCurrent,
13821 channel, BW40_LOW_PRIMARY);
13822 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013823 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013824 mac_ctx->scan.countryCodeCurrent,
13825 channel, BW40_HIGH_PRIMARY);
13826 }
13827 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013828 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013829 mac_ctx->scan.countryCodeCurrent,
13830 channel, BW20);
13831 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013832 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013833 mac_ctx->scan.countryCodeCurrent,
13834 channel, BWALL);
13835 }
13836}
13837#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013838
13839#ifdef FEATURE_GREEN_AP
13840/**
13841 * sme_send_egap_conf_params() - set the enhanced green ap configuration params
13842 * @enable: enable/disable the enhanced green ap feature
13843 * @inactivity_time: inactivity timeout value
13844 * @wait_time: wait timeout value
13845 * @flag: feature flag in bitmasp
13846 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013847 * Return: Return QDF_STATUS, otherwise appropriate failure code
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013848 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013849QDF_STATUS sme_send_egap_conf_params(uint32_t enable, uint32_t inactivity_time,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013850 uint32_t wait_time, uint32_t flags)
13851{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013852 struct scheduler_msg message = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013853 QDF_STATUS status;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013854 struct egap_conf_params *egap_params;
13855
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013856 egap_params = qdf_mem_malloc(sizeof(*egap_params));
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013857 if (NULL == egap_params) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013858 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013859 "%s: fail to alloc egap_params", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013860 return QDF_STATUS_E_NOMEM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013861 }
13862
13863 egap_params->enable = enable;
13864 egap_params->inactivity_time = inactivity_time;
13865 egap_params->wait_time = wait_time;
13866 egap_params->flags = flags;
13867
13868 message.type = WMA_SET_EGAP_CONF_PARAMS;
13869 message.bodyptr = egap_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013870 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013871 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013873 "%s: Not able to post msg to WMA!", __func__);
13874
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013875 qdf_mem_free(egap_params);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013876 }
13877 return status;
13878}
13879#endif
Sandeep Puligillae0875662016-02-12 16:09:21 -080013880
13881/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013882 * sme_set_fw_test() - set fw test
13883 * @fw_test: fw test param
13884 *
13885 * Return: Return QDF_STATUS, otherwise appropriate failure code
13886 */
13887QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13888{
13889 void *wma_handle;
13890
13891 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13892 if (!wma_handle) {
13893 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13894 "wma handle is NULL");
13895 return QDF_STATUS_E_FAILURE;
13896 }
13897 wma_process_fw_test_cmd(wma_handle, fw_test);
13898 return QDF_STATUS_SUCCESS;
13899}
13900
13901/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013902 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13903 * @hal: mac handel
13904 * @vdev_id: vdev identifier
13905 *
13906 * Return: Return QDF_STATUS, otherwise appropriate failure code
13907 */
13908QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13909{
13910 void *wma_handle;
13911
13912 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13913 if (!wma_handle) {
13914 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13915 "wma handle is NULL");
13916 return QDF_STATUS_E_FAILURE;
13917 }
13918 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13919 return QDF_STATUS_SUCCESS;
13920}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013921
13922/**
13923 * sme_update_mimo_power_save() - Update MIMO power save
13924 * configuration
13925 * @hal: The handle returned by macOpen
13926 * @is_ht_smps_enabled: enable/disable ht smps
13927 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013928 * @send_smps_action: flag to send smps force mode command
13929 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013930 *
13931 * Return: QDF_STATUS if SME update mimo power save
13932 * configuration sucsess else failue status
13933 */
13934QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13935 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013936 uint8_t ht_smps_mode,
13937 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013938{
13939 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013940
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013941 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013942 is_ht_smps_enabled, ht_smps_mode,
13943 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013944 mac_ctx->roam.configParam.enableHtSmps =
13945 is_ht_smps_enabled;
13946 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013947 mac_ctx->roam.configParam.send_smps_action =
13948 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013949
13950 return QDF_STATUS_SUCCESS;
13951}
13952
13953/**
13954 * sme_is_sta_smps_allowed() - check if the supported nss for
13955 * the session is greater than 1x1 to enable sta SMPS
13956 * @hal: The handle returned by macOpen
13957 * @session_id: session id
13958 *
13959 * Return: bool returns true if supported nss is greater than
13960 * 1x1 else false
13961 */
13962bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13963{
13964 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013965 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013966
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013967 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13968 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013969 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013970 return false;
13971 }
13972
13973 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013974 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013975 return false;
13976 }
13977
13978 return (csr_session->supported_nss_1x1 == true) ? false : true;
13979}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013980
13981/**
13982 * sme_add_beacon_filter() - set the beacon filter configuration
13983 * @hal: The handle returned by macOpen
13984 * @session_id: session id
13985 * @ie_map: bitwise array of IEs
13986 *
13987 * Return: Return QDF_STATUS, otherwise appropriate failure code
13988 */
13989QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13990 uint32_t session_id,
13991 uint32_t *ie_map)
13992{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013993 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013994 QDF_STATUS qdf_status;
13995 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13996 struct beacon_filter_param *filter_param;
13997
13998 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013999 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014000 return QDF_STATUS_E_FAILURE;
14001 }
14002
14003 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14004 if (NULL == filter_param) {
14005 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14006 "%s: fail to alloc filter_param", __func__);
14007 return QDF_STATUS_E_FAILURE;
14008 }
14009
14010 filter_param->vdev_id = session_id;
14011
14012 qdf_mem_copy(filter_param->ie_map, ie_map,
14013 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14014
14015 message.type = WMA_ADD_BCN_FILTER_CMDID;
14016 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014017 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014018 &message);
14019 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14020 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14021 "%s: Not able to post msg to WDA!",
14022 __func__);
14023
14024 qdf_mem_free(filter_param);
14025 }
14026 return qdf_status;
14027}
14028
14029/**
14030 * sme_remove_beacon_filter() - set the beacon filter configuration
14031 * @hal: The handle returned by macOpen
14032 * @session_id: session id
14033 *
14034 * Return: Return QDF_STATUS, otherwise appropriate failure code
14035 */
14036QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14037{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014038 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014039 QDF_STATUS qdf_status;
14040 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14041 struct beacon_filter_param *filter_param;
14042
14043 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014044 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014045 return QDF_STATUS_E_FAILURE;
14046 }
14047
14048 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14049 if (NULL == filter_param) {
14050 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14051 "%s: fail to alloc filter_param", __func__);
14052 return QDF_STATUS_E_FAILURE;
14053 }
14054
14055 filter_param->vdev_id = session_id;
14056
14057 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14058 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014059 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014060 &message);
14061 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14062 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14063 "%s: Not able to post msg to WDA!",
14064 __func__);
14065
14066 qdf_mem_free(filter_param);
14067 }
14068 return qdf_status;
14069}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014070
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014071/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014072 * sme_send_disassoc_req_frame - send disassoc req
14073 * @hal: handler to hal
14074 * @session_id: session id
14075 * @peer_mac: peer mac address
14076 * @reason: reason for disassociation
14077 * wait_for_ack: wait for acknowledgment
14078 *
14079 * function to send disassoc request to lim
14080 *
14081 * return: none
14082 */
14083void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14084 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14085{
14086 struct sme_send_disassoc_frm_req *msg;
14087 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14088 A_UINT8 *buf;
14089 A_UINT16 tmp;
14090
14091 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14092
14093 if (NULL == msg)
14094 qdf_status = QDF_STATUS_E_FAILURE;
14095 else
14096 qdf_status = QDF_STATUS_SUCCESS;
14097
14098 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14099 return;
14100
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014101 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14102
14103 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14104
14105 buf = &msg->session_id;
14106
14107 /* session id */
14108 *buf = (A_UINT8) session_id;
14109 buf += sizeof(A_UINT8);
14110
14111 /* transaction id */
14112 *buf = 0;
14113 *(buf + 1) = 0;
14114 buf += sizeof(A_UINT16);
14115
14116 /* Set the peer MAC address before sending the message to LIM */
14117 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14118
14119 buf += QDF_MAC_ADDR_SIZE;
14120
14121 /* reasoncode */
14122 tmp = (uint16_t) reason;
14123 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14124 buf += sizeof(uint16_t);
14125
14126 *buf = wait_for_ack;
14127 buf += sizeof(uint8_t);
14128
Rajeev Kumard138ac52017-01-30 18:38:37 -080014129 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014130
14131 if (qdf_status != QDF_STATUS_SUCCESS)
14132 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14133 FL("cds_send_mb_message Failed"));
14134}
14135
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014136QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14137 bpf_get_offload_cb callback,
14138 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014139{
14140 QDF_STATUS status = QDF_STATUS_SUCCESS;
14141 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014142 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014143
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014144 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014145
14146 status = sme_acquire_global_lock(&mac_ctx->sme);
14147 if (QDF_STATUS_SUCCESS == status) {
14148 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014149 mac_ctx->sme.bpf_get_offload_cb = callback;
14150 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014151 cds_msg.bodyptr = NULL;
14152 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014153 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014154 if (!QDF_IS_STATUS_SUCCESS(status)) {
14155 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14156 FL("Post bpf get offload msg fail"));
14157 status = QDF_STATUS_E_FAILURE;
14158 }
14159 sme_release_global_lock(&mac_ctx->sme);
14160 } else {
14161 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14162 FL("sme_acquire_global_lock error"));
14163 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014164 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014165 return status;
14166}
14167
14168
14169/**
14170 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14171 * @hal: HAL handle
14172 * @bpf_set_offload: struct to set bpf filter instructions.
14173 *
14174 * Return: QDF_STATUS enumeration.
14175 */
14176QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14177 struct sir_bpf_set_offload *req)
14178{
14179 QDF_STATUS status = QDF_STATUS_SUCCESS;
14180 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014181 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014182 struct sir_bpf_set_offload *set_offload;
14183
Arun Khandavallica198b52016-04-26 20:53:35 +053014184 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14185 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014186
14187 if (NULL == set_offload) {
14188 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14189 FL("Failed to alloc set_offload"));
14190 return QDF_STATUS_E_NOMEM;
14191 }
14192
14193 set_offload->session_id = req->session_id;
14194 set_offload->filter_id = req->filter_id;
14195 set_offload->current_offset = req->current_offset;
14196 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014197 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014198 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014199 set_offload->program = ((uint8_t *)set_offload) +
14200 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014201 qdf_mem_copy(set_offload->program, req->program,
14202 set_offload->current_length);
14203 }
14204 status = sme_acquire_global_lock(&mac_ctx->sme);
14205 if (QDF_STATUS_SUCCESS == status) {
14206 /* Serialize the req through MC thread */
14207 cds_msg.bodyptr = set_offload;
14208 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014209 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014210
14211 if (!QDF_IS_STATUS_SUCCESS(status)) {
14212 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14213 FL("Post BPF set offload msg fail"));
14214 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014215 qdf_mem_free(set_offload);
14216 }
14217 sme_release_global_lock(&mac_ctx->sme);
14218 } else {
14219 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14220 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014221 qdf_mem_free(set_offload);
14222 }
14223 return status;
14224}
14225
14226/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014227 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14228 * @hal: hal pointer
14229 *
14230 * Return: wni dot11 mode.
14231 */
14232uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14233{
14234 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14235
14236 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14237 mac_ctx->roam.configParam.uCfgDot11Mode);
14238}
14239
14240/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014241 * sme_create_mon_session() - post message to create PE session for monitormode
14242 * operation
14243 * @hal_handle: Handle to the HAL
14244 * @bssid: pointer to bssid
14245 *
14246 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14247 */
14248QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14249{
14250 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14251 struct sir_create_session *msg;
14252
14253 msg = qdf_mem_malloc(sizeof(*msg));
14254 if (NULL != msg) {
14255 msg->type = eWNI_SME_MON_INIT_SESSION;
14256 msg->msg_len = sizeof(*msg);
14257 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014258 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014259 }
14260 return status;
14261}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014262
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014263void sme_set_chan_info_callback(tHalHandle hal_handle,
14264 void (*callback)(struct scan_chan_info *chan_info))
14265{
14266 tpAniSirGlobal mac;
14267
14268 if (hal_handle == NULL) {
14269 QDF_ASSERT(0);
14270 return;
14271 }
14272 mac = PMAC_STRUCT(hal_handle);
14273 mac->chan_info_cb = callback;
14274}
14275
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014276/**
14277 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14278 * @hal: The handle returned by macOpen
14279 * @params: adaptive_dwelltime_params config
14280 *
14281 * Return: QDF_STATUS if adaptive dwell time update
14282 * configuration sucsess else failure status
14283 */
14284QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14285 struct adaptive_dwelltime_params *params)
14286{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014287 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014288 QDF_STATUS status;
14289 struct adaptive_dwelltime_params *dwelltime_params;
14290
14291 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14292 if (NULL == dwelltime_params) {
14293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14294 "%s: fail to alloc dwelltime_params", __func__);
14295 return QDF_STATUS_E_NOMEM;
14296 }
14297
14298 dwelltime_params->is_enabled = params->is_enabled;
14299 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14300 dwelltime_params->lpf_weight = params->lpf_weight;
14301 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14302 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14303
14304 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14305 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014306 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014307 if (!QDF_IS_STATUS_SUCCESS(status)) {
14308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14309 "%s: Not able to post msg to WMA!", __func__);
14310
14311 qdf_mem_free(dwelltime_params);
14312 }
14313 return status;
14314}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014315
14316/**
14317 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14318 * @hal: Pointer to HAL
14319 * @vdev_id: vdev_id for which IE is targeted
14320 *
14321 * Return: None
14322 */
14323void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14324{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014325 struct sir_set_vdev_ies_per_band *p_msg;
14326 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14327
14328 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14329 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014330 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014331 return;
14332 }
14333
14334 p_msg->vdev_id = vdev_id;
14335 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14336 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014337 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014338 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014339 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014340 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014341 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014342}
14343
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014344/**
14345 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14346 * @hal: Pointer to HAL
14347 * @enable2x2: 1x1 or 2x2 mode.
14348 *
14349 * Sends the set pdev IE req with Nss value.
14350 *
14351 * Return: None
14352 */
14353void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14354{
14355 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14356 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14357 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14358
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014359 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14360 eCSR_CFG_DOT11_MODE_AUTO) ||
14361 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14362 eCSR_CFG_DOT11_MODE_11N) ||
14363 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14364 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14365 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14366 eCSR_CFG_DOT11_MODE_11AC) ||
14367 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14368 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14369 return;
14370
14371 status = sme_acquire_global_lock(&mac_ctx->sme);
14372 if (QDF_STATUS_SUCCESS == status) {
14373 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14374 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014375 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014376 sme_release_global_lock(&mac_ctx->sme);
14377 return;
14378 }
14379
14380 ht_vht_cfg->pdev_id = 0;
14381 if (enable2x2)
14382 ht_vht_cfg->nss = 2;
14383 else
14384 ht_vht_cfg->nss = 1;
14385 ht_vht_cfg->dot11mode =
14386 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14387 mac_ctx->roam.configParam.uCfgDot11Mode);
14388
14389 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14390 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014391 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14392 ht_vht_cfg->nss,
14393 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014394 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014395 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014396 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014397
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014398 sme_release_global_lock(&mac_ctx->sme);
14399 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014400}
14401
14402/**
14403 * sme_update_vdev_type_nss() - sets the nss per vdev type
14404 * @hal: Pointer to HAL
14405 * @max_supp_nss: max_supported Nss
14406 * @band: 5G or 2.4G band
14407 *
14408 * Sets the per band Nss for each vdev type based on INI and configured
14409 * chain mask value.
14410 *
14411 * Return: None
14412 */
14413void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
14414 uint32_t vdev_type_nss, eCsrBand band)
14415{
14416 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14417 struct vdev_type_nss *vdev_nss;
14418
14419 if (eCSR_BAND_5G == band)
14420 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14421 else
14422 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14423
14424 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14425 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14426 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14427 CFG_P2P_GO_NSS(vdev_type_nss));
14428 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14429 CFG_P2P_CLI_NSS(vdev_type_nss));
14430 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14431 CFG_P2P_DEV_NSS(vdev_type_nss));
14432 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14433 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14434 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14435
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014436 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 -070014437 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14438 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14439 vdev_nss->tdls, vdev_nss->ocb);
14440}
Peng Xu8fdaa492016-06-22 10:20:47 -070014441
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014442#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14443#define MAX_BSS_COLOR_VAL 63
14444#define MIN_BSS_COLOR_VAL 1
14445
14446QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14447 uint8_t bss_color)
14448
14449{
14450 struct sir_set_he_bss_color *bss_color_msg;
14451 uint8_t len;
14452
14453 if (!hal) {
14454 sme_err("Invalid hal pointer");
14455 return QDF_STATUS_E_FAULT;
14456 }
14457
14458 sme_debug("Set HE bss_color %d", bss_color);
14459
14460 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14461 sme_debug("Invalid HE bss_color %d", bss_color);
14462 return QDF_STATUS_E_INVAL;
14463 }
14464 len = sizeof(*bss_color_msg);
14465 bss_color_msg = qdf_mem_malloc(len);
14466 if (!bss_color_msg) {
14467 sme_err("mem alloc failed");
14468 return QDF_STATUS_E_NOMEM;
14469 }
14470 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14471 bss_color_msg->length = len;
14472 bss_color_msg->session_id = session_id;
14473 bss_color_msg->bss_color = bss_color;
14474 return umac_send_mb_message_to_mac(bss_color_msg);
14475}
14476#endif
14477
Peng Xu8fdaa492016-06-22 10:20:47 -070014478/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014479 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14480 * @hal: Pointer to HAL
14481 * @hw_dbs_capable: HW DBS capability
14482 *
14483 * Sets HW DBS capability based on INI and fw capability.
14484 *
14485 * Return: None
14486 */
14487void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14488{
14489 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014490
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014491 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14492}
14493
14494/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014495 * sme_register_p2p_lo_event() - Register for the p2p lo event
14496 * @hHal: reference to the HAL
14497 * @context: the context of the call
14498 * @callback: the callback to hdd
14499 *
14500 * This function registers the callback function for P2P listen
14501 * offload stop event.
14502 *
14503 * Return: none
14504 */
14505void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14506 p2p_lo_callback callback)
14507{
14508 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14509 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14510
14511 status = sme_acquire_global_lock(&pMac->sme);
14512 pMac->sme.p2p_lo_event_callback = callback;
14513 pMac->sme.p2p_lo_event_context = context;
14514 sme_release_global_lock(&pMac->sme);
14515}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014516
14517/**
14518 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14519 * @hal: The handle returned by macOpen
14520 * @session_id: session id
14521 * @dbg_args: args for mac pwr debug command
14522 * Return: Return QDF_STATUS, otherwise appropriate failure code
14523 */
14524QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14525 struct sir_mac_pwr_dbg_cmd*
14526 dbg_args)
14527{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014528 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014529 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14530 struct sir_mac_pwr_dbg_cmd *req;
14531 int i;
14532
14533 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014534 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014535 return QDF_STATUS_E_FAILURE;
14536 }
14537
14538 req = qdf_mem_malloc(sizeof(*req));
14539 if (NULL == req) {
14540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14541 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14542 return QDF_STATUS_E_FAILURE;
14543 }
14544 req->module_id = dbg_args->module_id;
14545 req->pdev_id = dbg_args->pdev_id;
14546 req->num_args = dbg_args->num_args;
14547 for (i = 0; i < req->num_args; i++)
14548 req->args[i] = dbg_args->args[i];
14549
14550 message.type = SIR_HAL_POWER_DBG_CMD;
14551 message.bodyptr = req;
14552
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014553 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014554 (QDF_MODULE_ID_WMA, &message))) {
14555 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14556 "%s: Not able to post msg to WDA!",
14557 __func__);
14558 qdf_mem_free(req);
14559 }
14560 return QDF_STATUS_SUCCESS;
14561}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014562/**
14563 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014564 * @dev_mode: connection type.
14565 * @nss2g: Pointer to the 2G Nss parameter.
14566 * @nss5g: Pointer to the 5G Nss parameter.
14567 *
14568 * Fills the 2G and 5G Nss values based on connection type.
14569 *
14570 * Return: None
14571 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014572void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14573 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014574{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014575 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14576
14577 if (NULL == mac_ctx) {
14578 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14579 FL("Invalid MAC context"));
14580 return;
14581 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014582 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14583}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014584
14585/**
14586 * sme_update_sta_roam_policy() - update sta roam policy for
14587 * unsafe and DFS channels.
14588 * @hal_handle: hal handle for getting global mac struct
14589 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14590 * skipped or not
14591 * @skip_unsafe_channels: Param to tell if driver needs to
14592 * skip unsafe channels or not.
14593 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014594 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014595 *
14596 * sme_update_sta_roam_policy update sta rome policies to csr
14597 * this function will call csrUpdateChannelList as well
14598 * to include/exclude DFS channels and unsafe channels.
14599 *
14600 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14601 */
14602QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14603 enum sta_roam_policy_dfs_mode dfs_mode,
14604 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014605 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014606{
14607 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14608 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014609 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014610
14611 if (!mac_ctx) {
14612 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14613 "%s: mac_ctx is null", __func__);
14614 return QDF_STATUS_E_FAILURE;
14615 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014616
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014617 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14618 if (!sme_config) {
14619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14620 FL("failed to allocate memory for sme_config"));
14621 return QDF_STATUS_E_FAILURE;
14622 }
14623 qdf_mem_zero(sme_config, sizeof(*sme_config));
14624 sme_get_config_param(hal_handle, sme_config);
14625
14626 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014627 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014628 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014629 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014630 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014631 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014632
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014633 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014634
14635 status = csr_update_channel_list(mac_ctx);
14636 if (QDF_STATUS_SUCCESS != status) {
14637 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14638 FL("failed to update the supported channel list"));
14639 }
14640 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14641 csr_roam_offload_scan(mac_ctx, session_id,
14642 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14643 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014644
14645 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014646 return status;
14647}
14648
14649/**
14650 * sme_enable_disable_chanavoidind_event - configure ca event ind
14651 * @hal: handler to hal
14652 * @set_value: enable/disable
14653 *
14654 * function to enable/disable chan avoidance indication
14655 *
14656 * Return: QDF_STATUS
14657 */
14658QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14659 uint8_t set_value)
14660{
14661 QDF_STATUS status;
14662 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014663 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014664
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014665 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014666 status = sme_acquire_global_lock(&mac_ctx->sme);
14667 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014668 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014669 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14670 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014671 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014672 sme_release_global_lock(&mac_ctx->sme);
14673 return status;
14674 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014675 return status;
14676}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014677
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014678/*
14679 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14680 * @hal: reference to the HAL
14681 * @session_id: current session ID
14682 * @ie_data: Pointer to Scan IE data
14683 * @ie_len: Length of @ie_data
14684 *
14685 * Return: QDF_STATUS
14686 */
14687QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14688 uint8_t *ie_data, uint16_t ie_len)
14689{
14690 QDF_STATUS status;
14691 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14692 struct hdd_default_scan_ie *set_ie_params;
14693
14694 status = sme_acquire_global_lock(&mac_ctx->sme);
14695 if (QDF_IS_STATUS_SUCCESS(status)) {
14696 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14697 if (!set_ie_params)
14698 status = QDF_STATUS_E_NOMEM;
14699 else {
14700 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14701 set_ie_params->length = sizeof(*set_ie_params);
14702 set_ie_params->session_id = session_id;
14703 set_ie_params->ie_len = ie_len;
14704 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014705 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014706 }
14707 sme_release_global_lock(&mac_ctx->sme);
14708 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014709 return status;
14710}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014711
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014712QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14713 struct sar_limit_cmd_params *sar_limit_cmd)
14714{
14715 void *wma_handle;
14716
14717 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14718 if (!wma_handle) {
14719 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14720 "wma handle is NULL");
14721 return QDF_STATUS_E_FAILURE;
14722 }
14723
14724 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14725}
14726
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053014727#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014728/**
14729 * sme_encrypt_decrypt_msg() - handles encrypt/decrypt mesaage
14730 * @hal: HAL handle
14731 * @encrypt_decrypt_params: struct to set encryption/decryption params.
14732 *
14733 * Return: QDF_STATUS enumeration.
14734 */
14735QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
Jeff Johnsone8216e82017-01-26 15:54:51 -080014736 struct encrypt_decrypt_req_params *encrypt_decrypt_params,
14737 sme_encrypt_decrypt_callback callback,
14738 void *context)
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014739{
14740 QDF_STATUS status = QDF_STATUS_SUCCESS;
14741 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014742 struct scheduler_msg cds_msg = {0};
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014743 struct encrypt_decrypt_req_params *params;
14744 uint8_t *ptr;
14745
14746 ptr = qdf_mem_malloc(sizeof(*params) +
14747 encrypt_decrypt_params->data_len);
14748 if (ptr == NULL) {
14749 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014750 "Failed to alloc memory for encrypt/decrypt params");
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014751 return QDF_STATUS_E_NOMEM;
14752 }
14753
14754 params = (struct encrypt_decrypt_req_params *)ptr;
14755
14756 *params = *encrypt_decrypt_params;
14757
14758 if (params->data_len) {
14759 params->data = ptr + sizeof(*params);
14760
14761 qdf_mem_copy(params->data, encrypt_decrypt_params->data,
14762 params->data_len);
14763 }
14764
14765 status = sme_acquire_global_lock(&mac_ctx->sme);
14766 if (status == QDF_STATUS_SUCCESS) {
14767 /* Serialize the req through MC thread */
Jeff Johnsone8216e82017-01-26 15:54:51 -080014768 mac_ctx->sme.encrypt_decrypt_cb = callback;
14769 mac_ctx->sme.encrypt_decrypt_context = context;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014770 cds_msg.bodyptr = params;
14771 cds_msg.type = WMA_ENCRYPT_DECRYPT_MSG;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014772 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014773
14774 if (!QDF_IS_STATUS_SUCCESS(status)) {
14775 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14776 FL("Post encrypt/decrypt msg fail"));
14777 status = QDF_STATUS_E_FAILURE;
14778 qdf_mem_free(params);
14779 }
14780 sme_release_global_lock(&mac_ctx->sme);
14781 } else {
14782 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14783 FL("sme_acquire_global_lock failed"));
14784 qdf_mem_free(params);
14785 }
14786 return status;
14787
14788}
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053014789#endif
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014790
Jeff Johnson6136fb92017-03-30 15:21:49 -070014791#ifdef WLAN_FEATURE_FIPS
14792QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14793 wma_fips_cb callback, void *context)
14794{
14795 void *wma_handle;
14796
14797 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14798 if (!wma_handle) {
14799 sme_err("wma handle is NULL");
14800 return QDF_STATUS_E_FAILURE;
14801 }
14802
14803 return wma_fips_request(wma_handle, param, callback, context);
14804}
14805#endif
14806
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014807QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14808{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014809 void *wma_handle;
14810
14811 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14812 if (!wma_handle) {
14813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14814 "wma_handle is NULL");
14815 return QDF_STATUS_E_FAILURE;
14816 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014817 if (QDF_STATUS_SUCCESS !=
14818 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14819 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14820 "%s: Failed to set cts2self for p2p GO to firmware",
14821 __func__);
14822 return QDF_STATUS_E_FAILURE;
14823 }
14824 return QDF_STATUS_SUCCESS;
14825}
Yingying Tang95409972016-10-20 15:16:15 +080014826
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014827/**
14828 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14829 * @hal: Handle returned by mac_open
14830 * @session_id: Session ID on which tx fail count needs to be updated to FW
14831 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14832 *
14833 * This function is used to set tx fail count threshold to firmware.
14834 * firmware will issue disocnnect with peer device once this threshold is
14835 * reached.
14836 *
14837 * Return: Return QDF_STATUS, otherwise appropriate failure code
14838 */
14839QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14840 uint8_t session_id, uint32_t tx_fail_count)
14841{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014842 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14843 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014844 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014845
14846 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14847 if (NULL == tx_fail_cnt) {
14848 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14849 "%s: fail to alloc filter_param", __func__);
14850 return QDF_STATUS_E_FAILURE;
14851 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014852 sme_debug("session_id: %d tx_fail_count: %d",
14853 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014854 tx_fail_cnt->session_id = session_id;
14855 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14856
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014857 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014858 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14859 msg.reserved = 0;
14860 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014861 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014862
14863 if (!QDF_IS_STATUS_SUCCESS(status)) {
14864 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014865 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014866 qdf_mem_free(tx_fail_cnt);
14867 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014868 return status;
14869}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014870
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014871QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14872 void (*cb)(void *, struct sir_lost_link_info *))
14873{
14874 QDF_STATUS status = QDF_STATUS_SUCCESS;
14875 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14876
14877 status = sme_acquire_global_lock(&mac->sme);
14878 if (QDF_IS_STATUS_SUCCESS(status)) {
14879 mac->sme.lost_link_info_cb = cb;
14880 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014881 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014882 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014883 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014884
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014885 return status;
14886}
Yingying Tang95409972016-10-20 15:16:15 +080014887
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014888#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014889bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014890{
14891 return roam_info->isESEAssoc;
14892}
Manjeet Singh2f785062017-03-08 18:14:18 +053014893#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014894/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014895 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014896 * params from ini.
14897 * @hal_handle: Handle returned by mac_open
14898 * @5g_pref_params: pref params from ini.
14899 *
14900 * Returns: None
14901 */
14902void sme_set_5g_band_pref(tHalHandle hal_handle,
14903 struct sme_5g_band_pref_params *pref_params)
14904{
14905
14906 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14907 struct roam_ext_params *roam_params;
14908 QDF_STATUS status = QDF_STATUS_SUCCESS;
14909
14910 if (!pref_params) {
14911 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14912 "Invalid 5G pref params!");
14913 return;
14914 }
14915 status = sme_acquire_global_lock(&mac_ctx->sme);
14916 if (QDF_STATUS_SUCCESS == status) {
14917 roam_params = &mac_ctx->roam.configParam.roam_params;
14918 roam_params->raise_rssi_thresh_5g =
14919 pref_params->rssi_boost_threshold_5g;
14920 roam_params->raise_factor_5g =
14921 pref_params->rssi_boost_factor_5g;
14922 roam_params->max_raise_rssi_5g =
14923 pref_params->max_rssi_boost_5g;
14924 roam_params->drop_rssi_thresh_5g =
14925 pref_params->rssi_penalize_threshold_5g;
14926 roam_params->drop_factor_5g =
14927 pref_params->rssi_penalize_factor_5g;
14928 roam_params->max_drop_rssi_5g =
14929 pref_params->max_rssi_penalize_5g;
14930
14931 sme_release_global_lock(&mac_ctx->sme);
14932 } else
14933 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14934 "Unable to acquire global sme lock");
14935}
14936
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014937
14938bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14939{
14940 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014941
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014942 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14943}
Yingying Tang95409972016-10-20 15:16:15 +080014944
14945#ifdef WLAN_FEATURE_WOW_PULSE
14946/**
14947 * sme_set_wow_pulse() - set wow pulse info
14948 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14949 *
14950 * Return: QDF_STATUS
14951 */
14952QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14953{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014954 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014955 QDF_STATUS status;
14956 struct wow_pulse_mode *wow_pulse_set_cmd;
14957
14958 if (!wow_pulse_set_info) {
14959 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14960 "%s: invalid wow_pulse_set_info pointer", __func__);
14961 return QDF_STATUS_E_FAILURE;
14962 }
14963
14964 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14965 if (NULL == wow_pulse_set_cmd) {
14966 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14967 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14968 return QDF_STATUS_E_NOMEM;
14969 }
14970
14971 *wow_pulse_set_cmd = *wow_pulse_set_info;
14972
14973 message.type = WMA_SET_WOW_PULSE_CMD;
14974 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014975 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014976 &message);
14977 if (!QDF_IS_STATUS_SUCCESS(status)) {
14978 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14979 "%s: Not able to post msg to WDA!",
14980 __func__);
14981 qdf_mem_free(wow_pulse_set_cmd);
14982 status = QDF_STATUS_E_FAILURE;
14983 }
14984
14985 return status;
14986}
14987#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014988
14989/**
14990 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14991 * different fields and IEs from bss descriptor.
14992 * @frame_buf: frame buffer to populate
14993 * @bss_descp: bss descriptor
14994 * @bssid: bssid of the beacon frame to populate
14995 * @ie_len: length of IE fields
14996 *
14997 * Return: None
14998 */
14999static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
15000 tSirBssDescription *bss_descp,
15001 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080015002 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015003{
15004 tDot11fBeacon1 *bcn_fixed;
15005 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
15006
15007 /* populate mac header first to indicate beacon */
15008 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15009 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
15010 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
15011 qdf_mem_copy((uint8_t *) mac_hdr->da,
15012 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
15013 sizeof(struct qdf_mac_addr));
15014 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15015 sizeof(struct qdf_mac_addr));
15016 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15017 sizeof(struct qdf_mac_addr));
15018
15019 /* now populate fixed params */
15020 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15021 /* populate timestamp */
15022 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15023 sizeof(bss_descp->timeStamp));
15024 /* populate beacon interval */
15025 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15026 /* populate capability */
15027 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15028 sizeof(bss_descp->capabilityInfo));
15029
15030 /* copy IEs now */
15031 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15032 + SIR_MAC_B_PR_SSID_OFFSET,
15033 &bss_descp->ieFields, ie_len);
15034}
15035
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015036QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
15037 tCsrRoamProfile *profile,
15038 const uint8_t *bssid,
15039 int8_t *rssi, int8_t *snr)
15040{
15041 tSirBssDescription *bss_descp;
15042 tCsrScanResultFilter *scan_filter;
15043 struct scan_result_list *bss_list;
15044 tScanResultHandle result_handle = NULL;
15045 QDF_STATUS status = QDF_STATUS_SUCCESS;
15046 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15047
15048 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15049 if (NULL == scan_filter) {
15050 sme_err("memory allocation failed");
15051 status = QDF_STATUS_E_NOMEM;
15052 goto free_scan_flter;
15053 }
15054
15055 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15056 profile, scan_filter);
15057 if (QDF_STATUS_SUCCESS != status) {
15058 sme_err("prepare_filter failed");
15059 goto free_scan_flter;
15060 }
15061
15062 /* update filter to get scan result with just target BSSID */
15063 if (NULL == scan_filter->BSSIDs.bssid) {
15064 scan_filter->BSSIDs.bssid =
15065 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15066 if (scan_filter->BSSIDs.bssid == NULL) {
15067 sme_err("malloc failed");
15068 status = QDF_STATUS_E_NOMEM;
15069 goto free_scan_flter;
15070 }
15071 }
15072
15073 scan_filter->BSSIDs.numOfBSSIDs = 1;
15074 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15075 bssid, sizeof(struct qdf_mac_addr));
15076
15077 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15078 if (QDF_STATUS_SUCCESS != status) {
15079 sme_err("parse_scan_result failed");
15080 goto free_scan_flter;
15081 }
15082
15083 bss_list = (struct scan_result_list *)result_handle;
15084 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15085 if (!bss_descp) {
15086 sme_err("unable to fetch bss descriptor");
15087 status = QDF_STATUS_E_FAULT;
15088 goto free_scan_flter;
15089 }
15090
15091 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15092 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15093
15094 if (rssi)
15095 *rssi = bss_descp->rssi;
15096 if (snr)
15097 *snr = bss_descp->sinr;
15098
15099free_scan_flter:
15100 /* free scan filter and exit */
15101 if (scan_filter) {
15102 csr_free_scan_filter(mac_ctx, scan_filter);
15103 qdf_mem_free(scan_filter);
15104 }
15105
15106 if (result_handle)
15107 csr_scan_result_purge(mac_ctx, result_handle);
15108
15109 return status;
15110}
15111
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015112QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15113 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015114 uint8_t **frame_buf, uint32_t *frame_len,
15115 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015116{
15117 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015118 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015119 tCsrScanResultFilter *scan_filter;
15120 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15121 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015122 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015123 uint32_t ie_len;
15124
15125 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15126 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015127 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015128 status = QDF_STATUS_E_NOMEM;
15129 goto free_scan_flter;
15130 }
15131 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15132 profile, scan_filter);
15133 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015134 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015135 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015136 goto free_scan_flter;
15137 }
15138
15139 /* update filter to get scan result with just target BSSID */
15140 if (NULL == scan_filter->BSSIDs.bssid) {
15141 scan_filter->BSSIDs.bssid =
15142 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15143 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015144 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015145 status = QDF_STATUS_E_NOMEM;
15146 goto free_scan_flter;
15147 }
15148 }
15149 scan_filter->BSSIDs.numOfBSSIDs = 1;
15150 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15151 bssid, sizeof(struct qdf_mac_addr));
15152
15153 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15154 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015155 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015156 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015157 goto free_scan_flter;
15158 }
15159
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015160 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015161 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015162 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015163 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015164 status = QDF_STATUS_E_FAULT;
15165 goto free_scan_flter;
15166 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015167
Naveen Rawat81f058c2017-06-02 16:02:39 -070015168 /**
15169 * Length of BSS descriptor is without length of
15170 * length itself and length of pointer that holds ieFields.
15171 *
15172 * tSirBssDescription
15173 * +--------+---------------------------------+---------------+
15174 * | length | other fields | pointer to IEs|
15175 * +--------+---------------------------------+---------------+
15176 * ^
15177 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015178 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015179 ie_len = bss_descp->length + sizeof(bss_descp->length)
15180 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015181 sme_debug("found bss_descriptor ie_len: %d channel %d",
15182 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015183
15184 /* include mac header and fixed params along with IEs in frame */
15185 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15186 *frame_buf = qdf_mem_malloc(*frame_len);
15187 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015188 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015189 status = QDF_STATUS_E_NOMEM;
15190 goto free_scan_flter;
15191 }
15192
15193 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15194
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015195 if (!*channel)
15196 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015197free_scan_flter:
15198 /* free scan filter and exit */
15199 if (scan_filter) {
15200 csr_free_scan_filter(mac_ctx, scan_filter);
15201 qdf_mem_free(scan_filter);
15202 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015203 if (result_handle)
15204 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015205
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015206 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015207}
15208
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015209QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15210 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015211 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015212{
15213 QDF_STATUS status;
15214 struct wma_roam_invoke_cmd *fastreassoc;
15215 struct scheduler_msg msg = {0};
15216
15217 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15218 if (NULL == fastreassoc) {
15219 sme_err("qdf_mem_malloc failed for fastreassoc");
15220 return QDF_STATUS_E_NOMEM;
15221 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015222 /* if both are same then set the flag */
15223 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15224 fastreassoc->is_same_bssid = true;
15225 sme_debug("bssid same, bssid[%pM]", bssid);
15226 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015227 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015228 fastreassoc->bssid[0] = bssid[0];
15229 fastreassoc->bssid[1] = bssid[1];
15230 fastreassoc->bssid[2] = bssid[2];
15231 fastreassoc->bssid[3] = bssid[3];
15232 fastreassoc->bssid[4] = bssid[4];
15233 fastreassoc->bssid[5] = bssid[5];
15234
15235 status = sme_get_beacon_frm(hal, profile, bssid,
15236 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015237 &fastreassoc->frame_len,
15238 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015239
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015240 if (!channel) {
15241 sme_err("channel retrieval from BSS desc fails!");
15242 qdf_mem_free(fastreassoc);
15243 return QDF_STATUS_E_FAULT;
15244 }
15245
15246 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015247 if (QDF_STATUS_SUCCESS != status) {
15248 sme_warn("sme_get_beacon_frm failed");
15249 fastreassoc->frame_buf = NULL;
15250 fastreassoc->frame_len = 0;
15251 }
15252
15253 msg.type = SIR_HAL_ROAM_INVOKE;
15254 msg.reserved = 0;
15255 msg.bodyptr = fastreassoc;
15256 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15257 if (QDF_STATUS_SUCCESS != status) {
15258 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15259 qdf_mem_free(fastreassoc);
15260 }
15261
15262 return status;
15263}
15264
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015265QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15266 tPmkidCacheInfo *pmk_cache_info,
15267 bool is_add)
15268{
15269 struct wmi_unified_pmk_cache *pmk_cache;
15270 struct scheduler_msg msg;
15271
15272 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15273 if (!pmk_cache) {
15274 sme_err("Memory allocation failure");
15275 return QDF_STATUS_E_NOMEM;
15276 }
15277
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015278 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15279
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015280 pmk_cache->session_id = session_id;
15281
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015282 if (!pmk_cache_info)
15283 goto send_flush_cmd;
15284
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015285 if (!pmk_cache_info->ssid_len) {
15286 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15287 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15288 &pmk_cache->bssid);
15289 } else {
15290 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15291 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15292 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15293 pmk_cache_info->ssid,
15294 pmk_cache->ssid.length);
15295 }
15296 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15297 pmk_cache_info->cache_id[1]);
15298
15299 if (is_add)
15300 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15301 else
15302 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15303
15304 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15305 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15306 CSR_RSN_PMKID_SIZE);
15307
15308 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15309 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15310 pmk_cache->pmk_len);
15311
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015312send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015313 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15314 msg.reserved = 0;
15315 msg.bodyptr = pmk_cache;
15316 if (QDF_STATUS_SUCCESS !=
15317 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15318 sme_err("Not able to post message to WDA");
15319 qdf_mem_free(pmk_cache);
15320 return QDF_STATUS_E_FAILURE;
15321 }
15322
15323 return QDF_STATUS_SUCCESS;
15324}
15325
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015326/* ARP DEBUG STATS */
15327
15328/**
15329 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15330 * @hal: handle to hal
15331 * @set_stats_param: pointer to set stats param
15332 *
15333 * Return: Return QDF_STATUS.
15334 */
15335QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15336 struct set_arp_stats_params
15337 *set_stats_param)
15338{
15339 struct set_arp_stats_params *arp_set_param;
15340 struct scheduler_msg msg;
15341
15342 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15343 if (arp_set_param == NULL) {
15344 sme_err("Memory allocation failure");
15345 return QDF_STATUS_E_NOMEM;
15346 }
15347
15348 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15349
15350 msg.type = WMA_SET_ARP_STATS_REQ;
15351 msg.reserved = 0;
15352 msg.bodyptr = arp_set_param;
15353
15354 if (QDF_STATUS_SUCCESS !=
15355 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15356 sme_err("Not able to post message to WDA");
15357 qdf_mem_free(arp_set_param);
15358 return QDF_STATUS_E_FAILURE;
15359 }
15360
15361 return QDF_STATUS_SUCCESS;
15362}
15363
15364/**
15365 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15366 * @hal: handle to hal
15367 * @get_stats_param: pointer to set stats param
15368 *
15369 * Return: Return QDF_STATUS.
15370 */
15371QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15372 struct get_arp_stats_params
15373 *get_stats_param)
15374{
15375 struct get_arp_stats_params *arp_get_param;
15376 struct scheduler_msg msg;
15377
15378 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15379 if (arp_get_param == NULL) {
15380 sme_err("Memory allocation failure");
15381 return QDF_STATUS_E_NOMEM;
15382 }
15383
15384 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15385
15386 msg.type = WMA_GET_ARP_STATS_REQ;
15387 msg.reserved = 0;
15388 msg.bodyptr = arp_get_param;
15389
15390 if (QDF_STATUS_SUCCESS !=
15391 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15392 sme_err("Not able to post message to WDA");
15393 qdf_mem_free(arp_get_param);
15394 return QDF_STATUS_E_FAILURE;
15395 }
15396
15397 return QDF_STATUS_SUCCESS;
15398}
15399
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015400QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15401 uint32_t param_value, uint32_t vdev_id)
15402{
15403 void *wma_handle;
15404
15405 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15406 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015407 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015408 return QDF_STATUS_E_FAILURE;
15409 }
15410
15411 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15412 param_value, vdev_id);
15413}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015414
15415QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015416 bool (*set_connection_info_cb)(bool),
15417 bool (*get_connection_info_cb)(uint8_t *session_id,
15418 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015419{
15420 QDF_STATUS status = QDF_STATUS_SUCCESS;
15421 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15422
15423 status = sme_acquire_global_lock(&pMac->sme);
15424 if (QDF_IS_STATUS_SUCCESS(status)) {
15425 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015426 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015427 sme_release_global_lock(&pMac->sme);
15428 }
15429 return status;
15430}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015431
15432QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15433 void (*cb)(void *, struct rso_cmd_status *))
15434{
15435 QDF_STATUS status = QDF_STATUS_SUCCESS;
15436 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15437
15438 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015439 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015440 return status;
15441}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015442
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015443QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15444 struct wmi_dbs_scan_sel_params *params)
15445{
15446 struct scheduler_msg message = {0};
15447 QDF_STATUS status;
15448 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15449 uint32_t i;
15450
15451 if (0 == params->num_clients) {
15452 sme_err("Num of clients is 0");
15453 return QDF_STATUS_E_FAILURE;
15454 }
15455
15456 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15457 if (!dbs_scan_params) {
15458 sme_err("fail to alloc dbs_scan_params");
15459 return QDF_STATUS_E_NOMEM;
15460 }
15461
15462 dbs_scan_params->num_clients = params->num_clients;
15463 dbs_scan_params->pdev_id = params->pdev_id;
15464 for (i = 0; i < params->num_clients; i++) {
15465 dbs_scan_params->module_id[i] = params->module_id[i];
15466 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15467 dbs_scan_params->num_non_dbs_scans[i] =
15468 params->num_non_dbs_scans[i];
15469 }
15470 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15471 message.bodyptr = dbs_scan_params;
15472 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15473 if (!QDF_IS_STATUS_SUCCESS(status)) {
15474 sme_err("Not able to post msg to WMA!");
15475 qdf_mem_free(dbs_scan_params);
15476 }
15477
15478 return status;
15479}
15480
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015481QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15482{
15483 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15484 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015485 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015486 struct sme_rcpi_req *rcpi_req;
15487
15488 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15489 if (rcpi_req == NULL) {
15490 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15491 "%s: Not able to allocate memory for rcpi req",
15492 __func__);
15493 return QDF_STATUS_E_NOMEM;
15494 }
15495 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15496
15497 status = sme_acquire_global_lock(&pMac->sme);
15498 if (QDF_IS_STATUS_SUCCESS(status)) {
15499 msg.bodyptr = rcpi_req;
15500 msg.type = WMA_GET_RCPI_REQ;
15501 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15502 sme_release_global_lock(&pMac->sme);
15503 if (!QDF_IS_STATUS_SUCCESS(status)) {
15504 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15505 FL("post get rcpi req failed"));
15506 status = QDF_STATUS_E_FAILURE;
15507 qdf_mem_free(rcpi_req);
15508 }
15509 } else {
15510 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15511 FL("sme_acquire_global_lock failed"));
15512 qdf_mem_free(rcpi_req);
15513 }
15514
15515 return status;
15516}
15517
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015518void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15519{
15520 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15521 void *wma_handle;
15522 QDF_STATUS status;
15523
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015524 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015525 if (QDF_STATUS_SUCCESS != status) {
15526 mac_ctx->pdev = NULL;
15527 return;
15528 }
15529 mac_ctx->pdev = pdev;
15530 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15531 if (!wma_handle) {
15532 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015533 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015534 return;
15535 }
15536 wma_store_pdev(wma_handle, pdev);
15537}
15538
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015539QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15540 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15541{
15542 QDF_STATUS status;
15543 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15544
15545 status = sme_acquire_global_lock(&mac->sme);
15546 if (QDF_IS_STATUS_SUCCESS(status)) {
15547 mac->sme.congestion_cb = congestion_cb;
15548 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015549 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015550 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015551 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015552 }
15553
15554 return status;
15555}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015556
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015557QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15558 uint32_t param_val)
15559{
15560 return wma_configure_smps_params(vdev_id, param_id, param_val);
15561}
15562
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015563QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15564 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15565{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015566 wma_cli_set_cmd_t *iwcmd;
15567 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015568
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015569 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15570 if (!iwcmd) {
15571 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015572 return QDF_STATUS_E_NOMEM;
15573 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015574
15575 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15576 iwcmd->param_sec_value = 0;
15577 iwcmd->param_vdev_id = vdev_id;
15578 iwcmd->param_id = param_id;
15579 iwcmd->param_vp_dev = req_cat;
15580 iwcmd->param_value = param_val;
15581 wma_ipa_uc_stat_request(iwcmd);
15582 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015583
15584 return status;
15585}
lifeng66831662017-05-19 16:01:35 +080015586
15587QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15588 struct sir_set_rx_reorder_timeout_val *req)
15589{
15590 QDF_STATUS status;
15591
15592 status = wma_set_rx_reorder_timeout_val(hal, req);
15593
15594 return status;
15595}
15596
15597QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15598 struct sir_peer_set_rx_blocksize *req)
15599{
15600 QDF_STATUS status;
15601
15602 status = wma_set_rx_blocksize(hal, req);
15603
15604 return status;
15605}
Naveen Rawat247a8682017-06-05 15:00:31 -070015606
15607int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15608{
15609 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15610}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015611
15612QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15613 void (*cb)(void *, uint32_t bt_activity))
15614{
15615 QDF_STATUS status;
15616 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15617
15618 status = sme_acquire_global_lock(&mac->sme);
15619 if (QDF_IS_STATUS_SUCCESS(status)) {
15620 mac->sme.bt_activity_info_cb = cb;
15621 sme_release_global_lock(&mac->sme);
15622 sme_debug("bt activity info callback set");
15623 } else {
15624 sme_debug("sme_acquire_global_lock failed %d", status);
15625 }
15626
15627 return status;
15628}
lifengd217d192017-05-09 19:44:16 +080015629
15630QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15631 struct get_chain_rssi_req_params *input,
15632 get_chain_rssi_callback callback,
15633 void *context)
15634{
15635 QDF_STATUS status = QDF_STATUS_SUCCESS;
15636 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15637
15638 SME_ENTER();
15639
15640 if (NULL == input) {
15641 sme_err("Invalid req params");
15642 return QDF_STATUS_E_INVAL;
15643 }
15644
15645 mac_ctx->sme.get_chain_rssi_cb = callback;
15646 mac_ctx->sme.get_chain_rssi_context = context;
15647 wma_get_chain_rssi(hal, input);
15648
15649 SME_EXIT();
15650 return status;
15651}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015652
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015653QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15654 struct scheduler_msg *msg)
15655{
15656 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15657
15658 if (msg == NULL) {
15659 sme_err("Empty message for SME Msg callback");
15660 return status;
15661 }
15662 status = sme_process_msg(hal, msg);
15663 return status;
15664}
15665
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015666void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15667{
15668 struct csr_roam_session *session;
15669 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15670
15671 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15672 sme_err("%s Invalid session id: %d", __func__, session_id);
15673 return;
15674 }
15675
15676 session = CSR_GET_SESSION(mac_ctx, session_id);
15677 if (!session) {
15678 sme_err("%s Failed to get session for id: %d",
15679 __func__, session_id);
15680 return;
15681 }
15682
15683 sme_debug("Total No. of Disconnections: %d",
15684 session->disconnect_stats.disconnection_cnt);
15685
15686 sme_debug("No. of Diconnects Triggered by Application: %d",
15687 session->disconnect_stats.disconnection_by_app);
15688
15689 sme_debug("No. of Disassoc Sent by Peer: %d",
15690 session->disconnect_stats.disassoc_by_peer);
15691
15692 sme_debug("No. of Deauth Sent by Peer: %d",
15693 session->disconnect_stats.deauth_by_peer);
15694
15695 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15696 session->disconnect_stats.bmiss);
15697
15698 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15699 session->disconnect_stats.peer_kickout);
15700}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015701
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015702 /**
15703 * sme_set_vc_mode_config() - Set voltage corner config to FW
15704 * @bitmap: Bitmap that referes to voltage corner config with
15705 * different phymode and bw configuration
15706 *
15707 * Return: QDF_STATUS
15708 */
15709QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15710{
15711 void *wma_handle;
15712
15713 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15714 if (!wma_handle) {
15715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15716 "wma_handle is NULL");
15717 return QDF_STATUS_E_FAILURE;
15718 }
15719 if (QDF_STATUS_SUCCESS !=
15720 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15721 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15722 "%s: Failed to set Voltage Control config to FW",
15723 __func__);
15724 return QDF_STATUS_E_FAILURE;
15725 }
15726 return QDF_STATUS_SUCCESS;
15727}
15728
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015729/**
15730 * sme_set_bmiss_bcnt() - set bmiss config parameters
15731 * @vdev_id: virtual device for the command
15732 * @first_cnt: bmiss first value
15733 * @final_cnt: bmiss final value
15734 *
15735 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15736 */
15737QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15738 uint32_t final_cnt)
15739{
15740 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15741}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015742
15743QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15744 bool is_tos_active, uint32_t max_off_chan_time,
15745 uint32_t rest_time, bool skip_dfs_chan)
15746{
15747 struct sir_limit_off_chan *cmd;
15748 struct scheduler_msg msg = {0};
15749
15750 cmd = qdf_mem_malloc(sizeof(*cmd));
15751 if (!cmd) {
15752 sme_err("qdf_mem_malloc failed for limit off channel");
15753 return QDF_STATUS_E_NOMEM;
15754 }
15755
15756 cmd->vdev_id = vdev_id;
15757 cmd->is_tos_active = is_tos_active;
15758 cmd->max_off_chan_time = max_off_chan_time;
15759 cmd->rest_time = rest_time;
15760 cmd->skip_dfs_chans = skip_dfs_chan;
15761
15762 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15763 msg.reserved = 0;
15764 msg.bodyptr = cmd;
15765
15766 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15767 &msg))) {
15768 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15769 qdf_mem_free(cmd);
15770 return QDF_STATUS_E_FAILURE;
15771 }
15772
15773 return QDF_STATUS_SUCCESS;
15774}