blob: fcf28de9e8a36b9fdb038ef0344e6dd71d74ccba [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;
983 scan_params.num_bssid_favored =
984 roam_params_src->num_bssid_favored;
985 scan_params.raise_rssi_thresh_5g =
986 roam_params_src->raise_rssi_thresh_5g;
987 scan_params.drop_rssi_thresh_5g =
988 roam_params_src->drop_rssi_thresh_5g;
989 scan_params.raise_factor_5g =
990 roam_params_src->raise_factor_5g;
991 scan_params.drop_factor_5g =
992 roam_params_src->drop_factor_5g;
993 scan_params.max_raise_rssi_5g =
994 roam_params_src->max_raise_rssi_5g;
995 scan_params.max_drop_rssi_5g =
996 roam_params_src->max_drop_rssi_5g;
997 scan_params.is_5g_pref_enabled =
998 roam_params_src->is_5g_pref_enabled;
999
1000 if (scan_params.num_bssid_favored > MAX_FAVORED_BSSID)
1001 scan_params.num_bssid_favored = MAX_FAVORED_BSSID;
1002
1003 for (i = 0; i < scan_params.num_bssid_favored; i++) {
1004 qdf_copy_macaddr(&scan_params.bssid_favored[i],
1005 &roam_params_src->bssid_favored[i]);
1006 scan_params.bssid_favored_factor[i] =
1007 roam_params_src->bssid_favored_factor[i];
1008 }
1009
1010 if (scan_params.num_bssid_avoid_list >
1011 MAX_AVOID_LIST_BSSID)
1012 scan_params.num_bssid_avoid_list =
1013 MAX_AVOID_LIST_BSSID;
1014
1015 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
1016 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
1017 &roam_params_src->bssid_avoid_list[i]);
1018 }
1019
1020 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
1021 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001022 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +05301023 status);
1024}
1025
1026/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 * sme_update_roam_params() - Store/Update the roaming params
1028 * @hal: Handle for Hal layer
1029 * @session_id: SME Session ID
1030 * @roam_params_src: The source buffer to copy
1031 * @update_param: Type of parameter to be updated
1032 *
1033 * Return: Return the status of the updation.
1034 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301035QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001036 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 int update_param)
1038{
1039 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1040 struct roam_ext_params *roam_params_dst;
1041 uint8_t i;
1042
1043 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1044 switch (update_param) {
1045 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1046 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001047 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001049 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001051 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001053 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001055 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001057 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001059 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 roam_params_dst->is_5g_pref_enabled = true;
1061 break;
1062 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301063 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1065 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001066 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1068 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001069 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301070 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001071 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 roam_params_dst->ssid_allowed_list[i].length);
1073 }
1074 break;
1075 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301076 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1078 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001079 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301081 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001082 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 sizeof(tSirMacAddr));
1084 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001085 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 }
1087 break;
1088 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301089 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301090 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001092 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301094 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001095 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 }
1097 break;
1098 case REASON_ROAM_GOOD_RSSI_CHANGED:
1099 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001100 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 break;
1102 default:
1103 break;
1104 }
1105 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1106 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301107
1108 sme_update_scan_roam_params(mac_ctx);
1109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110 return 0;
1111}
1112
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301113/*
1114 * sme_process_ready_to_suspend() -
1115 * On getting ready to suspend indication, this function calls
1116 * callback registered (HDD callbacks) with SME to inform ready
1117 * to suspend indication.
1118 *
1119 * hHal - Handle returned by mac_open.
1120 * pReadyToSuspend - Parameter received along with ready to suspend
1121 * indication from WMA.
1122 * Return: None
1123 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001124static void sme_process_ready_to_suspend(tHalHandle hHal,
1125 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126{
1127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1128
1129 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 "%s: pMac is null", __func__);
1132 return;
1133 }
1134
1135 if (NULL != pMac->readyToSuspendCallback) {
1136 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1137 pReadyToSuspend->suspended);
1138 pMac->readyToSuspendCallback = NULL;
1139 }
1140}
1141
1142#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001144/**
1145 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1146 * @hHal - Handle returned by mac_open.
1147 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1148 * indication from WMA.
1149 *
1150 * On getting ready to Ext WoW indication, this function calls callback
1151 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1152 *
1153 * Return: None
1154 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001155static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1156 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157{
1158 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1159
1160 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301161 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 "%s: pMac is null", __func__);
1163 return;
1164 }
1165
1166 if (NULL != pMac->readyToExtWoWCallback) {
1167 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1168 pReadyToExtWoW->status);
1169 pMac->readyToExtWoWCallback = NULL;
1170 pMac->readyToExtWoWContext = NULL;
1171 }
1172
1173}
1174#endif
1175
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301176/*
1177 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1178 * that the NIC is ready tio run.
1179 * The function is called by HDD at the end of initialization stage so PE/HAL
1180 * can enable the NIC to running state.
1181 * This is a synchronous call
1182 *
1183 * @hHal - The handle returned by mac_open.
1184 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1185 * successfully.
1186 * Other status means SME failed to send the message to PE.
1187 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301188QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189{
Abhishek Singhde410b72017-05-22 15:25:39 +05301190 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301191 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1193
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301194 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1196 do {
1197
Abhishek Singhde410b72017-05-22 15:25:39 +05301198 msg = qdf_mem_malloc(sizeof(*msg));
1199 if (!msg) {
1200 sme_err("Memory allocation failed! for msg");
1201 return QDF_STATUS_E_NOMEM;
1202 }
1203 msg->messageType = eWNI_SME_SYS_READY_IND;
1204 msg->length = sizeof(*msg);
1205 msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
1206 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001207 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301209 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1210 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301211 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001213 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 break;
1215 }
1216
1217 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301218 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001219 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220 break;
1221 }
1222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 pMac->sme.state = SME_STATE_READY;
1224 } while (0);
1225
1226 return status;
1227}
1228
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001229QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1230{
1231 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1232 QDF_STATUS status = QDF_STATUS_SUCCESS;
1233
1234 if (NULL == mac_ctx) {
1235 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1236 FL("Invalid MAC context"));
1237 return QDF_STATUS_E_FAILURE;
1238 }
1239
1240 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1241 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1242 status = QDF_STATUS_E_INVAL;
1243
1244 return status;
1245}
1246
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301247/*
1248 * sme_start() - Put all SME modules at ready state.
1249 * The function starts each module in SME, PMC, CSR, etc. . Upon
1250 * successfully return, all modules are ready to run.
1251 * This is a synchronous call
1252 *
1253 * hHal - The handle returned by mac_open.
1254 * Return QDF_STATUS_SUCCESS - SME is ready.
1255 * Other status means SME is failed to start
1256 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301257QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301259 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001261 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262
1263 do {
1264 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301265 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001266 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 break;
1268 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001269 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001270 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001271 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1272 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1273 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1274 sme_cbacks.sme_soc_set_dual_mac_config =
1275 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001276 sme_cbacks.sme_change_mcc_beacon_interval =
1277 sme_change_mcc_beacon_interval;
1278 sme_cbacks.sme_get_ap_channel_from_scan =
1279 sme_get_ap_channel_from_scan;
1280 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001281 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1282 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001283 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001284 status);
1285 break;
1286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001289 /* START RRM */
1290 status = rrm_start(pMac);
1291 if (!QDF_IS_STATUS_SUCCESS(status)) {
1292 sme_err("Failed to start RRM");
1293 break;
1294 }
1295 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 return status;
1297}
1298
Arif Hussaincd151632017-02-11 16:57:19 -08001299static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1300 struct scheduler_msg *msg)
1301{
1302 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001303 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001304 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1305 uint32_t session_id = 0;
1306 eRoamCmdStatus roam_status;
1307 eCsrRoamResult roam_result;
1308
1309 switch (msg->type) {
1310 case eWNI_SME_DFS_RADAR_FOUND:
1311 {
1312 session_id = msg->bodyval;
1313 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1314 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301315 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001316 "sapdfs: Radar indication event occurred");
1317 break;
1318 }
1319 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1320 {
1321 csa_ie_tx_complete_rsp =
1322 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1323 if (!csa_ie_tx_complete_rsp) {
1324 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1325 return QDF_STATUS_E_FAILURE;
1326 }
1327 session_id = csa_ie_tx_complete_rsp->sessionId;
1328 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1329 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301330 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001331 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1332 session_id);
1333 break;
1334 }
1335 case eWNI_SME_DFS_CAC_COMPLETE:
1336 {
1337 session_id = msg->bodyval;
1338 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1339 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301340 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001341 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1342 session_id);
1343 break;
1344 }
1345 default:
1346 {
1347 sme_err("Invalid DFS message: 0x%x", msg->type);
1348 status = QDF_STATUS_E_FAILURE;
1349 return status;
1350 }
1351 }
1352
1353 /* Indicate Radar Event to SAP */
1354 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1355 roam_status, roam_result);
1356 return status;
1357}
1358
1359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301361/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 * Handle the unprotected management frame indication from LIM and
1363 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301364 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301365QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1367{
1368 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301369 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001370 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1372
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001373 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1374 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1375 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376
1377 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001378 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1380
1381 return status;
1382}
1383#endif
1384
Kapil Gupta8878ad92017-02-13 11:56:04 +05301385QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1386{
1387 QDF_STATUS status = QDF_STATUS_SUCCESS;
1388 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001389 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301390 eRoamCmdStatus roamStatus;
1391 eCsrRoamResult roamResult;
1392
1393 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
1394 roamInfo->dfs_event.sessionId = session_id;
1395
1396 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1397 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301398 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301399 "sapdfs: Updated new channel event");
1400
1401 /* Indicate channel Event to SAP */
1402 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1403 roamStatus, roamResult);
1404
1405 qdf_mem_free(roamInfo);
1406 return status;
1407}
1408
1409
Abhishek Singh518323d2015-10-19 17:42:01 +05301410/**
1411 * sme_extended_change_channel_ind()- function to indicate ECSA
1412 * action frame is received in lim to SAP
1413 * @mac_ctx: pointer to global mac structure
1414 * @msg_buf: contain new channel and session id.
1415 *
1416 * This function is called to post ECSA action frame
1417 * receive event to SAP.
1418 *
1419 * Return: success if msg indicated to SAP else return failure
1420 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301422 void *msg_buf)
1423{
1424 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301425 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301426 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001427 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301428 eRoamCmdStatus roam_status;
1429 eCsrRoamResult roam_result;
1430
Abhishek Singh518323d2015-10-19 17:42:01 +05301431 ext_chan_ind = msg_buf;
1432 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001433 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301434 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301435 }
1436 session_id = ext_chan_ind->session_id;
1437 roamInfo.target_channel = ext_chan_ind->new_channel;
1438 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1439 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001440 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1441 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301442
1443 /* Indicate Ext Channel Change event to SAP */
1444 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1445 roam_status, roam_result);
1446 return status;
1447}
1448
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001449/**
1450 * sme_process_fw_mem_dump_rsp - process fw memory dump response from WMA
1451 *
1452 * @mac_ctx: pointer to MAC handle.
1453 * @msg: pointer to received SME msg.
1454 *
1455 * This function process the received SME message and calls the corresponding
1456 * callback which was already registered with SME.
1457 *
1458 * Return: None
1459 */
1460#ifdef WLAN_FEATURE_MEMDUMP
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001461static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1462 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001463{
1464 if (msg->bodyptr) {
1465 if (mac_ctx->sme.fw_dump_callback)
1466 mac_ctx->sme.fw_dump_callback(mac_ctx->hHdd,
1467 (struct fw_dump_rsp *) msg->bodyptr);
1468 qdf_mem_free(msg->bodyptr);
1469 }
1470}
1471#else
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001472static void sme_process_fw_mem_dump_rsp(tpAniSirGlobal mac_ctx,
1473 struct scheduler_msg *msg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001474{
1475}
1476#endif
1477
1478#ifdef FEATURE_WLAN_ESE
1479/**
1480 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1481 * @hHal: HAL handle
1482 * @sessionId: session id
1483 * @isEseIniFeatureEnabled: ese ini enabled
1484 *
1485 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1486 * isEseIniFeatureEnabled. This is a synchronous call
1487 *
1488 * Return: QDF_STATUS enumeration
1489 */
1490QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1491 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1492{
1493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1494
1495 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1496 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001498 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1499 __func__,
1500 pMac->roam.configParam.isEseIniFeatureEnabled,
1501 isEseIniFeatureEnabled);
1502 return QDF_STATUS_SUCCESS;
1503 }
1504
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301505 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001506 "%s: EseEnabled is changed from %d to %d", __func__,
1507 pMac->roam.configParam.isEseIniFeatureEnabled,
1508 isEseIniFeatureEnabled);
1509 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001510 csr_neighbor_roam_update_fast_roaming_enabled(
1511 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001512
1513 if (true == isEseIniFeatureEnabled)
1514 sme_update_fast_transition_enabled(hHal, true);
1515
1516 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1517 csr_roam_offload_scan(pMac, sessionId,
1518 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1519 REASON_ESE_INI_CFG_CHANGED);
1520
1521 return QDF_STATUS_SUCCESS;
1522}
1523
1524/**
1525 * sme_set_plm_request() - set plm request
1526 * @hHal: HAL handle
1527 * @pPlmReq: Pointer to input plm request
1528 *
1529 * Return: QDF_STATUS enumeration
1530 */
1531QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1532{
1533 QDF_STATUS status;
1534 bool ret = false;
1535 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001536 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001537 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001538 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301539 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1540 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001541
1542 status = sme_acquire_global_lock(&pMac->sme);
1543 if (!QDF_IS_STATUS_SUCCESS(status))
1544 return status;
1545
1546 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001547 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001548 sme_release_global_lock(&pMac->sme);
1549 return QDF_STATUS_E_FAILURE;
1550 }
1551
1552 if (!pSession->sessionActive) {
1553 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1554 FL("Invalid Sessionid"));
1555 sme_release_global_lock(&pMac->sme);
1556 return QDF_STATUS_E_FAILURE;
1557 }
1558
1559 if (!pPlmReq->enable)
1560 goto send_plm_start;
1561 /* validating channel numbers */
1562 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1563 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1564 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001565 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1566 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001567 pPlmReq->plmChList[count])) {
1568 /* DFS channel is provided, no PLM bursts can be
1569 * transmitted. Ignoring these channels.
1570 */
1571 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301572 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001573 FL("DFS channel %d ignored for PLM"),
1574 pPlmReq->plmChList[count]);
1575 continue;
1576 }
1577 } else if (!ret) {
1578 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301579 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001580 FL("Unsupported channel %d ignored for PLM"),
1581 pPlmReq->plmChList[count]);
1582 continue;
1583 }
1584 ch_list[valid_count] = pPlmReq->plmChList[count];
1585 valid_count++;
1586 } /* End of for () */
1587
1588 /* Copying back the valid channel list to plm struct */
1589 qdf_mem_set((void *)pPlmReq->plmChList,
1590 pPlmReq->plmNumCh, 0);
1591 if (valid_count)
1592 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1593 valid_count);
1594 /* All are invalid channels, FW need to send the PLM
1595 * report with "incapable" bit set.
1596 */
1597 pPlmReq->plmNumCh = valid_count;
1598
1599send_plm_start:
1600 /* PLM START */
1601 msg.type = WMA_SET_PLM_REQ;
1602 msg.reserved = 0;
1603 msg.bodyptr = pPlmReq;
1604
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001605 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001606 &msg))) {
1607 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1608 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1609 sme_release_global_lock(&pMac->sme);
1610 return QDF_STATUS_E_FAILURE;
1611 }
1612
1613 sme_release_global_lock(&pMac->sme);
1614 return status;
1615}
1616
1617/**
1618 * sme_tsm_ie_ind() - sme tsm ie indication
1619 * @hHal: HAL handle
1620 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 *
1622 * Handle the tsm ie indication from LIM and forward it to HDD.
1623 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001624 * Return: QDF_STATUS enumeration
1625 */
1626static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627{
1628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301629 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001630 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301632
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001633 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1634 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1635 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001637 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301638 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 return status;
1640}
1641
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001642/**
1643 * sme_set_cckm_ie() - set cckm ie
1644 * @hHal: HAL handle
1645 * @sessionId: session id
1646 * @pCckmIe: Pointer to CCKM Ie
1647 * @cckmIeLen: Length of @pCckmIe
1648 *
1649 * Function to store the CCKM IE passed from supplicant and use
1650 * it while packing reassociation request.
1651 *
1652 * Return: QDF_STATUS enumeration
1653 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301654QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 uint8_t *pCckmIe, uint8_t cckmIeLen)
1656{
1657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301661 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1663 sme_release_global_lock(&pMac->sme);
1664 }
1665 return status;
1666}
1667
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001668/**
1669 * sme_set_ese_beacon_request() - set ese beacon request
1670 * @hHal: HAL handle
1671 * @sessionId: session id
1672 * @pEseBcnReq: Ese beacon report
1673 *
1674 * function to set ESE beacon request parameters
1675 *
1676 * Return: QDF_STATUS enumeration
1677 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301678QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 const tCsrEseBeaconReq *pEseBcnReq)
1680{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001681 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1683 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1684 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1685 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301686 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1688
1689 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001690 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301691 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 }
1693
1694 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301695 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 sizeof(tCsrEseBeaconReq));
1697
1698 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301699 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001701 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301702 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 }
1704
1705 pSmeRrmContext->eseBcnReqInProgress = true;
1706
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001707 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708
1709 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1710 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301711 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 pSession->connectedProfile.bssid.bytes,
1713 sizeof(tSirMacAddr));
1714 pSmeBcnReportReq->channelInfo.channelNum = 255;
1715 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1716 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1717
1718 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1719 pBeaconReq =
1720 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1721 pSmeBcnReportReq->fMeasurementtype[counter] =
1722 pBeaconReq->scanMode;
1723 pSmeBcnReportReq->measurementDuration[counter] =
1724 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1725 pSmeBcnReportReq->channelList.channelNumber[counter] =
1726 pBeaconReq->channel;
1727 }
1728
1729 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1730
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301731 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 pSmeRrmContext->eseBcnReqInProgress = false;
1733
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301734 qdf_mem_free(pSmeBcnReportReq);
1735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 return status;
1737}
1738
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001739/**
1740 * sme_get_tsm_stats() - SME get tsm stats
1741 * @hHal: HAL handle
1742 * @callback: SME sends back the requested stats using the callback
1743 * @staId: The station ID for which the stats is requested for
1744 * @bssId: bssid
1745 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001746 * @tid: Traffic id
1747 *
1748 * API register a callback to get TSM Stats.
1749 *
1750 * Return: QDF_STATUS enumeration
1751 */
1752QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1753 tCsrTsmStatsCallback callback,
1754 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001755 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001756{
1757 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1758 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1759
1760 status = sme_acquire_global_lock(&pMac->sme);
1761 if (QDF_IS_STATUS_SUCCESS(status)) {
1762 status = csr_get_tsm_stats(pMac, callback,
1763 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001764 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001765 sme_release_global_lock(&pMac->sme);
1766 }
1767 return status;
1768}
1769
1770/**
1771 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1772 * @hHal: pointer HAL handle returned by mac_open
1773 * @sessionId: sme session id
1774 * @pChannelList: Output channel list
1775 * @numChannels: Output number of channels
1776 *
1777 * This routine is called to set ese roam scan channel list.
1778 * This is a synchronous call
1779 *
1780 * Return: QDF_STATUS
1781 */
1782QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1783 uint8_t sessionId,
1784 uint8_t *pChannelList,
1785 uint8_t numChannels)
1786{
1787 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1788 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001789 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1790 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001791 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1792 uint8_t newChannelList[128] = { 0 };
1793 uint8_t i = 0, j = 0;
1794
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001795 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1797 FL("Invalid sme session id: %d"), sessionId);
1798 return QDF_STATUS_E_INVAL;
1799 }
1800
1801 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1802 curchnl_list_info =
1803 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1804
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001805 status = sme_acquire_global_lock(&pMac->sme);
1806 if (!QDF_IS_STATUS_SUCCESS(status)) {
1807 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1808 csr_roam_offload_scan(pMac, sessionId,
1809 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1810 REASON_CHANNEL_LIST_CHANGED);
1811 return status;
1812 }
1813 if (NULL != curchnl_list_info->ChannelList) {
1814 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1815 j += snprintf(oldChannelList + j,
1816 sizeof(oldChannelList) - j, "%d",
1817 curchnl_list_info->ChannelList[i]);
1818 }
1819 }
1820 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1821 pChannelList, numChannels,
1822 csr_get_current_band(hHal));
1823 if (QDF_IS_STATUS_SUCCESS(status)) {
1824 if (NULL != curchnl_list_info->ChannelList) {
1825 j = 0;
1826 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1827 j += snprintf(newChannelList + j,
1828 sizeof(newChannelList) - j, "%d",
1829 curchnl_list_info->ChannelList[i]);
1830 }
1831 }
1832 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1833 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1834 newChannelList, oldChannelList,
1835 pNeighborRoamInfo->neighborRoamState);
1836 }
1837 sme_release_global_lock(&pMac->sme);
1838 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1839 csr_roam_offload_scan(pMac, sessionId,
1840 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1841 REASON_CHANNEL_LIST_CHANGED);
1842 return status;
1843}
1844
1845#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846
Jeff Johnson49c02f92016-10-07 10:29:09 -07001847static
1848QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1849 tpSirIbssGetPeerInfoRspParams
1850 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001851{
1852 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1853
1854 if (NULL == pMac) {
1855 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1856 "%s: pMac is null", __func__);
1857 return QDF_STATUS_E_FAILURE;
1858 }
1859 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1860 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1861 "%s: HDD callback is null", __func__);
1862 return QDF_STATUS_E_FAILURE;
1863 }
1864 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1865 &pIbssPeerInfoParams->
1866 ibssPeerInfoRspParams);
1867 return QDF_STATUS_SUCCESS;
1868}
1869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1872 * @mac: Global MAC pointer
1873 * @msg: Dual mac config response
1874 *
1875 * Processes the dual mac configuration response and invokes the HDD callback
1876 * to process further
1877 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301878static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 uint8_t *msg)
1880{
1881 tListElem *entry = NULL;
1882 tSmeCmd *command = NULL;
1883 bool found;
1884 dual_mac_cb callback = NULL;
1885 struct sir_dual_mac_config_resp *param;
1886
1887 param = (struct sir_dual_mac_config_resp *)msg;
1888 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001889 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 /* Not returning. Need to check if active command list
1891 * needs to be freed
1892 */
1893 }
1894
Krunal Sonia8270f52017-02-23 19:51:25 -08001895 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001897 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301898 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 }
1900
1901 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1902 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001903 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301904 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 }
1906
1907 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001908 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301909 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 }
1911
1912 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1913 if (callback) {
1914 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001915 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001917 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 callback(param->status,
1919 command->u.set_dual_mac_cmd.scan_config,
1920 command->u.set_dual_mac_cmd.fw_mode_config);
1921 }
1922 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001923 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 }
1925
Krunal Soni72dba662017-02-15 20:13:17 -08001926 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 if (found)
1928 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001929 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301931 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932}
1933
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001934/**
1935 * sme_process_antenna_mode_resp() - Process set antenna mode
1936 * response
1937 * @mac: Global MAC pointer
1938 * @msg: antenna mode response
1939 *
1940 * Processes the antenna mode response and invokes the HDD
1941 * callback to process further
1942 */
1943static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1944 uint8_t *msg)
1945{
1946 tListElem *entry;
1947 tSmeCmd *command;
1948 bool found;
1949 antenna_mode_cb callback;
1950 struct sir_antenna_mode_resp *param;
1951
1952 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301953 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001954 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001955 /* Not returning. Need to check if active command list
1956 * needs to be freed
1957 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001958
Krunal Sonia8270f52017-02-23 19:51:25 -08001959 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001960 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001961 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001962 return QDF_STATUS_E_FAILURE;
1963 }
1964
1965 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1966 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001967 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001968 return QDF_STATUS_E_FAILURE;
1969 }
1970
1971 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001972 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001973 return QDF_STATUS_E_FAILURE;
1974 }
1975
1976 callback =
1977 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1978 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301979 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001980 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301981 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001982 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001983 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001984 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001985 }
1986
Krunal Soni72dba662017-02-15 20:13:17 -08001987 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001988 if (found)
1989 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001990 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001991
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001992 return QDF_STATUS_SUCCESS;
1993}
1994
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301995/*
1996 * sme_process_msg() - The main message processor for SME.
1997 * The function is called by a message dispatcher when to process a message
1998 * targeted for SME.
1999 * This is a synchronous call
2000 *
2001 * hHal - The handle returned by mac_open.
2002 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
2003 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
2004 * Other status means SME failed to process the message to HAL.
2005 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002006QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302008 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2010
2011 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002012 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 return status;
2014 }
2015 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302016 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002017 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302019 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 return status;
2021 }
2022 if (!SME_IS_START(pMac)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002023 sme_warn("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302025 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 goto release_lock;
2027 }
2028 switch (pMsg->type) {
2029#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302031 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
2033 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302034 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 break;
2036#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 case WNI_CFG_SET_CNF:
2038 case WNI_CFG_DNLD_CNF:
2039 case WNI_CFG_GET_RSP:
2040 case WNI_CFG_ADD_GRP_ADDR_CNF:
2041 case WNI_CFG_DEL_GRP_ADDR_CNF:
2042 break;
2043 case eWNI_SME_ADDTS_RSP:
2044 case eWNI_SME_DELTS_RSP:
2045 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 /* QoS */
2048 if (pMsg->bodyptr) {
2049#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2050 status = sme_qos_msg_processor(pMac, pMsg->type,
2051 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302052 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053#endif
2054 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002055 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 }
2057 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 case eWNI_SME_NEIGHBOR_REPORT_IND:
2059 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 if (pMsg->bodyptr) {
2061 status = sme_rrm_msg_processor(pMac, pMsg->type,
2062 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302063 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302065 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 }
2067 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 case eWNI_SME_ADD_STA_SELF_RSP:
2069 if (pMsg->bodyptr) {
2070 status = csr_process_add_sta_session_rsp(pMac,
2071 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302072 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002074 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 }
2076 break;
2077 case eWNI_SME_DEL_STA_SELF_RSP:
2078 if (pMsg->bodyptr) {
2079 status = csr_process_del_sta_session_rsp(pMac,
2080 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302081 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002083 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 }
2085 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 case eWNI_SME_CHANGE_COUNTRY_CODE:
2087 if (pMsg->bodyptr) {
2088 status = sme_handle_change_country_code((void *)pMac,
2089 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302090 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002092 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 }
2094 break;
2095 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2096 if (pMsg->bodyptr) {
2097 status = sme_handle_generic_change_country_code(
2098 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302099 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002101 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 }
2103 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105#ifdef WLAN_FEATURE_11W
2106 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2107 if (pMsg->bodyptr) {
2108 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302109 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002111 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 }
2113 break;
2114#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002115#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 case eWNI_SME_TSM_IE_IND:
2117 if (pMsg->bodyptr) {
2118 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302119 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002121 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 }
2123 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002124#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2126 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2127 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302128 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002130 case eWNI_SME_IBSS_PEER_INFO_RSP:
2131 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002132 sme_ibss_peer_info_response_handler(pMac,
2133 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002134 qdf_mem_free(pMsg->bodyptr);
2135 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002136 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002137 }
2138 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 case eWNI_SME_READY_TO_SUSPEND_IND:
2140 if (pMsg->bodyptr) {
2141 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302142 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002144 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 }
2146 break;
2147#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2148 case eWNI_SME_READY_TO_EXTWOW_IND:
2149 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002150 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302151 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002153 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 }
2155 break;
2156#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2158 case eWNI_SME_AUTO_SHUTDOWN_IND:
2159 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302160 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 FL("Auto shutdown notification"));
2162 pMac->sme.pAutoShutdownNotificationCb();
2163 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302164 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 break;
2166#endif
2167 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002168 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002170 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302171 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 break;
2173 case eWNI_SME_CHANNEL_CHANGE_RSP:
2174 if (pMsg->bodyptr) {
2175 status = sme_process_channel_change_resp(pMac,
2176 pMsg->type,
2177 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302178 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002180 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 }
2182 break;
2183#ifdef WLAN_FEATURE_STATS_EXT
2184 case eWNI_SME_STATS_EXT_EVENT:
2185 if (pMsg->bodyptr) {
2186 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002189 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 }
2191 break;
2192#endif
Will Huang558f8082017-05-31 16:22:24 +08002193 case eWNI_SME_GET_PEER_INFO_IND:
2194 if (pMac->sme.pget_peer_info_ind_cb)
2195 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2196 pMac->sme.pget_peer_info_cb_context);
2197 qdf_mem_free(pMsg->bodyptr);
2198 break;
2199 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2200 if (pMac->sme.pget_peer_info_ext_ind_cb)
2201 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2202 pMac->sme.pget_peer_info_ext_cb_context);
2203 qdf_mem_free(pMsg->bodyptr);
2204 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 case eWNI_SME_CSA_OFFLOAD_EVENT:
2206 if (pMsg->bodyptr) {
2207 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 }
2210 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002211 case eWNI_SME_TSF_EVENT:
2212 if (pMac->sme.get_tsf_cb) {
2213 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2214 (struct stsf *)pMsg->bodyptr);
2215 }
2216 if (pMsg->bodyptr)
2217 qdf_mem_free(pMsg->bodyptr);
2218 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219#ifdef WLAN_FEATURE_NAN
2220 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302221 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2222 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 if (pMsg->bodyptr) {
2224 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302225 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 }
2227 break;
2228#endif /* WLAN_FEATURE_NAN */
2229 case eWNI_SME_LINK_STATUS_IND:
2230 {
2231 tAniGetLinkStatus *pLinkStatus =
2232 (tAniGetLinkStatus *) pMsg->bodyptr;
2233 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302234 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 pMac->sme.linkStatusCallback(
2236 pLinkStatus->linkStatus,
2237 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 pMac->sme.linkStatusCallback = NULL;
2240 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302241 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 }
2243 break;
2244 }
2245 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302246 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2248 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 break;
2250 case eWNI_SME_SNR_IND:
2251 {
2252 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 if (pSnrReq) {
2255 if (pSnrReq->snrCallback) {
2256 ((tCsrSnrCallback)
2257 (pSnrReq->snrCallback))
2258 (pSnrReq->snr, pSnrReq->staId,
2259 pSnrReq->pDevContext);
2260 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302261 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 }
2263 break;
2264 }
2265#ifdef FEATURE_WLAN_EXTSCAN
2266 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2267 if (pMac->sme.pExtScanIndCb)
2268 pMac->sme.pExtScanIndCb(pMac->hHdd,
2269 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2270 pMsg->bodyptr);
2271 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002272 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 pMsg->type);
2274
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302275 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 break;
2277 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2278 if (pMac->sme.pExtScanIndCb)
2279 pMac->sme.pExtScanIndCb(pMac->hHdd,
2280 eSIR_EPNO_NETWORK_FOUND_IND,
2281 pMsg->bodyptr);
2282 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002283 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 pMsg->type);
2285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 break;
2288#endif
2289 case eWNI_SME_FW_DUMP_IND:
2290 sme_process_fw_mem_dump_rsp(pMac, pMsg);
2291 break;
2292 case eWNI_SME_SET_HW_MODE_RESP:
2293 if (pMsg->bodyptr) {
2294 status = sme_process_set_hw_mode_resp(pMac,
2295 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302296 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002298 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 }
2300 break;
2301 case eWNI_SME_HW_MODE_TRANS_IND:
2302 if (pMsg->bodyptr) {
2303 status = sme_process_hw_mode_trans_ind(pMac,
2304 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302305 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002307 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 }
2309 break;
2310 case eWNI_SME_NSS_UPDATE_RSP:
2311 if (pMsg->bodyptr) {
2312 status = sme_process_nss_update_resp(pMac,
2313 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302314 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002316 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 }
2318 break;
2319 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302320 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 pMac->sme.ocb_set_config_callback(
2322 pMac->sme.ocb_set_config_context,
2323 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302324 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002325 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 pMac->sme.ocb_set_config_callback = NULL;
2327 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302328 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 break;
2330 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302331 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 pMac->sme.ocb_get_tsf_timer_callback(
2333 pMac->sme.ocb_get_tsf_timer_context,
2334 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302335 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002336 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2338 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302339 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 break;
2341 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302342 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 pMac->sme.dcc_get_stats_callback(
2344 pMac->sme.dcc_get_stats_context,
2345 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302346 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002347 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 pMac->sme.dcc_get_stats_callback = NULL;
2349 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302350 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 break;
2352 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302353 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 pMac->sme.dcc_update_ndl_callback(
2355 pMac->sme.dcc_update_ndl_context,
2356 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302357 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002358 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 pMac->sme.dcc_update_ndl_callback = NULL;
2360 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302361 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 break;
2363 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302364 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 pMac->sme.dcc_stats_event_callback(
2366 pMac->sme.dcc_stats_event_context,
2367 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302368 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002369 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302370 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 break;
2372 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2373 if (pMsg->bodyptr) {
2374 status = sme_process_dual_mac_config_resp(pMac,
2375 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302376 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002378 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 }
2380 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2381 if (pMac->sme.set_thermal_level_cb)
2382 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2383 pMsg->bodyval);
2384 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302385 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2386 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302387 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302388 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002389 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2390 if (pMsg->bodyptr) {
2391 status = sme_process_antenna_mode_resp(pMac,
2392 pMsg->bodyptr);
2393 qdf_mem_free(pMsg->bodyptr);
2394 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002395 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002396 }
2397 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002398 case eWNI_SME_NDP_CONFIRM_IND:
2399 case eWNI_SME_NDP_NEW_PEER_IND:
2400 case eWNI_SME_NDP_INITIATOR_RSP:
Abhishek Singh4fef7472016-06-06 11:36:03 -07002401 case eWNI_SME_NDP_INDICATION:
2402 case eWNI_SME_NDP_RESPONDER_RSP:
Naveen Rawatf28315c2016-06-29 18:06:02 -07002403 case eWNI_SME_NDP_END_RSP:
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07002404 case eWNI_SME_NDP_END_IND:
2405 case eWNI_SME_NDP_PEER_DEPARTED_IND:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002406 sme_ndp_msg_processor(pMac, pMsg);
2407 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302408 case eWNI_SME_LOST_LINK_INFO_IND:
2409 if (pMac->sme.lost_link_info_cb)
2410 pMac->sme.lost_link_info_cb(pMac->hHdd,
2411 (struct sir_lost_link_info *)pMsg->bodyptr);
2412 qdf_mem_free(pMsg->bodyptr);
2413 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302414 case eWNI_SME_RSO_CMD_STATUS_IND:
2415 if (pMac->sme.rso_cmd_status_cb)
2416 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002417 qdf_mem_free(pMsg->bodyptr);
2418 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002419 case eWMI_SME_LL_STATS_IND:
2420 if (pMac->sme.link_layer_stats_ext_cb)
2421 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2422 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302423 qdf_mem_free(pMsg->bodyptr);
2424 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302425 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2426 if (pMac->sme.bt_activity_info_cb)
2427 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2428 pMsg->bodyval);
2429 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 default:
2431
2432 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2433 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2434 /* CSR */
2435 if (pMsg->bodyptr) {
2436 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302437 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302438 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002439 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002441 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302443 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 }
2445 } /* switch */
2446release_lock:
2447 sme_release_global_lock(&pMac->sme);
2448 return status;
2449}
2450
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002451QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2452{
2453 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2454
2455 if (mac_ctx == NULL) {
2456 QDF_ASSERT(0);
2457 return QDF_STATUS_E_FAILURE;
2458 }
2459
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002460 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002461}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463/**
2464 * sme_process_nss_update_resp() - Process nss update response
2465 * @mac: Global MAC pointer
2466 * @msg: nss update response
2467 *
2468 * Processes the nss update response and invokes the HDD
2469 * callback to process further
2470 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302471static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472{
2473 tListElem *entry = NULL;
2474 tSmeCmd *command = NULL;
2475 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002476 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 struct sir_beacon_tx_complete_rsp *param;
2478
2479 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302480 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002481 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 /* Not returning. Need to check if active command list
2483 * needs to be freed
2484 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485
Krunal Sonia8270f52017-02-23 19:51:25 -08002486 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002488 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302489 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 }
2491
2492 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2493 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002494 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302495 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 }
2497
2498 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002499 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302500 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 }
2502
2503 callback = command->u.nss_update_cmd.nss_update_cb;
2504 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302505 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002506 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302507 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 callback(command->u.nss_update_cmd.context,
2509 param->tx_status,
2510 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302511 command->u.nss_update_cmd.next_action,
2512 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002514 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 }
2516
Krunal Soni72dba662017-02-15 20:13:17 -08002517 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 if (found) {
2519 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002520 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002522
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302523 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524}
2525
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302526/* No need to hold the global lock here because this function can only be
2527 * called after sme_stop.
2528 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002529void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530{
2531 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302532 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302533 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 }
2535
2536}
2537
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302538/*
2539 * sme_stop() - Stop all SME modules and put them at idle state
2540 *
2541 * The function stops each module in SME, PMC, CSR, etc. . Upon
2542 * return, all modules are at idle state ready to start.
2543 * This is a synchronous call
2544 *
2545 * hHal - The handle returned by mac_open
2546 * tHalStopType - reason for stopping
2547 * Return QDF_STATUS_SUCCESS - SME is stopped.
2548 * Other status means SME is failed to stop but caller should still
2549 * consider SME is stopped.
2550 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302553 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2554 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2556
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002557 status = rrm_stop(pMac);
2558 if (!QDF_IS_STATUS_SUCCESS(status)) {
2559 sme_err("rrm_stop failed with status: %d", status);
2560 }
2561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302563 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002564 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 fail_status = status;
2566 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302568 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002570
2571 pMac->sme.state = SME_STATE_STOP;
2572
2573 return status;
2574}
2575
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302576/*
2577 * sme_close() - Release all SME modules and their resources.
2578 * The function release each module in SME, PMC, CSR, etc. . Upon
2579 * return, all modules are at closed state.
2580 *
2581 * No SME APIs can be involved after smeClose except smeOpen.
2582 * smeClose must be called before mac_close.
2583 * This is a synchronous call
2584 *
2585 * hHal - The handle returned by mac_open
2586 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2587 *
2588 * Other status means SME is failed to be closed but caller still cannot
2589 * call any other SME functions except smeOpen.
2590 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302591QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302593 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2594 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2596
2597 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302598 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599
2600 /* Note: pSession will be invalid from here on, do not access */
2601 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302602 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002603 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 fail_status = status;
2605 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2607 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302608 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002609 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 fail_status = status;
2611 }
2612#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302614 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002615 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 fail_status = status;
2617 }
2618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302620 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002621 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 fail_status = status;
2623 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 free_sme_cmd_list(pMac);
2626
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302627 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302628 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302629 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302631 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633
2634 pMac->sme.state = SME_STATE_STOP;
2635
2636 return status;
2637}
2638
2639/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302640 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2641 * scan list
2642 * @hal: hal context.
2643 * @bssid: bssid to be removed
2644 *
2645 * This function remove the given bssid from scan list.
2646 *
2647 * Return: QDF status.
2648 */
2649QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2650 tSirMacAddr bssid)
2651{
2652 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2653 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2654
2655 status = sme_acquire_global_lock(&mac_ctx->sme);
2656 if (QDF_IS_STATUS_SUCCESS(status)) {
2657 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2658 sme_release_global_lock(&mac_ctx->sme);
2659 }
2660
2661 return status;
2662}
2663
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302665/*
2666 * sme_scan_get_result
2667 * A wrapper function to request scan results from CSR.
2668 * This is a synchronous call
2669 *
2670 * pFilter - If pFilter is NULL, all cached results are returned
2671 * phResult - an object for the result.
2672 * Return QDF_STATUS
2673 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302674QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 tCsrScanResultFilter *pFilter,
2676 tScanResultHandle *phResult)
2677{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302678 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2680
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302681 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2683 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302685 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 status = csr_scan_get_result(hHal, pFilter, phResult);
2687 sme_release_global_lock(&pMac->sme);
2688 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689
2690 return status;
2691}
2692
2693/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002694 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002695 * AP's channel id from
2696 * CSR by filtering the
2697 * result which matches
2698 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002699 * @profile: SAP profile
2700 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2701 * best ap from scan cache.
2702 *
2703 * This function is written to get AP's channel id from CSR by filtering
2704 * the result which matches our roam profile. This is a synchronous call.
2705 *
2706 * Return: QDF_STATUS.
2707 */
2708QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2709 tScanResultHandle *scan_cache,
2710 uint8_t *ap_chnl_id)
2711{
2712 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2713 profile,
2714 scan_cache,
2715 ap_chnl_id);
2716}
2717
2718/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2720 * channel id from CSR by filtering the
2721 * result which matches our roam profile.
2722 * @profile: SAP adapter
2723 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2724 * best ap from scan cache.
2725 *
2726 * This function is written to get AP's channel id from CSR by filtering
2727 * the result which matches our roam profile. This is a synchronous call.
2728 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302729 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002731QDF_STATUS sme_get_ap_channel_from_scan_cache(
2732 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2733 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302735 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002736 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 tCsrScanResultFilter *scan_filter = NULL;
2738 tScanResultHandle filtered_scan_result = NULL;
2739 tSirBssDescription first_ap_profile;
2740
2741 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302746 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302748 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302750 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302751 }
2752 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2753 if (NULL == profile) {
2754 scan_filter->EncryptionType.numEntries = 1;
2755 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302757 } else {
2758 /* Here is the profile we need to connect to */
2759 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 profile,
2761 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302762 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302764 if (QDF_STATUS_SUCCESS == status) {
2765 /* Save the WPS info */
2766 if (NULL != profile) {
2767 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302769 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302772 scan_filter->bWPSAssociation = 0;
2773 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302775 } else {
2776 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2777 FL("Preparing the profile filter failed"));
2778 qdf_mem_free(scan_filter);
2779 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 }
2781 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302782 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002783 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302785 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2787 &first_ap_profile);
2788 *scan_cache = filtered_scan_result;
2789 if (0 != first_ap_profile.channelId) {
2790 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302791 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302792 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 FL("Found best AP & its on chnl[%d]"),
2794 first_ap_profile.channelId);
2795 } else {
2796 /*
2797 * This means scan result is empty
2798 * so set the channel to zero, caller should
2799 * take of zero channel id case.
2800 */
2801 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302802 QDF_TRACE(QDF_MODULE_ID_SME,
2803 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302805 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 }
2807 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302808 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302810 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 }
2812 csr_free_scan_filter(mac_ctx, scan_filter);
2813 sme_release_global_lock(&mac_ctx->sme);
2814 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002817 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302818 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302820 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 return status;
2822}
2823
2824/**
2825 * sme_store_joinreq_param() - This function will pass station's join
2826 * request to store to csr.
2827 * @hal_handle: pointer to hal context.
2828 * @profile: pointer to station's roam profile.
2829 * @scan_cache: pointer to station's scan cache.
2830 * @roam_id: reference to roam_id variable being passed.
2831 * @session_id: station's session id.
2832 *
2833 * This function will pass station's join request further down to csr
2834 * to store it. this stored parameter will be used later.
2835 *
2836 * Return: true or false based on function's overall success.
2837 **/
2838bool sme_store_joinreq_param(tHalHandle hal_handle,
2839 tCsrRoamProfile *profile,
2840 tScanResultHandle scan_cache,
2841 uint32_t *roam_id,
2842 uint32_t session_id)
2843{
2844 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302845 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 bool ret_status = true;
2847
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302848 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2850 session_id, 0));
2851 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302854 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 sme_release_global_lock(&mac_ctx->sme);
2857 } else {
2858 ret_status = false;
2859 }
2860
2861 return ret_status;
2862}
2863
2864/**
2865 * sme_clear_joinreq_param() - This function will pass station's clear
2866 * the join request to csr.
2867 * @hal_handle: pointer to hal context.
2868 * @session_id: station's session id.
2869 *
2870 * This function will pass station's clear join request further down to csr
2871 * to cleanup.
2872 *
2873 * Return: true or false based on function's overall success.
2874 **/
2875bool sme_clear_joinreq_param(tHalHandle hal_handle,
2876 uint32_t session_id)
2877{
2878 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302879 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 bool ret_status = true;
2881
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302882 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2884 session_id, 0));
2885 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302886 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302888 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 sme_release_global_lock(&mac_ctx->sme);
2891 } else {
2892 ret_status = false;
2893 }
2894
2895 return ret_status;
2896}
2897
2898/**
2899 * sme_issue_stored_joinreq() - This function will issues station's stored
2900 * the join request to csr.
2901 * @hal_handle: pointer to hal context.
2902 * @roam_id: reference to roam_id variable being passed.
2903 * @session_id: station's session id.
2904 *
2905 * This function will issue station's stored join request further down to csr
2906 * to proceed forward.
2907 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302908 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 uint32_t *roam_id,
2912 uint32_t session_id)
2913{
2914 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302915 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2916 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302918 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2920 session_id, 0));
2921 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 if (QDF_STATUS_SUCCESS == status) {
2923 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 roam_id,
2925 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302926 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 }
2928 sme_release_global_lock(&mac_ctx->sme);
2929 } else {
2930 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302931 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 }
2933 return ret_status;
2934}
2935
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302936/*
2937 * sme_scan_flush_result() -
2938 * A wrapper function to request CSR to clear scan results.
2939 * This is a synchronous call
2940 *
2941 * Return QDF_STATUS
2942 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302943QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302945 QDF_STATUS status = QDF_STATUS_E_FAILURE;
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 0, 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 status = csr_scan_flush_result(hHal);
2954 sme_release_global_lock(&pMac->sme);
2955 }
2956
2957 return status;
2958}
2959
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302960/*
2961 * sme_filter_scan_results() -
2962 * A wrapper function to request CSR to clear scan results.
2963 * This is a synchronous call
2964 *
2965 * tHalHandle - HAL context handle
2966 * sessionId - session id
2967 * Return QDF_STATUS
2968 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302969QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302971 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2973
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302974 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2976 sessionId, 0));
2977 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 csr_scan_filter_results(pMac);
2980 sme_release_global_lock(&pMac->sme);
2981 }
2982
2983 return status;
2984}
2985
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302986QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302988 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2990
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302991 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2993 sessionId, 0));
2994 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302995 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 status = csr_scan_flush_selective_result(hHal, true);
2997 sme_release_global_lock(&pMac->sme);
2998 }
2999
3000 return status;
3001}
3002
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303003/*
3004 * sme_scan_result_get_first() -
3005 * A wrapper function to request CSR to returns the first element of
3006 * scan result.
3007 * This is a synchronous call
3008 *
3009 * hScanResult - returned from csr_scan_get_result
3010 * Return tCsrScanResultInfo * - NULL if no result
3011 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
3013 tScanResultHandle hScanResult)
3014{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303015 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3017 tCsrScanResultInfo *pRet = NULL;
3018
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303019 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3021 NO_SESSION, 0));
3022 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303023 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 pRet = csr_scan_result_get_first(pMac, hScanResult);
3025 sme_release_global_lock(&pMac->sme);
3026 }
3027
3028 return pRet;
3029}
3030
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303031/*
3032 * sme_scan_result_get_next() -
3033 * A wrapper function to request CSR to returns the next element of
3034 * scan result. It can be called without calling csr_scan_result_get_first first
3035 * This is a synchronous call
3036 *
3037 * hScanResult - returned from csr_scan_get_result
3038 * Return Null if no result or reach the end
3039 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3041 tScanResultHandle hScanResult)
3042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303043 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3045 tCsrScanResultInfo *pRet = NULL;
3046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303048 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 pRet = csr_scan_result_get_next(pMac, hScanResult);
3050 sme_release_global_lock(&pMac->sme);
3051 }
3052
3053 return pRet;
3054}
3055
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303056/*
3057 * sme_scan_result_purge() -
3058 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3059 * in the list and free memory for each item
3060 * This is a synchronous call
3061 *
3062 * hScanResult - returned from csr_scan_get_result. hScanResult is
3063 * considered gone by
3064 * calling this function and even before this function reutrns.
3065 * Return QDF_STATUS
3066 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003067QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303069 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003070 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303072 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3074 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003075 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303076 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003077 status = csr_scan_result_purge(mac_ctx, hScanResult);
3078 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 }
3080
3081 return status;
3082}
3083
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303084/*
3085 * sme_scan_get_pmkid_candidate_list() -
3086 * A wrapper function to return the PMKID candidate list
3087 * This is a synchronous call
3088 *
3089 * pPmkidList - caller allocated buffer point to an array of
3090 * tPmkidCandidateInfo
3091 * pNumItems - pointer to a variable that has the number of
3092 * tPmkidCandidateInfo allocated when retruning, this is
3093 * either the number needed or number of items put into
3094 * pPmkidList
3095 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3096 * big enough and pNumItems
3097 * has the number of tPmkidCandidateInfo.
3098 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3099 * not sizeof(tPmkidCandidateInfo) * something
3100 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 tPmkidCandidateInfo *pPmkidList,
3103 uint32_t *pNumItems)
3104{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303105 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3107
3108 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 status =
3111 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3112 pPmkidList,
3113 pNumItems);
3114 sme_release_global_lock(&pMac->sme);
3115 }
3116
3117 return status;
3118}
3119
3120eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3121{
3122 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 return pMac->roam.configParam.phyMode;
3125}
3126
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303127/*
3128 * sme_get_channel_bonding_mode5_g() -
3129 * get the channel bonding mode for 5G band
3130 *
3131 * hHal - HAL handle
3132 * Return channel bonding mode for 5G
3133 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3135{
3136 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3137 tSmeConfigParams smeConfig;
3138
3139 sme_get_config_param(pMac, &smeConfig);
3140
3141 return smeConfig.csrConfig.channelBondingMode5GHz;
3142}
3143
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303144/*
3145 * sme_get_channel_bonding_mode24_g() -
3146 * get the channel bonding mode for 2.4G band
3147 *
3148 * hHal - HAL handle
3149 * Return channel bonding mode for 2.4G
3150 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3152{
3153 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3154 tSmeConfigParams smeConfig;
3155
3156 sme_get_config_param(pMac, &smeConfig);
3157
3158 return smeConfig.csrConfig.channelBondingMode24GHz;
3159}
3160
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303161/*
3162 * sme_roam_connect() -
3163 * A wrapper function to request CSR to inititiate an association
3164 * This is an asynchronous call.
3165 *
3166 * sessionId - the sessionId returned by sme_open_session.
3167 * pProfile - description of the network to which to connect
3168 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3169 * from csr_scan_get_result
3170 * pRoamId - to get back the request ID
3171 * Return QDF_STATUS
3172 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303173QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3175{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303176 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3178
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303179 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303180 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303182 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303185 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3187 status =
3188 csr_roam_connect(pMac, sessionId, pProfile,
3189 pRoamId);
3190 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003191 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303192 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 }
3194 sme_release_global_lock(&pMac->sme);
3195 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003196 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 }
3198
3199 return status;
3200}
3201
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303202/*
3203 * sme_set_phy_mode() -
3204 * Changes the PhyMode.
3205 *
3206 * hHal - The handle returned by mac_open.
3207 * phyMode new phyMode which is to set
3208 * Return QDF_STATUS SUCCESS.
3209 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303210QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211{
3212 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3213
3214 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303215 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 }
3219
3220 pMac->roam.configParam.phyMode = phyMode;
3221 pMac->roam.configParam.uCfgDot11Mode =
3222 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303223 pMac->roam.configParam.phyMode,
3224 pMac->roam.configParam.
3225 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228}
3229
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303230/*
3231 * sme_roam_reassoc() -
3232 * A wrapper function to request CSR to inititiate a re-association
3233 *
3234 * pProfile - can be NULL to join the currently connected AP. In that
3235 * case modProfileFields should carry the modified field(s) which could trigger
3236 * reassoc
3237 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3238 * that might need modification dynamically once STA is up & running and this
3239 * could trigger a reassoc
3240 * pRoamId - to get back the request ID
3241 * Return QDF_STATUS
3242 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303243QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 tCsrRoamProfile *pProfile,
3245 tCsrRoamModifyProfileFields modProfileFields,
3246 uint32_t *pRoamId, bool fForce)
3247{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3250
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303251 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303254 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303256 if ((NULL == pProfile) && (fForce == 1))
3257 status = csr_reassoc(pMac, sessionId,
3258 &modProfileFields, pRoamId,
3259 fForce);
3260 else
3261 status = csr_roam_reassoc(pMac, sessionId,
3262 pProfile,
3263 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303265 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 }
3267 sme_release_global_lock(&pMac->sme);
3268 }
3269
3270 return status;
3271}
3272
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303273/*
3274 * sme_roam_connect_to_last_profile() -
3275 * A wrapper function to request CSR to disconnect and reconnect with
3276 * the same profile
3277 * This is an asynchronous call.
3278 *
3279 * Return QDF_STATUS. It returns fail if currently connected
3280 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303281QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303283 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3285
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303286 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3288 sessionId, 0));
3289 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303290 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303291 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3292 status = csr_roam_connect_to_last_profile(pMac,
3293 sessionId);
3294 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 sme_release_global_lock(&pMac->sme);
3297 }
3298
3299 return status;
3300}
3301
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303302/*
3303 * sme_roam_disconnect() -
3304 * A wrapper function to request CSR to disconnect from a network
3305 * This is an asynchronous call.
3306 *
3307 * reason -- To indicate the reason for disconnecting. Currently, only
3308 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3309 * Return QDF_STATUS
3310 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303311QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 eCsrRoamDisconnectReason reason)
3313{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303314 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3316
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303317 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3319 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303321 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303322 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303324 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303325 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 sme_release_global_lock(&pMac->sme);
3327 }
3328
3329 return status;
3330}
3331
Abhishek Singhca408032016-09-13 15:26:12 +05303332/* sme_dhcp_done_ind() - send dhcp done ind
3333 * @hal: hal context
3334 * @session_id: session id
3335 *
3336 * Return: void.
3337 */
3338void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3339{
3340 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303341 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303342
3343 if (!mac_ctx)
3344 return;
3345
3346 session = CSR_GET_SESSION(mac_ctx, session_id);
3347 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003348 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303349 return;
3350 }
3351 session->dhcp_done = true;
3352}
3353
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303354/*
3355 * sme_roam_stop_bss() -
3356 * To stop BSS for Soft AP. This is an asynchronous API.
3357 *
3358 * hHal - Global structure
3359 * sessionId - sessionId of SoftAP
3360 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3361 * actual results
3362 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303363QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303365 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303369 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303370 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3371 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
3372 true);
3373 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303374 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 sme_release_global_lock(&pMac->sme);
3376 }
3377
3378 return status;
3379}
3380
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303381/**
3382 * sme_roam_disconnect_sta() - disassociate a station
3383 * @hHal: Global structure
3384 * @sessionId: SessionId of SoftAP
3385 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3386 *
3387 * To disassociate a station. This is an asynchronous API.
3388 *
3389 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3390 * be called to indicate actual result.
3391 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303392QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003393 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3397
3398 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303399 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 return status;
3401 }
3402
3403 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303404 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303405 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303407 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303408 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303409 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 sme_release_global_lock(&pMac->sme);
3411 }
3412
3413 return status;
3414}
3415
3416/**
3417 * sme_roam_deauth_sta() - deauthenticate a station
3418 * @hHal: Global structure
3419 * @sessionId: SessionId of SoftAP
3420 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3421 *
3422 * To disassociate a station. This is an asynchronous API.
3423 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303424 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 * code on error. Roam callback will be called to indicate actual
3426 * result
3427 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303428QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003429 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303431 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3433
3434 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303435 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 return status;
3437 }
3438
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303439 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303440 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3441 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303444 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 status =
3446 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3447 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303448 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303449 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 sme_release_global_lock(&pMac->sme);
3451 }
3452
3453 return status;
3454}
3455
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303456/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303457 * sme_roam_get_associated_stas() -
3458 * To probe the list of associated stations from various modules
3459 * of CORE stack.
3460 * This is an asynchronous API.
3461 *
3462 * sessionId - sessionId of SoftAP
3463 * modId - Module from whom list of associtated stations is
3464 * to be probed. If an invalid module is passed then
3465 * by default QDF_MODULE_ID_PE will be probed.
3466 * pUsrContext - Opaque HDD context
3467 * pfnSapEventCallback - Sap event callback in HDD
3468 * pAssocBuf - Caller allocated memory to be filled with associatd
3469 * stations info
3470 * Return QDF_STATUS
3471 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303472QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303473 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 void *pfnSapEventCallback,
3475 uint8_t *pAssocStasBuf)
3476{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303477 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3479
3480 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303481 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 return status;
3483 }
3484
3485 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303487 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303489 csr_roam_get_associated_stas(pMac, sessionId,
3490 modId,
3491 pUsrContext,
3492 pfnSapEventCallback,
3493 pAssocStasBuf);
3494 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303495 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 sme_release_global_lock(&pMac->sme);
3497 }
3498
3499 return status;
3500}
3501
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303502/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303503 * sme_roam_get_connect_state() -
3504 * A wrapper function to request CSR to return the current connect state
3505 * of Roaming
3506 * This is a synchronous call.
3507 *
3508 * Return QDF_STATUS
3509 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 eCsrConnectState *pState)
3512{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3515
3516 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303518 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3519 status = csr_roam_get_connect_state(pMac, sessionId,
3520 pState);
3521 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 sme_release_global_lock(&pMac->sme);
3524 }
3525
3526 return status;
3527}
3528
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303529/*
3530 * sme_roam_get_connect_profile() -
3531 * A wrapper function to request CSR to return the current connect
3532 * profile. Caller must call csr_roam_free_connect_profile after it is done
3533 * and before reuse for another csr_roam_get_connect_profile call.
3534 * This is a synchronous call.
3535 *
3536 * pProfile - pointer to a caller allocated structure
3537 * tCsrRoamConnectedProfile
3538 * eturn QDF_STATUS. Failure if not connected
3539 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303540QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 tCsrRoamConnectedProfile *pProfile)
3542{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303543 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3545
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_GET_CONNECTPROFILE,
3548 sessionId, 0));
3549 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303550 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303551 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3552 status = csr_roam_get_connect_profile(pMac, sessionId,
3553 pProfile);
3554 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303555 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 sme_release_global_lock(&pMac->sme);
3557 }
3558
3559 return status;
3560}
3561
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003562/**
3563 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3564 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3565 *
3566 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3567 *
3568 * Return: none
3569 */
3570void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303572 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3574 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003575 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576}
3577
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303578/*
3579 * sme_roam_set_pmkid_cache() -
3580 * A wrapper function to request CSR to return the PMKID candidate list
3581 * This is a synchronous call.
3582
3583 * pPMKIDCache - caller allocated buffer point to an array of
3584 * tPmkidCacheInfo
3585 * numItems - a variable that has the number of tPmkidCacheInfo
3586 * allocated when retruning, this is either the number needed
3587 * or number of items put into pPMKIDCache
3588 * update_entire_cache - this bool value specifies if the entire pmkid
3589 * cache should be overwritten or should it be
3590 * updated entry by entry.
3591 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3592 * big enough and pNumItems has the number of
3593 * tPmkidCacheInfo.
3594 * \Note: pNumItems is a number of tPmkidCacheInfo,
3595 * not sizeof(tPmkidCacheInfo) * something
3596 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303597QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 tPmkidCacheInfo *pPMKIDCache,
3599 uint32_t numItems, bool update_entire_cache)
3600{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303601 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3603
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303604 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3606 numItems));
3607 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303608 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303609 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3610 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3611 pPMKIDCache,
3612 numItems, update_entire_cache);
3613 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303614 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 sme_release_global_lock(&pMac->sme);
3616 }
3617
3618 return status;
3619}
3620
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303621QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303622 tPmkidCacheInfo *pmksa,
3623 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303625 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303627
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303628 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303629 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3630 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303632 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303633 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303635 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303636 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 sme_release_global_lock(&pMac->sme);
3639 }
3640 return status;
3641}
3642
3643#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303644/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 * \fn sme_roam_set_psk_pmk
3646 * \brief a wrapper function to request CSR to save PSK/PMK
3647 * This is a synchronous call.
3648 * \param hHal - Global structure
3649 * \param sessionId - SME sessionId
3650 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3651 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3652 * connections. Need to pass this information to
3653 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 uint8_t *pPSK_PMK, size_t pmk_len)
3658{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303663 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303664 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3665 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303667 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303668 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669 sme_release_global_lock(&pMac->sme);
3670 }
3671 return status;
3672}
3673#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303674/*
3675 * sme_roam_get_security_req_ie() -
3676 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3677 * passes to PE to JOIN request or START_BSS request
3678 * This is a synchronous call.
3679 *
3680 * pLen - caller allocated memory that has the length of pBuf as input.
3681 * Upon returned, *pLen has the needed or IE length in pBuf.
3682 * pBuf - Caller allocated memory that contain the IE field, if any,
3683 * upon return
3684 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3685 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3686 * big enough
3687 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303688QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 uint32_t *pLen, uint8_t *pBuf,
3690 eCsrSecurityType secType)
3691{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303692 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3694
3695 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303696 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303697 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3698 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3699 pLen, pBuf);
3700 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303701 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 sme_release_global_lock(&pMac->sme);
3703 }
3704
3705 return status;
3706}
3707
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303708/*
3709 * sme_roam_get_security_rsp_ie() -
3710 * A wrapper function to request CSR to return the WPA or RSN or
3711 * WAPI IE from the beacon or probe rsp if connected
3712 * This is a synchronous call.
3713 *
3714 * pLen - caller allocated memory that has the length of pBuf as input.
3715 * Upon returned, *pLen has the needed or IE length in pBuf.
3716 * pBuf - Caller allocated memory that contain the IE field, if any,
3717 * upon return
3718 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3719 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3720 * big enough
3721 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303722QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 uint32_t *pLen, uint8_t *pBuf,
3724 eCsrSecurityType secType)
3725{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303726 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3728
3729 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303730 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303731 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3732 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3733 pLen, pBuf);
3734 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 sme_release_global_lock(&pMac->sme);
3737 }
3738
3739 return status;
3740
3741}
3742
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303743/*
3744 * sme_roam_get_num_pmkid_cache() -
3745 * A wrapper function to request CSR to return number of PMKID cache
3746 * entries
3747 * This is a synchronous call.
3748 *
3749 * Return uint32_t - the number of PMKID cache entries
3750 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3752{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303753 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3755 uint32_t numPmkidCache = 0;
3756
3757 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303758 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3760 numPmkidCache =
3761 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303762 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303763 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303764 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 sme_release_global_lock(&pMac->sme);
3766 }
3767
3768 return numPmkidCache;
3769}
3770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303771/*
3772 * sme_roam_get_pmkid_cache() -
3773 * A wrapper function to request CSR to return PMKID cache from CSR
3774 * This is a synchronous call.
3775 *
3776 * pNum - caller allocated memory that has the space of the number of
3777 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3778 * needed or actually number in tPmkidCacheInfo.
3779 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3780 * any, upon return
3781 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3782 * big enough
3783 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303784QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303785 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3789
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303790 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3792 0));
3793 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303795 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3796 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303798 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 sme_release_global_lock(&pMac->sme);
3801 }
3802
3803 return status;
3804}
3805
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303806/*
3807 * sme_get_config_param() -
3808 * A wrapper function that HDD calls to get the global settings
3809 * currently maintained by CSR.
3810 * This is a synchronous call.
3811 *
3812 * pParam - caller allocated memory
3813 * Return QDF_STATUS
3814 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303815QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303817 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003818 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3819
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303820 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3822 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303823 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303825 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003826 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 sme_release_global_lock(&pMac->sme);
3828 return status;
3829 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303830 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003831 &pMac->rrm.rrmSmeContext.rrmConfig,
3832 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303833 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 sme_release_global_lock(&pMac->sme);
3835 }
3836
3837 return status;
3838}
3839
3840/**
3841 * sme_cfg_set_int() - Sets the cfg parameter value.
3842 * @hal: Handle to hal.
3843 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003844 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 *
3846 * This function sets the string value in cfg parameter.
3847 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303848 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303850QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851{
3852 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854
3855 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303856 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857
3858 return status;
3859}
3860
3861/**
3862 * sme_cfg_set_str() - Sets the cfg parameter string.
3863 * @hal: Handle to hal.
3864 * @cfg_id: Configuration parameter ID.
3865 * @str: Pointer to the string buffer.
3866 * @length: Length of the string.
3867 *
3868 * This function sets the string value in cfg parameter.
3869 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303870 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 uint32_t length)
3874{
3875 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303876 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877
3878 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303879 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
3881 return status;
3882}
3883
3884/**
3885 * sme_cfg_get_int() - Gets the cfg parameter value.
3886 * @hal: Handle to hal.
3887 * @cfg_id: Configuration parameter ID.
3888 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003889 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 *
3891 * This function gets the value of the cfg parameter.
3892 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303893 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303895QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896{
3897 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899
3900 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303901 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902
3903 return status;
3904}
3905
3906/**
3907 * sme_cfg_get_str() - Gets the cfg parameter string.
3908 * @hal: Handle to hal.
3909 * @cfg_id: Configuration parameter ID.
3910 * @str: Pointer to the string buffer.
3911 * @length: Pointer to length of the string.
3912 *
3913 * This function gets the string value of the cfg parameter.
3914 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303915 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303917QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 uint32_t *length)
3919{
3920 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303921 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922
3923 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303924 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925
3926 return status;
3927}
3928
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303929/*
3930 * sme_get_modify_profile_fields() -
3931 * HDD or SME - QOS calls this function to get the current values of
3932 * connected profile fields, changing which can cause reassoc.
3933 * This function must be called after CFG is downloaded and STA is in connected
3934 * state. Also, make sure to call this function to get the current profile
3935 * fields before calling the reassoc. So that pModifyProfileFields will have
3936 * all the latest values plus the one(s) has been updated as part of reassoc
3937 * request.
3938 *
3939 * pModifyProfileFields - pointer to the connected profile fields
3940 * changing which can cause reassoc
3941 * Return QDF_STATUS
3942 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303943QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 tCsrRoamModifyProfileFields *
3945 pModifyProfileFields)
3946{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303947 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3949
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303950 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3952 0));
3953 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303954 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303955 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3956 status = csr_get_modify_profile_fields(pMac, sessionId,
3957 pModifyProfileFields);
3958 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303959 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960 sme_release_global_lock(&pMac->sme);
3961 }
3962
3963 return status;
3964}
3965
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303966/*
3967 * sme_set_dhcp_till_power_active_flag() -
3968 * Sets/Clears DHCP related flag to disable/enable auto PS
3969 *
3970 * hal - The handle returned by mac_open.
3971 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3973{
3974 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3975 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3976
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303977 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3979 flag));
3980 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3981 ps_global_info->remain_in_power_active_till_dhcp = flag;
3982}
3983
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303984/*
3985 * sme_register11d_scan_done_callback() -
3986 * Register a routine of type csr_scan_completeCallback which is
3987 * called whenever an 11d scan is done
3988 *
3989 * hHal - The handle returned by mac_open.
3990 * callback - 11d scan complete routine to be registered
3991 * Return QDF_STATUS
3992 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303993QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303994 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303996 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3998
3999 pMac->scan.callback11dScanDone = callback;
4000
4001 return status;
4002}
4003
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304004/**
4005 * sme_deregister11d_scan_done_callback() - De-register scandone callback
4006 * @h_hal: Handler return by mac_open
4007 *
4008 * This function De-registers the scandone callback to SME
4009 *
4010 * Return: None
4011 */
4012void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
4013{
4014 tpAniSirGlobal pmac;
4015
4016 if (!h_hal) {
4017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4018 FL("hHal is not valid"));
4019 return;
4020 }
4021
4022 pmac = PMAC_STRUCT(h_hal);
4023 pmac->scan.callback11dScanDone = NULL;
4024}
4025
4026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027#ifdef FEATURE_OEM_DATA_SUPPORT
4028/**
4029 * sme_register_oem_data_rsp_callback() - Register a routine of
4030 * type send_oem_data_rsp_msg
4031 * @h_hal: Handle returned by mac_open.
4032 * @callback: Callback to send response
4033 * to oem application.
4034 *
4035 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4036 * callback function.
4037 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304040QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 sme_send_oem_data_rsp_msg callback)
4042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304043 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4045
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004046 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047
4048 return status;
4049
4050}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304051
4052/**
4053 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4054 * @h_hal: Handler return by mac_open
4055 * This function De-registers the OEM data response callback to SME
4056 *
4057 * Return: None
4058 */
4059void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4060{
4061 tpAniSirGlobal pmac;
4062
4063 if (!h_hal) {
4064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4065 FL("hHal is not valid"));
4066 return;
4067 }
4068 pmac = PMAC_STRUCT(h_hal);
4069
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004070 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304071}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072
4073/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004074 * sme_oem_update_capability() - update UMAC's oem related capability.
4075 * @hal: Handle returned by mac_open
4076 * @oem_cap: pointer to oem_capability
4077 *
4078 * This function updates OEM capability to UMAC. Currently RTT
4079 * related capabilities are updated. More capabilities can be
4080 * added in future.
4081 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304082 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004083 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004085 struct sme_oem_capability *cap)
4086{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304087 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004088 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4089 uint8_t *bytes;
4090
4091 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4092
4093 if (cap->ftm_rr)
4094 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4095 if (cap->lci_capability)
4096 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4097
4098 return status;
4099}
4100
4101/**
4102 * sme_oem_get_capability() - get oem capability
4103 * @hal: Handle returned by mac_open
4104 * @oem_cap: pointer to oem_capability
4105 *
4106 * This function is used to get the OEM capability from UMAC.
4107 * Currently RTT related capabilities are received. More
4108 * capabilities can be added in future.
4109 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304110 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004111 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304112QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004113 struct sme_oem_capability *cap)
4114{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304115 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004116 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4117 uint8_t *bytes;
4118
4119 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4120
4121 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4122 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4123
4124 return status;
4125}
Naveen Rawat910726a2017-03-06 11:42:51 -08004126#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004127
4128/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4130 * function to MAC/SYS
4131 *
4132 * @hal: hal handle
4133 * @callback: hdd function that has to be registered
4134 *
4135 * Return: void
4136 */
4137void sme_register_ftm_msg_processor(tHalHandle hal,
4138 hdd_ftm_msg_processor callback)
4139{
4140 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4141
4142 if (mac_ctx == NULL) {
Naveen Rawatcf684762016-06-27 15:30:24 -07004143 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4144 FL("mac ctx is NULL"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 return;
4146 }
Naveen Rawatcf684762016-06-27 15:30:24 -07004147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 mac_ctx->ftm_msg_processor_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149}
4150
4151/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4153 * @hal_ctx - The handle returned by mac_open.
4154 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4155 * Used for success/failure notification by SME
4156 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4157 * back to HDD at the time of callback.
4158 * @wake_reason_ind_cb - Callback routine provided by HDD.
4159 * Used for Wake Reason Indication by SME
4160 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4161 * back to HDD at the time of callback.
4162 *
4163 * WoWLAN works on top of BMPS mode.
4164 * If the device is not in BMPS mode,
4165 * SME will will cache the information that
4166 * WOWL has been enabled and attempt to put the device
4167 * in BMPS. On entry into BMPS, SME will enable the
4168 * WOWL mode.
4169 * Note 1: If we exit BMPS mode (someone requests full power),
4170 * we will NOT resume WOWL when we go back to BMPS again.
4171 * Request for full power (while in WOWL mode) means disable
4172 * WOWL and go to full power.
4173 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4174 * On entry into BMPS, SME will give priority to UAPSD and
4175 * enable only UAPSD if both UAPSD and WOWL are required.
4176 * Currently there is no requirement or use case to support
4177 * UAPSD and WOWL at the same time.
4178 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304179 * Return: QDF_STATUS
4180 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4181 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4182 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 * WOWL after BMPS mode is entered.
4184 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304185QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 void (*enter_wowl_callback_routine)(void
4187 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304188 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 void *enter_wowl_callback_context,
4190#ifdef WLAN_WAKEUP_EVENTS
4191 void (*wakeIndicationCB)(void *callback_context,
4192 tpSirWakeReasonInd
4193 wake_reason_ind),
4194 void *wakeIndicationCBContext,
4195#endif /* WLAN_WAKEUP_EVENTS */
4196 tpSirSmeWowlEnterParams wowl_enter_params,
4197 uint8_t session_id)
4198{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304199 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4201 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304202
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304203 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4205
4206 /* cache the WOWL information */
4207 ps_global_info->ps_params[session_id].wowl_enter_params =
4208 *wowl_enter_params;
4209 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4210 enter_wowl_callback_routine;
4211 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4212 enter_wowl_callback_context;
4213#ifdef WLAN_WAKEUP_EVENTS
4214 /* Cache the Wake Reason Indication callback information */
4215 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4216 wakeIndicationCB;
4217 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4218 wakeIndicationCBContext;
4219#endif /* WLAN_WAKEUP_EVENTS */
4220
4221 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4222 return status;
4223}
4224/**
4225 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4226 * @hal_ctx - The handle returned by mac_open.
4227 * @wowl_exit_params - Carries info on which smesession
4228 * wowl exit is requested.
4229 *
4230 * SME will initiate exit from WoWLAN mode and device will be
4231 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304232 * Return QDF_STATUS
4233 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4234 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304236QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 tpSirSmeWowlExitParams wowl_exit_params)
4238{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304239 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4241 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304242
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304243 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4245 session_id = wowl_exit_params->sessionId;
4246 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4247 return status;
4248}
4249
4250/**
4251 * sme_roam_set_key() - To set encryption key.
4252 * @hal: hal global context
4253 * @session_id: session id
4254 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4255 * @ptr_roam_id: Upon success return, this is the id caller can use to
4256 * identify the request in roamcallback
4257 *
4258 * This function should be called only when connected. This is an asynchronous
4259 * API.
4260 *
4261 * Return: Status of operation
4262 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304263QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4265{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304266 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4268 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304269 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4271
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304272 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 session_id, 0));
4274 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004275 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304276 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 }
4278 /*Once Setkey is done, we can go in BMPS */
4279 if (set_key->keyLength)
4280 ps_global_info->remain_in_power_active_till_dhcp = false;
4281
4282 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304283 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 return status;
4285
4286 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4287 if (ptr_roam_id)
4288 *ptr_roam_id = roam_id;
4289
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004290 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004292 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 session = CSR_GET_SESSION(mac_ctx, session_id);
4294 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004295 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304297 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 }
4299 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4300 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4301 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4302 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4303 set_key->encType)) {
4304 session->pCurRoamProfile->negotiatedUCEncryptionType =
4305 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4306 }
4307 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4308 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4309 set_key->encType)) {
4310 session->pCurRoamProfile->negotiatedUCEncryptionType =
4311 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4312 }
4313 }
4314 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4315 sme_release_global_lock(&mac_ctx->sme);
4316 return status;
4317}
4318
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304319/**
4320 * sme_roam_set_default_key_index - To set default wep key idx
4321 * @hal: pointer to hal handler
4322 * @session_id: session id
4323 * @default_idx: default wep key index
4324 *
4325 * This function prepares a message and post to WMA to set wep default
4326 * key index
4327 *
4328 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4329 */
4330QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4331 uint8_t default_idx)
4332{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004333 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304334 struct wep_update_default_key_idx *update_key;
4335
4336 update_key = qdf_mem_malloc(sizeof(*update_key));
4337 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004338 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304339 return QDF_STATUS_E_NOMEM;
4340 }
4341
4342 update_key->session_id = session_id;
4343 update_key->default_idx = default_idx;
4344
4345 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4346 msg.reserved = 0;
4347 msg.bodyptr = (void *)update_key;
4348
4349 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004350 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004351 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304352 qdf_mem_free(update_key);
4353 return QDF_STATUS_E_FAILURE;
4354 }
4355
4356 return QDF_STATUS_SUCCESS;
4357}
4358
4359
Jeff Johnson8bd23352017-09-26 11:39:24 -07004360/**
4361 * sme_get_rssi() - API to retrieve current RSSI
4362 * @hHal: HAL handle for device
4363 * @callback: SME sends back the requested stats using the callback
4364 * @staId: The station ID for which the RSSI is requested for
4365 * @bssid: The bssid of the connected session
4366 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4367 * RSSI, do not hold up but return this value.
4368 * @pContext: user context to be passed back along with the callback
4369 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304370 * A wrapper function that client calls to register a callback to get RSSI
4371 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004372 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304373 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304375 tCsrRssiCallback callback, uint8_t staId,
4376 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004377 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304379 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4381
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304382 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4384 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304385 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 status = csr_get_rssi(pMac, callback,
4387 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004388 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 sme_release_global_lock(&pMac->sme);
4390 }
4391 return status;
4392}
4393
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304394/*
4395 * sme_get_snr() -
4396 * A wrapper function that client calls to register a callback to get SNR
4397 *
4398 * callback - SME sends back the requested stats using the callback
4399 * staId - The station ID for which the stats is requested for
4400 * pContext - user context to be passed back along with the callback
4401 * p_cds_context - cds context
4402 * \return QDF_STATUS
4403 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304404QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304406 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304408 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4410
4411 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304412 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4414 sme_release_global_lock(&pMac->sme);
4415 }
4416 return status;
4417}
4418
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304419/*
4420 * sme_get_statistics() -
4421 * A wrapper function that client calls to register a callback to get
4422 * different PHY level statistics from CSR.
4423 *
4424 * requesterId - different client requesting for statistics,
4425 * HDD, UMA/GAN etc
4426 * statsMask - The different category/categories of stats requester
4427 * is looking for
4428 * callback - SME sends back the requested stats using the callback
4429 * periodicity - If requester needs periodic update in millisec, 0 means
4430 * it's an one time request
4431 * cache - If requester is happy with cached stats
4432 * staId - The station ID for which the stats is requested for
4433 * pContext - user context to be passed back along with the callback
4434 * sessionId - sme session interface
4435 * Return QDF_STATUS
4436 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304437QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 eCsrStatsRequesterType requesterId,
4439 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004440 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304442 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4444
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304447 status = csr_get_statistics(pMac, requesterId, statsMask,
4448 callback, staId, pContext,
4449 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 sme_release_global_lock(&pMac->sme);
4451 }
4452
4453 return status;
4454
4455}
4456
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304457QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 tCsrLinkStatusCallback callback,
4459 void *pContext, uint8_t sessionId)
4460{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304461 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4463 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004464 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304467 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304470 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 "%s: Not able to allocate memory for link status",
4472 __func__);
4473 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304474 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 }
4476
4477 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4478 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4479 pMsg->sessionId = sessionId;
4480 pMac->sme.linkStatusContext = pContext;
4481 pMac->sme.linkStatusCallback = callback;
4482
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004483 message.type = WMA_LINK_STATUS_GET_REQ;
4484 message.bodyptr = pMsg;
4485 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304487 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004488 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4489 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304490 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304492 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 pMac->sme.linkStatusContext = NULL;
4494 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304495 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 }
4497
4498 sme_release_global_lock(&pMac->sme);
4499 }
4500
4501 return status;
4502}
4503
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304504/*
4505 * sme_get_country_code() -
4506 * To return the current country code. If no country code is applied,
4507 * default country code is used to fill the buffer.
4508 * If 11d supported is turned off, an error is return and the last
4509 * applied/default country code is used.
4510 * This is a synchronous API.
4511 *
4512 * pBuf - pointer to a caller allocated buffer for returned country code.
4513 * pbLen For input, this parameter indicates how big is the buffer.
4514 * Upon return, this parameter has the number of bytes for
4515 * country. If pBuf doesn't have enough space, this function
4516 * returns fail status and this parameter contains the number
4517 * that is needed.
4518 *
4519 * Return QDF_STATUS SUCCESS.
4520 *
4521 * FAILURE or RESOURCES The API finished and failed.
4522 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304523QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524{
4525 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4526
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304527 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4529
4530 return csr_get_country_code(pMac, pBuf, pbLen);
4531}
4532
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533/* some support functions */
4534bool sme_is11d_supported(tHalHandle hHal)
4535{
4536 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4537
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004538 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539}
4540
4541bool sme_is11h_supported(tHalHandle hHal)
4542{
4543 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4544
4545 return csr_is11h_supported(pMac);
4546}
4547
4548bool sme_is_wmm_supported(tHalHandle hHal)
4549{
4550 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4551
4552 return csr_is_wmm_supported(pMac);
4553}
4554
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304555/*
4556 * sme_change_country_code() -
4557 * Change Country code from upperlayer during WLAN driver operation.
4558 * This is a synchronous API.
4559 *
4560 * hHal - The handle returned by mac_open.
4561 * pCountry New Country Code String
4562 * sendRegHint If we want to send reg hint to nl80211
4563 * Return QDF_STATUS SUCCESS.
4564 * FAILURE or RESOURCES The API finished and failed.
4565 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 tSmeChangeCountryCallback callback,
4568 uint8_t *pCountry,
4569 void *pContext,
4570 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004571 bool countryFromUserSpace,
4572 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004576 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 tAniChangeCountryCodeReq *pMsg;
4578
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304579 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4581 0));
4582 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304583 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4585 && (!pMac->roam.configParam.
4586 fSupplicantCountryCodeHasPriority)) {
4587
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004588 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589
4590 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304591 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 return status;
4593 }
4594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304595 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004597 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304599 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 }
4601
4602 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4603 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304604 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 pMsg->countryFromUserSpace = countryFromUserSpace;
4606 pMsg->sendRegHint = sendRegHint;
4607 pMsg->changeCCCallback = callback;
4608 pMsg->pDevContext = pContext;
4609 pMsg->p_cds_context = p_cds_context;
4610
4611 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4612 msg.bodyptr = pMsg;
4613 msg.reserved = 0;
4614
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004616 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004617 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304619 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 sme_release_global_lock(&pMac->sme);
4622 }
4623
4624 return status;
4625}
4626
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304627/*
4628 * sme_generic_change_country_code() -
4629 * Change Country code from upperlayer during WLAN driver operation.
4630 * This is a synchronous API.
4631 *
4632 * hHal - The handle returned by mac_open.
4633 * pCountry New Country Code String
4634 * reg_domain regulatory domain
4635 * Return QDF_STATUS SUCCESS.
4636 * FAILURE or RESOURCES The API finished and failed.
4637 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304638QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004639 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304641 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004643 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 tAniGenericChangeCountryCodeReq *pMsg;
4645
4646 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648 "%s: pMac is null", __func__);
4649 return status;
4650 }
4651
4652 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304653 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304654 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655
4656 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004657 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304659 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 }
4661
4662 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4663 pMsg->msgLen =
4664 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304665 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004666 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667
4668 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4669 msg.bodyptr = pMsg;
4670 msg.reserved = 0;
4671
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304672 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004673 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004674 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304675 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 sme_release_global_lock(&pMac->sme);
4679 }
4680
4681 return status;
4682}
4683
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304684/*
4685 * sme_dhcp_start_ind() -
4686 * API to signal the FW about the DHCP Start event.
4687 *
4688 * hHal - HAL handle for device.
4689 * device_mode - mode(AP,SAP etc) of the device.
4690 * macAddr - MAC address of the adapter.
4691 * sessionId - session ID.
4692 * Return QDF_STATUS SUCCESS.
4693 * FAILURE or RESOURCES The API finished and failed.
4694 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304695QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 uint8_t device_mode,
4697 uint8_t *macAddr, uint8_t sessionId)
4698{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304699 QDF_STATUS status;
4700 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004702 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304704 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705
4706 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304707 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 pSession = CSR_GET_SESSION(pMac, sessionId);
4709
4710 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004711 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304713 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 }
Arif Hussain3316f402016-11-10 13:08:03 -08004715 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304717 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304719 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 "%s: Not able to allocate memory for dhcp start",
4721 __func__);
4722 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304723 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 }
4725 pMsg->msgType = WMA_DHCP_START_IND;
4726 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4727 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304728 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304729 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304730 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004731 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004733 message.type = WMA_DHCP_START_IND;
4734 message.bodyptr = pMsg;
4735 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304736 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004737 sessionId, message.type));
4738 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4739 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304741 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304743 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304744 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 }
4746 sme_release_global_lock(&pMac->sme);
4747 }
4748 return status;
4749}
4750
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304751/*
4752 * sme_dhcp_stop_ind() -
4753 * API to signal the FW about the DHCP complete event.
4754 *
4755 * hHal - HAL handle for device.
4756 * device_mode - mode(AP, SAP etc) of the device.
4757 * macAddr - MAC address of the adapter.
4758 * sessionId - session ID.
4759 * Return QDF_STATUS SUCCESS.
4760 * FAILURE or RESOURCES The API finished and failed.
4761 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304762QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763 uint8_t device_mode,
4764 uint8_t *macAddr, uint8_t sessionId)
4765{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304766 QDF_STATUS status;
4767 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004769 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304771 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772
4773 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304774 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 pSession = CSR_GET_SESSION(pMac, sessionId);
4776
4777 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004778 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304780 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 }
Arif Hussain3316f402016-11-10 13:08:03 -08004782 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304784 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304786 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 "%s: Not able to allocate memory for dhcp stop",
4788 __func__);
4789 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304790 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791 }
4792
4793 pMsg->msgType = WMA_DHCP_STOP_IND;
4794 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4795 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304796 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304797 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304798 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004799 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004800
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004801 message.type = WMA_DHCP_STOP_IND;
4802 message.bodyptr = pMsg;
4803 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304804 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004805 sessionId, message.type));
4806 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4807 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304809 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304811 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304812 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 }
4814
4815 sme_release_global_lock(&pMac->sme);
4816 }
4817 return status;
4818}
4819
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304820/*
4821 * sme_TXFailMonitorStopInd() -
4822 * API to signal the FW to start monitoring TX failures
4823 *
4824 * Return QDF_STATUS SUCCESS.
4825 * FAILURE or RESOURCES The API finished and failed.
4826 */
4827QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4828 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004829 void *txFailIndCallback)
4830{
4831 QDF_STATUS status;
4832 QDF_STATUS qdf_status;
4833 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004834 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004835 tAniTXFailMonitorInd *pMsg;
4836
4837 status = sme_acquire_global_lock(&pMac->sme);
4838 if (QDF_STATUS_SUCCESS == status) {
4839 pMsg = (tAniTXFailMonitorInd *)
4840 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4841 if (NULL == pMsg) {
4842 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4843 "%s: Failed to allocate memory", __func__);
4844 sme_release_global_lock(&pMac->sme);
4845 return QDF_STATUS_E_NOMEM;
4846 }
4847
4848 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4849 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4850
4851 /* tx_fail_count = 0 should disable the Monitoring in FW */
4852 pMsg->tx_fail_count = tx_fail_count;
4853 pMsg->txFailIndCallback = txFailIndCallback;
4854
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004855 message.type = WMA_TX_FAIL_MONITOR_IND;
4856 message.bodyptr = pMsg;
4857 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004858
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004859 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4860 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004861 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4862 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4863 "%s: Post TX Fail monitor Start MSG fail",
4864 __func__);
4865 qdf_mem_free(pMsg);
4866 status = QDF_STATUS_E_FAILURE;
4867 }
4868 sme_release_global_lock(&pMac->sme);
4869 }
4870 return status;
4871}
4872
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304873/*
4874 * sme_set_cfg_privacy() -
4875 * API to set configure privacy parameters
4876 *
4877 * hHal - The handle returned by mac_open.
4878 * pProfile - Pointer CSR Roam profile.
4879 * fPrivacy - This parameter indicates status of privacy
4880 * Return void
4881 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882void sme_set_cfg_privacy(tHalHandle hHal,
4883 tCsrRoamProfile *pProfile, bool fPrivacy)
4884{
4885 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304886
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304887 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304889 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4891 sme_release_global_lock(&pMac->sme);
4892 }
4893}
4894
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304895/*
4896 * sme_neighbor_report_request() -
4897 * API to request neighbor report.
4898 *
4899 * hHal - The handle returned by mac_open.
4900 * pRrmNeighborReq - Pointer to a caller allocated object of type
4901 * tRrmNeighborReq. Caller owns the memory and is
4902 * responsible for freeing it.
4903 * Return QDF_STATUS
4904 * QDF_STATUS_E_FAILURE - failure
4905 * QDF_STATUS_SUCCESS success
4906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304907QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304909 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304911 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304913
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304914 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4916 0));
4917
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304918 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 status =
4920 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304921 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 sme_release_global_lock(&pMac->sme);
4923 }
4924
4925 return status;
4926}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304928/*
4929 * sme_get_wcnss_wlan_compiled_version() -
4930 * This API returns the version of the WCNSS WLAN API with
4931 * which the HOST driver was built
4932 *
4933 * hHal - The handle returned by mac_open.
4934 * pVersion - Points to the Version structure to be filled
4935 * Return QDF_STATUS
4936 * QDF_STATUS_E_INVAL - failure
4937 * QDF_STATUS_SUCCESS success
4938 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304939QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940 tSirVersionType *pVersion)
4941{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304942 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304945 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304947 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304949 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950
4951 sme_release_global_lock(&pMac->sme);
4952 }
4953
4954 return status;
4955}
4956
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304957/*
4958 * sme_get_wcnss_wlan_reported_version() -
4959 * This API returns the version of the WCNSS WLAN API with
4960 * which the WCNSS driver reports it was built
4961 * hHal - The handle returned by mac_open.
4962 * pVersion - Points to the Version structure to be filled
4963 * Return QDF_STATUS
4964 * QDF_STATUS_E_INVAL - failure
4965 * QDF_STATUS_SUCCESS success
4966 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304967QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968 tSirVersionType *pVersion)
4969{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304970 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4972
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304973 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304975 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978
4979 sme_release_global_lock(&pMac->sme);
4980 }
4981
4982 return status;
4983}
4984
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304985/*
4986 * sme_get_wcnss_software_version() -
4987 * This API returns the version string of the WCNSS driver
4988 *
4989 * hHal - The handle returned by mac_open.
4990 * pVersion - Points to the Version string buffer to be filled
4991 * versionBufferSize - THe size of the Version string buffer
4992 * Return QDF_STATUS
4993 * QDF_STATUS_E_INVAL - failure
4994 * QDF_STATUS_SUCCESS success
4995 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304996QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997 uint8_t *pVersion,
4998 uint32_t versionBufferSize)
4999{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305000 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305003 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305004 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07005006 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 pVersion,
5008 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305009 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305010 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 sme_release_global_lock(&pMac->sme);
5012 }
5013
5014 return status;
5015}
5016
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305017/*
5018 * sme_get_wcnss_hardware_version() -
5019 * This API returns the version string of the WCNSS hardware
5020 *
5021 * hHal - The handle returned by mac_open.
5022 * pVersion - Points to the Version string buffer to be filled
5023 * versionBufferSize - THe size of the Version string buffer
5024 * Return QDF_STATUS
5025 * QDF_STATUS_E_INVAL - failure
5026 * QDF_STATUS_SUCCESS success
5027 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305028QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005029 uint8_t *pVersion,
5030 uint32_t versionBufferSize)
5031{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305032 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5034
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305035 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305037 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305039 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040
5041 sme_release_global_lock(&pMac->sme);
5042 }
5043
5044 return status;
5045}
5046
5047#ifdef FEATURE_WLAN_WAPI
5048
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305049/*
5050 * sme_scan_get_bkid_candidate_list() -
5051 * A wrapper function to return the BKID candidate list
5052 *
5053 * pBkidList - caller allocated buffer point to an array of
5054 * tBkidCandidateInfo
5055 * pNumItems - pointer to a variable that has the number of
5056 * tBkidCandidateInfo allocated when retruning, this is
5057 * either the number needed or number of items put into
5058 * pPmkidList
5059 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5060 * big enough and pNumItems
5061 * has the number of tBkidCandidateInfo.
5062 * Note: pNumItems is a number of tBkidCandidateInfo,
5063 * not sizeof(tBkidCandidateInfo) * something
5064 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305065QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005066 tBkidCandidateInfo *pBkidList,
5067 uint32_t *pNumItems)
5068{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305069 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5071
5072 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305073 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305075 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5076 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 sme_release_global_lock(&pMac->sme);
5078 }
5079
5080 return status;
5081}
5082#endif /* FEATURE_WLAN_WAPI */
5083
5084#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005085/**
5086 * sme_oem_data_req() - send oem data request to WMA
5087 * @hal: HAL handle
5088 * @hdd_oem_req: OEM data request from HDD
5089 *
5090 * Return: QDF_STATUS
5091 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005092QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305094 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005095 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005096 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005098 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005099 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5100 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005101 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005102 return QDF_STATUS_E_FAILURE;
5103 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005105 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5106 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005107 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005108 return QDF_STATUS_E_NOMEM;
5109 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005111 oem_data_req->data_len = hdd_oem_req->data_len;
5112 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5113 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005114 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005115 return QDF_STATUS_E_NOMEM;
5116 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005118 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5119 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005120
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005121 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305123 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005124 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305125 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005126 sme_debug("OEM request(length: %d) sent to WMA",
5127 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005128
5129 if (oem_data_req->data_len)
5130 qdf_mem_free(oem_data_req->data);
5131 qdf_mem_free(oem_data_req);
5132
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005133 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 return status;
5135}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136#endif /*FEATURE_OEM_DATA_SUPPORT */
5137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305138/*
5139 * sme_open_session() - Open a session for scan/roam operation.
5140 *
5141 * This is a synchronous API.
5142 *
5143 * hHal - The handle returned by mac_open.
5144 * callback - A pointer to the function caller specifies for
5145 * roam/connect status indication
5146 * pContext - The context passed with callback
5147 * pSelfMacAddr - Caller allocated memory filled with self MAC address
5148 * (6 bytes)
5149 * pbSessionId - pointer to a caller allocated buffer for returned session ID
5150 *
5151 * Return QDF_STATUS_SUCCESS - session is opened. sessionId returned.
5152 *
5153 * Other status means SME is failed to open the session.
5154 * QDF_STATUS_E_RESOURCES - no more session available.
5155 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305156QDF_STATUS sme_open_session(tHalHandle hHal, csr_roam_completeCallback callback,
Dustin Brownd28772b2017-03-17 14:16:07 -07005157 void *pContext, uint8_t *pSelfMacAddr,
5158 uint8_t session_id, uint32_t type, uint32_t subType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159{
Arif Hussainee677012017-01-26 17:50:13 -08005160 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005161 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Arif Hussainee677012017-01-26 17:50:13 -08005162 struct cdp_pdev *pdev;
5163 ol_txrx_peer_handle peer;
5164 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005165 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305167 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005168 "%s: type=%d, session_id %d subType=%d addr:%pM",
5169 __func__, type, session_id, subType, pSelfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170
Arif Hussainee677012017-01-26 17:50:13 -08005171 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5172
5173 if (NULL == pdev) {
5174 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5175 "%s: Failed to get pdev handler", __func__);
5176 return status;
5177 }
5178
Dustin Brownd28772b2017-03-17 14:16:07 -07005179 status = sme_acquire_global_lock(&pMac->sme);
5180 if (QDF_IS_STATUS_ERROR(status))
5181 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005183 peer = cdp_peer_find_by_addr(soc, pdev, pSelfMacAddr, &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005184 if (peer) {
5185 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5186 "%s: Peer=%d exist with same MAC",
5187 __func__, peer_id);
5188 status = QDF_STATUS_E_INVAL;
5189 } else {
5190 status = csr_roam_open_session(pMac, callback, pContext,
5191 pSelfMacAddr, session_id, type, subType);
5192 }
Dustin Brownd28772b2017-03-17 14:16:07 -07005193 sme_release_global_lock(&pMac->sme);
5194
5195 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
5196 session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197
5198 return status;
5199}
5200
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305201/*
5202 * sme_close_session() - Open a session for scan/roam operation.
5203 *
5204 * This is a synchronous API.
5205 *
5206 * hHal - The handle returned by mac_open.
5207 * sessionId - A previous opened session's ID.
5208 * Return QDF_STATUS_SUCCESS - session is closed.
5209 * Other status means SME is failed to open the session.
5210 * QDF_STATUS_E_INVAL - session is not opened.
5211 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305212QDF_STATUS sme_close_session(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 csr_roamSessionCloseCallback callback,
5214 void *pContext)
5215{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305216 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5218
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305219 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, sessionId, 0));
5221 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305222 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 status = csr_roam_close_session(pMac, sessionId, false,
5224 callback, pContext);
5225
5226 sme_release_global_lock(&pMac->sme);
5227 }
5228
5229 return status;
5230}
5231
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305232/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305233 * sme_change_mcc_beacon_interval() -
5234 * To update P2P-GO beaconInterval. This function should be called after
5235 * disassociating all the station is done
5236 * This is an asynchronous API.
5237 *
5238 * @sessionId: Session Identifier
5239 * Return QDF_STATUS SUCCESS
5240 * FAILURE or RESOURCES
5241 * The API finished and failed.
5242 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005243QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305245 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005246 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005248 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305249 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005250 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5251 sessionId);
5252 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 }
5254 return status;
5255}
5256
5257/**
5258 * sme_set_host_offload(): API to set the host offload feature.
5259 * @hHal: The handle returned by mac_open.
5260 * @sessionId: Session Identifier
5261 * @request: Pointer to the offload request.
5262 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305263 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005264 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305265QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 tpSirHostOffloadReq request)
5267{
5268 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305269 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305271 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5273 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305274 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275#ifdef WLAN_NS_OFFLOAD
5276 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5277 status = sme_set_ps_ns_offload(hHal, request,
5278 sessionId);
5279 } else
5280#endif /* WLAN_NS_OFFLOAD */
5281 {
5282 status = sme_set_ps_host_offload(hHal, request,
5283 sessionId);
5284 }
5285 sme_release_global_lock(&pMac->sme);
5286 }
5287
5288 return status;
5289}
5290
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305291/*
5292 * sme_set_keep_alive() -
5293 * API to set the Keep Alive feature.
5294 *
5295 * hHal - The handle returned by mac_open.
5296 * request - Pointer to the Keep Alive request.
5297 * Return QDF_STATUS
5298 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305299QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 tpSirKeepAliveReq request)
5301{
5302 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005303 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305305 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 FL("WMA_SET_KEEP_ALIVE message"));
5309
5310 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305311 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305313 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305315 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305317 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305318 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 }
5321
Anurag Chouhanc5548422016-02-24 18:33:27 +05305322 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305323 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305325 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 "buff TP %d input TP %d ", request_buf->timePeriod,
5327 request->timePeriod);
5328 request_buf->sessionId = session_id;
5329
5330 msg.type = WMA_SET_KEEP_ALIVE;
5331 msg.reserved = 0;
5332 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305333 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5334 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305335 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005336 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305337 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305338 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305339 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305340 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 }
5342
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305343 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344}
5345
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305346/*
5347 * sme_get_operation_channel() -
5348 * API to get current channel on which STA is parked his function gives
5349 * channel information only of infra station or IBSS station
5350 *
5351 * hHal, pointer to memory location and sessionId
5352 * Returns QDF_STATUS_SUCCESS
5353 * QDF_STATUS_E_FAILURE
5354 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305355QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 uint8_t sessionId)
5357{
5358 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305359 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360
5361 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5362 pSession = CSR_GET_SESSION(pMac, sessionId);
5363
5364 if ((pSession->connectedProfile.BSSType ==
5365 eCSR_BSS_TYPE_INFRASTRUCTURE)
5366 || (pSession->connectedProfile.BSSType ==
5367 eCSR_BSS_TYPE_IBSS)
5368 || (pSession->connectedProfile.BSSType ==
5369 eCSR_BSS_TYPE_INFRA_AP)
5370 || (pSession->connectedProfile.BSSType ==
5371 eCSR_BSS_TYPE_START_IBSS)) {
5372 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305373 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 }
5375 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305376 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005377} /* sme_get_operation_channel ends here */
5378
Abhishek Singh7996eb72015-12-30 17:24:02 +05305379/**
5380 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5381 * management frame indication to PE.
5382 *
5383 * @hal: hal pointer
5384 * @callback: callback pointer to be registered
5385 *
5386 * This function is used to register a callback for management
5387 * frame indication to PE.
5388 *
5389 * Return: Success if msg is posted to PE else Failure.
5390 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305391QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305392 sir_mgmt_frame_ind_callback callback)
5393{
5394 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5395 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305396 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305397
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305398 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305399 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305400 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305401 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005402 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305403 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305404 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305405 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305406 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5407 msg->length = sizeof(*msg);
5408
5409 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005410 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305411 sme_release_global_lock(&mac_ctx->sme);
5412 return status;
5413 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305414 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305415}
5416
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305417/*
5418 * sme_RegisterMgtFrame() -
5419 * To register managment frame of specified type and subtype.
5420 *
5421 * frameType - type of the frame that needs to be passed to HDD.
5422 * matchData - data which needs to be matched before passing frame
5423 * to HDD.
5424 * matchDataLen - Length of matched data.
5425 * Return QDF_STATUS
5426 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305427QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 uint16_t frameType, uint8_t *matchData,
5429 uint16_t matchLen)
5430{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305431 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5433
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305435 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 tSirRegisterMgmtFrame *pMsg;
5437 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305438 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5439 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440
5441 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005442 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305444 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 }
5446
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305447 if (!CSR_IS_SESSION_ANY(sessionId) &&
5448 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305449 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 "%s Invalid Sessionid", __func__);
5451 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305452 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 }
5454
5455 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5456
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305457 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305459 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5462 pMsg->length = len;
5463 pMsg->sessionId = sessionId;
5464 pMsg->registerFrame = true;
5465 pMsg->frameType = frameType;
5466 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305467 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005468 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 }
5470 sme_release_global_lock(&pMac->sme);
5471 }
5472 return status;
5473}
5474
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305475/*
5476 * sme_DeregisterMgtFrame() -
5477 * To De-register managment frame of specified type and subtype.
5478 *
5479 * frameType - type of the frame that needs to be passed to HDD.
5480 * matchData - data which needs to be matched before passing frame
5481 * to HDD.
5482 * matchDataLen - Length of matched data.
5483 * Return QDF_STATUS
5484 */
5485QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005486 uint16_t frameType, uint8_t *matchData,
5487 uint16_t matchLen)
5488{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305489 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5491
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305492 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5494 0));
5495 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305496 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 tSirRegisterMgmtFrame *pMsg;
5498 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305499 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5500 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501
5502 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005503 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305505 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 }
5507
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305508 if (!CSR_IS_SESSION_ANY(sessionId) &&
5509 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305510 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511 "%s Invalid Sessionid", __func__);
5512 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305513 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 }
5515
5516 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5517
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305518 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005519 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305520 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5523 pMsg->length = len;
5524 pMsg->registerFrame = false;
5525 pMsg->frameType = frameType;
5526 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305527 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005528 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 }
5530 sme_release_global_lock(&pMac->sme);
5531 }
5532 return status;
5533}
5534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005536/**
5537 * sme_configure_ext_wow() - configure Extr WoW
5538 * @hHal - The handle returned by mac_open.
5539 * @wlanExtParams - Depicts the wlan Ext params.
5540 * @callback - ext_wow callback to be registered.
5541 * @callback_context - ext_wow callback context
5542 *
5543 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305544 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005545 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305546QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005547 tpSirExtWoWParams wlanExtParams,
5548 csr_readyToExtWoWCallback callback,
5549 void *callback_context)
5550{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305551 QDF_STATUS status = QDF_STATUS_SUCCESS;
5552 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005554 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305555 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556
5557 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305558 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305560 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5562
5563 pMac->readyToExtWoWCallback = callback;
5564 pMac->readyToExtWoWContext = callback_context;
5565
5566 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305567 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568
5569 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305570 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005571 message.bodyptr = MsgPtr;
5572 message.type = WMA_WLAN_EXT_WOW;
5573 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5574 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305575 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 pMac->readyToExtWoWCallback = NULL;
5577 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305578 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305579 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 }
5581 sme_release_global_lock(&pMac->sme);
5582 } else {
5583 pMac->readyToExtWoWCallback = NULL;
5584 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305585 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 }
5587
5588 return status;
5589}
5590
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305591/*
5592 * sme_configure_app_type1_params() -
5593 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5594 *
5595 * hHal - The handle returned by mac_open.
5596 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5597 * Return QDF_STATUS
5598 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305599QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 tpSirAppType1Params wlanAppType1Params)
5601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305602 QDF_STATUS status = QDF_STATUS_SUCCESS;
5603 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005605 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305606 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607
5608 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305609 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305611 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5613 0));
5614
5615 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305616 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305618 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005619 message.bodyptr = MsgPtr;
5620 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5621 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5622 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305623 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305624 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305625 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 }
5627 sme_release_global_lock(&pMac->sme);
5628 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305629 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 }
5631
5632 return status;
5633}
5634
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305635/*
5636 * sme_configure_app_type2_params() -
5637 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5638 *
5639 * hHal - The handle returned by mac_open.
5640 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5641 * Return QDF_STATUS
5642 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305643QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305644 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305646 QDF_STATUS status = QDF_STATUS_SUCCESS;
5647 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005649 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305650 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651
5652 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305653 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305655 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005656 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5657 0));
5658
5659 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305660 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305662 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005663 message.bodyptr = MsgPtr;
5664 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5665 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5666 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305667 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305668 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305669 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 }
5671 sme_release_global_lock(&pMac->sme);
5672 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305673 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 }
5675
5676 return status;
5677}
5678#endif
5679
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305680/*
5681 * sme_get_infra_session_id
5682 * To get the session ID for infra session, if connected
5683 * This is a synchronous API.
5684 *
5685 * hHal - The handle returned by mac_open.
5686 * sessionid, -1 if infra session is not connected
5687 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005688int8_t sme_get_infra_session_id(tHalHandle hHal)
5689{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305690 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691 int8_t sessionid = -1;
5692 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5693
5694 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305695 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696
5697 sessionid = csr_get_infra_session_id(pMac);
5698
5699 sme_release_global_lock(&pMac->sme);
5700 }
5701
5702 return sessionid;
5703}
5704
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305705/*
5706 * sme_get_infra_operation_channel() -
5707 * To get the operating channel for infra session, if connected
5708 * This is a synchronous API.
5709 *
5710 * hHal - The handle returned by mac_open.
5711 * sessionId - the sessionId returned by sme_open_session.
5712 * Return operating channel, 0 if infra session is not connected
5713 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5715{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305716 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005717 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5718 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305721 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722
5723 channel = csr_get_infra_operation_channel(pMac, sessionId);
5724
5725 sme_release_global_lock(&pMac->sme);
5726 }
5727
5728 return channel;
5729}
5730
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305731/* This routine will return poerating channel on which other BSS is operating
5732 * to be used for concurrency mode. If other BSS is not up or not connected it
5733 * will return 0
5734 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5736{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305737 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5739 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305740
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005741 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305742 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743
5744 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5746 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 sme_release_global_lock(&pMac->sme);
5748 }
5749
5750 return channel;
5751}
5752
5753#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5754uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5755 eCsrPhyMode sapPhyMode,
5756 uint8_t cc_switch_mode)
5757{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305758 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005759 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5760 uint16_t channel = 0;
5761
5762 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305763 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305765 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5766 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 cc_switch_mode);
5768 sme_release_global_lock(&pMac->sme);
5769 }
5770
5771 return channel;
5772}
5773#endif
5774
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305775/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005776 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005777 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005778 * @cb_fn: Callback function pointer
5779 * @db_ctx: Callback data
5780 *
5781 * Return: QDF_STATUS
5782 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005783QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005784 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5785{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005786 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005787 QDF_STATUS status;
5788
Manikandan Mohan976e7562016-03-15 16:33:31 -07005789 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005790 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005791 mac->sme.get_tsf_cb = cb_fn;
5792 mac->sme.get_tsf_cxt = cb_ctx;
5793 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005794 }
5795 return status;
5796}
5797
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305798/**
5799 * sme_reset_tsfcb() - Reset callback for TSF capture
5800 * @h_hal: Handler return by mac_open
5801 *
5802 * This function reset the tsf capture callback to SME
5803 *
5804 * Return: QDF_STATUS
5805 */
5806QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5807{
5808 tpAniSirGlobal mac;
5809 QDF_STATUS status;
5810
5811 if (!h_hal) {
5812 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5813 FL("h_hal is not valid"));
5814 return QDF_STATUS_E_INVAL;
5815 }
5816 mac = PMAC_STRUCT(h_hal);
5817
5818 status = sme_acquire_global_lock(&mac->sme);
5819 if (QDF_IS_STATUS_SUCCESS(status)) {
5820 mac->sme.get_tsf_cb = NULL;
5821 mac->sme.get_tsf_cxt = NULL;
5822 sme_release_global_lock(&mac->sme);
5823 }
5824 return status;
5825}
5826
Manikandan Mohan976e7562016-03-15 16:33:31 -07005827#ifdef WLAN_FEATURE_TSF
5828/*
5829 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5830 * @h_hal: Handler return by mac_open
5831 * @pinvalue: gpio pin id
5832 *
5833 * Return: QDF_STATUS
5834 */
5835QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5836{
5837 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005838 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005839 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5840
5841 status = sme_acquire_global_lock(&mac->sme);
5842 if (QDF_IS_STATUS_SUCCESS(status)) {
5843 tsf_msg.type = WMA_TSF_GPIO_PIN;
5844 tsf_msg.reserved = 0;
5845 tsf_msg.bodyval = pinvalue;
5846
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005847 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005848 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005849 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005850 status = QDF_STATUS_E_FAILURE;
5851 }
5852 sme_release_global_lock(&mac->sme);
5853 }
5854 return status;
5855}
5856#endif
5857
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005858QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 uint32_t *len)
5860{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305861 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005862 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005864 if (NULL == mac_ctx) {
5865 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5866 FL("Invalid MAC context"));
5867 return QDF_STATUS_E_FAILURE;
5868 }
5869
5870 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305871 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005872 status = csr_get_cfg_valid_channels(mac_ctx,
5873 aValidChannels, len);
5874 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875 }
5876
5877 return status;
5878}
5879
Amar Singhal6edf9732016-11-20 21:43:40 -08005880void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5881{
5882 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5883
5884 mac_ctx->reg_hint_src = cc_src;
5885}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305886/*
5887 * sme_handle_change_country_code() -
5888 * Change Country code, Reg Domain and channel list
5889 *
5890 * Details Country Code Priority
5891 * If Supplicant country code is priority than 11d is disabled.
5892 * If 11D is enabled, we update the country code after every scan.
5893 * Hence when Supplicant country code is priority, we don't need 11D info.
5894 * Country code from Supplicant is set as current courtry code.
5895 * User can send reset command XX (instead of country code) to reset the
5896 * country code to default values. If 11D is priority,
5897 * Than Supplicant country code code is set to default code. But 11D code
5898 * is set as current country code
5899 *
5900 * pMac - The handle returned by mac_open.
5901 * pMsgBuf - MSG Buffer
5902 * Return QDF_STATUS
5903 */
5904static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5905 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305907 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 tAniChangeCountryCodeReq *pMsg;
5909 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305910 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005911 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005912
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305913 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005914 /*
5915 * if the reset Supplicant country code command is triggered,
5916 * enable 11D, reset the country code and return
5917 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005918 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 pMac->roam.configParam.Is11dSupportEnabled =
5920 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5921
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005922 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5923 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924
5925 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305926 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305927 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 default_country,
5929 WNI_CFG_COUNTRY_CODE_LEN);
5930 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305931 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 return status;
5933 }
5934 /*
5935 * Update the 11d country to default country so that when
5936 * callback is received for this default country, driver will
5937 * not disable the 11d taking it as valid country by user.
5938 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005939 sme_debug(
5940 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305942 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 pMsg->countryCode,
5944 WNI_CFG_COUNTRY_CODE_LEN);
5945 } else {
5946 /* if Supplicant country code has priority, disable 11d */
5947 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305948 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005950 }
5951
5952 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305953 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954
5955 /* Set Current Country code and Current Regulatory domain */
5956 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305957 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 /* Supplicant country code failed. So give 11D priority */
5959 pMac->roam.configParam.Is11dSupportEnabled =
5960 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005961 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005962 return status;
5963 }
5964
5965 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305966 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
5968
5969 /* Get Domain ID from country code */
5970 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305971 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07005973 domainIdIoctl,
5974 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305975 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005976 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977 return status;
5978 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305979 /* Supplicant country code is invalid, so we are on world mode
5980 * now. So give 11D chance to update
5981 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 pMac->roam.configParam.Is11dSupportEnabled =
5983 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005984 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 }
5986
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005987 if (domainIdIoctl >= REGDOMAIN_COUNT) {
5988 sme_err("Invalid regId %d", domainIdIoctl);
5989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 } else {
5991 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
5992 /* set again if we find AP with 11d info during scan */
5993 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005994 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305995 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305996 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305997 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 sizeof(pMac->scan.countryCode11d));
5999 }
6000 }
6001
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306002 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306004 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306006 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007}
6008
6009/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006010 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 * @mac_ctx: mac global context
6012 * @msg: request msg packet
6013 *
6014 * If Supplicant country code is priority than 11d is disabled.
6015 * If 11D is enabled, we update the country code after every scan.
6016 * Hence when Supplicant country code is priority, we don't need 11D info.
6017 * Country code from Supplicant is set as current country code.
6018 *
6019 * Return: status of operation
6020 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306021static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006022sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
6023 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306025 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006026 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006027 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006028 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006029 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006030
Amar Singhal6edf9732016-11-20 21:43:40 -08006031 if (SOURCE_11D != mac_ctx->reg_hint_src) {
6032 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
6033 if (user_ctry_priority)
6034 mac_ctx->roam.configParam.Is11dSupportEnabled =
6035 false;
6036 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306037 if (mac_ctx->roam.configParam.
6038 Is11dSupportEnabled &&
6039 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006041 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006042
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306043 status =
6044 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08006045 mac_ctx,
6046 mac_ctx->scan.countryCode11d,
6047 &reg_domain_id,
6048 SOURCE_11D);
6049 return QDF_STATUS_E_FAILURE;
6050 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006051 }
6052 }
6053 } else {
6054 /* if kernel gets invalid country code; it
6055 * resets the country code to world
6056 */
6057 if (('0' != msg->countryCode[0]) ||
6058 ('0' != msg->countryCode[1]))
6059 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6060 msg->countryCode,
6061 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006063
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006064 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6065 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 /* get the channels based on new cc */
6069 status = csr_get_channel_and_power_list(mac_ctx);
6070
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306071 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006072 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073 return status;
6074 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006075
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 /* reset info based on new cc, and we are done */
6077 csr_apply_channel_power_info_wrapper(mac_ctx);
6078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006080
6081 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 * Country IE
6083 */
6084 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006085
Amar Singhal6edf9732016-11-20 21:43:40 -08006086 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006089
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306090 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091}
6092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093static bool
6094sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6095{
6096 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306097 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 ch_lst_info = &mac_ctx->scan.base_channels;
6100 for (i = 0; i < ch_lst_info->numChannels; i++) {
6101 if (ch_lst_info->channelList[i] == curr_ch)
6102 return true;
6103 }
6104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006105 return false;
6106}
6107/**
6108 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6109 * if channel is not supported
6110 * @mac_ctx: mac global context
6111 *
6112 * If new country code does not support the channel on which STA/P2P client
6113 * is connetced, it sends the disconnect to the AP/P2P GO
6114 *
6115 * Return: void
6116 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306117static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006118{
6119 uint8_t session_id, found = false;
6120 uint8_t curr_ch;
6121
6122 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6123 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6124 continue;
6125 found = false;
6126 /* Session is connected.Check the channel */
6127 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6128 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006129 sme_debug("Current Operating channel : %d, session :%d",
6130 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6132 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006133 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 csr_roam_disconnect(mac_ctx, session_id,
6135 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6136 }
6137 }
6138}
6139
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306141QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 tpSirRcvFltMcAddrList pMulticastAddrs)
6143{
6144 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006145 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306147 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306149 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6150 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006151 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006152 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006154 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006155 pSession = CSR_GET_SESSION(pMac, sessionId);
6156 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6157 (!csr_is_conn_state_infra(pMac, sessionId) &&
6158 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306159 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006160 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306162 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163 }
6164
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306165 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306167 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306168 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306170 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171 }
6172
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006173 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6174 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306175 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006176 "%s: Request ignored, session %d is not connected or started",
6177 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306178 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306179 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006180 }
6181
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306182 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006183 sizeof(tSirRcvFltMcAddrList));
6184
Anurag Chouhanc5548422016-02-24 18:33:27 +05306185 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6186 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006187 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188
6189 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6190 msg.reserved = 0;
6191 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306192 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6193 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006194 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006195 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306197 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306199 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 }
6202
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306203 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205#endif /* WLAN_FEATURE_PACKET_FILTERING */
6206
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306207/*
6208 * sme_is_channel_valid() -
6209 * To check if the channel is valid for currently established domain
6210 * This is a synchronous API.
6211 *
6212 * hHal - The handle returned by mac_open.
6213 * channel - channel to verify
6214 * Return true/false, true if channel is valid
6215 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006216bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6217{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306218 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219 bool valid = false;
6220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6221
6222 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306223 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224
6225 valid = csr_roam_is_channel_valid(pMac, channel);
6226
6227 sme_release_global_lock(&pMac->sme);
6228 }
6229
6230 return valid;
6231}
6232
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306233/*
6234 * sme_set_freq_band() -
6235 * Used to set frequency band.
6236 *
6237 * hHal
6238 * sessionId - Session Identifier
6239 * band value to be configured
6240 * Return QDF_STATUS
6241 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306242QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006243{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306244 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6246
6247 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306248 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 status = csr_set_band(hHal, sessionId, eBand);
6250 sme_release_global_lock(&pMac->sme);
6251 }
6252 return status;
6253}
6254
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306255/*
6256 * sme_get_freq_band() -
6257 * Used to get the current band settings.
6258 *
6259 * hHal
6260 * pBand pointer to hold band value
6261 * Return QDF_STATUS
6262 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306263QDF_STATUS sme_get_freq_band(tHalHandle hHal, eCsrBand *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006264{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306265 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006266 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6267
6268 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306269 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 *pBand = csr_get_current_band(hHal);
6271 sme_release_global_lock(&pMac->sme);
6272 }
6273 return status;
6274}
6275
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306276/*
6277 * sme_set_max_tx_power_per_band() -
6278 * Set the Maximum Transmit Power specific to band dynamically.
6279 * Note: this setting will not persist over reboots.
6280 *
6281 * band
6282 * power to set in dB
6283 * Return QDF_STATUS
6284 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306285QDF_STATUS sme_set_max_tx_power_per_band(eCsrBand band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006287 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6289
6290 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306291 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6295 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306296 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 }
6298
6299 pMaxTxPowerPerBandParams->power = dB;
6300 pMaxTxPowerPerBandParams->bandInfo = band;
6301
6302 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6303 msg.reserved = 0;
6304 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306305 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6306 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006307 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006308 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306309 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006310 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6311 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306312 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306313 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006314 }
6315
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306316 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006317}
6318
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306319/*
6320 * sme_set_max_tx_power() -
6321 * Set the Maximum Transmit Power dynamically. Note: this setting will
6322 * not persist over reboots.
6323 *
6324 * hHal
6325 * pBssid BSSID to set the power cap for
6326 * pBssid pSelfMacAddress self MAC Address
6327 * pBssid power to set in dB
6328 * Return QDF_STATUS
6329 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306330QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6331 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006333 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006334 tpMaxTxPowerParams pMaxTxParams = NULL;
6335
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306336 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006337 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306338 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006339 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306340 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341 "%s: Not able to allocate memory for pMaxTxParams",
6342 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306343 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006344 }
6345
Anurag Chouhanc5548422016-02-24 18:33:27 +05306346 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6347 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006348 pMaxTxParams->power = dB;
6349
6350 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6351 msg.reserved = 0;
6352 msg.bodyptr = pMaxTxParams;
6353
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006354 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006355 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306356 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006357 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6358 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306359 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306360 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006361 }
6362
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306363 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364}
6365
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306366/*
6367 * sme_set_custom_mac_addr() -
6368 * Set the customer Mac Address.
6369 *
6370 * customMacAddr customer MAC Address
6371 * Return QDF_STATUS
6372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306373QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006375 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376 tSirMacAddr *pBaseMacAddr;
6377
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306378 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006379 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306380 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006381 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306382 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006383 }
6384
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306385 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006386
6387 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6388 msg.reserved = 0;
6389 msg.bodyptr = pBaseMacAddr;
6390
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006391 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006392 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306393 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306394 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306395 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306396 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397 }
6398
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306399 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400}
6401
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306402/*
6403 * sme_set_tx_power() -
6404 * Set Transmit Power dynamically.
6405 *
6406 * hHal
6407 * sessionId Target Session ID
6408 * BSSID
6409 * dev_mode dev_mode such as station, P2PGO, SAP
6410 * dBm power to set
6411 * Return QDF_STATUS
6412 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306413QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306414 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006415 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006417 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418 tpMaxTxPowerParams pTxParams = NULL;
6419 int8_t power = (int8_t) dBm;
6420
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306421 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006422 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6423
6424 /* make sure there is no overflow */
6425 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006427 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 }
6430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306431 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006432 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306433 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006434 "%s: Not able to allocate memory for pTxParams",
6435 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306436 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006437 }
6438
Anurag Chouhanc5548422016-02-24 18:33:27 +05306439 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006440 pTxParams->power = power; /* unit is dBm */
6441 pTxParams->dev_mode = dev_mode;
6442 msg.type = WMA_SET_TX_POWER_REQ;
6443 msg.reserved = 0;
6444 msg.bodyptr = pTxParams;
6445
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006446 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006447 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006449 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6450 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306451 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306452 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006453 }
6454
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306455 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456}
6457
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306458QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6459 uint8_t param_val)
6460{
6461 QDF_STATUS status;
6462 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6463
6464 pMac->roam.configParam.is_fils_enabled = !param_val;
6465
6466 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6467 status = wma_cli_set_command((int)session_id,
6468 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6469 !param_val, VDEV_CMD);
6470 if (status)
6471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6472 "%s: Failed to set enable bcast probe setting",
6473 __func__);
6474
6475 return status;
6476}
6477
6478QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306479 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306481 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306482 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 uint16_t len;
6484
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306485 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306486 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306487 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306488 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6489 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306491 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006492 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306493 sme_release_global_lock(&mac_ctx->sme);
6494 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006495 }
6496
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306497 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6498 mac_ctx->ignore_assoc_disallowed = param_val;
6499
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306500 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306501 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006502
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306503 len = sizeof(*msg);
6504 msg = qdf_mem_malloc(len);
6505 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306506 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006507 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306508 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6509 msg->length = len;
6510 msg->session_id = session_id;
6511 msg->param_type = param_type;
6512 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006513 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306515 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516 }
6517 return status;
6518}
6519
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306520/*
6521 * sme_set_tm_level() -
6522 * Set Thermal Mitigation Level to RIVA
6523 *
6524 * hHal - The handle returned by mac_open.
6525 * newTMLevel - new Thermal Mitigation Level
6526 * tmMode - Thermal Mitigation handle mode, default 0
6527 * Return QDF_STATUS
6528 */
6529QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6530 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006531{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306532 QDF_STATUS status = QDF_STATUS_SUCCESS;
6533 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006534 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006535 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006536 tAniSetTmLevelReq *setTmLevelReq = NULL;
6537
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306538 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006539 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6540 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306541 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006542 setTmLevelReq =
6543 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306544 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006545 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306546 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 "%s: Not able to allocate memory for sme_set_tm_level",
6548 __func__);
6549 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306550 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551 }
6552
6553 setTmLevelReq->tmMode = tmMode;
6554 setTmLevelReq->newTmLevel = newTMLevel;
6555
6556 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006557 message.bodyptr = setTmLevelReq;
6558 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306559 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006560 NO_SESSION, message.type));
6561 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6562 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306563 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306564 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306566 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306567 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006568 }
6569 sme_release_global_lock(&pMac->sme);
6570 }
6571 return status;
6572}
6573
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306574/*
6575 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6576 * Host and FW.
6577 *
6578 * hHal - HAL handle for device
6579 * Return NONE
6580 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006581void sme_feature_caps_exchange(tHalHandle hHal)
6582{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306583 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306584 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6585 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586}
6587
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306588/*
6589 * sme_disable_feature_capablity() - SME interface to disable Active mode
6590 * offload capablity in Host.
6591 *
6592 * hHal - HAL handle for device
6593 * Return NONE
6594 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595void sme_disable_feature_capablity(uint8_t feature_index)
6596{
6597}
6598
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306599/*
6600 * sme_reset_power_values_for5_g
6601 * Reset the power values for 5G band with default power values.
6602 *
6603 * hHal - HAL handle for device
6604 * Return NONE
6605 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606void sme_reset_power_values_for5_g(tHalHandle hHal)
6607{
6608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306609
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306610 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006611 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6612 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306613 /* Store the channel+power info in the global place: Cfg */
6614 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615}
6616
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306617/*
6618 * sme_update_roam_prefer5_g_hz() -
6619 * Enable/disable Roam prefer 5G runtime option
6620 * This function is called through dynamic setConfig callback function
6621 * to configure the Roam prefer 5G runtime option
6622 *
6623 * hHal - HAL handle for device
6624 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6625 * Return Success or failure
6626 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306628QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6629 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630{
6631 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306632 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006633
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306634 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6636 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306637 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306638 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006639 "%s: gRoamPrefer5GHz is changed from %d to %d",
6640 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6641 nRoamPrefer5GHz);
6642 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6643 sme_release_global_lock(&pMac->sme);
6644 }
6645
6646 return status;
6647}
6648
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306649/*
6650 * sme_set_roam_intra_band() -
6651 * enable/disable Intra band roaming
6652 * This function is called through dynamic setConfig callback function
6653 * to configure the intra band roaming
6654 * hHal - HAL handle for device
6655 * nRoamIntraBand Enable/Disable Intra band roaming
6656 * Return Success or failure
6657 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306658QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006659{
6660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306661 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006662
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306663 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6665 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306666 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006668 "%s: gRoamIntraBand is changed from %d to %d",
6669 __func__, pMac->roam.configParam.nRoamIntraBand,
6670 nRoamIntraBand);
6671 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6672 sme_release_global_lock(&pMac->sme);
6673 }
6674
6675 return status;
6676}
6677
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306678/*
6679 * sme_update_roam_scan_n_probes() -
6680 * Function to update roam scan N probes
6681 * This function is called through dynamic setConfig callback function
6682 * to update roam scan N probes
6683 * hHal - HAL handle for device
6684 * sessionId - Session Identifier
6685 * nProbes number of probe requests to be sent out
6686 * Return Success or failure
6687 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306688QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 const uint8_t nProbes)
6690{
6691 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306692 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006693
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306694 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006695 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6696 NO_SESSION, 0));
6697 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306698 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306699 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006700 "%s: gRoamScanNProbes is changed from %d to %d",
6701 __func__, pMac->roam.configParam.nProbes, nProbes);
6702 pMac->roam.configParam.nProbes = nProbes;
6703 sme_release_global_lock(&pMac->sme);
6704 }
6705 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6706 csr_roam_offload_scan(pMac, sessionId,
6707 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6708 REASON_NPROBES_CHANGED);
6709 }
6710 return status;
6711}
6712
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306713/*
6714 * sme_update_roam_scan_home_away_time() -
6715 * Function to update roam scan Home away time
6716 * This function is called through dynamic setConfig callback function
6717 * to update roam scan home away time
6718 *
6719 * hHal - HAL handle for device
6720 * sessionId - Session Identifier
6721 * nRoamScanAwayTime Scan home away time
6722 * bSendOffloadCmd If true then send offload command to firmware
6723 * If false then command is not sent to firmware
6724 * Return Success or failure
6725 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306726QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006727 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306728 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006729 const bool bSendOffloadCmd)
6730{
6731 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306732 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006733
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306734 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006735 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6736 NO_SESSION, 0));
6737 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306738 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006740 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6741 __func__,
6742 pMac->roam.configParam.nRoamScanHomeAwayTime,
6743 nRoamScanHomeAwayTime);
6744 pMac->roam.configParam.nRoamScanHomeAwayTime =
6745 nRoamScanHomeAwayTime;
6746 sme_release_global_lock(&pMac->sme);
6747 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306748 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6749 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 csr_roam_offload_scan(pMac, sessionId,
6751 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6752 REASON_HOME_AWAY_TIME_CHANGED);
6753 }
6754 return status;
6755}
6756
Abhishek Singh518323d2015-10-19 17:42:01 +05306757/**
6758 * sme_ext_change_channel()- function to post send ECSA
6759 * action frame to csr.
6760 * @hHal: Hal context
6761 * @channel: new channel to switch
6762 * @session_id: senssion it should be sent on.
6763 *
6764 * This function is called to post ECSA frame to csr.
6765 *
6766 * Return: success if msg is sent else return failure
6767 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306768QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306769 uint8_t session_id)
6770{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306771 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306772 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6773 uint8_t channel_state;
6774
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006775 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306776 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006777 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306778
6779 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006780 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306781 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306782 }
6783
6784 status = sme_acquire_global_lock(&mac_ctx->sme);
6785
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306786 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306787 /* update the channel list to the firmware */
6788 status = csr_send_ext_change_channel(mac_ctx,
6789 channel, session_id);
6790 sme_release_global_lock(&mac_ctx->sme);
6791 }
6792
6793 return status;
6794}
6795
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306796/*
6797 * sme_get_roam_intra_band() -
6798 * get Intra band roaming
6799 *
6800 * hHal - HAL handle for device
6801 * Return Success or failure
6802 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006803bool sme_get_roam_intra_band(tHalHandle hHal)
6804{
6805 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306806
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306807 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006808 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6809 return pMac->roam.configParam.nRoamIntraBand;
6810}
6811
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306812/*
6813 * sme_get_roam_scan_n_probes() -
6814 * get N Probes
6815 *
6816 * hHal - HAL handle for device
6817 * Return Success or failure
6818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006819uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6820{
6821 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 return pMac->roam.configParam.nProbes;
6824}
6825
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306826/*
6827 * sme_get_roam_scan_home_away_time() -
6828 * get Roam scan home away time
6829 *
6830 * hHal - HAL handle for device
6831 * Return Success or failure
6832 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6834{
6835 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006837 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6838}
6839
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306840/*
6841 * sme_update_roam_rssi_diff() -
6842 * Update RoamRssiDiff
6843 * This function is called through dynamic setConfig callback function
6844 * to configure RoamRssiDiff
6845 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6846 *
6847 * hHal - HAL handle for device
6848 * sessionId - Session Identifier
6849 * RoamRssiDiff - minimum rssi difference between potential
6850 * candidate and current AP.
6851 * Return Success or failure
6852 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306854QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 uint8_t RoamRssiDiff)
6856{
6857 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306858 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006859
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006860 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6861 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6862 FL("Invalid sme session id: %d"), sessionId);
6863 return QDF_STATUS_E_INVAL;
6864 }
6865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006866 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306867 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306868 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006869 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6870 RoamRssiDiff,
6871 pMac->roam.configParam.RoamRssiDiff,
6872 mac_trace_get_neighbour_roam_state(pMac->roam.
6873 neighborRoamInfo
6874 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306875 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006876 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6877 sme_release_global_lock(&pMac->sme);
6878 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006879
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306880 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006881 csr_roam_offload_scan(pMac, sessionId,
6882 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6883 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006884 return status;
6885}
6886
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306887#ifdef WLAN_FEATURE_FILS_SK
6888QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6889 tCsrRoamProfile *src_profile)
6890{
6891 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6892 QDF_STATUS status = QDF_STATUS_SUCCESS;
6893 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6894 &mac->roam.neighborRoamInfo[session_id];
6895
6896 if (session_id >= CSR_ROAM_SESSION_MAX) {
6897 sme_err("Invalid sme session id: %d", session_id);
6898 return QDF_STATUS_E_INVAL;
6899 }
6900
6901 if (!src_profile) {
6902 sme_err("src roam profile NULL");
6903 return QDF_STATUS_E_INVAL;
6904 }
6905
6906 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6907 (neighbor_roam_info->neighborRoamState !=
6908 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6909 sme_info("Fast roam is disabled or not connected(%d)",
6910 neighbor_roam_info->neighborRoamState);
6911 return QDF_STATUS_E_PERM;
6912 }
6913
6914 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306915 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306916 sme_debug("Updating fils config to fw");
6917 csr_roam_offload_scan(mac, session_id,
6918 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6919 REASON_FILS_PARAMS_CHANGED);
6920 } else {
6921 sme_info("LFR3 not enabled");
6922 return QDF_STATUS_E_INVAL;
6923 }
6924
6925 return status;
6926}
6927
6928void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6929 tCsrRoamProfile *profile, uint32_t if_addr)
6930{
6931 int i;
6932 struct scheduler_msg msg;
6933 QDF_STATUS status;
6934 struct hlp_params *params;
6935 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6936 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6937 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6938 &mac->roam.neighborRoamInfo[session_id];
6939
6940 if (!session) {
6941 sme_err("session NULL");
6942 return;
6943 }
6944
6945 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6946 (neighbor_roam_info->neighborRoamState !=
6947 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6948 sme_debug("Fast roam is disabled or not connected(%d)",
6949 neighbor_roam_info->neighborRoamState);
6950 return;
6951 }
6952
6953 params = qdf_mem_malloc(sizeof(*params));
6954 if (!params) {
6955 sme_err("Mem alloc for HLP IE fails");
6956 return;
6957 }
6958 if ((profile->hlp_ie_len +
6959 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6960 sme_err("HLP IE len exceeds %d",
6961 profile->hlp_ie_len);
6962 qdf_mem_free(params);
6963 return;
6964 }
6965
6966 params->vdev_id = session_id;
6967 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6968
6969 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6970 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6971
6972 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6973 profile->hlp_ie, profile->hlp_ie_len);
6974
6975 msg.type = SIR_HAL_HLP_IE_INFO;
6976 msg.reserved = 0;
6977 msg.bodyptr = params;
6978 status = sme_acquire_global_lock(&mac->sme);
6979 if (status != QDF_STATUS_SUCCESS) {
6980 sme_err("sme lock acquire fails");
6981 qdf_mem_free(params);
6982 return;
6983 }
6984
6985 if (!QDF_IS_STATUS_SUCCESS
6986 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6987 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6988 sme_release_global_lock(&mac->sme);
6989 qdf_mem_free(params);
6990 return;
6991 }
6992
6993 sme_release_global_lock(&mac->sme);
6994}
6995
Jeff Johnson172237b2017-11-07 15:32:59 -08006996void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306997{
6998 struct fils_join_rsp_params *roam_fils_params;
6999
7000 if (!roam_info) {
7001 sme_err("FILS Roam Info NULL");
7002 return;
7003 }
7004
7005 roam_fils_params = roam_info->fils_join_rsp;
7006 if (!roam_fils_params) {
7007 sme_err("FILS Roam Param NULL");
7008 return;
7009 }
7010
7011 if (roam_fils_params->fils_pmk)
7012 qdf_mem_free(roam_fils_params->fils_pmk);
7013
7014 qdf_mem_free(roam_fils_params);
7015
7016 roam_info->fils_join_rsp = NULL;
7017}
7018
7019#else
7020inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
7021 tCsrRoamProfile *profile, uint32_t if_addr)
7022{}
7023#endif
7024
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307025/*
7026 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
7027 * support at runtime
7028 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7029 * isFastTransitionEnabled.
7030 * This is a synchronous call
7031 *
7032 * hHal - The handle returned by mac_open.
7033 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7034 * successfully.
7035 * Other status means SME is failed to update isFastTransitionEnabled.
7036 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307037QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007038 bool isFastTransitionEnabled)
7039{
7040 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307041 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007042
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307043 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007044 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7045 0));
7046 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307047 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049 "%s: FastTransitionEnabled is changed from %d to %d",
7050 __func__,
7051 pMac->roam.configParam.isFastTransitionEnabled,
7052 isFastTransitionEnabled);
7053 pMac->roam.configParam.isFastTransitionEnabled =
7054 isFastTransitionEnabled;
7055 sme_release_global_lock(&pMac->sme);
7056 }
7057
7058 return status;
7059}
7060
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307061/*
7062 * sme_update_wes_mode() -
7063 * Update WES Mode
7064 * This function is called through dynamic setConfig callback function
7065 * to configure isWESModeEnabled
7066 *
7067 * hHal - HAL handle for device
7068 * isWESModeEnabled - WES mode
7069 * sessionId - Session Identifier
7070 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7071 * Other status means SME is failed to update isWESModeEnabled.
7072 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007073
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307074QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 uint8_t sessionId)
7076{
7077 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307078 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007080 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7081 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7082 FL("Invalid sme session id: %d"), sessionId);
7083 return QDF_STATUS_E_INVAL;
7084 }
7085
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307087 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307088 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7090 isWESModeEnabled,
7091 pMac->roam.configParam.isWESModeEnabled,
7092 mac_trace_get_neighbour_roam_state(pMac->roam.
7093 neighborRoamInfo
7094 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307095 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7097 sme_release_global_lock(&pMac->sme);
7098 }
7099
7100 return status;
7101}
7102
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307103/*
7104 * sme_set_roam_scan_control() -
7105 * Set roam scan control
7106 * This function is called to set roam scan control
7107 * if roam scan control is set to 0, roaming scan cache is cleared
7108 * any value other than 0 is treated as invalid value
7109 * hHal - HAL handle for device
7110 * sessionId - Session Identifier
7111 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7112 * Other status means SME failure to update
7113 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307114QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115 bool roamScanControl)
7116{
7117 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307118 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007119
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307120 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007122
7123 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7125 FL("Invalid sme session id: %d"), sessionId);
7126 return QDF_STATUS_E_INVAL;
7127 }
7128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007129 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307130 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307131 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7133 roamScanControl,
7134 pMac->roam.configParam.nRoamScanControl,
7135 mac_trace_get_neighbour_roam_state(pMac->roam.
7136 neighborRoamInfo
7137 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307138 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7140 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007142 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307143 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7144 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007145 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7146 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307147 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7148 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007149 }
7150 }
7151 sme_release_global_lock(&pMac->sme);
7152 }
7153 return status;
7154}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007155
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307156/*
7157 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7158 * support at runtime
7159 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7160 * isFastRoamIniFeatureEnabled.
7161 * This is a synchronous call
7162 *
7163 * hHal - The handle returned by mac_open.
7164 * sessionId - Session Identifier
7165 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7166 * successfully.
7167 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7168 */
7169QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7170 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7171{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7173
7174 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7175 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307176 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007177 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7178 __func__,
7179 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7180 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307181 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007182 }
7183
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307184 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007185 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7186 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7187 isFastRoamIniFeatureEnabled);
7188 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7189 isFastRoamIniFeatureEnabled;
7190 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307191 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007192
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307193 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007194}
7195
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307196/**
7197 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7198 * @hal - The handle returned by macOpen.
7199 * @session_id - Session Identifier
7200 * @is_fast_roam_enabled - flag to enable/disable roaming
7201 *
7202 * When Supplicant issues enabled/disable fast roaming on the basis
7203 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7204 *
7205 * Return: QDF_STATUS
7206 */
7207
7208QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7209 const bool is_fast_roam_enabled)
7210{
7211 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307212 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307213 QDF_STATUS status;
7214
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007215 /*
7216 * supplicant_disabled_roaming flag is set to true in
7217 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7218 * request with BSSID. This flag is reset when supplicant sends
7219 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007220 *
7221 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007222 * if roaming is disabled using driver command or INI and
7223 * supplicant_disabled_roaming flag remains set. So make sure to set
7224 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7225 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007226 */
7227 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007228 session->pCurRoamProfile->supplicant_disabled_roaming =
7229 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007230
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307231 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007232 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307233 if (!is_fast_roam_enabled)
7234 return QDF_STATUS_SUCCESS;
7235 return QDF_STATUS_E_FAILURE;
7236 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307237
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307238 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7239 session_id, is_fast_roam_enabled);
7240 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007241 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307242 return QDF_STATUS_E_FAILURE;
7243 }
7244
7245 return QDF_STATUS_SUCCESS;
7246}
7247
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307248/*
7249 * sme_update_is_mawc_ini_feature_enabled() -
7250 * Enable/disable LFR MAWC support at runtime
7251 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7252 * isMAWCIniFeatureEnabled.
7253 * This is a synchronous call
7254 *
7255 * hHal - The handle returned by mac_open.
7256 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7257 * Other status means SME is failed to update MAWCEnabled.
7258 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307259QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260 const bool MAWCEnabled)
7261{
7262 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307263 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007264
7265 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307266 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307267 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007268 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007269 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7270 MAWCEnabled);
7271 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7272 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007273 sme_release_global_lock(&pMac->sme);
7274 }
7275
7276 return status;
7277
7278}
7279
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007280/**
7281 * sme_stop_roaming() - Stop roaming for a given sessionId
7282 * This is a synchronous call
7283 *
7284 * @hHal - The handle returned by mac_open
7285 * @sessionId - Session Identifier
7286 *
7287 * Return QDF_STATUS_SUCCESS on success
7288 * Other status on failure
7289 */
7290QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007291{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007292 struct scheduler_msg wma_msg = {0};
7293 tSirRetStatus status;
7294 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007295 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7296 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007297 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007298
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007299 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007300 sme_err("incorrect session/vdev ID");
7301 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007302 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007303
7304 session = CSR_GET_SESSION(mac_ctx, session_id);
7305 if (session->pCurRoamProfile &&
7306 !session->pCurRoamProfile->roaming_allowed_on_iface) {
7307 sme_debug("Roaming was never started on session %d",
7308 session_id);
7309 return QDF_STATUS_SUCCESS;
7310 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007311 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007312 req = qdf_mem_malloc(sizeof(*req));
7313 if (!req) {
7314 sme_err("failed to allocated memory");
7315 return QDF_STATUS_E_NOMEM;
7316 }
7317
7318 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307319 if (reason == eCsrForcedDisassoc)
7320 req->reason = REASON_ROAM_STOP_ALL;
7321 else
7322 req->reason = REASON_ROAM_SYNCH_FAILED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007323 req->sessionId = session_id;
7324 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007325 req->middle_of_roaming = 1;
7326 else
7327 csr_roam_reset_roam_params(mac_ctx);
7328
7329 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7330 wma_msg.bodyptr = req;
7331
7332 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7333 if (eSIR_SUCCESS != status) {
7334 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007335 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007336 qdf_mem_free(req);
7337 return QDF_STATUS_E_FAULT;
7338 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007339 roam_info->b_roam_scan_offload_started = false;
7340 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007341
7342 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007343}
7344
Abhishek Singhd5686472017-09-20 15:18:50 +05307345void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7346{
7347 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7348 QDF_STATUS status = QDF_STATUS_SUCCESS;
7349 struct csr_roam_session *session;
7350
7351 status = sme_acquire_global_lock(&mac_ctx->sme);
7352 if (QDF_IS_STATUS_SUCCESS(status)) {
7353 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7354 session = CSR_GET_SESSION(mac_ctx, session_id);
7355 if (session)
7356 session->discon_in_progress = true;
7357 }
7358 sme_release_global_lock(&mac_ctx->sme);
7359 }
7360}
7361
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307362/*
7363 * sme_start_roaming() - Start roaming for a given sessionId
7364 * This is a synchronous call
7365 *
7366 * hHal - The handle returned by mac_open
7367 * sessionId - Session Identifier
7368 * Return QDF_STATUS_SUCCESS on success
7369 * Other status on failure
7370 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307371QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372{
7373 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307374 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007375
7376 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307377 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007378 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7379 reason);
7380 sme_release_global_lock(&pMac->sme);
7381 }
7382
7383 return status;
7384}
7385
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307386/*
7387 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7388 * Concurrent session exists
7389 * This is a synchronuous call
7390 *
7391 * hHal - The handle returned by mac_open.
7392 * Return QDF_STATUS_SUCCESS
7393 * Other status means SME is failed
7394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307395QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007396 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307397 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007398{
7399
7400 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307401 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007402
7403 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307404 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007405 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7406 bFastRoamInConIniFeatureEnabled;
7407 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7408 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7409 0;
7410 }
7411 sme_release_global_lock(&pMac->sme);
7412 }
7413
7414 return status;
7415}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007416
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307417/*
7418 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7419 * Monitoring at runtime
7420 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7421 * fEnableFwRssiMonitoring.
7422 * This is a synchronous call
7423 *
7424 * hHal - The handle returned by mac_open.
7425 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7426 * config successfully.
7427 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307429QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007430 bool fEnableFwRssiMonitoring)
7431{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307432 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433
7434 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307435 fEnableFwRssiMonitoring) ==
7436 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307437 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307438 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7440 }
7441
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307442 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007443}
7444
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307445/*
7446 * sme_set_roam_opportunistic_scan_threshold_diff() -
7447 * Update Opportunistic Scan threshold diff
7448 * This function is called through dynamic setConfig callback function
7449 * to configure nOpportunisticThresholdDiff
7450 *
7451 * hHal - HAL handle for device
7452 * sessionId - Session Identifier
7453 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7454 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7455 * successfully.
7456 * else SME is failed to update nOpportunisticThresholdDiff.
7457 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307458QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 uint8_t sessionId,
7460 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307461 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007462{
7463 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307464 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465
7466 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307467 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007468 status = csr_neighbor_roam_update_config(pMac, sessionId,
7469 nOpportunisticThresholdDiff,
7470 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307471 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007472 pMac->roam.configParam.neighborRoamConfig.
7473 nOpportunisticThresholdDiff =
7474 nOpportunisticThresholdDiff;
7475 }
7476 sme_release_global_lock(&pMac->sme);
7477 }
7478 return status;
7479}
7480
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307481/*
7482 * sme_get_roam_opportunistic_scan_threshold_diff()
7483 * gets Opportunistic Scan threshold diff
7484 * This is a synchronous call
7485 *
7486 * hHal - The handle returned by mac_open
7487 * Return uint8_t - nOpportunisticThresholdDiff
7488 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007489uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7490{
7491 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307492
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007493 return pMac->roam.configParam.neighborRoamConfig.
7494 nOpportunisticThresholdDiff;
7495}
7496
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307497/*
7498 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7499 * This function is called through dynamic setConfig callback function
7500 * to configure nRoamRescanRssiDiff
7501 *
7502 * hHal - HAL handle for device
7503 * sessionId - Session Identifier
7504 * nRoamRescanRssiDiff - roam rescan rssi diff
7505 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7506 * successfully.
7507 * else SME is failed to update nRoamRescanRssiDiff.
7508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307509QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007510 uint8_t sessionId,
7511 const uint8_t nRoamRescanRssiDiff)
7512{
7513 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307514 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515
7516 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307517 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007518 status = csr_neighbor_roam_update_config(pMac, sessionId,
7519 nRoamRescanRssiDiff,
7520 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307521 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007522 pMac->roam.configParam.neighborRoamConfig.
7523 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7524 }
7525 sme_release_global_lock(&pMac->sme);
7526 }
7527 return status;
7528}
7529
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307530/*
7531 * sme_get_roam_rescan_rssi_diff()
7532 * gets roam rescan rssi diff
7533 * This is a synchronous call
7534 *
7535 * hHal - The handle returned by mac_open
7536 * Return int8_t - nRoamRescanRssiDiff
7537 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007538uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7539{
7540 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007542 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7543}
7544
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307545/*
7546 * sme_set_roam_bmiss_first_bcnt() -
7547 * Update Roam count for first beacon miss
7548 * This function is called through dynamic setConfig callback function
7549 * to configure nRoamBmissFirstBcnt
7550 * hHal - HAL handle for device
7551 * sessionId - Session Identifier
7552 * nRoamBmissFirstBcnt - Roam first bmiss count
7553 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7554 * successfully.
7555 * else SME is failed to update nRoamBmissFirstBcnt
7556 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307557QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 uint8_t sessionId,
7559 const uint8_t nRoamBmissFirstBcnt)
7560{
7561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307562 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007563
7564 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307565 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007566 status = csr_neighbor_roam_update_config(pMac, sessionId,
7567 nRoamBmissFirstBcnt,
7568 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307569 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007570 pMac->roam.configParam.neighborRoamConfig.
7571 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7572 }
7573 sme_release_global_lock(&pMac->sme);
7574 }
7575 return status;
7576}
7577
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307578/*
7579 * sme_get_roam_bmiss_first_bcnt() -
7580 * get neighbor roam beacon miss first count
7581 *
7582 * hHal - The handle returned by mac_open.
7583 * Return uint8_t - neighbor roam beacon miss first count
7584 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007585uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7586{
7587 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007589 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7590}
7591
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307592/*
7593 * sme_set_roam_bmiss_final_bcnt() -
7594 * Update Roam count for final beacon miss
7595 * This function is called through dynamic setConfig callback function
7596 * to configure nRoamBmissFinalBcnt
7597 * hHal - HAL handle for device
7598 * sessionId - Session Identifier
7599 * nRoamBmissFinalBcnt - Roam final bmiss count
7600 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7601 * successfully.
7602 * else SME is failed to update nRoamBmissFinalBcnt
7603 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307604QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007605 uint8_t sessionId,
7606 const uint8_t nRoamBmissFinalBcnt)
7607{
7608 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307609 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007610
7611 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307612 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007613 status = csr_neighbor_roam_update_config(pMac, sessionId,
7614 nRoamBmissFinalBcnt,
7615 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307616 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007617 pMac->roam.configParam.neighborRoamConfig.
7618 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7619 }
7620 sme_release_global_lock(&pMac->sme);
7621 }
7622 return status;
7623}
7624
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307625/*
7626 * sme_get_roam_bmiss_final_bcnt() -
7627 * gets Roam count for final beacon miss
7628 * This is a synchronous call
7629 *
7630 * hHal - The handle returned by mac_open
7631 * Return uint8_t - nRoamBmissFinalBcnt
7632 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007633uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7634{
7635 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007637 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7638}
7639
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307640/*
7641 * sme_set_roam_beacon_rssi_weight() -
7642 * Update Roam beacon rssi weight
7643 * This function is called through dynamic setConfig callback function
7644 * to configure nRoamBeaconRssiWeight
7645 *
7646 * hHal - HAL handle for device
7647 * sessionId - Session Identifier
7648 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7649 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7650 * successfully.
7651 * else SME is failed to update nRoamBeaconRssiWeight
7652 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307653QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007654 uint8_t sessionId,
7655 const uint8_t nRoamBeaconRssiWeight)
7656{
7657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007659
7660 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307661 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007662 status = csr_neighbor_roam_update_config(pMac, sessionId,
7663 nRoamBeaconRssiWeight,
7664 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307665 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007666 pMac->roam.configParam.neighborRoamConfig.
7667 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7668 }
7669 sme_release_global_lock(&pMac->sme);
7670 }
7671 return status;
7672}
7673
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307674/*
7675 * sme_get_roam_beacon_rssi_weight() -
7676 * gets Roam beacon rssi weight
7677 * This is a synchronous call
7678 *
7679 * hHal - The handle returned by mac_open
7680 * Return uint8_t - nRoamBeaconRssiWeight
7681 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7683{
7684 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7687}
7688
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307689/*
7690 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7691 * rssi threshold
7692 * This is a synchronous call
7693 *
7694 * hHal - The handle returned by mac_open.
7695 * sessionId - Session Identifier
7696 * Return QDF_STATUS_SUCCESS - SME update config successful.
7697 * Other status means SME is failed to update
7698 */
7699QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7700 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7701{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007702 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307703 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007704
7705 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307706 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007707 status = csr_neighbor_roam_update_config(pMac,
7708 sessionId, neighborLookupRssiThreshold,
7709 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307710 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 pMac->roam.configParam.neighborRoamConfig.
7712 nNeighborLookupRssiThreshold =
7713 neighborLookupRssiThreshold;
7714 }
7715 sme_release_global_lock(&pMac->sme);
7716 }
7717 return status;
7718}
7719
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307720/*
7721 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7722 * This is a synchronous call
7723 *
7724 * hal - The handle returned by macOpen.
7725 * session_id - Session Identifier
7726 * delay_before_vdev_stop - value to be set
7727 * Return QDF_STATUS_SUCCESS - SME update config successful.
7728 * Other status means SME is failed to update
7729 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307730QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007731 uint8_t session_id,
7732 uint8_t delay_before_vdev_stop)
7733{
7734 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307735 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007736
7737 if (session_id >= CSR_ROAM_SESSION_MAX) {
7738 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7739 FL("Invalid sme session id: %d"), session_id);
7740 return QDF_STATUS_E_INVAL;
7741 }
7742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007743 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307744 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7746 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007747 pMac->roam.configParam.neighborRoamConfig.
7748 delay_before_vdev_stop,
7749 delay_before_vdev_stop);
7750 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7751 delay_before_vdev_stop = delay_before_vdev_stop;
7752 pMac->roam.configParam.neighborRoamConfig.
7753 delay_before_vdev_stop = delay_before_vdev_stop;
7754 sme_release_global_lock(&pMac->sme);
7755 }
7756 return status;
7757}
7758
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307759/*
7760 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7761 * rssi threshold
7762 * This is a synchronous call
7763 *
7764 * hHal - The handle returned by mac_open.
7765 * Return QDF_STATUS_SUCCESS - SME update config successful.
7766 * Other status means SME is failed to update
7767 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7769{
7770 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007772 return pMac->roam.configParam.neighborRoamConfig.
7773 nNeighborLookupRssiThreshold;
7774}
7775
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307776/*
7777 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7778 * refresh period
7779 * This is a synchronous call
7780 *
7781 * hHal - The handle returned by mac_open.
7782 * sessionId - Session Identifier
7783 * Return QDF_STATUS_SUCCESS - SME update config successful.
7784 * Other status means SME is failed to update
7785 */
7786QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7787 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7788{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007789 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307790 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307791 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007792 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7793
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007794 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7796 FL("Invalid sme session id: %d"), sessionId);
7797 return QDF_STATUS_E_INVAL;
7798 }
7799
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007800 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307801 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007802 pNeighborRoamConfig =
7803 &pMac->roam.configParam.neighborRoamConfig;
7804 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307805 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007806 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7807 neighborScanResultsRefreshPeriod,
7808 pMac->roam.configParam.neighborRoamConfig.
7809 nNeighborResultsRefreshPeriod,
7810 mac_trace_get_neighbour_roam_state(pMac->roam.
7811 neighborRoamInfo
7812 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307813 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7815 neighborScanResultsRefreshPeriod;
7816 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7817 neighborScanResultsRefreshPeriod;
7818
7819 sme_release_global_lock(&pMac->sme);
7820 }
7821 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7822 csr_roam_offload_scan(pMac, sessionId,
7823 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307824 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007825 }
7826 return status;
7827}
7828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307829/*
7830 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7831 * offload feaure
7832 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7833 * gRoamScanOffloadEnabled.
7834 * This is a synchronous call
7835 *
7836 * hHal - The handle returned by mac_open.
7837 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7838 * Other status means SME is failed to update.
7839 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307840QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 bool nRoamScanOffloadEnabled)
7842{
7843 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307844 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007845
7846 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307847 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307848 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307849 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007850 pMac->roam.configParam.isRoamOffloadScanEnabled,
7851 nRoamScanOffloadEnabled);
7852 pMac->roam.configParam.isRoamOffloadScanEnabled =
7853 nRoamScanOffloadEnabled;
7854 sme_release_global_lock(&pMac->sme);
7855 }
7856
7857 return status;
7858}
7859
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307860/*
7861 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7862 * refresh period
7863 * This is a synchronous call
7864 *
7865 * \param hHal - The handle returned by mac_open.
7866 * \return uint16_t - Neighbor scan results refresh period value
7867 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007868uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7869{
7870 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007872 return pMac->roam.configParam.neighborRoamConfig.
7873 nNeighborResultsRefreshPeriod;
7874}
7875
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307876/*
7877 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7878 * This is a synchronuous call
7879 *
7880 * hHal - The handle returned by mac_open.
7881 * Return QDF_STATUS_SUCCESS - SME update config successful.
7882 * Other status means SME is failed to update
7883 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007884uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7885{
7886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007888 return pMac->roam.configParam.neighborRoamConfig.
7889 nEmptyScanRefreshPeriod;
7890}
7891
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307892/*
7893 * sme_update_empty_scan_refresh_period
7894 * Update nEmptyScanRefreshPeriod
7895 * This function is called through dynamic setConfig callback function
7896 * to configure nEmptyScanRefreshPeriod
7897 * Usage: adb shell iwpriv wlan0 setConfig
7898 * nEmptyScanRefreshPeriod=[0 .. 60]
7899 *
7900 * hHal - HAL handle for device
7901 * sessionId - Session Identifier
7902 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7903 * Return Success or failure
7904 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307906QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7907 sessionId, uint16_t
7908 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007909{
7910 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307911 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307912 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007913 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7914
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007915 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7917 FL("Invalid sme session id: %d"), sessionId);
7918 return QDF_STATUS_E_INVAL;
7919 }
7920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007921 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307922 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007923 pNeighborRoamConfig =
7924 &pMac->roam.configParam.neighborRoamConfig;
7925 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007927 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7928 nEmptyScanRefreshPeriod,
7929 pMac->roam.configParam.neighborRoamConfig.
7930 nEmptyScanRefreshPeriod,
7931 mac_trace_get_neighbour_roam_state(pMac->roam.
7932 neighborRoamInfo
7933 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307934 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007935 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7936 nEmptyScanRefreshPeriod;
7937 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7938 nEmptyScanRefreshPeriod;
7939 sme_release_global_lock(&pMac->sme);
7940 }
7941 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7942 csr_roam_offload_scan(pMac, sessionId,
7943 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7944 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7945 }
7946 return status;
7947}
7948
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307949/*
7950 * sme_set_neighbor_scan_min_chan_time() -
7951 * Update nNeighborScanMinChanTime
7952 * This function is called through dynamic setConfig callback function
7953 * to configure gNeighborScanChannelMinTime
7954 * Usage: adb shell iwpriv wlan0 setConfig
7955 * gNeighborScanChannelMinTime=[0 .. 60]
7956 *
7957 * hHal - HAL handle for device
7958 * nNeighborScanMinChanTime - Channel minimum dwell time
7959 * sessionId - Session Identifier
7960 * Return Success or failure
7961 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307962QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963 const uint16_t
7964 nNeighborScanMinChanTime,
7965 uint8_t sessionId)
7966{
7967 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307968 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007969
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007970 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7971 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7972 FL("Invalid sme session id: %d"), sessionId);
7973 return QDF_STATUS_E_INVAL;
7974 }
7975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007976 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307977 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307978 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007979 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7980 nNeighborScanMinChanTime,
7981 pMac->roam.configParam.neighborRoamConfig.
7982 nNeighborScanMinChanTime,
7983 mac_trace_get_neighbour_roam_state(pMac->roam.
7984 neighborRoamInfo
7985 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307986 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007987
7988 pMac->roam.configParam.neighborRoamConfig.
7989 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7990 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7991 minChannelScanTime = nNeighborScanMinChanTime;
7992 sme_release_global_lock(&pMac->sme);
7993 }
7994
7995 return status;
7996}
7997
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307998/*
7999 * sme_set_neighbor_scan_max_chan_time() -
8000 * Update nNeighborScanMaxChanTime
8001 * This function is called through dynamic setConfig callback function
8002 * to configure gNeighborScanChannelMaxTime
8003 * Usage: adb shell iwpriv wlan0 setConfig
8004 * gNeighborScanChannelMaxTime=[0 .. 60]
8005 *
8006 * hHal - HAL handle for device
8007 * sessionId - Session Identifier
8008 * nNeighborScanMinChanTime - Channel maximum dwell time
8009 * Return Success or failure
8010 */
8011QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
8012 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008013 const uint16_t
8014 nNeighborScanMaxChanTime)
8015{
8016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308017 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308018 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8020
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008021 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8022 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8023 FL("Invalid sme session id: %d"), sessionId);
8024 return QDF_STATUS_E_INVAL;
8025 }
8026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008027 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308028 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008029 pNeighborRoamConfig =
8030 &pMac->roam.configParam.neighborRoamConfig;
8031 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8034 nNeighborScanMaxChanTime,
8035 pMac->roam.configParam.neighborRoamConfig.
8036 nNeighborScanMaxChanTime,
8037 mac_trace_get_neighbour_roam_state(pMac->roam.
8038 neighborRoamInfo
8039 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308040 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008041 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8042 nNeighborScanMaxChanTime;
8043 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8044 nNeighborScanMaxChanTime;
8045 sme_release_global_lock(&pMac->sme);
8046 }
8047 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8048 csr_roam_offload_scan(pMac, sessionId,
8049 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8050 REASON_SCAN_CH_TIME_CHANGED);
8051 }
8052
8053 return status;
8054}
8055
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308056/*
8057 * sme_get_neighbor_scan_min_chan_time() -
8058 * get neighbor scan min channel time
8059 *
8060 * hHal - The handle returned by mac_open.
8061 * sessionId - Session Identifier
8062 * Return uint16_t - channel min time value
8063 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008064uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8065{
8066 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008067
8068 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8069 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8070 FL("Invalid sme session id: %d"), sessionId);
8071 return 0;
8072 }
8073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008074 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8075 minChannelScanTime;
8076}
8077
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308078/*
8079 * sme_get_neighbor_roam_state() -
8080 * get neighbor roam state
8081 *
8082 * hHal - The handle returned by mac_open.
8083 * sessionId - Session Identifier
8084 * Return uint32_t - neighbor roam state
8085 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8087{
8088 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008089
8090 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8092 FL("Invalid sme session id: %d"), sessionId);
8093 return 0;
8094 }
8095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008096 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8097}
8098
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308099/*
8100 * sme_get_current_roam_state() -
8101 * get current roam state
8102 *
8103 * hHal - The handle returned by mac_open.
8104 * sessionId - Session Identifier
8105 * Return uint32_t - current roam state
8106 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008107uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8108{
8109 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 return pMac->roam.curState[sessionId];
8112}
8113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308114/*
8115 * sme_get_current_roam_sub_state() -
8116 * \brief get neighbor roam sub state
8117 *
8118 * hHal - The handle returned by mac_open.
8119 * sessionId - Session Identifier
8120 * Return uint32_t - current roam sub state
8121 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008122uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8123{
8124 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126 return pMac->roam.curSubState[sessionId];
8127}
8128
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308129/*
8130 * sme_get_lim_sme_state() -
8131 * get Lim Sme state
8132 *
8133 * hHal - The handle returned by mac_open.
8134 * Return uint32_t - Lim Sme state
8135 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8137{
8138 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308139
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140 return pMac->lim.gLimSmeState;
8141}
8142
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308143/*
8144 * sme_get_lim_mlm_state() -
8145 * get Lim Mlm state
8146 *
8147 * hHal - The handle returned by mac_open.
8148 * Return uint32_t - Lim Mlm state
8149 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008150uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8151{
8152 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154 return pMac->lim.gLimMlmState;
8155}
8156
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308157/*
8158 * sme_is_lim_session_valid() -
8159 * is Lim session valid
8160 *
8161 * hHal - The handle returned by mac_open.
8162 * sessionId - Session Identifier
8163 * Return bool - true or false
8164 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8166{
8167 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308168
8169 if (sessionId > pMac->lim.maxBssId)
8170 return false;
8171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 return pMac->lim.gpSession[sessionId].valid;
8173}
8174
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308175/*
8176 * sme_get_lim_sme_session_state() -
8177 * get Lim Sme session state
8178 *
8179 * hHal - The handle returned by mac_open.
8180 * sessionId - Session Identifier
8181 * Return uint32_t - Lim Sme session state
8182 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008183uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8184{
8185 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008187 return pMac->lim.gpSession[sessionId].limSmeState;
8188}
8189
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308190/*
8191 * sme_get_lim_mlm_session_state() -
8192 * \brief get Lim Mlm session state
8193 *
8194 * hHal - The handle returned by mac_open.
8195 * sessionId - Session Identifier
8196 * Return uint32_t - Lim Mlm session state
8197 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8199{
8200 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008202 return pMac->lim.gpSession[sessionId].limMlmState;
8203}
8204
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308205/*
8206 * sme_get_neighbor_scan_max_chan_time() -
8207 * get neighbor scan max channel time
8208 *
8209 * hHal - The handle returned by mac_open.
8210 * sessionId - Session Identifier
8211 * Return uint16_t - channel max time value
8212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008213uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8214{
8215 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008216
8217 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8218 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8219 FL("Invalid sme session id: %d"), sessionId);
8220 return 0;
8221 }
8222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8224 maxChannelScanTime;
8225}
8226
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308227/*
8228 * sme_set_neighbor_scan_period() -
8229 * Update nNeighborScanPeriod
8230 * This function is called through dynamic setConfig callback function
8231 * to configure nNeighborScanPeriod
8232 * Usage: adb shell iwpriv wlan0 setConfig
8233 * nNeighborScanPeriod=[0 .. 1000]
8234 *
8235 * hHal - HAL handle for device
8236 * sessionId - Session Identifier
8237 * nNeighborScanPeriod - neighbor scan period
8238 * Return Success or failure
8239 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308240QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008241 const uint16_t nNeighborScanPeriod)
8242{
8243 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308244 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308245 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008246 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8247
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008248 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8249 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8250 FL("Invalid sme session id: %d"), sessionId);
8251 return QDF_STATUS_E_INVAL;
8252 }
8253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308255 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008256 pNeighborRoamConfig =
8257 &pMac->roam.configParam.neighborRoamConfig;
8258 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308260 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008261 nNeighborScanPeriod,
8262 pMac->roam.configParam.neighborRoamConfig.
8263 nNeighborScanTimerPeriod,
8264 mac_trace_get_neighbour_roam_state(pMac->roam.
8265 neighborRoamInfo
8266 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308267 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008268 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8269 nNeighborScanPeriod;
8270 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8271 nNeighborScanPeriod;
8272 sme_release_global_lock(&pMac->sme);
8273 }
8274 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8275 csr_roam_offload_scan(pMac, sessionId,
8276 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8277 REASON_SCAN_HOME_TIME_CHANGED);
8278 }
8279
8280 return status;
8281}
8282
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308283/*
8284 * sme_get_neighbor_scan_period() -
8285 * get neighbor scan period
8286 *
8287 * hHal - The handle returned by mac_open.
8288 * sessionId - Session Identifier
8289 * Return uint16_t - neighbor scan period
8290 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008291uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8292{
8293 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008294
8295 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8296 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8297 FL("Invalid sme session id: %d"), sessionId);
8298 return 0;
8299 }
8300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008301 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8302 neighborScanPeriod;
8303}
8304
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308305/**
8306 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8307 * This function is called through dynamic setConfig callback function
8308 * to configure neighbor_scan_min_period
8309 *
8310 * @hal - HAL handle for device
8311 * @session_id - Session Identifier
8312 * @neighbor_scan_min_period - neighbor scan min period
8313 *
8314 * Return - QDF_STATUS
8315 */
8316QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8317 uint8_t session_id,
8318 const uint16_t
8319 neighbor_scan_min_period)
8320{
8321 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8322 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308323 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308324 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308326 if (session_id >= CSR_ROAM_SESSION_MAX) {
8327 sme_err("Invalid sme session id: %d", session_id);
8328 return QDF_STATUS_E_INVAL;
8329 }
8330
8331 status = sme_acquire_global_lock(&pmac->sme);
8332 if (QDF_IS_STATUS_SUCCESS(status)) {
8333 p_neighbor_roam_config =
8334 &pmac->roam.configParam.neighborRoamConfig;
8335 p_neighbor_roam_info = &pmac->
8336 roam.neighborRoamInfo[session_id];
8337 sme_debug("LFR:set neighbor scan min period, old:%d, "
8338 "new: %d, state: %s",
8339 pmac->roam.configParam.neighborRoamConfig.
8340 neighbor_scan_min_timer_period,
8341 neighbor_scan_min_period,
8342 mac_trace_get_neighbour_roam_state(pmac->roam.
8343 neighborRoamInfo[session_id].
8344 neighborRoamState));
8345 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8346 neighbor_scan_min_period;
8347 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8348 neighbor_scan_min_period;
8349 sme_release_global_lock(&pmac->sme);
8350 }
8351
8352 return status;
8353}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008354
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308355/*
8356 * sme_get_roam_rssi_diff() - get Roam rssi diff
8357 * This is a synchronous call
8358 *
8359 * hHal - The handle returned by mac_open.
8360 * Return uint16_t - Rssi diff value
8361 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008362uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8363{
8364 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008366 return pMac->roam.configParam.RoamRssiDiff;
8367}
8368
8369/**
8370 * sme_change_roam_scan_channel_list() - to change scan channel list
8371 * @hHal: pointer HAL handle returned by mac_open
8372 * @sessionId: sme session id
8373 * @pChannelList: Output channel list
8374 * @numChannels: Output number of channels
8375 *
8376 * This routine is called to Change roam scan channel list.
8377 * This is a synchronous call
8378 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308379 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008380 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308381QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382 uint8_t *pChannelList,
8383 uint8_t numChannels)
8384{
8385 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308386 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008387 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008388 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8389 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8390 uint8_t i = 0, j = 0;
8391 tCsrChannelInfo *chan_info;
8392
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008393 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8395 FL("Invalid sme session id: %d"), sessionId);
8396 return QDF_STATUS_E_INVAL;
8397 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008398
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008399 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008400 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308401 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008402 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8403 csr_roam_offload_scan(pMac, sessionId,
8404 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8405 REASON_CHANNEL_LIST_CHANGED);
8406 return status;
8407 }
8408 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8409
8410 if (NULL != chan_info->ChannelList) {
8411 for (i = 0; i < chan_info->numOfChannels; i++) {
8412 if (j < sizeof(oldChannelList))
8413 j += snprintf(oldChannelList + j,
8414 sizeof(oldChannelList) -
8415 j, "%d",
8416 chan_info->ChannelList[i]);
8417 else
8418 break;
8419 }
8420 }
8421 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8422 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8423 numChannels);
8424 sme_set_roam_scan_control(hHal, sessionId, 1);
8425 if (NULL != chan_info->ChannelList) {
8426 j = 0;
8427 for (i = 0; i < chan_info->numOfChannels; i++) {
8428 if (j < sizeof(newChannelList))
8429 j += snprintf(newChannelList + j,
8430 sizeof(newChannelList) -
8431 j, " %d",
8432 chan_info->ChannelList[i]);
8433 else
8434 break;
8435 }
8436 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308438 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008439 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308440 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 sme_release_global_lock(&pMac->sme);
8442
8443 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8444 csr_roam_offload_scan(pMac, sessionId,
8445 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8446 REASON_CHANNEL_LIST_CHANGED);
8447 return status;
8448}
8449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008450/**
8451 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8452 * @hHal: HAL pointer
8453 * @pChannelList: Output channel list
8454 * @pNumChannels: Output number of channels
8455 * @sessionId: Session Identifier
8456 *
8457 * To get roam scan channel list This is a synchronous call
8458 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308459 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308461QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008462 uint8_t *pChannelList, uint8_t *pNumChannels,
8463 uint8_t sessionId)
8464{
8465 int i = 0;
8466 uint8_t *pOutPtr = pChannelList;
8467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008468 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308469 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008471 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8472 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8473 FL("Invalid sme session id: %d"), sessionId);
8474 return QDF_STATUS_E_INVAL;
8475 }
8476
8477 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308479 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008480 return status;
8481 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308482 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008483 FL("Roam Scan channel list is NOT yet initialized"));
8484 *pNumChannels = 0;
8485 sme_release_global_lock(&pMac->sme);
8486 return status;
8487 }
8488
8489 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308490 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008491 pOutPtr[i] =
8492 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308493
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494 pOutPtr[i] = '\0';
8495 sme_release_global_lock(&pMac->sme);
8496 return status;
8497}
8498
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308499/*
8500 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8501 * This is a synchronuous call
8502 *
8503 * hHal - The handle returned by mac_open.
8504 * Return true (1) - if the ESE feature is enabled
8505 * false (0) - if feature is disabled (compile or runtime)
8506 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8508{
8509#ifdef FEATURE_WLAN_ESE
8510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308511
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512 return csr_roam_is_ese_ini_feature_enabled(pMac);
8513#else
8514 return false;
8515#endif
8516}
8517
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308518/*
8519 * sme_get_wes_mode() - get WES Mode
8520 * This is a synchronous call
8521 *
8522 * hHal - The handle returned by mac_open
8523 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525bool sme_get_wes_mode(tHalHandle hHal)
8526{
8527 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008529 return pMac->roam.configParam.isWESModeEnabled;
8530}
8531
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308532/*
8533 * sme_get_roam_scan_control() - get scan control
8534 * This is a synchronous call
8535 *
8536 * hHal - The handle returned by mac_open.
8537 * Return bool - Enabled(1)/Disabled(0)
8538 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539bool sme_get_roam_scan_control(tHalHandle hHal)
8540{
8541 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308542
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008543 return pMac->roam.configParam.nRoamScanControl;
8544}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008545
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308546/*
8547 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8548 * This is a synchronuous call
8549 * hHal - The handle returned by mac_open.
8550 * Return true (1) - if the feature is enabled
8551 * false (0) - if feature is disabled (compile or runtime)
8552 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008553bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8554{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008555 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008557 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558}
8559
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308560/*
8561 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8562 * This is a synchronuous call
8563 *
8564 * hHal - The handle returned by mac_open.
8565 * Return true (1) - if the feature is enabled
8566 * false (0) - if feature is disabled (compile or runtime)
8567 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008568bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8569{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008570 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008572 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008573}
8574
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008575/**
8576 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8577 * @feature: enum value of requested feature.
8578 *
8579 * Retrun: 1 if supported; 0 otherwise
8580 */
8581bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008582{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008583 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008584}
8585
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308586QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008587 void *plsContext,
8588 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8589 void *pContext))
8590{
8591
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308592 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008593 tpAniSirGlobal pMac;
8594 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308595 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008596
Jeff Johnsona5317a62017-01-26 08:51:25 -08008597 if (!hHal || !pCallbackfn || !lsReq) {
8598 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8599 FL("Invalid parameter"));
8600 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008601 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008602
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308603 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8604 if (!wma_handle) {
8605 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8606 "wma handle is NULL");
8607 return QDF_STATUS_E_FAILURE;
8608 }
8609
Jeff Johnsona5317a62017-01-26 08:51:25 -08008610 pMac = PMAC_STRUCT(hHal);
8611 req = qdf_mem_malloc(sizeof(*req));
8612 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008613 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008614 return QDF_STATUS_E_NOMEM;
8615 }
8616 *req = *lsReq;
8617
8618 status = sme_acquire_global_lock(&pMac->sme);
8619 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008620 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008621 qdf_mem_free(req);
8622 return QDF_STATUS_E_FAILURE;
8623 }
8624
8625 pMac->sme.pLinkSpeedCbContext = plsContext;
8626 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308627 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008628 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008630 return status;
8631}
8632
Will Huang558f8082017-05-31 16:22:24 +08008633QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8634 void *context,
8635 void (*callbackfn)(struct sir_peer_info_resp *param,
8636 void *pcontext))
8637{
8638
8639 QDF_STATUS status;
8640 QDF_STATUS qdf_status;
8641 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8642 struct scheduler_msg message;
8643
8644 status = sme_acquire_global_lock(&mac->sme);
8645 if (QDF_STATUS_SUCCESS == status) {
8646 if (NULL == callbackfn) {
8647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8648 "%s: Indication Call back is NULL",
8649 __func__);
8650 sme_release_global_lock(&mac->sme);
8651 return QDF_STATUS_E_FAILURE;
8652 }
8653
8654 mac->sme.pget_peer_info_ind_cb = callbackfn;
8655 mac->sme.pget_peer_info_cb_context = context;
8656
8657 /* serialize the req through MC thread */
8658 message.bodyptr = qdf_mem_malloc(sizeof(req));
8659 if (NULL == message.bodyptr) {
8660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8661 "%s: Memory allocation failed.", __func__);
8662 sme_release_global_lock(&mac->sme);
8663 return QDF_STATUS_E_NOMEM;
8664 }
8665 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8666 message.type = WMA_GET_PEER_INFO;
8667 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8668 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8669 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8670 "%s: Post get peer info msg fail", __func__);
8671 qdf_mem_free(message.bodyptr);
8672 status = QDF_STATUS_E_FAILURE;
8673 }
8674 sme_release_global_lock(&mac->sme);
8675 }
8676 return status;
8677}
8678
8679QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8680 struct sir_peer_info_ext_req *req,
8681 void *context,
8682 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8683 void *pcontext))
8684{
8685 QDF_STATUS status;
8686 QDF_STATUS qdf_status;
8687 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8688 struct scheduler_msg message;
8689
8690 status = sme_acquire_global_lock(&mac->sme);
8691 if (QDF_STATUS_SUCCESS == status) {
8692 if (NULL == callbackfn) {
8693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8694 "%s: Indication Call back is NULL",
8695 __func__);
8696 sme_release_global_lock(&mac->sme);
8697 return QDF_STATUS_E_FAILURE;
8698 }
8699
8700 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8701 mac->sme.pget_peer_info_ext_cb_context = context;
8702
8703 /* serialize the req through MC thread */
8704 message.bodyptr =
8705 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8706 if (NULL == message.bodyptr) {
8707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8708 "%s: Memory allocation failed.", __func__);
8709 sme_release_global_lock(&mac->sme);
8710 return QDF_STATUS_E_NOMEM;
8711 }
8712 qdf_mem_copy(message.bodyptr,
8713 req,
8714 sizeof(struct sir_peer_info_ext_req));
8715 message.type = WMA_GET_PEER_INFO_EXT;
8716 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8717 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8718 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8719 "%s: Post get rssi msg fail", __func__);
8720 qdf_mem_free(message.bodyptr);
8721 status = QDF_STATUS_E_FAILURE;
8722 }
8723 sme_release_global_lock(&mac->sme);
8724 }
8725 return status;
8726}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008727
8728/*
8729 * SME API to enable/disable WLAN driver initiated SSR
8730 */
8731void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8732{
8733 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308734 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735
8736 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308737 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008738 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008739 /* not serializing this messsage, as this is only going
8740 * to set a variable in WMA/WDI
8741 */
8742 WMA_SetEnableSSR(enableSSR);
8743 sme_release_global_lock(&pMac->sme);
8744 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745}
8746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008747/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8748ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8749{
8750 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8751}
8752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308753/*
8754 * sme_set_curr_device_mode() - Sets the current operating device mode.
8755 *
8756 * hHal - The handle returned by mac_open.
8757 * currDeviceMode - Current operating device mode.
8758 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008759void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008760 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761{
8762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765}
8766
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308767/*
8768 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8769 * This is a synchronous call
8770 *
8771 * hHal - The handle returned by mac_open
8772 * sessionId - Session Identifier
8773 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8774 * BSSID, channel etc.)
8775 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8776 * Other status means SME is failed to send the request.
8777 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308779QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 uint8_t sessionId,
8781 tCsrHandoffRequest *pHandoffInfo)
8782{
8783 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308784 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008785
8786 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308787 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308788 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008789 "%s: invoked", __func__);
8790 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8791 sme_release_global_lock(&pMac->sme);
8792 }
8793
8794 return status;
8795}
8796
8797#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308798/*
8799 * sme_ipa_offload_enable_disable() -
8800 * API to enable/disable IPA offload
8801 *
8802 * hal - The handle returned by macOpen.
8803 * session_id - Session Identifier
8804 * request - Pointer to the offload request.
8805 * Return QDF_STATUS
8806 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308807QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008808 struct sir_ipa_offload_enable_disable *request)
8809{
8810 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308811 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008812 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008813 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008814
8815 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308816 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308817 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308819 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308820 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008821 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308822 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 }
8824
8825 request_buf->offload_type = request->offload_type;
8826 request_buf->vdev_id = request->vdev_id;
8827 request_buf->enable = request->enable;
8828
8829 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8830 msg.reserved = 0;
8831 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308832 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008833 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308835 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308836 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008839 }
8840
8841 sme_release_global_lock(&pMac->sme);
8842 }
8843
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308844 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008845}
8846#endif /* IPA_OFFLOAD */
8847
8848/*
8849 * SME API to check if there is any infra station or
8850 * P2P client is connected
8851 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308852QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853{
8854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308855
8856 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308857 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308858
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008860}
8861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862/**
8863 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8864 * @hal: global hal handle
8865 * @addPeriodicTxPtrnParams: request message
8866 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308869QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870sme_add_periodic_tx_ptrn(tHalHandle hal,
8871 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8872{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308873 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008874 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8875 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008876 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008877
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008878 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008879
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308880 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008881 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008882 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308883 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 }
8885
8886 *req_msg = *addPeriodicTxPtrnParams;
8887
8888 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308889 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008890 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308892 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 return status;
8894 }
8895
8896 /* Serialize the req through MC thread */
8897 msg.bodyptr = req_msg;
8898 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308899 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8900 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008901 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308902 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008903 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308905 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 }
8907 sme_release_global_lock(&mac->sme);
8908 return status;
8909}
8910
8911/**
8912 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8913 * @hal: global hal handle
8914 * @delPeriodicTxPtrnParams: request message
8915 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308916 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308918QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008919sme_del_periodic_tx_ptrn(tHalHandle hal,
8920 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8921{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308922 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008923 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8924 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008925 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008927 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308929 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008930 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008931 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308932 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 }
8934
8935 *req_msg = *delPeriodicTxPtrnParams;
8936
8937 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308938 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008939 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308941 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008942 return status;
8943 }
8944
8945 /* Serialize the req through MC thread */
8946 msg.bodyptr = req_msg;
8947 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308948 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8949 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008950 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308951 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008952 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008953 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308954 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008955 }
8956 sme_release_global_lock(&mac->sme);
8957 return status;
8958}
8959
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308960/*
8961 * sme_enable_rmc() - enables RMC
8962 * @hHal : Pointer to global HAL handle
8963 * @sessionId : Session ID
8964 *
8965 * Return: QDF_STATUS
8966 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008967QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8968{
8969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008971 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008972 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8973
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008974 SME_ENTER();
8975
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008976 status = sme_acquire_global_lock(&pMac->sme);
8977 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008978 message.bodyptr = NULL;
8979 message.type = WMA_RMC_ENABLE_IND;
8980 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8981 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008982 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8983 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8984 "%s: failed to post message to WMA",
8985 __func__);
8986 status = QDF_STATUS_E_FAILURE;
8987 }
8988 sme_release_global_lock(&pMac->sme);
8989 }
8990 return status;
8991}
8992
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308993/*
8994 * sme_disable_rmc() - disables RMC
8995 * @hHal : Pointer to global HAL handle
8996 * @sessionId : Session ID
8997 *
8998 * Return: QDF_STATUS
8999 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009000QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9001{
9002 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9003 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009004 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009005 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9006
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009007 SME_ENTER();
9008
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009009 status = sme_acquire_global_lock(&pMac->sme);
9010 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009011 message.bodyptr = NULL;
9012 message.type = WMA_RMC_DISABLE_IND;
9013 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9014 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9017 "%s: failed to post message to WMA",
9018 __func__);
9019 status = QDF_STATUS_E_FAILURE;
9020 }
9021 sme_release_global_lock(&pMac->sme);
9022 }
9023 return status;
9024}
9025
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309026/*
9027 * sme_send_rmc_action_period() - sends RMC action period param to target
9028 * @hHal : Pointer to global HAL handle
9029 * @sessionId : Session ID
9030 *
9031 * Return: QDF_STATUS
9032 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009033QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9034{
9035 QDF_STATUS status = QDF_STATUS_SUCCESS;
9036 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9037 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009038 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009039
9040 status = sme_acquire_global_lock(&pMac->sme);
9041 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009042 message.bodyptr = NULL;
9043 message.type = WMA_RMC_ACTION_PERIOD_IND;
9044 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9045 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009046 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9047 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9048 "%s: failed to post message to WMA",
9049 __func__);
9050 status = QDF_STATUS_E_FAILURE;
9051 }
9052 sme_release_global_lock(&pMac->sme);
9053 }
9054
9055 return status;
9056}
9057
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309058/*
9059 * sme_request_ibss_peer_info() - request ibss peer info
9060 * @hHal : Pointer to global HAL handle
9061 * @pUserData : Pointer to user data
9062 * @peerInfoCbk : Peer info callback
9063 * @allPeerInfoReqd : All peer info required or not
9064 * @staIdx : sta index
9065 *
9066 * Return: QDF_STATUS
9067 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009068QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9069 pIbssPeerInfoCb peerInfoCbk,
9070 bool allPeerInfoReqd, uint8_t staIdx)
9071{
9072 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9073 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9074 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009075 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009076 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9077
9078 status = sme_acquire_global_lock(&pMac->sme);
9079 if (QDF_STATUS_SUCCESS == status) {
9080 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9081 pMac->sme.peerInfoParams.pUserData = pUserData;
9082
9083 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309084 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009085 if (NULL == pIbssInfoReqParams) {
9086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9087 "%s: Not able to allocate memory for dhcp start",
9088 __func__);
9089 sme_release_global_lock(&pMac->sme);
9090 return QDF_STATUS_E_NOMEM;
9091 }
9092 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9093 pIbssInfoReqParams->staIdx = staIdx;
9094
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009095 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9096 message.bodyptr = pIbssInfoReqParams;
9097 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009098
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009099 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9100 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009101 if (QDF_STATUS_SUCCESS != qdf_status) {
9102 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9103 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9104 __func__);
9105 qdf_mem_free(pIbssInfoReqParams);
9106 qdf_status = QDF_STATUS_E_FAILURE;
9107 }
9108 sme_release_global_lock(&pMac->sme);
9109 }
9110
9111 return qdf_status;
9112}
9113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309114/*
9115 * sme_send_cesium_enable_ind() -
9116 * Used to send proprietary cesium enable indication to fw
9117 *
9118 * hHal
9119 * sessionId
9120 * Return QDF_STATUS
9121 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009122QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9123{
9124 QDF_STATUS status = QDF_STATUS_SUCCESS;
9125 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9126 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009127 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009128
9129 status = sme_acquire_global_lock(&pMac->sme);
9130 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009131 message.bodyptr = NULL;
9132 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9133 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9134 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009135 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9136 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9137 "%s: failed to post message to WMA",
9138 __func__);
9139 status = QDF_STATUS_E_FAILURE;
9140 }
9141 sme_release_global_lock(&pMac->sme);
9142 }
9143
9144 return status;
9145}
9146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009147void sme_get_command_q_status(tHalHandle hHal)
9148{
9149 tSmeCmd *pTempCmd = NULL;
9150 tListElem *pEntry;
9151 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9152
9153 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309154 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 "%s: pMac is NULL", __func__);
9156 return;
9157 }
9158
Krunal Sonia8270f52017-02-23 19:51:25 -08009159 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309160 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009161 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309162
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009163 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9165 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309166 if (eSmeCsrCommandMask & pTempCmd->command)
9167 /* CSR command is stuck. See what the reason code is
9168 * for that command
9169 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009170 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009171 } /* if(pTempCmd) */
9172
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009173 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009174 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009175
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009176}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009177/**
9178 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9179 * @hal: The handle returned by macOpen
9180 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9181 */
9182void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9183 bool sta_prefer_80MHz_over_160MHz)
9184{
9185 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309186
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009187 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9188}
9189
Agrawal Ashishb141b092016-09-02 19:59:26 +05309190#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009191/**
9192 * sme_set_dot11p_config() - API to set the 802.11p config
9193 * @hHal: The handle returned by macOpen
9194 * @enable_dot11p: 802.11p config param
9195 */
9196void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9197{
9198 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009200 pMac->enable_dot11p = enable_dot11p;
9201}
9202
9203/**
9204 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9205 * @src: the source configuration
9206 *
9207 * Return: pointer to the copied OCB configuration
9208 */
9209static struct sir_ocb_config *sme_copy_sir_ocb_config(
9210 struct sir_ocb_config *src)
9211{
9212 struct sir_ocb_config *dst;
9213 uint32_t length;
9214 void *cursor;
9215
9216 length = sizeof(*src) +
9217 src->channel_count * sizeof(*src->channels) +
9218 src->schedule_size * sizeof(*src->schedule) +
9219 src->dcc_ndl_chan_list_len +
9220 src->dcc_ndl_active_state_list_len;
9221
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309222 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009223 if (!dst)
9224 return NULL;
9225
9226 *dst = *src;
9227
9228 cursor = dst;
9229 cursor += sizeof(*dst);
9230 dst->channels = cursor;
9231 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309232 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009233 src->channel_count * sizeof(*src->channels));
9234 dst->schedule = cursor;
9235 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309236 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009237 src->schedule_size * sizeof(*src->schedule));
9238 dst->dcc_ndl_chan_list = cursor;
9239 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309240 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009241 src->dcc_ndl_chan_list_len);
9242 dst->dcc_ndl_active_state_list = cursor;
9243 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309244 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009245 src->dcc_ndl_active_state_list,
9246 src->dcc_ndl_active_state_list_len);
9247 return dst;
9248}
9249
9250/**
9251 * sme_ocb_set_config() - Set the OCB configuration
9252 * @hHal: reference to the HAL
9253 * @context: the context of the call
9254 * @callback: the callback to hdd
9255 * @config: the OCB configuration
9256 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309257 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009258 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309259QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 ocb_callback callback,
9261 struct sir_ocb_config *config)
9262{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309263 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009265 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 struct sir_ocb_config *msg_body;
9267
9268 /* Lock the SME structure */
9269 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309270 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009271 return status;
9272
9273 /*
9274 * Check if there is a pending request and return an error if one
9275 * exists
9276 */
9277 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309278 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009279 goto end;
9280 }
9281
9282 msg_body = sme_copy_sir_ocb_config(config);
9283
9284 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309285 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009286 goto end;
9287 }
9288
9289 msg.type = WMA_OCB_SET_CONFIG_CMD;
9290 msg.bodyptr = msg_body;
9291
9292 /* Set the request callback and context */
9293 pMac->sme.ocb_set_config_callback = callback;
9294 pMac->sme.ocb_set_config_context = context;
9295
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009296 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309297 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309298 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 FL("Error posting message to WDA: %d"), status);
9300 pMac->sme.ocb_set_config_callback = callback;
9301 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309302 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303 goto end;
9304 }
9305
9306end:
9307 sme_release_global_lock(&pMac->sme);
9308
9309 return status;
9310}
9311
9312/**
9313 * sme_ocb_set_utc_time() - Set the OCB UTC time
9314 * @hHal: reference to the HAL
9315 * @utc: the UTC time struct
9316 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309317 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009318 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309319QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309321 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009323 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009324 struct sir_ocb_utc *sme_utc;
9325
9326 /* Lock the SME structure */
9327 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309328 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009329 return status;
9330
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309331 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309333 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009334 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309335 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009336 goto end;
9337 }
9338 *sme_utc = *utc;
9339
9340 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9341 msg.reserved = 0;
9342 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009343 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309344 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309345 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009346 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309347 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 goto end;
9349 }
9350
9351end:
9352 sme_release_global_lock(&pMac->sme);
9353
9354 return status;
9355}
9356
9357/**
9358 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9359 * @hHal: reference to the HAL
9360 * @timing_advert: the timing advertisement struct
9361 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309362 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309364QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 struct sir_ocb_timing_advert *timing_advert)
9366{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309367 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009369 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009370 void *buf;
9371 struct sir_ocb_timing_advert *sme_timing_advert;
9372
9373 /* Lock the SME structure */
9374 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309375 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009376 return status;
9377
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309378 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 timing_advert->template_length);
9380 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309381 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009382 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309383 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009384 goto end;
9385 }
9386
9387 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9388 *sme_timing_advert = *timing_advert;
9389 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309390 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391 timing_advert->template_value, timing_advert->template_length);
9392
9393 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9394 msg.reserved = 0;
9395 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009396 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309397 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309398 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009399 FL("Not able to post msg to WDA"));
9400 goto end;
9401 }
9402
9403end:
9404 sme_release_global_lock(&pMac->sme);
9405
9406 return status;
9407}
9408
9409/**
9410 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9411 * @hHal: reference to the HAL
9412 * @timing_advert: the timing advertisement struct
9413 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309414 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009415 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309416QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009417 struct sir_ocb_timing_advert *timing_advert)
9418{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309419 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009421 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422 struct sir_ocb_timing_advert *sme_timing_advert;
9423
9424 /* Lock the SME structure */
9425 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309426 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009427 return status;
9428
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309429 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009430 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309431 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009432 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309433 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009434 goto end;
9435 }
9436 *sme_timing_advert = *timing_advert;
9437
9438 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9439 msg.reserved = 0;
9440 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009441 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309442 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009444 FL("Not able to post msg to WDA"));
9445 goto end;
9446 }
9447
9448end:
9449 sme_release_global_lock(&pMac->sme);
9450
9451 return status;
9452}
9453
9454/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009455 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9456 * @hal_handle: reference to the HAL
9457 * @self_addr: the self MAC address
9458 * @buf: the buffer that will contain the frame
9459 * @timestamp_offset: return for the offset of the timestamp field
9460 * @time_value_offset: return for the time_value field in the TA IE
9461 *
9462 * Return: the length of the buffer.
9463 */
9464int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9465 tSirMacAddr self_addr, uint8_t **buf,
9466 uint32_t *timestamp_offset,
9467 uint32_t *time_value_offset)
9468{
9469 int template_length;
9470 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9471
9472 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9473 timestamp_offset,
9474 time_value_offset);
9475 return template_length;
9476}
9477/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009478 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9479 * @hHal: reference to the HAL
9480 * @context: the context of the call
9481 * @callback: the callback to hdd
9482 * @request: the TSF timer request
9483 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309484 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009485 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309486QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487 ocb_callback callback,
9488 struct sir_ocb_get_tsf_timer *request)
9489{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309490 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009492 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009493 struct sir_ocb_get_tsf_timer *msg_body;
9494
9495 /* Lock the SME structure */
9496 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309497 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498 return status;
9499
9500 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309501 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009502 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309503 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009504 goto end;
9505 }
9506 *msg_body = *request;
9507
9508 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9509 msg.bodyptr = msg_body;
9510
9511 /* Set the request callback and the context */
9512 pMac->sme.ocb_get_tsf_timer_callback = callback;
9513 pMac->sme.ocb_get_tsf_timer_context = context;
9514
9515 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009516 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309517 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309518 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009519 FL("Error posting message to WDA: %d"), status);
9520 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9521 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309522 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009523 goto end;
9524 }
9525
9526end:
9527 sme_release_global_lock(&pMac->sme);
9528
9529 return status;
9530}
9531
9532/**
9533 * sme_dcc_get_stats() - Get the DCC stats
9534 * @hHal: reference to the HAL
9535 * @context: the context of the call
9536 * @callback: the callback to hdd
9537 * @request: the get DCC stats request
9538 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309539 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309541QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009542 ocb_callback callback,
9543 struct sir_dcc_get_stats *request)
9544{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309545 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009546 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009547 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009548 struct sir_dcc_get_stats *msg_body;
9549
9550 /* Lock the SME structure */
9551 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309552 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009553 return status;
9554
9555 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309556 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557 request->request_array_len);
9558 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309559 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009560 goto end;
9561 }
9562 *msg_body = *request;
9563 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309564 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009565 request->request_array_len);
9566
9567 msg.type = WMA_DCC_GET_STATS_CMD;
9568 msg.bodyptr = msg_body;
9569
9570 /* Set the request callback and context */
9571 pMac->sme.dcc_get_stats_callback = callback;
9572 pMac->sme.dcc_get_stats_context = context;
9573
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009574 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309575 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309576 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009577 FL("Error posting message to WDA: %d"), status);
9578 pMac->sme.dcc_get_stats_callback = callback;
9579 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309580 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 goto end;
9582 }
9583
9584end:
9585 sme_release_global_lock(&pMac->sme);
9586
9587 return status;
9588}
9589
9590/**
9591 * sme_dcc_clear_stats() - Clear the DCC stats
9592 * @hHal: reference to the HAL
9593 * @vdev_id: vdev id for OCB interface
9594 * @dcc_stats_bitmap: the entries in the stats to clear
9595 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309596 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309598QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009599 uint32_t dcc_stats_bitmap)
9600{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309601 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009602 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009603 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009604 struct sir_dcc_clear_stats *request;
9605
9606 /* Lock the SME structure */
9607 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309608 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 return status;
9610
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309611 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309613 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009614 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309615 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009616 goto end;
9617 }
9618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009619 request->vdev_id = vdev_id;
9620 request->dcc_stats_bitmap = dcc_stats_bitmap;
9621
9622 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9623 msg.bodyptr = request;
9624
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009625 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309626 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309627 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009628 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309629 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630 goto end;
9631 }
9632
9633end:
9634 sme_release_global_lock(&pMac->sme);
9635
9636 return status;
9637}
9638
9639/**
9640 * sme_dcc_update_ndl() - Update the DCC settings
9641 * @hHal: reference to the HAL
9642 * @context: the context of the call
9643 * @callback: the callback to hdd
9644 * @request: the update DCC request
9645 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309646 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309648QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649 ocb_callback callback,
9650 struct sir_dcc_update_ndl *request)
9651{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309652 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009653 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009654 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009655 struct sir_dcc_update_ndl *msg_body;
9656
9657 /* Lock the SME structure */
9658 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309659 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009660 return status;
9661
9662 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309663 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 request->dcc_ndl_chan_list_len +
9665 request->dcc_ndl_active_state_list_len);
9666 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009668 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309669 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009670 goto end;
9671 }
9672
9673 *msg_body = *request;
9674
9675 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9676 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9677 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309678 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309680 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 request->dcc_ndl_active_state_list,
9682 request->dcc_ndl_active_state_list_len);
9683
9684 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9685 msg.bodyptr = msg_body;
9686
9687 /* Set the request callback and the context */
9688 pMac->sme.dcc_update_ndl_callback = callback;
9689 pMac->sme.dcc_update_ndl_context = context;
9690
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009691 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309692 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009694 FL("Error posting message to WDA: %d"), status);
9695 pMac->sme.dcc_update_ndl_callback = NULL;
9696 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309697 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009698 goto end;
9699 }
9700
9701end:
9702 sme_release_global_lock(&pMac->sme);
9703
9704 return status;
9705}
9706
9707/**
9708 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9709 * event
9710 * @hHal: reference to the HAL
9711 * @context: the context of the call
9712 * @callback: the callback to hdd
9713 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309714 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009715 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309716QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009717 ocb_callback callback)
9718{
9719 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309720 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009721
9722 status = sme_acquire_global_lock(&pMac->sme);
9723 pMac->sme.dcc_stats_event_callback = callback;
9724 pMac->sme.dcc_stats_event_context = context;
9725 sme_release_global_lock(&pMac->sme);
9726
9727 return 0;
9728}
9729
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309730/**
9731 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9732 * event
9733 * @h_hal: Hal Handle
9734 *
9735 * This function de-registers the DCC perioc stats callback
9736 *
9737 * Return: QDF_STATUS Enumeration
9738 */
9739QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9740{
9741 tpAniSirGlobal mac;
9742 QDF_STATUS status;
9743
9744 if (!h_hal) {
9745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9746 FL("h_hal is not valid"));
9747 return QDF_STATUS_E_INVAL;
9748 }
9749 mac = PMAC_STRUCT(h_hal);
9750
9751 status = sme_acquire_global_lock(&mac->sme);
9752 if (!QDF_IS_STATUS_SUCCESS(status)) {
9753 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9754 FL("Failed to acquire global lock"));
9755 return status;
9756 }
9757 mac->sme.dcc_stats_event_callback = NULL;
9758 mac->sme.dcc_stats_event_context = NULL;
9759 sme_release_global_lock(&mac->sme);
9760
9761 return status;
9762}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309763#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009765void sme_get_recovery_stats(tHalHandle hHal)
9766{
9767 uint8_t i;
9768
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309769 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009770 "Self Recovery Stats");
9771 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9772 if (eSmeNoCommand !=
9773 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309774 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009775 "timestamp %llu: command 0x%0X: reason %d: session %d",
9776 g_self_recovery_stats.activeCmdStats[i].
9777 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309778 g_self_recovery_stats.activeCmdStats[i].command,
9779 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009780 g_self_recovery_stats.activeCmdStats[i].
9781 sessionId);
9782 }
9783 }
9784}
9785
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309786QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009787{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009788 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009789 tpSirModemPowerStateInd request_buf;
9790 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9791
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309792 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309793 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009794
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309795 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009796 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309797 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9799 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309800 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009801 }
9802
9803 request_buf->param = value;
9804
9805 msg.type = WMA_MODEM_POWER_STATE_IND;
9806 msg.reserved = 0;
9807 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309808 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009809 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309811 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9812 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309813 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309814 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009815 }
9816
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309817 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009818}
9819
9820#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309821QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309822 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 uint8_t sessionId,
9824 uint8_t channel_type)
9825{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009826 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009827 tUpdateVHTOpMode *pHtOpMode = NULL;
9828 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9829
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309830 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309831 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009832
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309833 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009834 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309835 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009836 "%s: Not able to allocate memory for setting OP mode",
9837 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309838 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009839 }
9840
9841 switch (channel_type) {
9842 case eHT_CHAN_HT20:
9843 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9844 break;
9845
9846 case eHT_CHAN_HT40MINUS:
9847 case eHT_CHAN_HT40PLUS:
9848 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9849 break;
9850
9851 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309852 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009853 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309854 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009855 }
9856
9857 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309858 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009859 sizeof(tSirMacAddr));
9860 pHtOpMode->smesessionId = sessionId;
9861
9862 msg.type = WMA_UPDATE_OP_MODE;
9863 msg.reserved = 0;
9864 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309865 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009866 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309867 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309868 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9869 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309870 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309871 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009872 }
9873
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309874 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 "%s: Notifed FW about OP mode: %d for staId=%d",
9876 __func__, pHtOpMode->opMode, staId);
9877
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309878 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009879}
9880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309881/*
9882 * sme_set_ht2040_mode() -
9883 * To update HT Operation beacon IE.
9884 *
9885 * Return QDF_STATUS SUCCESS
9886 * FAILURE or RESOURCES
9887 * The API finished and failed.
9888 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309889QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009890 uint8_t channel_type, bool obssEnabled)
9891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309892 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009893 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9894 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309895 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009896
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309897 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9898 sme_err("Session not valid for session id %d", sessionId);
9899 return QDF_STATUS_E_INVAL;
9900 }
9901 session = CSR_GET_SESSION(pMac, sessionId);
9902 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9903 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009904
9905 switch (channel_type) {
9906 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309907 if (!session->bssParams.cbMode)
9908 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009909 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9910 break;
9911 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309912 if (session->bssParams.cbMode)
9913 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009914 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9915 break;
9916 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309917 if (session->bssParams.cbMode)
9918 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009919 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9920 break;
9921 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309922 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309923 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009924 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309925 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009926 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309927 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928 status = csr_set_ht2040_mode(pMac, sessionId,
9929 cbMode, obssEnabled);
9930 sme_release_global_lock(&pMac->sme);
9931 }
9932 return status;
9933}
9934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009935#endif
9936
9937/*
9938 * SME API to enable/disable idle mode powersave
9939 * This should be called only if powersave offload
9940 * is enabled
9941 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309942QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009943{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309944 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009945
9946 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309949 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009950 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009952 " Idle Ps Set Value %d", value);
9953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309954 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309955 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009956 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309957 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009958 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309959
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309960 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009961}
9962
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309963int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9964 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009965{
9966 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309967 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009968
9969 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 "%s: pSession is NULL", __func__);
9972 return -EIO;
9973 }
9974 switch (ht_capab) {
9975 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9976 return pSession->htConfig.ht_rx_ldpc;
9977 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9978 return pSession->htConfig.ht_tx_stbc;
9979 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9980 return pSession->htConfig.ht_rx_stbc;
9981 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009982 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009983 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009984 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309986 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009987 "invalid ht capability");
9988 return -EIO;
9989 }
9990}
9991
9992int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9993 int value)
9994{
9995 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309996 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997
9998 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309999 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010000 "%s: pSession is NULL", __func__);
10001 return -EIO;
10002 }
10003
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010004 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010005 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010006 "Failed to set ht capability in target");
10007 return -EIO;
10008 }
10009
10010 switch (htCapab) {
10011 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10012 pSession->htConfig.ht_rx_ldpc = value;
10013 break;
10014 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10015 pSession->htConfig.ht_tx_stbc = value;
10016 break;
10017 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10018 pSession->htConfig.ht_rx_stbc = value;
10019 break;
10020 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010021 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010022 pSession->htConfig.ht_sgi20 = value;
10023 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010024 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010025 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010026 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010027 break;
10028 }
10029
Naveen Rawat8029a402017-06-01 10:54:19 -070010030 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010031 return 0;
10032}
10033
10034#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010035/*
10036 * sme_send_rate_update_ind() -
10037 * API to Update rate
10038 *
10039 * hHal - The handle returned by mac_open
10040 * rateUpdateParams - Pointer to rate update params
10041 * Return QDF_STATUS
10042 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010043QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010044 tSirRateUpdateInd *rateUpdateParams)
10045{
10046 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010047 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010048 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010049 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010050
10051 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010052 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010053 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010054 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010055 }
10056 *rate_upd = *rateUpdateParams;
10057
10058 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10059 rate_upd->mcastDataRate24GHzTxFlag =
10060 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10061 else if (rate_upd->reliableMcastDataRate ==
10062 HT20_SHORT_GI_MCS7_RATE)
10063 rate_upd->reliableMcastDataRateTxFlag =
10064 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10065
10066 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010067 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010068 msg.type = WMA_RATE_UPDATE_IND;
10069 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010070 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10071 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010072 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010073 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010074 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010075 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010076 __func__);
10077
10078 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010079 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010080 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010081 }
10082
10083 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010084 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010085 }
10086
10087 return status;
10088}
10089
10090/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010091 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10092 * @hal: Pointer to the mac context
10093 * @session_id: sme session id
10094 * @vendor_ie: vendor ie
10095 * @access_policy: vendor ie access policy
10096 *
10097 * This function updates the vendor ie and access policy to lim.
10098 *
10099 * Return: success or failure.
10100 */
10101QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10102 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10103{
10104 struct sme_update_access_policy_vendor_ie *msg;
10105 uint16_t msg_len;
10106 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010107
10108 msg_len = sizeof(*msg);
10109
10110 msg = qdf_mem_malloc(msg_len);
10111 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010112 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010113 return QDF_STATUS_E_FAILURE;
10114 }
10115
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010116 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10117 msg->length = (uint16_t)msg_len;
10118
10119 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10120
10121 msg->sme_session_id = session_id;
10122 msg->access_policy = access_policy;
10123
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010124 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10125 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010126
Rajeev Kumard138ac52017-01-30 18:38:37 -080010127 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010128
10129 return status;
10130}
10131
10132/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010133 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10134 * @hal: Handle returned by mac_open
10135 * @session_id: Session ID on which short frame retry limit needs to be
10136 * updated to FW
10137 * @short_limit_count_th: Retry count TH to retry short frame.
10138 *
10139 * This function is used to configure count to retry short frame.
10140 *
10141 * Return: QDF_STATUS
10142 */
10143QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10144 struct sme_short_retry_limit *short_retry_limit_th)
10145{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010146 QDF_STATUS status = QDF_STATUS_SUCCESS;
10147 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010148 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010149
10150 srl = qdf_mem_malloc(sizeof(*srl));
10151 if (NULL == srl) {
10152 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10153 "%s: fail to alloc short retry limit", __func__);
10154 return QDF_STATUS_E_FAILURE;
10155 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010156 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010157 short_retry_limit_th->session_id,
10158 short_retry_limit_th->short_retry_limit);
10159
10160 srl->session_id = short_retry_limit_th->session_id;
10161 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10162
10163 qdf_mem_zero(&msg, sizeof(msg));
10164 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10165 msg.reserved = 0;
10166 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010167 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010168 if (status != QDF_STATUS_SUCCESS) {
10169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10170 FL("Not able to post short retry limit count to WDA"));
10171 qdf_mem_free(srl);
10172 return QDF_STATUS_E_FAILURE;
10173 }
10174
10175 return status;
10176}
10177
10178/**
10179 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10180 * @hal: Handle returned by mac_open
10181 * @session_id: Session ID on which long frames retry TH needs to be updated
10182 * to FW
10183 * @long_limit_count_th: Retry count to retry long frame.
10184 *
10185 * This function is used to configure TH to retry long frame.
10186 *
10187 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010188 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010189QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10190 struct sme_long_retry_limit *long_retry_limit_th)
10191{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010192 QDF_STATUS status = QDF_STATUS_SUCCESS;
10193 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010194 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010195
10196 lrl = qdf_mem_malloc(sizeof(*lrl));
10197 if (NULL == lrl) {
10198 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10199 "%s: fail to alloc long retry limit", __func__);
10200 return QDF_STATUS_E_FAILURE;
10201 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010202 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010203 long_retry_limit_th->session_id,
10204 long_retry_limit_th->long_retry_limit);
10205
10206 lrl->session_id = long_retry_limit_th->session_id;
10207 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10208
10209 qdf_mem_zero(&msg, sizeof(msg));
10210 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10211 msg.reserved = 0;
10212 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010213 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010214
10215 if (status != QDF_STATUS_SUCCESS) {
10216 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10217 FL("Not able to post long retry limit count to WDA"));
10218 qdf_mem_free(lrl);
10219 return QDF_STATUS_E_FAILURE;
10220 }
10221
10222 return status;
10223}
10224
10225/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010226 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10227 * @hal: Handle returned by mac_open
10228 * @session_id: Session ID on which sta_inactivity_timeout needs
10229 * to be updated to FW
10230 * @sta_inactivity_timeout: sta inactivity timeout.
10231 *
10232 * If a station does not send anything in sta_inactivity_timeout seconds, an
10233 * empty data frame is sent to it in order to verify whether it is
10234 * still in range. If this frame is not ACKed, the station will be
10235 * disassociated and then deauthenticated.
10236 *
10237 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010238 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010239QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10240 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10241{
10242 struct sme_sta_inactivity_timeout *inactivity_time;
10243 void *wma_handle;
10244
10245 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10246 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10247 if (NULL == inactivity_time) {
10248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10249 "%s: fail to alloc inactivity_time", __func__);
10250 return QDF_STATUS_E_FAILURE;
10251 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010253 FL("sta_inactivity_timeout: %d"),
10254 sta_inactivity_timer->sta_inactivity_timeout);
10255 inactivity_time->session_id = sta_inactivity_timer->session_id;
10256 inactivity_time->sta_inactivity_timeout =
10257 sta_inactivity_timer->sta_inactivity_timeout;
10258
10259 wma_update_sta_inactivity_timeout(wma_handle,
10260 inactivity_time);
10261 return QDF_STATUS_SUCCESS;
10262}
10263
10264/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010265 * sme_get_reg_info() - To get registration info
10266 * @hHal: HAL context
10267 * @chanId: channel id
10268 * @regInfo1: first reg info to fill
10269 * @regInfo2: second reg info to fill
10270 *
10271 * This routine will give you reg info
10272 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010273 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010274 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010275QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276 uint32_t *regInfo1, uint32_t *regInfo2)
10277{
10278 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010279 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010280 uint8_t i;
10281 bool found = false;
10282
10283 status = sme_acquire_global_lock(&pMac->sme);
10284 *regInfo1 = 0;
10285 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010286 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287 return status;
10288
10289 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010290 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010291 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010292 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010293
10294 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010295 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 found = true;
10297 break;
10298 }
10299 }
10300 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010301 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010302
10303 sme_release_global_lock(&pMac->sme);
10304 return status;
10305}
10306
10307#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010308/*
10309 * sme_auto_shutdown_cb() -
10310 * Used to plug in callback function for receiving auto shutdown evt
10311 *
10312 * hHal
10313 * pCallbackfn : callback function pointer should be plugged in
10314 * Return QDF_STATUS
10315 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010316QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010317 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010318 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010319 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10320
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010322 "%s: Plug in Auto shutdown event callback", __func__);
10323
10324 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010325 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010326 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010328 sme_release_global_lock(&pMac->sme);
10329 }
10330
10331 return status;
10332}
10333
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010334/*
10335 * sme_set_auto_shutdown_timer() -
10336 * API to set auto shutdown timer value in FW.
10337 *
10338 * hHal - The handle returned by mac_open
10339 * timer_val - The auto shutdown timer value to be set
10340 * Return Configuration message posting status, SUCCESS or Fail
10341 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010342QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010343{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010344 QDF_STATUS status = QDF_STATUS_SUCCESS;
10345 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010346 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10347 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010348 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010349
10350 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010351 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010353 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010354 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010355 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010356 "%s Request Buffer Alloc Fail", __func__);
10357 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010358 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010359 }
10360
10361 auto_sh_cmd->timer_val = timer_val;
10362
10363 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010364 message.bodyptr = auto_sh_cmd;
10365 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10366 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10367 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010368 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010369 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010370 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010371 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010373 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010374 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010375 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010376 "%s: Posted Auto shutdown MSG", __func__);
10377 sme_release_global_lock(&pMac->sme);
10378 }
10379
10380 return status;
10381}
10382#endif
10383
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010384/*
10385 * sme_ch_avoid_update_req() -
10386 * API to request channel avoidance update from FW.
10387 *
10388 * hHal - The handle returned by mac_open
10389 * update_type - The udpate_type parameter of this request call
10390 * Return Configuration message posting status, SUCCESS or Fail
10391 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010392QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010393{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010394 QDF_STATUS status = QDF_STATUS_SUCCESS;
10395 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010396 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10397 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010398 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010399
10400 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010401 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010403 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010404 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010405 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010406 "%s Request Buffer Alloc Fail", __func__);
10407 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010408 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010409 }
10410
10411 cauReq->reserved_param = 0;
10412
10413 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010414 message.bodyptr = cauReq;
10415 message.type = WMA_CH_AVOID_UPDATE_REQ;
10416 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10417 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010418 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010419 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 "%s: Post Ch Avoid Update MSG fail",
10421 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010422 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010423 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010424 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010425 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010426 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 "%s: Posted Ch Avoid Update MSG", __func__);
10428 sme_release_global_lock(&pMac->sme);
10429 }
10430
10431 return status;
10432}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010433
10434/**
10435 * sme_set_miracast() - Function to set miracast value to UMAC
10436 * @hal: Handle returned by macOpen
10437 * @filter_type: 0-Disabled, 1-Source, 2-sink
10438 *
10439 * This function passes down the value of miracast set by
10440 * framework to UMAC
10441 *
10442 * Return: Configuration message posting status, SUCCESS or Fail
10443 *
10444 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010445QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010447 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 uint32_t *val;
10449 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10450
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010451 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010452 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010453 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010454 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010455 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010456 }
10457
10458 *val = filter_type;
10459
10460 msg.type = SIR_HAL_SET_MIRACAST;
10461 msg.reserved = 0;
10462 msg.bodyptr = val;
10463
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010464 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010465 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010466 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010467 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10468 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010469 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010470 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010471 }
10472
10473 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010474 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010475}
10476
10477/**
10478 * sme_set_mas() - Function to set MAS value to UMAC
10479 * @val: 1-Enable, 0-Disable
10480 *
10481 * This function passes down the value of MAS to the UMAC. A
10482 * value of 1 will enable MAS and a value of 0 will disable MAS
10483 *
10484 * Return: Configuration message posting status, SUCCESS or Fail
10485 *
10486 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010487QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010488{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010489 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010490 uint32_t *ptr_val;
10491
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010492 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010494 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010496 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 }
10498
10499 *ptr_val = val;
10500
10501 msg.type = SIR_HAL_SET_MAS;
10502 msg.reserved = 0;
10503 msg.bodyptr = ptr_val;
10504
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010505 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010506 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010507 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010508 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10509 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010510 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010511 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010513 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514}
10515
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010516/**
10517 * sme_roam_channel_change_req() - Channel change to new target channel
10518 * @hHal: handle returned by mac_open
10519 * @bssid: mac address of BSS
10520 * @ch_params: target channel information
10521 * @profile: CSR profile
10522 *
10523 * API to Indicate Channel change to new target channel
10524 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010525 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010526 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010527QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010528 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010529 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010530 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010531{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010532 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010533 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010534
10535 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010536 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010538 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010539 profile);
10540 sme_release_global_lock(&pMac->sme);
10541 }
10542 return status;
10543}
10544
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010545/*
10546 * sme_process_channel_change_resp() -
10547 * API to Indicate Channel change response message to SAP.
10548 *
10549 * Return QDF_STATUS
10550 */
10551static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010552 uint16_t msg_type, void *pMsgBuf)
10553{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010554 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010555 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 eCsrRoamResult roamResult;
10557 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10558 uint32_t SessionId = pChnlParams->peSessionId;
10559
10560 proam_info.channelChangeRespEvent =
10561 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010562 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010563 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010564 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010565 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010566 return status;
10567 }
10568 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10569 proam_info.channelChangeRespEvent->sessionId = SessionId;
10570 proam_info.channelChangeRespEvent->newChannelNumber =
10571 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010572
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010573 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010574 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10576 SessionId);
10577 proam_info.channelChangeRespEvent->channelChangeStatus =
10578 1;
10579 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10580 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10583 SessionId);
10584 proam_info.channelChangeRespEvent->channelChangeStatus =
10585 0;
10586 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10587 }
10588
10589 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10590 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10591
10592 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010593 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010594 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010595 status);
10596 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010597 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010598
10599 return status;
10600}
10601
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010602/*
10603 * sme_roam_start_beacon_req() -
10604 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10605 *
10606 * hHal - The handle returned by mac_open
10607 * sessionId - session ID
10608 * dfsCacWaitStatus - CAC WAIT status flag
10609 * Return QDF_STATUS
10610 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010611QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010612 uint8_t dfsCacWaitStatus)
10613{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010614 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010617 status = sme_acquire_global_lock(&pMac->sme);
10618
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010619 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010620 status = csr_roam_start_beacon_req(pMac, bssid,
10621 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010622 sme_release_global_lock(&pMac->sme);
10623 }
10624 return status;
10625}
10626
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010627/**
10628 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10629 * @hHal: handle returned by mac_open
10630 * @bssid: SAP bssid
10631 * @targetChannel: target channel information
10632 * @csaIeReqd: CSA IE Request
10633 * @ch_params: channel information
10634 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010635 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010636 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010637QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010638 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010639 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010640{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010641 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010644 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010645 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010646 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10647 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010648 sme_release_global_lock(&pMac->sme);
10649 }
10650 return status;
10651}
10652
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010653/*
10654 * sme_init_thermal_info() -
10655 * SME API to initialize the thermal mitigation parameters
10656 *
10657 * hHal
10658 * thermalParam : thermal mitigation parameters
10659 * Return QDF_STATUS
10660 */
10661QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10662 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010663{
10664 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010665 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010666 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10667
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010668 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010669 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010670 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010671 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010672 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010673 }
10674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010675 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10676 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010677
10678 pWmaParam->throttle_duty_cycle_tbl[0] =
10679 thermalParam.sme_throttle_duty_cycle_tbl[0];
10680 pWmaParam->throttle_duty_cycle_tbl[1] =
10681 thermalParam.sme_throttle_duty_cycle_tbl[1];
10682 pWmaParam->throttle_duty_cycle_tbl[2] =
10683 thermalParam.sme_throttle_duty_cycle_tbl[2];
10684 pWmaParam->throttle_duty_cycle_tbl[3] =
10685 thermalParam.sme_throttle_duty_cycle_tbl[3];
10686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 pWmaParam->thermalLevels[0].minTempThreshold =
10688 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10689 pWmaParam->thermalLevels[0].maxTempThreshold =
10690 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10691 pWmaParam->thermalLevels[1].minTempThreshold =
10692 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10693 pWmaParam->thermalLevels[1].maxTempThreshold =
10694 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10695 pWmaParam->thermalLevels[2].minTempThreshold =
10696 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10697 pWmaParam->thermalLevels[2].maxTempThreshold =
10698 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10699 pWmaParam->thermalLevels[3].minTempThreshold =
10700 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10701 pWmaParam->thermalLevels[3].maxTempThreshold =
10702 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10703
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010704 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010705 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10706 msg.bodyptr = pWmaParam;
10707
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010708 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010709 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010710 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10712 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010713 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010714 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010715 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 }
10717 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010718 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010719 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010720 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010721 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010722}
10723
10724/**
10725 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10726 * @hal: Handle returned by macOpen
10727 * @callback: sme_set_thermal_level_callback
10728 *
10729 * Plug in set thermal level callback
10730 *
10731 * Return: none
10732 */
10733void sme_add_set_thermal_level_callback(tHalHandle hal,
10734 sme_set_thermal_level_callback callback)
10735{
10736 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10737
10738 pMac->sme.set_thermal_level_cb = callback;
10739}
10740
10741/**
10742 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10743 * @hal: Handler to HAL
10744 * @level: Thermal mitigation level
10745 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010746 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010747 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010748QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010749{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010750 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010751 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010752 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010753
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010754 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010755 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010756 msg.type = WMA_SET_THERMAL_LEVEL;
10757 msg.bodyval = level;
10758
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010759 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010760 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10763 __func__);
10764 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010765 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010766 }
10767 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010768 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010769 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010770 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010771}
10772
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010773/*
10774 * sme_txpower_limit() -
10775 * SME API to set txpower limits
10776 *
10777 * hHal
10778 * psmetx : power limits for 2g/5g
10779 * Return QDF_STATUS
10780 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010781QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010782{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010783 QDF_STATUS status = QDF_STATUS_SUCCESS;
10784 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010785 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010786 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010787 tSirTxPowerLimit *tx_power_limit;
10788
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010789 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010790 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010791 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010792 "%s: Memory allocation for TxPowerLimit failed!",
10793 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010794 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010795 }
10796
10797 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010798
10799 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010800 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010801 message.type = WMA_TX_POWER_LIMIT;
10802 message.reserved = 0;
10803 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010804
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010805 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10806 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010807 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010808 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010809 "%s: not able to post WMA_TX_POWER_LIMIT",
10810 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010811 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010812 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813 }
10814 sme_release_global_lock(&pMac->sme);
10815 }
10816 return status;
10817}
10818
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010819QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010820{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010821 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010822 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010824 pMac->fEnableDebugLog = set_value;
10825 return status;
10826}
10827
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010828/*
10829 * sme_ap_disable_intra_bss_fwd() -
10830 * SME will send message to WMA to set Intra BSS in txrx
10831 *
10832 * hHal - The handle returned by mac_open
10833 * sessionId - session id ( vdev id)
10834 * disablefwd - bool value that indicate disable intrabss fwd disable
10835 * Return QDF_STATUS
10836 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010837QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010838 bool disablefwd)
10839{
10840 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010841 int status = QDF_STATUS_SUCCESS;
10842 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010843 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010844 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10845
10846 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010847 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010848 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010849 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010850 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010851 }
10852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 pSapDisableIntraFwd->sessionId = sessionId;
10854 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10855
10856 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010857 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010858 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010859 message.bodyptr = pSapDisableIntraFwd;
10860 message.type = WMA_SET_SAP_INTRABSS_DIS;
10861 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10862 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010863 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10864 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010865 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010866 }
10867 sme_release_global_lock(&pMac->sme);
10868 }
10869 return status;
10870}
10871
10872#ifdef WLAN_FEATURE_STATS_EXT
10873
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010874/*
10875 * sme_stats_ext_register_callback() -
10876 * This function called to register the callback that send vendor event for
10877 * stats ext
10878 *
10879 * callback - callback to be registered
10880 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010881void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10882{
10883 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10884
10885 pMac->sme.StatsExtCallback = callback;
10886}
10887
lifeng66831662017-05-19 16:01:35 +080010888void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10889 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10890{
10891 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10892
10893 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10894}
10895
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010896/**
10897 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10898 * @h_hal: Hal Handle
10899 *
10900 * This function is called to de initialize the HDD NAN feature. Currently
10901 * the only operation required is to de-register a callback with SME.
10902 *
10903 * Return: None
10904 */
10905void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10906{
10907 tpAniSirGlobal pmac;
10908
10909 if (!h_hal) {
10910 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10911 FL("hHal is not valid"));
10912 return;
10913 }
10914
10915 pmac = PMAC_STRUCT(h_hal);
10916 pmac->sme.StatsExtCallback = NULL;
10917}
10918
10919
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010920/*
10921 * sme_stats_ext_request() -
10922 * Function called when HDD receives STATS EXT vendor command from userspace
10923 *
10924 * sessionID - vdevID for the stats ext request
10925 * input - Stats Ext Request structure ptr
10926 * Return QDF_STATUS
10927 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010928QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010929{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010930 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010931 tpStatsExtRequest data;
10932 size_t data_len;
10933
10934 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010935 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010936
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010937 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010938 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 data->vdev_id = session_id;
10941 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010942 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010943 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010944 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945
10946 msg.type = WMA_STATS_EXT_REQUEST;
10947 msg.reserved = 0;
10948 msg.bodyptr = data;
10949
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010950 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010951 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010952 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010953 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10954 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010955 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010956 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010957 }
10958
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010959 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010960}
10961
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010962/*
10963 * sme_stats_ext_event() -
10964 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10965 * response from WMA
10966 *
10967 * hHal - HAL handle for device
10968 * pMsg - Message body passed from WMA; includes NAN header
10969 * Return QDF_STATUS
10970 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010971QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010972{
10973 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010974 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010975
10976 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010977 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010978 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010979 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010980 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010981 pMac->sme.StatsExtCallback(pMac->hHdd,
10982 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 }
10984
10985 return status;
10986}
10987
10988#endif
10989
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010990/*
10991 * sme_update_dfs_scan_mode() -
10992 * Update DFS roam scan mode
10993 * This function is called through dynamic setConfig callback function
10994 * to configure allowDFSChannelRoam.
10995 * hHal - HAL handle for device
10996 * sessionId - Session Identifier
10997 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10998 * 1 (passive), 2 (active)
10999 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11000 * successfully.
11001 * Other status means SME failed to update DFS roaming scan config.
11002 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011003QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011004 uint8_t allowDFSChannelRoam)
11005{
11006 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011007 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011008
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011009 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11010 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11011 FL("Invalid sme session id: %d"), sessionId);
11012 return QDF_STATUS_E_INVAL;
11013 }
11014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011016 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011018 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011019 allowDFSChannelRoam,
11020 pMac->roam.configParam.allowDFSChannelRoam,
11021 mac_trace_get_neighbour_roam_state(pMac->roam.
11022 neighborRoamInfo
11023 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011024 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011025 pMac->roam.configParam.allowDFSChannelRoam =
11026 allowDFSChannelRoam;
11027 sme_release_global_lock(&pMac->sme);
11028 }
11029 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11030 csr_roam_offload_scan(pMac, sessionId,
11031 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11032 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11033 }
11034
11035 return status;
11036}
11037
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011038/*
11039 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11040 * This is a synchronous call
11041 *
11042 * hHal - The handle returned by mac_open.
11043 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11044 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011045uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11046{
11047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011049 return pMac->roam.configParam.allowDFSChannelRoam;
11050}
11051
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011052/*
11053 * sme_modify_add_ie() -
11054 * This function sends msg to updates the additional IE buffers in PE
11055 *
11056 * hHal - global structure
11057 * pModifyIE - pointer to tModifyIE structure
11058 * updateType - type of buffer
11059 * Return Success or failure
11060 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011061QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011062 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11063{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011064 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011065 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011067 status = sme_acquire_global_lock(&pMac->sme);
11068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011069 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011070 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11071 sme_release_global_lock(&pMac->sme);
11072 }
11073 return status;
11074}
11075
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011076/*
11077 * sme_update_add_ie() -
11078 * This function sends msg to updates the additional IE buffers in PE
11079 *
11080 * hHal - global structure
11081 * pUpdateIE - pointer to structure tUpdateIE
11082 * updateType - type of buffer
11083 * Return Success or failure
11084 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011085QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11087{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011088 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011089 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011091 status = sme_acquire_global_lock(&pMac->sme);
11092
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011093 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011094 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11095 sme_release_global_lock(&pMac->sme);
11096 }
11097 return status;
11098}
11099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011100/**
11101 * sme_update_dsc_pto_up_mapping()
11102 * @hHal: HAL context
11103 * @dscpmapping: pointer to DSCP mapping structure
11104 * @sessionId: SME session id
11105 *
11106 * This routine is called to update dscp mapping
11107 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011108 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011109 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011110QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011111 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011112 uint8_t sessionId)
11113{
11114 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011115 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011116 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011117 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011118 tpPESession pSession = NULL;
11119
11120 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011121 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011122 return status;
11123 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11124 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011126 FL("Session lookup fails for CSR session"));
11127 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011128 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 }
11130 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011131 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011132 FL("Invalid session Id %u"), sessionId);
11133 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011134 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011135 }
11136
11137 pSession = pe_find_session_by_bssid(pMac,
11138 pCsrSession->connectedProfile.bssid.bytes,
11139 &peSessionId);
11140
11141 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011143 FL(" Session lookup fails for BSSID"));
11144 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011145 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011146 }
11147
11148 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011149 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011150 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011151 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152 }
11153 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11154 for (j = pSession->QosMapSet.dscp_range[i][0];
11155 j <= pSession->QosMapSet.dscp_range[i][1];
11156 j++) {
11157 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11158 && (pSession->QosMapSet.dscp_range[i][1] ==
11159 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011160 QDF_TRACE(QDF_MODULE_ID_SME,
11161 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011162 FL("User Priority %d isn't used"), i);
11163 break;
11164 } else {
11165 dscpmapping[j] = i;
11166 }
11167 }
11168 }
11169 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11170 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11171 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11172 pSession->QosMapSet.dscp_exceptions[i][1];
11173
11174 sme_release_global_lock(&pMac->sme);
11175 return status;
11176}
11177
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011178/*
11179 * sme_abort_roam_scan() -
11180 * API to abort current roam scan cycle by roam scan offload module.
11181 *
11182 * hHal - The handle returned by mac_open.
11183 * sessionId - Session Identifier
11184 * Return QDF_STATUS
11185 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011186
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011187QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011188{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011189 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011192 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11193 /* acquire the lock for the sme object */
11194 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011195 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 csr_roam_offload_scan(pMac, sessionId,
11197 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11198 REASON_ROAM_ABORT_ROAM_SCAN);
11199 /* release the lock for the sme object */
11200 sme_release_global_lock(&pMac->sme);
11201 }
11202 }
11203
11204 return status;
11205}
11206
11207#ifdef FEATURE_WLAN_EXTSCAN
11208/**
11209 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11210 * @hHal: HAL context
11211 * @wifiBand: RF band information
11212 * @aValidChannels: output array to store channel info
11213 * @pNumChannels: output number of channels
11214 *
11215 * SME API to fetch all valid channels filtered by band
11216 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011217 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011219QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220 uint8_t wifiBand,
11221 uint32_t *aValidChannels,
11222 uint8_t *pNumChannels)
11223{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011224 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011225 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011226 uint8_t numChannels = 0;
11227 uint8_t i = 0;
11228 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011229 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011230
11231 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011232 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011233 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011234 }
11235
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011236 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011237 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011238 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011239 }
11240
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011241 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011243 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011244 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011245 return status;
11246 }
11247
11248 switch (wifiBand) {
11249 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011250 sme_debug("Unspec Band, return all %d valid channels",
11251 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011252 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011253 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011254 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011255 break;
11256
11257 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011258 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011259 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011260 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 aValidChannels[numChannels++] =
11262 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011263 }
11264 break;
11265
11266 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011267 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011269 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011270 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011271 aValidChannels[numChannels++] =
11272 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011273 }
11274 break;
11275
11276 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011277 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011278 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011279 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11280 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011281 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282 aValidChannels[numChannels++] =
11283 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011284 }
11285 break;
11286
11287 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011288 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011289 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011290 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011291 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011292 aValidChannels[numChannels++] =
11293 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011294 }
11295 break;
11296
11297 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011298 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011299 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011300 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011301 aValidChannels[numChannels++] =
11302 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303 }
11304 break;
11305
11306 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011307 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011308 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011309 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011310 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011311 aValidChannels[numChannels++] =
11312 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011313 }
11314 break;
11315
11316 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011317 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011318 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011319 }
11320 *pNumChannels = numChannels;
11321
11322 return status;
11323}
11324
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011325/*
11326 * sme_ext_scan_get_capabilities() -
11327 * SME API to fetch extscan capabilities
11328 *
11329 * hHal
11330 * pReq: extscan capabilities structure
11331 * Return QDF_STATUS
11332 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011333QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011334 tSirGetExtScanCapabilitiesReqParams *
11335 pReq)
11336{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011337 QDF_STATUS status = QDF_STATUS_SUCCESS;
11338 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011340 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011341
11342 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011343 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011344 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011345 message.bodyptr = pReq;
11346 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011347 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011348 NO_SESSION, message.type));
11349 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11350 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011351 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11352 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011353
11354 sme_release_global_lock(&pMac->sme);
11355 }
11356 return status;
11357}
11358
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011359/*
11360 * sme_ext_scan_start() -
11361 * SME API to issue extscan start
11362 *
11363 * hHal
11364 * pStartCmd: extscan start structure
11365 * Return QDF_STATUS
11366 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011367QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011368 tSirWifiScanCmdReqParams *pStartCmd)
11369{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011370 QDF_STATUS status = QDF_STATUS_SUCCESS;
11371 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011372 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011373 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011374
11375 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011376 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011378 message.bodyptr = pStartCmd;
11379 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011380 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011381 NO_SESSION, message.type));
11382 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11383 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011384 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11385 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011386
11387 sme_release_global_lock(&pMac->sme);
11388 }
11389 return status;
11390}
11391
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011392/*
11393 * sme_ext_scan_stop() -
11394 * SME API to issue extscan stop
11395 *
11396 * hHal
11397 * pStopReq: extscan stop structure
11398 * Return QDF_STATUS
11399 */
11400QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11401 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011402{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011403 QDF_STATUS status = QDF_STATUS_SUCCESS;
11404 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011405 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011406 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011407
11408 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011409 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011410 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011411 message.bodyptr = pStopReq;
11412 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011413 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011414 NO_SESSION, message.type));
11415 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11416 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011417 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11418 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419 sme_release_global_lock(&pMac->sme);
11420 }
11421 return status;
11422}
11423
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011424/*
11425 * sme_set_bss_hotlist() -
11426 * SME API to set BSSID hotlist
11427 *
11428 * hHal
11429 * pSetHotListReq: extscan set hotlist structure
11430 * Return QDF_STATUS
11431 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011432QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011433 tSirExtScanSetBssidHotListReqParams *
11434 pSetHotListReq)
11435{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011436 QDF_STATUS status = QDF_STATUS_SUCCESS;
11437 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011439 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011440
11441 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011442 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011443 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011444 message.bodyptr = pSetHotListReq;
11445 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011446 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011447 NO_SESSION, message.type));
11448 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11449 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011450 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11451 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452
11453 sme_release_global_lock(&pMac->sme);
11454 }
11455 return status;
11456}
11457
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011458/*
11459 * sme_reset_bss_hotlist() -
11460 * SME API to reset BSSID hotlist
11461 *
11462 * hHal
11463 * pSetHotListReq: extscan set hotlist structure
11464 * Return QDF_STATUS
11465 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011466QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011467 tSirExtScanResetBssidHotlistReqParams *
11468 pResetReq)
11469{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011470 QDF_STATUS status = QDF_STATUS_SUCCESS;
11471 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011472 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011473 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011474
11475 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011476 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011477 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011478 message.bodyptr = pResetReq;
11479 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011480 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011481 NO_SESSION, message.type));
11482 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11483 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011484 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11485 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011486
11487 sme_release_global_lock(&pMac->sme);
11488 }
11489 return status;
11490}
11491
Manikandan Mohan80dea792016-04-28 16:36:48 -070011492/**
11493 * sme_send_wisa_params(): Pass WISA mode to WMA
11494 * @hal: HAL context
11495 * @wisa_params: pointer to WISA params struct
11496 * @sessionId: SME session id
11497 *
11498 * Pass WISA params to WMA
11499 *
11500 * Return: QDF_STATUS
11501 */
11502QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11503 struct sir_wisa_params *wisa_params)
11504{
11505 QDF_STATUS status = QDF_STATUS_SUCCESS;
11506 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011507 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011508 struct sir_wisa_params *cds_msg_wisa_params;
11509
11510 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11511 if (!cds_msg_wisa_params)
11512 return QDF_STATUS_E_NOMEM;
11513
11514 *cds_msg_wisa_params = *wisa_params;
11515 status = sme_acquire_global_lock(&mac->sme);
11516 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011517 message.bodyptr = cds_msg_wisa_params;
11518 message.type = WMA_SET_WISA_PARAMS;
11519 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011520 sme_release_global_lock(&mac->sme);
11521 }
11522 return status;
11523}
11524
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011525/*
11526 * sme_set_significant_change() -
11527 * SME API to set significant change
11528 *
11529 * hHal
11530 * pSetSignificantChangeReq: extscan set significant change structure
11531 * Return QDF_STATUS
11532 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011533QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011534 tSirExtScanSetSigChangeReqParams *
11535 pSetSignificantChangeReq)
11536{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011537 QDF_STATUS status = QDF_STATUS_SUCCESS;
11538 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011539 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011540 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011541
11542 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011543 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011544 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011545 message.bodyptr = pSetSignificantChangeReq;
11546 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011547 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011548 NO_SESSION, message.type));
11549 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11550 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011551 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11552 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011553
11554 sme_release_global_lock(&pMac->sme);
11555 }
11556 return status;
11557}
11558
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011559/*
11560 * sme_reset_significant_change
11561 * SME API to reset significant change
11562 *
11563 * hHal
11564 * pResetReq: extscan reset significant change structure
11565 * Return QDF_STATUS
11566 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011567QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011568 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011569 *pResetReq)
11570{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011571 QDF_STATUS status = QDF_STATUS_SUCCESS;
11572 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011574 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575
11576 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011577 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011578 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011579 message.bodyptr = pResetReq;
11580 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011581 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011582 NO_SESSION, message.type));
11583 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11584 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011585 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11586 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587
11588 sme_release_global_lock(&pMac->sme);
11589 }
11590 return status;
11591}
11592
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011593/*
11594 * sme_get_cached_results() -
11595 * SME API to get cached results
11596 *
11597 * hHal
11598 * pCachedResultsReq: extscan get cached results structure
11599 * Return QDF_STATUS
11600 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011601QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011602 tSirExtScanGetCachedResultsReqParams *
11603 pCachedResultsReq)
11604{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011605 QDF_STATUS status = QDF_STATUS_SUCCESS;
11606 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011608 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011609
11610 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011611 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011613 message.bodyptr = pCachedResultsReq;
11614 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011615 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011616 NO_SESSION, message.type));
11617 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11618 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011619 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11620 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011621
11622 sme_release_global_lock(&pMac->sme);
11623 }
11624 return status;
11625}
11626
11627/**
11628 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011629 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011630 * @input: request message
11631 *
11632 * This function constructs the cds message and fill in message type,
11633 * bodyptr with %input and posts it to WDA queue.
11634 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011635 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011636 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011637QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011638 struct wifi_epno_params *input)
11639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011640 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011641 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011642 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011643 struct wifi_epno_params *req_msg;
11644 int len, i;
11645
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011646 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011647 len = sizeof(*req_msg) +
11648 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011649
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011650 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011651 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011652 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011653 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011654 }
11655
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011656 req_msg->num_networks = input->num_networks;
11657 req_msg->request_id = input->request_id;
11658 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011659
11660 /* Fill only when num_networks are non zero */
11661 if (req_msg->num_networks) {
11662 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11663 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11664 req_msg->initial_score_max = input->initial_score_max;
11665 req_msg->same_network_bonus = input->same_network_bonus;
11666 req_msg->secure_bonus = input->secure_bonus;
11667 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11668 req_msg->current_connection_bonus =
11669 input->current_connection_bonus;
11670
11671 for (i = 0; i < req_msg->num_networks; i++) {
11672 req_msg->networks[i].flags = input->networks[i].flags;
11673 req_msg->networks[i].auth_bit_field =
11674 input->networks[i].auth_bit_field;
11675 req_msg->networks[i].ssid.length =
11676 input->networks[i].ssid.length;
11677 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11678 input->networks[i].ssid.ssId,
11679 req_msg->networks[i].ssid.length);
11680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011681 }
11682
11683 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011684 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011685 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011686 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011687 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011688 return status;
11689 }
11690
11691 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011692 message.bodyptr = req_msg;
11693 message.type = WMA_SET_EPNO_LIST_REQ;
11694 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011695 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011696 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011697 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011698 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011699 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011700 }
11701 sme_release_global_lock(&mac->sme);
11702 return status;
11703}
11704
11705/**
11706 * sme_set_passpoint_list() - set passpoint network list
11707 * @hal: global hal handle
11708 * @input: request message
11709 *
11710 * This function constructs the cds message and fill in message type,
11711 * bodyptr with @input and posts it to WDA queue.
11712 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011713 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011714 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011715QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011716 struct wifi_passpoint_req *input)
11717{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011718 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011719 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011720 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011721 struct wifi_passpoint_req *req_msg;
11722 int len, i;
11723
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011724 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011725 len = sizeof(*req_msg) +
11726 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011727 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011729 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011730 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 }
11732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733 req_msg->num_networks = input->num_networks;
11734 req_msg->request_id = input->request_id;
11735 req_msg->session_id = input->session_id;
11736 for (i = 0; i < req_msg->num_networks; i++) {
11737 req_msg->networks[i].id =
11738 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011739 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 input->networks[i].realm,
11741 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011742 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743 input->networks[i].plmn,
11744 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011745 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746 input->networks[i].roaming_consortium_ids,
11747 sizeof(req_msg->networks[i].roaming_consortium_ids));
11748 }
11749
11750 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011751 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011752 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011753 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011754 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 return status;
11756 }
11757
11758 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011759 message.bodyptr = req_msg;
11760 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11761 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011762 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011763 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011764 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011765 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011766 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011767 }
11768 sme_release_global_lock(&mac->sme);
11769 return status;
11770}
11771
11772/**
11773 * sme_reset_passpoint_list() - reset passpoint network list
11774 * @hHal: global hal handle
11775 * @input: request message
11776 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011777 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011778 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011779QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011780 struct wifi_passpoint_req *input)
11781{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011782 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011783 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011784 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011785 struct wifi_passpoint_req *req_msg;
11786
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011787 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011788 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011789 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011790 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011791 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011792 }
11793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 req_msg->request_id = input->request_id;
11795 req_msg->session_id = input->session_id;
11796
11797 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011798 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011799 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011801 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 return status;
11803 }
11804
11805 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011806 message.bodyptr = req_msg;
11807 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11808 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011809 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011810 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011812 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011813 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011814 }
11815 sme_release_global_lock(&mac->sme);
11816 return status;
11817}
11818
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011819QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011820 void (*pExtScanIndCb)(void *,
11821 const uint16_t,
11822 void *))
11823{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011824 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011825 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11826
11827 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011828 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011829 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11830 sme_release_global_lock(&pMac->sme);
11831 }
11832 return status;
11833}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011834#endif /* FEATURE_WLAN_EXTSCAN */
11835
11836#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11837
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011838/*
11839 * sme_ll_stats_clear_req() -
11840 * SME API to clear Link Layer Statistics
11841 *
11842 * hHal
11843 * pclearStatsReq: Link Layer clear stats request params structure
11844 * Return QDF_STATUS
11845 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011846QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011847 tSirLLStatsClearReq *pclearStatsReq)
11848{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011849 QDF_STATUS status = QDF_STATUS_SUCCESS;
11850 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011851 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011852 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853 tSirLLStatsClearReq *clear_stats_req;
11854
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011855 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011856 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011857 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858 "statsClearReqMask = 0x%X",
11859 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011860 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011861 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011862 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11864 "%s: invalid staId %d",
11865 __func__, pclearStatsReq->staId);
11866 return QDF_STATUS_E_INVAL;
11867 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011869 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870
11871 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011873 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11874 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011875 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011876 }
11877
11878 *clear_stats_req = *pclearStatsReq;
11879
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011880 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011882 message.bodyptr = clear_stats_req;
11883 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011884 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011885 NO_SESSION, message.type));
11886 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11887 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011888 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011889 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011890 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11891 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011892 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011893 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011894 }
11895 sme_release_global_lock(&pMac->sme);
11896 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011897 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11898 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011899 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011900 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011901 }
11902
11903 return status;
11904}
11905
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011906/*
11907 * sme_ll_stats_set_req() -
11908 * SME API to set the Link Layer Statistics
11909 *
11910 * hHal
11911 * psetStatsReq: Link Layer set stats request params structure
11912 * Return QDF_STATUS
11913 */
11914QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11915 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011916{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011917 QDF_STATUS status = QDF_STATUS_SUCCESS;
11918 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011920 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 tSirLLStatsSetReq *set_stats_req;
11922
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011923 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924 "%s: MPDU Size = %u", __func__,
11925 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011927 " Aggressive Stats Collections = %u",
11928 psetStatsReq->aggressiveStatisticsGathering);
11929
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011930 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011931
11932 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011933 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011934 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11935 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011936 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937 }
11938
11939 *set_stats_req = *psetStatsReq;
11940
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011941 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011942 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011943 message.bodyptr = set_stats_req;
11944 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011945 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011946 NO_SESSION, message.type));
11947 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11948 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011949 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011950 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011951 "%s: not able to post WMA_LL_STATS_SET_REQ",
11952 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011953 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011954 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011955 }
11956 sme_release_global_lock(&pMac->sme);
11957 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11959 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011960 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011961 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011962 }
11963
11964 return status;
11965}
11966
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011967/*
11968 * sme_ll_stats_get_req() -
11969 * SME API to get the Link Layer Statistics
11970 *
11971 * hHal
11972 * pgetStatsReq: Link Layer get stats request params structure
11973 * Return QDF_STATUS
11974 */
11975QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
11976 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011977{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011978 QDF_STATUS status = QDF_STATUS_SUCCESS;
11979 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011980 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011981 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011982 tSirLLStatsGetReq *get_stats_req;
11983
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011984 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011985
11986 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011987 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011988 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
11989 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011990 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011991 }
11992
11993 *get_stats_req = *pgetStatsReq;
11994
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011995 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011997 message.bodyptr = get_stats_req;
11998 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011999 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012000 NO_SESSION, message.type));
12001 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12002 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012003 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012004 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012005 "%s: not able to post WMA_LL_STATS_GET_REQ",
12006 __func__);
12007
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012008 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012009 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012010
12011 }
12012 sme_release_global_lock(&pMac->sme);
12013 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012014 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12015 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012016 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012017 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012018 }
12019
12020 return status;
12021}
12022
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012023/*
12024 * sme_set_link_layer_stats_ind_cb() -
12025 * SME API to trigger the stats are available after get request
12026 *
12027 * hHal
12028 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012029 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012030 * Return QDF_STATUS
12031 */
12032QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12033 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12034{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012035 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012036 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12037
12038 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012039 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012040 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12041 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012042 } else
12043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12044 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012045
12046 return status;
12047}
12048
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012049/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012050 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12051 * @hal: Mac global handle
12052 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12053 * status notification from FW
12054 *
12055 * Return: eHalStatus
12056 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012057QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12058 (tHddHandle callback_ctx, tSirLLStatsResults
12059 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012060{
12061 QDF_STATUS status;
12062 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12063
12064 status = sme_acquire_global_lock(&mac->sme);
12065 if (status == QDF_STATUS_SUCCESS) {
12066 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12067 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012068 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012069 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12070 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012071 return status;
12072}
12073
12074/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012075 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12076 * indication
12077 * @h_hal: Hal Handle
12078 *
12079 * This function reset's the link layer stats indication
12080 *
12081 * Return: QDF_STATUS Enumeration
12082 */
12083
12084QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12085{
12086 QDF_STATUS status;
12087 tpAniSirGlobal pmac;
12088
12089 if (!h_hal) {
12090 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12091 FL("hHal is not valid"));
12092 return QDF_STATUS_E_INVAL;
12093 }
12094 pmac = PMAC_STRUCT(h_hal);
12095
12096 status = sme_acquire_global_lock(&pmac->sme);
12097 if (QDF_IS_STATUS_SUCCESS(status)) {
12098 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12099 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012100 } else
12101 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12102 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012103
12104 return status;
12105}
12106
Zhang Qian73c348a2017-03-13 16:15:55 +080012107/**
12108 * sme_ll_stats_set_thresh - set threshold for mac counters
12109 * @hal, hal layer handle
12110 * @threshold, threshold for mac counters
12111 *
12112 * Return: QDF_STATUS Enumeration
12113 */
12114QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12115 struct sir_ll_ext_stats_threshold *threshold)
12116{
12117 QDF_STATUS status;
12118 tpAniSirGlobal mac;
12119 struct scheduler_msg message;
12120 struct sir_ll_ext_stats_threshold *thresh;
12121
12122 if (!threshold) {
12123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12124 FL("threshold is not valid"));
12125 return QDF_STATUS_E_INVAL;
12126 }
12127
12128 if (!hal) {
12129 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12130 FL("hal is not valid"));
12131 return QDF_STATUS_E_INVAL;
12132 }
12133 mac = PMAC_STRUCT(hal);
12134
12135 thresh = qdf_mem_malloc(sizeof(*thresh));
12136 if (!thresh) {
12137 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12138 "%s: Fail to alloc mem", __func__);
12139 return QDF_STATUS_E_NOMEM;
12140 }
12141 *thresh = *threshold;
12142
12143 status = sme_acquire_global_lock(&mac->sme);
12144 if (QDF_IS_STATUS_SUCCESS(status)) {
12145 /* Serialize the req through MC thread */
12146 message.bodyptr = thresh;
12147 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12148 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12149 NO_SESSION, message.type));
12150 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12151 if (!QDF_IS_STATUS_SUCCESS(status)) {
12152 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12153 "%s: not able to post WDA_LL_STATS_GET_REQ",
12154 __func__);
12155 qdf_mem_free(thresh);
12156 }
12157 sme_release_global_lock(&mac->sme);
12158 } else {
12159 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12160 FL("sme_acquire_global_lock error"));
12161 qdf_mem_free(thresh);
12162 }
12163 return status;
12164}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12167
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012168#ifdef WLAN_POWER_DEBUGFS
12169/**
12170 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12171 * @callback_fn: Pointer to the callback function for Power stats event
12172 * @power_stats_context: Pointer to context
12173 *
12174 * Return: QDF_STATUS
12175 */
12176QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12177 (struct power_stats_response *response,
12178 void *context), void *power_stats_context)
12179{
12180 QDF_STATUS status = QDF_STATUS_SUCCESS;
12181 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012182 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012183
12184 status = sme_acquire_global_lock(&mac_ctx->sme);
12185 if (QDF_IS_STATUS_SUCCESS(status)) {
12186 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012187 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012188 sme_release_global_lock(&mac_ctx->sme);
12189 return QDF_STATUS_E_FAILURE;
12190 }
12191
12192 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12193 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12194 msg.bodyptr = NULL;
12195 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012196 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012197 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012198 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012199 sme_release_global_lock(&mac_ctx->sme);
12200 }
12201 return status;
12202}
12203#endif
12204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012205/**
12206 * sme_fw_mem_dump_register_cb() - Register fw memory dump callback
12207 *
12208 * @hal - MAC global handle
12209 * @callback_routine - callback routine from HDD
12210 *
12211 * This API is invoked by HDD to register its callback in SME
12212 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012213 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012214 */
12215#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012216QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012217 void (*callback_routine)(void *cb_context,
12218 struct fw_dump_rsp *rsp))
12219{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012220 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012221 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12222
12223 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012224 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012225 pmac->sme.fw_dump_callback = callback_routine;
12226 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012227 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012228 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012229 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012230
12231 return status;
12232}
12233#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012234QDF_STATUS sme_fw_mem_dump_register_cb(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012235 void (*callback_routine)(void *cb_context,
12236 struct fw_dump_rsp *rsp))
12237{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012238 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012239}
12240#endif /* WLAN_FEATURE_MEMDUMP */
12241
12242/**
12243 * sme_fw_mem_dump_unregister_cb() - Unregister fw memory dump callback
12244 *
12245 * @hHal - MAC global handle
12246 *
12247 * This API is invoked by HDD to unregister its callback in SME
12248 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012249 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012250 */
12251#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012252QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012253{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012254 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012255 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
12256
12257 status = sme_acquire_global_lock(&pmac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012258 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012259 pmac->sme.fw_dump_callback = NULL;
12260 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012261 } else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012262 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012263 FL("sme_acquire_global_lock error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264
12265 return status;
12266}
12267#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012268QDF_STATUS sme_fw_mem_dump_unregister_cb(tHalHandle hal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012269{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012270 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012271}
12272#endif /* WLAN_FEATURE_MEMDUMP */
12273
12274#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012275/*
12276 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12277 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12278 *
12279 * hHal - The handle returned by mac_open.
12280 * nRoamOffloadEnabled - The bool to update with
12281 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12282 * Other status means SME is failed to update.
12283 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012284
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012285QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012286 bool nRoamOffloadEnabled)
12287{
12288 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012289 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012290
12291 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012292 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012294 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12295 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12296 nRoamOffloadEnabled);
12297 pMac->roam.configParam.isRoamOffloadEnabled =
12298 nRoamOffloadEnabled;
12299 sme_release_global_lock(&pMac->sme);
12300 }
12301
12302 return status;
12303}
12304
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012305/**
12306 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12307 * This is a synchronous call
12308 * @hal_ctx: The handle returned by mac_open.
12309 * @session_id: Session Identifier
12310 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012311 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012312 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12313 * Other status means SME is failed to update.
12314 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012315
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012316QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012317 uint8_t session_id,
12318 bool key_mgmt_offload_enabled,
12319 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012320{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012321 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012322 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012323
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012324 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012325 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012326 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012327 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012328 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12329 __func__, key_mgmt_offload_enabled);
12330 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12331 session_id,
12332 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012333 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012334 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012335 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012336 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012337 }
12338
12339 return status;
12340}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012341#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012342
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012343/*
12344 * sme_get_temperature() -
12345 * SME API to get the pdev temperature
12346 *
12347 * hHal
12348 * temperature context
12349 * pCallbackfn: callback fn with response (temperature)
12350 * Return QDF_STATUS
12351 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012352QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012353 void *tempContext,
12354 void (*pCallbackfn)(int temperature,
12355 void *pContext))
12356{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012357 QDF_STATUS status = QDF_STATUS_SUCCESS;
12358 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012359 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012360 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012361
12362 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012363 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012364 if ((NULL == pCallbackfn) &&
12365 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012366 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012367 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012368 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012369 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012370 } else if (NULL != pCallbackfn) {
12371 pMac->sme.pTemperatureCbContext = tempContext;
12372 pMac->sme.pGetTemperatureCb = pCallbackfn;
12373 }
12374 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012375 message.bodyptr = NULL;
12376 message.type = WMA_GET_TEMPERATURE_REQ;
12377 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12378 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012379 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012380 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012382 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012383 }
12384 sme_release_global_lock(&pMac->sme);
12385 }
12386 return status;
12387}
12388
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012389/*
12390 * sme_set_scanning_mac_oui() -
12391 * SME API to set scanning mac oui
12392 *
12393 * hHal
12394 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12395 * Return QDF_STATUS
12396 */
12397QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12398 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012399{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012400 QDF_STATUS status = QDF_STATUS_SUCCESS;
12401 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012402 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012403 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012404
12405 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012406 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012407 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012408 message.bodyptr = pScanMacOui;
12409 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12410 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12411 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012412 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012413 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012414 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012415 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012416 }
12417 sme_release_global_lock(&pMac->sme);
12418 }
12419 return status;
12420}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421
12422#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012423/*
12424 * sme_set_dhcp_srv_offload() -
12425 * SME API to set DHCP server offload info
12426 *
12427 * hHal
12428 * pDhcpSrvInfo : DHCP server offload info struct
12429 * Return QDF_STATUS
12430 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012431QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012432 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12433{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012434 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012435 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012436 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012437 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12438
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012439 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440
12441 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012442 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012443 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12444 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012445 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012446 }
12447
12448 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12449
12450 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012451 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012452 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012453 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12454 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012455
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012456 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012457 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12458 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012460 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012461 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012462 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012463 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 }
12465 sme_release_global_lock(&pMac->sme);
12466 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012467 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012468 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012469 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012470 }
12471
12472 return status;
12473}
12474#endif /* DHCP_SERVER_OFFLOAD */
12475
Krunal Soniaadaa272017-10-04 16:42:55 -070012476QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12477 uint32_t arg_count, uint32_t *arg)
12478{
12479 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12480 arg_count, arg);
12481}
12482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012483#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012484/*
12485 * sme_set_led_flashing() -
12486 * API to set the Led flashing parameters.
12487 *
12488 * hHal - The handle returned by mac_open.
12489 * x0, x1 - led flashing parameters
12490 * Return QDF_STATUS
12491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012492QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012493 uint32_t x0, uint32_t x1)
12494{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012495 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012497 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012498 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012499
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012500 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012502 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012503 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012504 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012505 }
12506
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012507 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012508 ledflashing->pattern_id = type;
12509 ledflashing->led_x0 = x0;
12510 ledflashing->led_x1 = x1;
12511
12512 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012513 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012514 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012515 message.bodyptr = ledflashing;
12516 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012517 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012518 sme_release_global_lock(&pMac->sme);
12519 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012520 if (!QDF_IS_STATUS_SUCCESS(status))
12521 qdf_mem_free(ledflashing);
12522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012523 return status;
12524}
12525#endif
12526
12527/**
12528 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12529 * @h_hal: corestack handler
12530 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012531 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012532 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012533QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012534{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012535 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12537
12538 status = sme_acquire_global_lock(&mac->sme);
12539
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012540 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012541
12542 mac->scan.fEnableDFSChnlScan = dfs_flag;
12543
12544 /* update the channel list to the firmware */
12545 status = csr_update_channel_list(mac);
12546
12547 sme_release_global_lock(&mac->sme);
12548 }
12549
12550 return status;
12551}
12552
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012553#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12554/**
12555 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12556 * concurreny rules set to avoid channel interference.
12557 * @hal - Hal context
12558 * @sap_ch - channel to switch
12559 * @sap_phy_mode - phy mode of SAP
12560 * @cc_switch_mode - concurreny switch mode
12561 * @session_id - sme session id.
12562 *
12563 * Return: true if there is no channel interference else return false
12564 */
12565bool sme_validate_sap_channel_switch(tHalHandle hal,
12566 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12567 uint8_t session_id)
12568{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012569 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012570 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012571 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012572 uint16_t intf_channel = 0;
12573
12574 if (!session)
12575 return false;
12576
12577 session->ch_switch_in_progress = true;
12578 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012579 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012580 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12581 sap_phy_mode,
12582 cc_switch_mode);
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,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012586 FL("sme_acquire_global_lock error!"));
12587 session->ch_switch_in_progress = false;
12588 return false;
12589 }
12590
12591 session->ch_switch_in_progress = false;
12592 return (intf_channel == 0) ? true : false;
12593}
12594#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012595
12596/**
12597 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12598 * @hal: hal
12599 * @session_id: session ID
12600 * @stats_avg_factor: average stats factor
12601 *
12602 * This function configures the stats avg factor in firmware
12603 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012604 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012605 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012606QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012607 uint16_t stats_avg_factor)
12608{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012609 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012610 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012611 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12612 struct sir_stats_avg_factor *stats_factor;
12613
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012614 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012615
12616 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012618 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12619 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012620 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012621 }
12622
12623 status = sme_acquire_global_lock(&mac->sme);
12624
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012625 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012626
12627 stats_factor->vdev_id = session_id;
12628 stats_factor->stats_avg_factor = stats_avg_factor;
12629
12630 /* serialize the req through MC thread */
12631 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12632 msg.bodyptr = stats_factor;
12633
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012634 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012635 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012636 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012637 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12638 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012639 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012640 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012641 }
12642 sme_release_global_lock(&mac->sme);
12643 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012644 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012645 "%s: sme_acquire_global_lock error!",
12646 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012647 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012648 }
12649
12650 return status;
12651}
12652
12653/**
12654 * sme_configure_guard_time() - function to configure guard time
12655 * @hal: hal
12656 * @session_id: session id
12657 * @guard_time: guard time
12658 *
12659 * This function configures the guard time in firmware
12660 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012661 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012662 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012663QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012664 uint32_t guard_time)
12665{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012666 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012667 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012668 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12669 struct sir_guard_time_request *g_time;
12670
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012671 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012672
12673 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012674 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012675 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12676 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012677 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012678 }
12679
12680 status = sme_acquire_global_lock(&mac->sme);
12681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012682 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012683
12684 g_time->vdev_id = session_id;
12685 g_time->guard_time = guard_time;
12686
12687 /* serialize the req through MC thread */
12688 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12689 msg.bodyptr = g_time;
12690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012691 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012692 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012693 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012694 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12695 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012696 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012697 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012698 }
12699 sme_release_global_lock(&mac->sme);
12700 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012701 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012702 "%s: sme_acquire_global_lock error!",
12703 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012704 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012705 }
12706
12707 return status;
12708}
12709
12710/**
12711 * sme_configure_modulated_dtim() - function to configure modulated dtim
12712 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12713 * @session_id: session ID
12714 * @modulated_dtim: modulated dtim value
12715 *
12716 * This function configures the modulated dtim in firmware
12717 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012718 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012719 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012720QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012721 uint32_t modulated_dtim)
12722{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012723 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012724 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012725 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12726 wma_cli_set_cmd_t *iwcmd;
12727
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012728 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012730 QDF_TRACE(QDF_MODULE_ID_SME,
12731 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012732 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012733 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012734 }
12735
12736 status = sme_acquire_global_lock(&mac->sme);
12737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012738 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012740 iwcmd->param_value = modulated_dtim;
12741 iwcmd->param_vdev_id = session_id;
12742 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12743 iwcmd->param_vp_dev = GEN_CMD;
12744 msg.type = WMA_CLI_SET_CMD;
12745 msg.reserved = 0;
12746 msg.bodyptr = (void *)iwcmd;
12747
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012748 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012749 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012750 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012751 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12752 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012753 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012754 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012755 }
12756 sme_release_global_lock(&mac->sme);
12757 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012759 "%s: sme_acquire_global_lock error!",
12760 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012761 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012762 }
12763
12764 return status;
12765}
12766
Mukul Sharma6398b252017-05-01 17:58:12 +053012767/**
12768 * sme_override_listen_interval() - function to override static LI
12769 * @h_hal: SME API to override listen interval
12770 * @session_id: session ID
12771 * @override_li: new LI value passed by user
12772 *
12773 * This function override (enable/disable) static a.k.a ini based LI
12774 *
12775 * Return: QDF_STATUS
12776 */
12777QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12778 uint32_t override_li)
12779{
12780 struct scheduler_msg msg = {0};
12781 QDF_STATUS status = QDF_STATUS_SUCCESS;
12782 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12783 wma_cli_set_cmd_t *iwcmd;
12784
12785 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12786 if (!iwcmd) {
12787 QDF_TRACE(QDF_MODULE_ID_SME,
12788 QDF_TRACE_LEVEL_FATAL,
12789 "%s: qdf_mem_malloc failed", __func__);
12790 return QDF_STATUS_E_NOMEM;
12791 }
12792
12793 status = sme_acquire_global_lock(&mac->sme);
12794
12795 if (status == QDF_STATUS_SUCCESS) {
12796
12797 iwcmd->param_value = override_li;
12798 iwcmd->param_vdev_id = session_id;
12799 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12800 iwcmd->param_vp_dev = GEN_CMD;
12801 msg.type = WMA_CLI_SET_CMD;
12802 msg.reserved = 0;
12803 msg.bodyptr = (void *)iwcmd;
12804
12805 if (!QDF_IS_STATUS_SUCCESS(
12806 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12808 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12809 __func__);
12810 qdf_mem_free(iwcmd);
12811 status = QDF_STATUS_E_FAILURE;
12812 }
12813 sme_release_global_lock(&mac->sme);
12814 } else {
12815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12816 "%s: sme_acquire_global_lock error!",
12817 __func__);
12818 qdf_mem_free(iwcmd);
12819 }
12820
12821 return status;
12822}
12823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012824/*
12825 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12826 * to either start/stop logging
12827 * @hal: HAL context
12828 * @start_log: Structure containing the wifi start logger params
12829 *
12830 * This function sends the start/stop logging command to WMA
12831 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012832 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012833 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012834QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012835 struct sir_wifi_start_log start_log)
12836{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012837 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012838 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012839 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012840 struct sir_wifi_start_log *req_msg;
12841 uint32_t len;
12842
12843 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012844 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012845 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012846 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012847 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012848 }
12849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012851 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012852 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012853 req_msg->ini_triggered = start_log.ini_triggered;
12854 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012855 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012856 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012857
12858 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012859 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012860 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012861 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012862 return status;
12863 }
12864
12865 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012866 message.bodyptr = req_msg;
12867 message.type = SIR_HAL_START_STOP_LOGGING;
12868 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012869 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012870 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012871 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012872 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012873 }
12874 sme_release_global_lock(&mac->sme);
12875
12876 return status;
12877}
12878
12879/**
12880 * sme_neighbor_middle_of_roaming() - Function to know if
12881 * STA is in the middle of roaming states
12882 * @hal: Handle returned by macOpen
12883 * @sessionId: sessionId of the STA session
12884 *
12885 * This function is a wrapper to call
12886 * csr_neighbor_middle_of_roaming to know STA is in the
12887 * middle of roaming states
12888 *
12889 * Return: True or False
12890 *
12891 */
12892bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12893{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012894 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12895 bool val = false;
12896
12897 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12898 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12899 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012900 sme_err("Invalid Session: %d", sessionId);
12901
Sandeep Puligillaca631612016-11-08 11:53:52 -080012902 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012903}
12904
12905/*
12906 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12907 * @mac: MAC handle
12908 *
12909 * This function is used to send the command that will
12910 * be used to flush the logs in the firmware
12911 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012912 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012913 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012914QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012915{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012916 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012917 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012919 /* Serialize the req through MC thread */
12920 message.bodyptr = NULL;
12921 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012922 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012923 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012924 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012925 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012927 return status;
12928}
12929
Jeff Johnsona1e92612017-09-24 15:33:44 -070012930QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012931 sme_ac_enum_type ac, uint8_t tid,
12932 uint8_t pri, uint32_t srvc_int,
12933 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012934 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012935 uint8_t psb, uint32_t sessionId,
12936 uint32_t delay_interval)
12937{
12938 void *wma_handle;
12939 t_wma_trigger_uapsd_params uapsd_params;
12940 enum uapsd_ac access_category;
12941
12942 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012943 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012944 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012945 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012946 }
12947
Anurag Chouhan6d760662016-02-20 16:05:43 +053012948 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012949 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012950 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012951 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012952 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012953 }
12954
12955 switch (ac) {
12956 case SME_AC_BK:
12957 access_category = UAPSD_BK;
12958 break;
12959 case SME_AC_BE:
12960 access_category = UAPSD_BE;
12961 break;
12962 case SME_AC_VI:
12963 access_category = UAPSD_VI;
12964 break;
12965 case SME_AC_VO:
12966 access_category = UAPSD_VO;
12967 break;
12968 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012969 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012970 }
12971
12972 uapsd_params.wmm_ac = access_category;
12973 uapsd_params.user_priority = pri;
12974 uapsd_params.service_interval = srvc_int;
12975 uapsd_params.delay_interval = delay_interval;
12976 uapsd_params.suspend_interval = sus_int;
12977
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012978 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012979 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012980 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012981 "Failed to Trigger Uapsd params for sessionId %d",
12982 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012983 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012984 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012985 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012986}
12987
Jeff Johnsona1e92612017-09-24 15:33:44 -070012988QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012989 sme_ac_enum_type ac,
12990 uint32_t sessionId)
12991{
12992 void *wma_handle;
12993 enum uapsd_ac access_category;
12994
12995 switch (ac) {
12996 case SME_AC_BK:
12997 access_category = UAPSD_BK;
12998 break;
12999 case SME_AC_BE:
13000 access_category = UAPSD_BE;
13001 break;
13002 case SME_AC_VI:
13003 access_category = UAPSD_VI;
13004 break;
13005 case SME_AC_VO:
13006 access_category = UAPSD_VO;
13007 break;
13008 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013009 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010 }
13011
Anurag Chouhan6d760662016-02-20 16:05:43 +053013012 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013013 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013014 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013015 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013016 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013017 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013018 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013020 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013021 "Failed to disable uapsd for ac %d for sessionId %d",
13022 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013023 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013024 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013025 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013026}
13027
13028/**
13029 * sme_update_nss() - SME API to change the number for spatial streams
13030 * (1 or 2)
13031 * @hal: Handle returned by mac open
13032 * @nss: Number of spatial streams
13033 *
13034 * This function is used to update the number of spatial streams supported.
13035 *
13036 * Return: Success upon successfully changing nss else failure
13037 *
13038 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013039QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013040{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013041 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013042 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13043 uint32_t i, value = 0;
13044 union {
13045 uint16_t cfg_value16;
13046 tSirMacHTCapabilityInfo ht_cap_info;
13047 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013048 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013049
13050 status = sme_acquire_global_lock(&mac_ctx->sme);
13051
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013052 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013053 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13054
13055 /* get the HT capability info*/
13056 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13057 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13058
13059 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13060 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13061 csr_session = &mac_ctx->roam.roamSession[i];
13062 csr_session->htConfig.ht_tx_stbc =
13063 uHTCapabilityInfo.ht_cap_info.txSTBC;
13064 }
13065 }
13066
13067 sme_release_global_lock(&mac_ctx->sme);
13068 }
13069 return status;
13070}
13071
13072/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013073 * sme_update_user_configured_nss() - sets the nss based on user request
13074 * @hal: Pointer to HAL
13075 * @nss: number of streams
13076 *
13077 * Return: None
13078 */
13079void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13080{
13081 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13082
13083 mac_ctx->user_configured_nss = nss;
13084}
13085
13086/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013087 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13088 * @hal: global hal handle
13089 * @cb: callback function pointer
13090 *
13091 * This function stores nud debug stats callback function.
13092 *
13093 * Return: QDF_STATUS enumeration.
13094 */
13095QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13096 void (*cb)(void *, struct rsp_stats *))
13097{
13098 QDF_STATUS status = QDF_STATUS_SUCCESS;
13099 tpAniSirGlobal mac;
13100
13101 if (!hal) {
13102 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13103 FL("hal is not valid"));
13104 return QDF_STATUS_E_INVAL;
13105 }
13106 mac = PMAC_STRUCT(hal);
13107
13108 status = sme_acquire_global_lock(&mac->sme);
13109 if (!QDF_IS_STATUS_SUCCESS(status)) {
13110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13111 FL("sme_acquire_global_lock failed!(status=%d)"),
13112 status);
13113 return status;
13114 }
13115
13116 mac->sme.get_arp_stats_cb = cb;
13117 sme_release_global_lock(&mac->sme);
13118 return status;
13119}
13120
13121/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013123 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013124 * @cb: callback function pointer
13125 *
13126 * This function stores the rssi threshold breached callback function.
13127 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013128 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013129 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013130QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013131 void (*cb)(void *, struct rssi_breach_event *))
13132{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013133 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013134 tpAniSirGlobal mac;
13135
13136 if (!h_hal) {
13137 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13138 FL("hHal is not valid"));
13139 return QDF_STATUS_E_INVAL;
13140 }
13141 mac = PMAC_STRUCT(h_hal);
13142
13143 status = sme_acquire_global_lock(&mac->sme);
13144 if (!QDF_IS_STATUS_SUCCESS(status)) {
13145 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13146 FL("sme_acquire_global_lock failed!(status=%d)"),
13147 status);
13148 return status;
13149 }
13150
13151 mac->sme.rssi_threshold_breached_cb = cb;
13152 sme_release_global_lock(&mac->sme);
13153 return status;
13154}
13155
13156/**
13157 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13158 * @hal: global hal handle
13159 *
13160 * This function de-registers the rssi threshold breached callback function.
13161 *
13162 * Return: QDF_STATUS enumeration.
13163 */
13164QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13165{
13166 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013167 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13168
13169 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013170 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013171 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013172 return status;
13173 }
13174
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013175 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013176 sme_release_global_lock(&mac->sme);
13177 return status;
13178}
13179
13180/**
13181 * sme_is_any_session_in_connected_state() - SME wrapper API to
13182 * check if any session is in connected state or not.
13183 *
13184 * @hal: Handle returned by mac open
13185 *
13186 * This function is used to check if any valid sme session is in
13187 * connected state or not.
13188 *
13189 * Return: true if any session is connected, else false.
13190 *
13191 */
13192bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13193{
13194 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013195 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013196 bool ret = false;
13197
13198 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013199 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013200 ret = csr_is_any_session_in_connect_state(mac_ctx);
13201 sme_release_global_lock(&mac_ctx->sme);
13202 }
13203 return ret;
13204}
13205
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013206QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13207 void (*cb)(void *,
13208 struct chip_pwr_save_fail_detected_params *)) {
13209
13210 QDF_STATUS status = QDF_STATUS_SUCCESS;
13211 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13212
13213 status = sme_acquire_global_lock(&mac->sme);
13214 if (status != QDF_STATUS_SUCCESS) {
13215 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13216 return status;
13217 }
13218 mac->sme.chip_power_save_fail_cb = cb;
13219 sme_release_global_lock(&mac->sme);
13220 return status;
13221}
13222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223/**
13224 * sme_set_rssi_monitoring() - set rssi monitoring
13225 * @hal: global hal handle
13226 * @input: request message
13227 *
13228 * This function constructs the vos message and fill in message type,
13229 * bodyptr with @input and posts it to WDA queue.
13230 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013231 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013232 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013233QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013234 struct rssi_monitor_req *input)
13235{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013236 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013237 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013238 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013239 struct rssi_monitor_req *req_msg;
13240
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013241 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013242 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013243 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013244 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013245 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013246 }
13247
13248 *req_msg = *input;
13249
13250 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013251 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013252 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013253 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013254 return status;
13255 }
13256
13257 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013258 message.bodyptr = req_msg;
13259 message.type = WMA_SET_RSSI_MONITOR_REQ;
13260 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013261 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013262 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013263 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013264 }
13265 sme_release_global_lock(&mac->sme);
13266
13267 return status;
13268}
13269
13270/**
13271 * sme_fw_mem_dump() - Get FW memory dump
13272 * @hHal: hal handle
13273 * @recvd_req: received memory dump request.
13274 *
13275 * This API is invoked by HDD to indicate FW to start
13276 * dumping firmware memory.
13277 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013278 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013279 */
13280#ifdef WLAN_FEATURE_MEMDUMP
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013281QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013283 QDF_STATUS status = QDF_STATUS_SUCCESS;
13284 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013286 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013287 struct fw_dump_req *send_req;
13288 struct fw_dump_seg_req seg_req;
13289 int loop;
13290
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013291 send_req = qdf_mem_malloc(sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013292 if (!send_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013293 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 FL("Memory allocation failed for WDA_FW_MEM_DUMP"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013295 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013296 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013297 qdf_mem_copy(send_req, recvd_req, sizeof(*send_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013298
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013299 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013300 FL("request_id:%d num_seg:%d"),
13301 send_req->request_id, send_req->num_seg);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013302 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013303 FL("Segment Information"));
13304 for (loop = 0; loop < send_req->num_seg; loop++) {
13305 seg_req = send_req->segment[loop];
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013306 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013307 FL("seg_number:%d"), loop);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013309 FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
13310 seg_req.seg_id, seg_req.seg_start_addr_lo,
13311 seg_req.seg_start_addr_hi);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013312 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013313 FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
13314 seg_req.seg_length, seg_req.dst_addr_lo,
13315 seg_req.dst_addr_hi);
13316 }
13317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013318 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013319 msg.bodyptr = send_req;
13320 msg.type = WMA_FW_MEM_DUMP_REQ;
13321 msg.reserved = 0;
13322
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013323 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013324 if (QDF_STATUS_SUCCESS != qdf_status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013325 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013326 FL("Not able to post WMA_FW_MEM_DUMP"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013327 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013328 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013329 }
13330 sme_release_global_lock(&pMac->sme);
13331 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013332 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013333 FL("Failed to acquire SME Global Lock"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013334 qdf_mem_free(send_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013335 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013336 }
13337
13338 return status;
13339}
13340#else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013341QDF_STATUS sme_fw_mem_dump(tHalHandle hHal, void *recvd_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013342{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013343 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013344}
13345#endif /* WLAN_FEATURE_MEMDUMP */
13346
13347/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013348 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013349 * @hal: Handle returned by macOpen
13350 * @msg: PCL channel list and length structure
13351 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013352 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013353 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013354 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013355QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013356{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013357 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013358 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013359 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013360 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 uint32_t len, i;
13362
13363 len = sizeof(*req_msg);
13364
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013365 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013366 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013367 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013368 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013369 }
13370
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013371 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013372 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013373 req_msg->weight_list[i] = msg.weight_list[i];
13374 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013375
13376 req_msg->pcl_len = msg.pcl_len;
13377
13378 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013379 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013380 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013381 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013382 return status;
13383 }
13384
13385 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013386 message.bodyptr = req_msg;
13387 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13388 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013389 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013390 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013391 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013392 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013393 }
13394 sme_release_global_lock(&mac->sme);
13395
13396 return status;
13397}
13398
13399/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013400 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013401 * @hal: Handle returned by macOpen
13402 * @msg: HW mode structure containing hw mode and callback details
13403 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013404 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013405 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013406 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013407QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013408{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013409 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013410 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013411 tSmeCmd *cmd = NULL;
13412
13413 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013414 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013415 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013416 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013417 }
13418
Krunal Soni78618d92017-02-14 21:46:31 -080013419 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013420 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013421 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013422 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013423 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013424 }
13425
13426 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013427 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013428 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13429 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013430 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13431 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013432 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013433 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013434
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013435 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013436 cmd->u.set_hw_mode_cmd.session_id,
13437 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013438 csr_queue_sme_command(mac, cmd, false);
13439
13440 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013441 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013442}
13443
13444/**
13445 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13446 * @hal: Handle returned by macOpen
13447 * @callback: HDD callback to be registered
13448 *
13449 * Registers the HDD callback with SME. This callback will be invoked when
13450 * HW mode transition event is received from the FW
13451 *
13452 * Return: None
13453 */
13454void sme_register_hw_mode_trans_cb(tHalHandle hal,
13455 hw_mode_transition_cb callback)
13456{
13457 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13458
13459 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460}
13461
13462/**
13463 * sme_nss_update_request() - Send beacon templete update to FW with new
13464 * nss value
13465 * @hal: Handle returned by macOpen
13466 * @vdev_id: the session id
13467 * @new_nss: the new nss value
13468 * @cback: hdd callback
13469 * @next_action: next action to happen at policy mgr after beacon update
13470 *
13471 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013472 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013473 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013474QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13475 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13476 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13477 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013479 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013480 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013481 tSmeCmd *cmd = NULL;
13482
13483 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013484 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013485 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013486 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013487 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013488 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013489 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013490 }
13491 cmd->command = e_sme_command_nss_update;
13492 /* Sessionized modules may require this info */
13493 cmd->sessionId = vdev_id;
13494 cmd->u.nss_update_cmd.new_nss = new_nss;
13495 cmd->u.nss_update_cmd.session_id = vdev_id;
13496 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013497 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013498 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013499 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013500
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013501 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013502 csr_queue_sme_command(mac, cmd, false);
13503 sme_release_global_lock(&mac->sme);
13504 }
13505 return status;
13506}
13507
13508/**
13509 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13510 * @hal: Handle returned by macOpen
13511 * @msg: Structure containing the dual mac config parameters
13512 *
13513 * Queues configuration information to CSR to configure
13514 * WLAN firmware for the dual MAC features
13515 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013516 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013517 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013518QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013519{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013520 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013521 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013522 tSmeCmd *cmd;
13523
13524 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013525 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013526 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013527 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013528 }
13529
Krunal Soni78618d92017-02-14 21:46:31 -080013530 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013531 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013532 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013533 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013534 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013535 }
13536
13537 cmd->command = e_sme_command_set_dual_mac_config;
13538 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13539 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13540 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13541
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013542 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013543 cmd->u.set_dual_mac_cmd.scan_config,
13544 cmd->u.set_dual_mac_cmd.fw_mode_config);
13545 csr_queue_sme_command(mac, cmd, false);
13546
13547 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013549}
13550
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013551#ifdef FEATURE_LFR_SUBNET_DETECTION
13552/**
13553 * sme_gateway_param_update() - to update gateway parameters with WMA
13554 * @Hal: hal handle
13555 * @gw_params: request parameters from HDD
13556 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013557 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013558 *
13559 * This routine will update gateway parameters to WMA
13560 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013561QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013562 struct gateway_param_update_req *gw_params)
13563{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013564 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013565 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013566 struct gateway_param_update_req *request_buf;
13567
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013568 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013569 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013570 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013571 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013572 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013573 }
13574
13575 *request_buf = *gw_params;
13576
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013577 message.type = WMA_GW_PARAM_UPDATE_REQ;
13578 message.reserved = 0;
13579 message.bodyptr = request_buf;
13580 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013581 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013582 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013583 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013584 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013585 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013586 }
13587
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013588 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013589}
13590#endif /* FEATURE_LFR_SUBNET_DETECTION */
13591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013592/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013593 * sme_soc_set_antenna_mode() - set antenna mode
13594 * @hal: Handle returned by macOpen
13595 * @msg: Structure containing the antenna mode parameters
13596 *
13597 * Send the command to CSR to send
13598 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13599 *
13600 * Return: QDF_STATUS
13601 */
13602QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13603 struct sir_antenna_mode_param *msg)
13604{
13605 QDF_STATUS status = QDF_STATUS_SUCCESS;
13606 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13607 tSmeCmd *cmd;
13608
13609 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013610 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013611 return QDF_STATUS_E_FAILURE;
13612 }
13613
13614 status = sme_acquire_global_lock(&mac->sme);
13615 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013616 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013617 return QDF_STATUS_E_RESOURCES;
13618 }
13619
Krunal Soni78618d92017-02-14 21:46:31 -080013620 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013621 if (!cmd) {
13622 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013623 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013624 return QDF_STATUS_E_NULL_VALUE;
13625 }
13626
13627 cmd->command = e_sme_command_set_antenna_mode;
13628 cmd->u.set_antenna_mode_cmd = *msg;
13629
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013630 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013631 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13632 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13633
13634 csr_queue_sme_command(mac, cmd, false);
13635 sme_release_global_lock(&mac->sme);
13636
13637 return QDF_STATUS_SUCCESS;
13638}
13639
13640/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013641 * sme_set_peer_authorized() - call peer authorized callback
13642 * @peer_addr: peer mac address
13643 * @auth_cb: auth callback
13644 * @vdev_id: vdev id
13645 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013646 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013648QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013649 sme_peer_authorized_fp auth_cb,
13650 uint32_t vdev_id)
13651{
13652 void *wma_handle;
13653
Anurag Chouhan6d760662016-02-20 16:05:43 +053013654 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013655 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013658 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013659 }
13660
13661 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13662 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13663 1, vdev_id);
13664}
13665
13666/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013667 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013668 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013669 * @fcc_constraint: flag to enable/disable the constraint
13670 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013671 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013672 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013673 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013674QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13675 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013676{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013677 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13679
13680 status = sme_acquire_global_lock(&mac_ptr->sme);
13681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013682 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013683
13684 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13685 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013686 if (scan_pending)
13687 mac_ptr->scan.defer_update_channel_list = true;
13688 else
13689 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013690 }
13691
13692 sme_release_global_lock(&mac_ptr->sme);
13693 }
13694
13695 return status;
13696}
13697/**
13698 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13699 * @hal: Global MAC pointer
13700 *
13701 * Return: NULL.
13702 */
13703void sme_setdef_dot11mode(tHalHandle hal)
13704{
13705 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013707 csr_set_default_dot11_mode(mac_ctx);
13708}
13709
13710/**
13711 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13712 * params
13713 * @hal_handle - The handle returned by macOpen.
13714 * @session_id - Session Identifier
13715 * @notify_id - Identifies 1 of the 4 parameters to be modified
13716 * @val New value of the parameter
13717 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013718 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013719 * Other status means SME failed to update
13720 */
13721
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013722QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013723 uint8_t session_id,
13724 uint32_t notify_id,
13725 int32_t val)
13726{
13727 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013728 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013729 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013730 tpCsrNeighborRoamControlInfo nr_info = NULL;
13731 uint32_t reason = 0;
13732
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013733 if (session_id >= CSR_ROAM_SESSION_MAX) {
13734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13735 FL("Invalid sme session id: %d"), session_id);
13736 return QDF_STATUS_E_INVAL;
13737 }
13738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013739 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013740 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013741 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13742 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13743 switch (notify_id) {
13744 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013746 "%s: gRoamScanHirssiMaxCount %d => %d",
13747 __func__, nr_config->nhi_rssi_scan_max_count,
13748 val);
13749 nr_config->nhi_rssi_scan_max_count = val;
13750 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13751 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13752 break;
13753
13754 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013755 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013756 FL("gRoamScanHiRssiDelta %d => %d"),
13757 nr_config->nhi_rssi_scan_rssi_delta,
13758 val);
13759 nr_config->nhi_rssi_scan_rssi_delta = val;
13760 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13761 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13762 break;
13763
13764 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013765 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013766 FL("gRoamScanHiRssiDelay %d => %d"),
13767 nr_config->nhi_rssi_scan_delay,
13768 val);
13769 nr_config->nhi_rssi_scan_delay = val;
13770 nr_info->cfgParams.hi_rssi_scan_delay = val;
13771 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13772 break;
13773
13774 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013775 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013776 FL("gRoamScanHiRssiUpperBound %d => %d"),
13777 nr_config->nhi_rssi_scan_rssi_ub,
13778 val);
13779 nr_config->nhi_rssi_scan_rssi_ub = val;
13780 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13781 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13782 break;
13783
13784 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013786 FL("invalid parameter notify_id %d"),
13787 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013788 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013789 break;
13790 }
13791 sme_release_global_lock(&mac_ctx->sme);
13792 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013793 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013794 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013795 csr_roam_offload_scan(mac_ctx, session_id,
13796 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13797 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013798
13799 return status;
13800}
13801
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013802/**
13803 * sme_update_tgt_services() - update the target services config.
13804 * @hal: HAL pointer.
13805 * @cfg: wma_tgt_services parameters.
13806 *
13807 * update the target services config.
13808 *
13809 * Return: None.
13810 */
13811void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13812{
13813 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13814
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013815 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013816 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013817 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013819 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013820 mac_ctx->is_fils_roaming_supported =
13821 cfg->is_fils_roaming_supported;
13822 sme_debug("mac_ctx->pmf_offload: %d fils_roam support %d",
13823 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013824
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013825}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013826
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013827/**
13828 * sme_is_session_id_valid() - Check if the session id is valid
13829 * @hal: Pointer to HAL
13830 * @session_id: Session id
13831 *
13832 * Checks if the session id is valid or not
13833 *
13834 * Return: True is the session id is valid, false otherwise
13835 */
13836bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13837{
13838 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013839
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013840 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013841 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13842 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013843 return false;
13844 }
13845
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013846 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013847 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013848
13849 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013850}
13851
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013852#ifdef FEATURE_WLAN_TDLS
13853
13854/**
13855 * sme_get_opclass() - determine operating class
13856 * @hal: Pointer to HAL
13857 * @channel: channel id
13858 * @bw_offset: bandwidth offset
13859 * @opclass: pointer to operating class
13860 *
13861 * Function will determine operating class from regdm_get_opclass_from_channel
13862 *
13863 * Return: none
13864 */
13865void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13866 uint8_t *opclass)
13867{
13868 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13869
13870 /* redgm opclass table contains opclass for 40MHz low primary,
13871 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13872 * first we will check if bit for 40MHz is set and if so find
13873 * matching opclass either with low primary or high primary
13874 * (a channel would never be in both) and then search for opclass
13875 * matching 20MHz, else for any BW.
13876 */
13877 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013878 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013879 mac_ctx->scan.countryCodeCurrent,
13880 channel, BW40_LOW_PRIMARY);
13881 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013882 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013883 mac_ctx->scan.countryCodeCurrent,
13884 channel, BW40_HIGH_PRIMARY);
13885 }
13886 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013887 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013888 mac_ctx->scan.countryCodeCurrent,
13889 channel, BW20);
13890 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013891 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013892 mac_ctx->scan.countryCodeCurrent,
13893 channel, BWALL);
13894 }
13895}
13896#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013897
13898#ifdef FEATURE_GREEN_AP
13899/**
13900 * sme_send_egap_conf_params() - set the enhanced green ap configuration params
13901 * @enable: enable/disable the enhanced green ap feature
13902 * @inactivity_time: inactivity timeout value
13903 * @wait_time: wait timeout value
13904 * @flag: feature flag in bitmasp
13905 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013906 * Return: Return QDF_STATUS, otherwise appropriate failure code
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013907 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013908QDF_STATUS sme_send_egap_conf_params(uint32_t enable, uint32_t inactivity_time,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013909 uint32_t wait_time, uint32_t flags)
13910{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013911 struct scheduler_msg message = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013912 QDF_STATUS status;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013913 struct egap_conf_params *egap_params;
13914
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013915 egap_params = qdf_mem_malloc(sizeof(*egap_params));
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013916 if (NULL == egap_params) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013918 "%s: fail to alloc egap_params", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013919 return QDF_STATUS_E_NOMEM;
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013920 }
13921
13922 egap_params->enable = enable;
13923 egap_params->inactivity_time = inactivity_time;
13924 egap_params->wait_time = wait_time;
13925 egap_params->flags = flags;
13926
13927 message.type = WMA_SET_EGAP_CONF_PARAMS;
13928 message.bodyptr = egap_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013929 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013930 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013931 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013932 "%s: Not able to post msg to WMA!", __func__);
13933
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013934 qdf_mem_free(egap_params);
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013935 }
13936 return status;
13937}
13938#endif
Sandeep Puligillae0875662016-02-12 16:09:21 -080013939
13940/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013941 * sme_set_fw_test() - set fw test
13942 * @fw_test: fw test param
13943 *
13944 * Return: Return QDF_STATUS, otherwise appropriate failure code
13945 */
13946QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13947{
13948 void *wma_handle;
13949
13950 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13951 if (!wma_handle) {
13952 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13953 "wma handle is NULL");
13954 return QDF_STATUS_E_FAILURE;
13955 }
13956 wma_process_fw_test_cmd(wma_handle, fw_test);
13957 return QDF_STATUS_SUCCESS;
13958}
13959
13960/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013961 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13962 * @hal: mac handel
13963 * @vdev_id: vdev identifier
13964 *
13965 * Return: Return QDF_STATUS, otherwise appropriate failure code
13966 */
13967QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13968{
13969 void *wma_handle;
13970
13971 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13972 if (!wma_handle) {
13973 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13974 "wma handle is NULL");
13975 return QDF_STATUS_E_FAILURE;
13976 }
13977 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13978 return QDF_STATUS_SUCCESS;
13979}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013980
13981/**
13982 * sme_update_mimo_power_save() - Update MIMO power save
13983 * configuration
13984 * @hal: The handle returned by macOpen
13985 * @is_ht_smps_enabled: enable/disable ht smps
13986 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013987 * @send_smps_action: flag to send smps force mode command
13988 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013989 *
13990 * Return: QDF_STATUS if SME update mimo power save
13991 * configuration sucsess else failue status
13992 */
13993QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13994 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013995 uint8_t ht_smps_mode,
13996 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013997{
13998 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013999
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014000 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080014001 is_ht_smps_enabled, ht_smps_mode,
14002 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014003 mac_ctx->roam.configParam.enableHtSmps =
14004 is_ht_smps_enabled;
14005 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080014006 mac_ctx->roam.configParam.send_smps_action =
14007 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014008
14009 return QDF_STATUS_SUCCESS;
14010}
14011
14012/**
14013 * sme_is_sta_smps_allowed() - check if the supported nss for
14014 * the session is greater than 1x1 to enable sta SMPS
14015 * @hal: The handle returned by macOpen
14016 * @session_id: session id
14017 *
14018 * Return: bool returns true if supported nss is greater than
14019 * 1x1 else false
14020 */
14021bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
14022{
14023 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014024 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014025
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014026 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
14027 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014028 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053014029 return false;
14030 }
14031
14032 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014033 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080014034 return false;
14035 }
14036
14037 return (csr_session->supported_nss_1x1 == true) ? false : true;
14038}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014039
14040/**
14041 * sme_add_beacon_filter() - set the beacon filter configuration
14042 * @hal: The handle returned by macOpen
14043 * @session_id: session id
14044 * @ie_map: bitwise array of IEs
14045 *
14046 * Return: Return QDF_STATUS, otherwise appropriate failure code
14047 */
14048QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
14049 uint32_t session_id,
14050 uint32_t *ie_map)
14051{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014052 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014053 QDF_STATUS qdf_status;
14054 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14055 struct beacon_filter_param *filter_param;
14056
14057 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014058 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014059 return QDF_STATUS_E_FAILURE;
14060 }
14061
14062 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14063 if (NULL == filter_param) {
14064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14065 "%s: fail to alloc filter_param", __func__);
14066 return QDF_STATUS_E_FAILURE;
14067 }
14068
14069 filter_param->vdev_id = session_id;
14070
14071 qdf_mem_copy(filter_param->ie_map, ie_map,
14072 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
14073
14074 message.type = WMA_ADD_BCN_FILTER_CMDID;
14075 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014076 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014077 &message);
14078 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14079 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14080 "%s: Not able to post msg to WDA!",
14081 __func__);
14082
14083 qdf_mem_free(filter_param);
14084 }
14085 return qdf_status;
14086}
14087
14088/**
14089 * sme_remove_beacon_filter() - set the beacon filter configuration
14090 * @hal: The handle returned by macOpen
14091 * @session_id: session id
14092 *
14093 * Return: Return QDF_STATUS, otherwise appropriate failure code
14094 */
14095QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14096{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014097 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014098 QDF_STATUS qdf_status;
14099 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14100 struct beacon_filter_param *filter_param;
14101
14102 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014103 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014104 return QDF_STATUS_E_FAILURE;
14105 }
14106
14107 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14108 if (NULL == filter_param) {
14109 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14110 "%s: fail to alloc filter_param", __func__);
14111 return QDF_STATUS_E_FAILURE;
14112 }
14113
14114 filter_param->vdev_id = session_id;
14115
14116 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14117 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014118 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014119 &message);
14120 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14121 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14122 "%s: Not able to post msg to WDA!",
14123 __func__);
14124
14125 qdf_mem_free(filter_param);
14126 }
14127 return qdf_status;
14128}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014129
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014130/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014131 * sme_send_disassoc_req_frame - send disassoc req
14132 * @hal: handler to hal
14133 * @session_id: session id
14134 * @peer_mac: peer mac address
14135 * @reason: reason for disassociation
14136 * wait_for_ack: wait for acknowledgment
14137 *
14138 * function to send disassoc request to lim
14139 *
14140 * return: none
14141 */
14142void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14143 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14144{
14145 struct sme_send_disassoc_frm_req *msg;
14146 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14147 A_UINT8 *buf;
14148 A_UINT16 tmp;
14149
14150 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14151
14152 if (NULL == msg)
14153 qdf_status = QDF_STATUS_E_FAILURE;
14154 else
14155 qdf_status = QDF_STATUS_SUCCESS;
14156
14157 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14158 return;
14159
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014160 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14161
14162 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14163
14164 buf = &msg->session_id;
14165
14166 /* session id */
14167 *buf = (A_UINT8) session_id;
14168 buf += sizeof(A_UINT8);
14169
14170 /* transaction id */
14171 *buf = 0;
14172 *(buf + 1) = 0;
14173 buf += sizeof(A_UINT16);
14174
14175 /* Set the peer MAC address before sending the message to LIM */
14176 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14177
14178 buf += QDF_MAC_ADDR_SIZE;
14179
14180 /* reasoncode */
14181 tmp = (uint16_t) reason;
14182 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14183 buf += sizeof(uint16_t);
14184
14185 *buf = wait_for_ack;
14186 buf += sizeof(uint8_t);
14187
Rajeev Kumard138ac52017-01-30 18:38:37 -080014188 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014189
14190 if (qdf_status != QDF_STATUS_SUCCESS)
14191 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14192 FL("cds_send_mb_message Failed"));
14193}
14194
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014195QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14196 bpf_get_offload_cb callback,
14197 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014198{
14199 QDF_STATUS status = QDF_STATUS_SUCCESS;
14200 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014201 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014202
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014203 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014204
14205 status = sme_acquire_global_lock(&mac_ctx->sme);
14206 if (QDF_STATUS_SUCCESS == status) {
14207 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014208 mac_ctx->sme.bpf_get_offload_cb = callback;
14209 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014210 cds_msg.bodyptr = NULL;
14211 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014212 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014213 if (!QDF_IS_STATUS_SUCCESS(status)) {
14214 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14215 FL("Post bpf get offload msg fail"));
14216 status = QDF_STATUS_E_FAILURE;
14217 }
14218 sme_release_global_lock(&mac_ctx->sme);
14219 } else {
14220 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14221 FL("sme_acquire_global_lock error"));
14222 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014223 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014224 return status;
14225}
14226
14227
14228/**
14229 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14230 * @hal: HAL handle
14231 * @bpf_set_offload: struct to set bpf filter instructions.
14232 *
14233 * Return: QDF_STATUS enumeration.
14234 */
14235QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14236 struct sir_bpf_set_offload *req)
14237{
14238 QDF_STATUS status = QDF_STATUS_SUCCESS;
14239 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014240 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014241 struct sir_bpf_set_offload *set_offload;
14242
Arun Khandavallica198b52016-04-26 20:53:35 +053014243 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14244 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014245
14246 if (NULL == set_offload) {
14247 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14248 FL("Failed to alloc set_offload"));
14249 return QDF_STATUS_E_NOMEM;
14250 }
14251
14252 set_offload->session_id = req->session_id;
14253 set_offload->filter_id = req->filter_id;
14254 set_offload->current_offset = req->current_offset;
14255 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014256 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014257 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014258 set_offload->program = ((uint8_t *)set_offload) +
14259 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014260 qdf_mem_copy(set_offload->program, req->program,
14261 set_offload->current_length);
14262 }
14263 status = sme_acquire_global_lock(&mac_ctx->sme);
14264 if (QDF_STATUS_SUCCESS == status) {
14265 /* Serialize the req through MC thread */
14266 cds_msg.bodyptr = set_offload;
14267 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014268 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014269
14270 if (!QDF_IS_STATUS_SUCCESS(status)) {
14271 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14272 FL("Post BPF set offload msg fail"));
14273 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014274 qdf_mem_free(set_offload);
14275 }
14276 sme_release_global_lock(&mac_ctx->sme);
14277 } else {
14278 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14279 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014280 qdf_mem_free(set_offload);
14281 }
14282 return status;
14283}
14284
14285/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014286 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14287 * @hal: hal pointer
14288 *
14289 * Return: wni dot11 mode.
14290 */
14291uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14292{
14293 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14294
14295 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14296 mac_ctx->roam.configParam.uCfgDot11Mode);
14297}
14298
14299/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014300 * sme_create_mon_session() - post message to create PE session for monitormode
14301 * operation
14302 * @hal_handle: Handle to the HAL
14303 * @bssid: pointer to bssid
14304 *
14305 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14306 */
14307QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14308{
14309 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14310 struct sir_create_session *msg;
14311
14312 msg = qdf_mem_malloc(sizeof(*msg));
14313 if (NULL != msg) {
14314 msg->type = eWNI_SME_MON_INIT_SESSION;
14315 msg->msg_len = sizeof(*msg);
14316 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014317 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014318 }
14319 return status;
14320}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014321
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014322void sme_set_chan_info_callback(tHalHandle hal_handle,
14323 void (*callback)(struct scan_chan_info *chan_info))
14324{
14325 tpAniSirGlobal mac;
14326
14327 if (hal_handle == NULL) {
14328 QDF_ASSERT(0);
14329 return;
14330 }
14331 mac = PMAC_STRUCT(hal_handle);
14332 mac->chan_info_cb = callback;
14333}
14334
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014335/**
14336 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14337 * @hal: The handle returned by macOpen
14338 * @params: adaptive_dwelltime_params config
14339 *
14340 * Return: QDF_STATUS if adaptive dwell time update
14341 * configuration sucsess else failure status
14342 */
14343QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14344 struct adaptive_dwelltime_params *params)
14345{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014346 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014347 QDF_STATUS status;
14348 struct adaptive_dwelltime_params *dwelltime_params;
14349
14350 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14351 if (NULL == dwelltime_params) {
14352 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14353 "%s: fail to alloc dwelltime_params", __func__);
14354 return QDF_STATUS_E_NOMEM;
14355 }
14356
14357 dwelltime_params->is_enabled = params->is_enabled;
14358 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14359 dwelltime_params->lpf_weight = params->lpf_weight;
14360 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14361 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14362
14363 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14364 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014365 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014366 if (!QDF_IS_STATUS_SUCCESS(status)) {
14367 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14368 "%s: Not able to post msg to WMA!", __func__);
14369
14370 qdf_mem_free(dwelltime_params);
14371 }
14372 return status;
14373}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014374
14375/**
14376 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14377 * @hal: Pointer to HAL
14378 * @vdev_id: vdev_id for which IE is targeted
14379 *
14380 * Return: None
14381 */
14382void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14383{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014384 struct sir_set_vdev_ies_per_band *p_msg;
14385 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14386
14387 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14388 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014389 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014390 return;
14391 }
14392
14393 p_msg->vdev_id = vdev_id;
14394 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14395 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014396 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014397 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014398 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014399 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014400 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014401}
14402
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014403/**
14404 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14405 * @hal: Pointer to HAL
14406 * @enable2x2: 1x1 or 2x2 mode.
14407 *
14408 * Sends the set pdev IE req with Nss value.
14409 *
14410 * Return: None
14411 */
14412void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14413{
14414 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14415 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14416 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14417
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014418 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14419 eCSR_CFG_DOT11_MODE_AUTO) ||
14420 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14421 eCSR_CFG_DOT11_MODE_11N) ||
14422 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14423 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14424 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14425 eCSR_CFG_DOT11_MODE_11AC) ||
14426 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14427 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14428 return;
14429
14430 status = sme_acquire_global_lock(&mac_ctx->sme);
14431 if (QDF_STATUS_SUCCESS == status) {
14432 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14433 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014434 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014435 sme_release_global_lock(&mac_ctx->sme);
14436 return;
14437 }
14438
14439 ht_vht_cfg->pdev_id = 0;
14440 if (enable2x2)
14441 ht_vht_cfg->nss = 2;
14442 else
14443 ht_vht_cfg->nss = 1;
14444 ht_vht_cfg->dot11mode =
14445 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14446 mac_ctx->roam.configParam.uCfgDot11Mode);
14447
14448 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14449 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014450 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14451 ht_vht_cfg->nss,
14452 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014453 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014454 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014455 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014456
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014457 sme_release_global_lock(&mac_ctx->sme);
14458 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014459}
14460
14461/**
14462 * sme_update_vdev_type_nss() - sets the nss per vdev type
14463 * @hal: Pointer to HAL
14464 * @max_supp_nss: max_supported Nss
14465 * @band: 5G or 2.4G band
14466 *
14467 * Sets the per band Nss for each vdev type based on INI and configured
14468 * chain mask value.
14469 *
14470 * Return: None
14471 */
14472void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
14473 uint32_t vdev_type_nss, eCsrBand band)
14474{
14475 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14476 struct vdev_type_nss *vdev_nss;
14477
14478 if (eCSR_BAND_5G == band)
14479 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14480 else
14481 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14482
14483 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14484 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14485 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14486 CFG_P2P_GO_NSS(vdev_type_nss));
14487 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14488 CFG_P2P_CLI_NSS(vdev_type_nss));
14489 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14490 CFG_P2P_DEV_NSS(vdev_type_nss));
14491 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14492 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14493 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14494
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014495 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 -070014496 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14497 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14498 vdev_nss->tdls, vdev_nss->ocb);
14499}
Peng Xu8fdaa492016-06-22 10:20:47 -070014500
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014501#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14502#define MAX_BSS_COLOR_VAL 63
14503#define MIN_BSS_COLOR_VAL 1
14504
14505QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14506 uint8_t bss_color)
14507
14508{
14509 struct sir_set_he_bss_color *bss_color_msg;
14510 uint8_t len;
14511
14512 if (!hal) {
14513 sme_err("Invalid hal pointer");
14514 return QDF_STATUS_E_FAULT;
14515 }
14516
14517 sme_debug("Set HE bss_color %d", bss_color);
14518
14519 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14520 sme_debug("Invalid HE bss_color %d", bss_color);
14521 return QDF_STATUS_E_INVAL;
14522 }
14523 len = sizeof(*bss_color_msg);
14524 bss_color_msg = qdf_mem_malloc(len);
14525 if (!bss_color_msg) {
14526 sme_err("mem alloc failed");
14527 return QDF_STATUS_E_NOMEM;
14528 }
14529 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14530 bss_color_msg->length = len;
14531 bss_color_msg->session_id = session_id;
14532 bss_color_msg->bss_color = bss_color;
14533 return umac_send_mb_message_to_mac(bss_color_msg);
14534}
14535#endif
14536
Peng Xu8fdaa492016-06-22 10:20:47 -070014537/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014538 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14539 * @hal: Pointer to HAL
14540 * @hw_dbs_capable: HW DBS capability
14541 *
14542 * Sets HW DBS capability based on INI and fw capability.
14543 *
14544 * Return: None
14545 */
14546void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14547{
14548 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014549
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014550 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14551}
14552
14553/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014554 * sme_register_p2p_lo_event() - Register for the p2p lo event
14555 * @hHal: reference to the HAL
14556 * @context: the context of the call
14557 * @callback: the callback to hdd
14558 *
14559 * This function registers the callback function for P2P listen
14560 * offload stop event.
14561 *
14562 * Return: none
14563 */
14564void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14565 p2p_lo_callback callback)
14566{
14567 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14568 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14569
14570 status = sme_acquire_global_lock(&pMac->sme);
14571 pMac->sme.p2p_lo_event_callback = callback;
14572 pMac->sme.p2p_lo_event_context = context;
14573 sme_release_global_lock(&pMac->sme);
14574}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014575
14576/**
14577 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14578 * @hal: The handle returned by macOpen
14579 * @session_id: session id
14580 * @dbg_args: args for mac pwr debug command
14581 * Return: Return QDF_STATUS, otherwise appropriate failure code
14582 */
14583QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14584 struct sir_mac_pwr_dbg_cmd*
14585 dbg_args)
14586{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014587 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014588 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14589 struct sir_mac_pwr_dbg_cmd *req;
14590 int i;
14591
14592 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014593 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014594 return QDF_STATUS_E_FAILURE;
14595 }
14596
14597 req = qdf_mem_malloc(sizeof(*req));
14598 if (NULL == req) {
14599 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14600 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14601 return QDF_STATUS_E_FAILURE;
14602 }
14603 req->module_id = dbg_args->module_id;
14604 req->pdev_id = dbg_args->pdev_id;
14605 req->num_args = dbg_args->num_args;
14606 for (i = 0; i < req->num_args; i++)
14607 req->args[i] = dbg_args->args[i];
14608
14609 message.type = SIR_HAL_POWER_DBG_CMD;
14610 message.bodyptr = req;
14611
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014612 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014613 (QDF_MODULE_ID_WMA, &message))) {
14614 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14615 "%s: Not able to post msg to WDA!",
14616 __func__);
14617 qdf_mem_free(req);
14618 }
14619 return QDF_STATUS_SUCCESS;
14620}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014621/**
14622 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014623 * @dev_mode: connection type.
14624 * @nss2g: Pointer to the 2G Nss parameter.
14625 * @nss5g: Pointer to the 5G Nss parameter.
14626 *
14627 * Fills the 2G and 5G Nss values based on connection type.
14628 *
14629 * Return: None
14630 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014631void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14632 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014633{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014634 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14635
14636 if (NULL == mac_ctx) {
14637 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14638 FL("Invalid MAC context"));
14639 return;
14640 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014641 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14642}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014643
14644/**
14645 * sme_update_sta_roam_policy() - update sta roam policy for
14646 * unsafe and DFS channels.
14647 * @hal_handle: hal handle for getting global mac struct
14648 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14649 * skipped or not
14650 * @skip_unsafe_channels: Param to tell if driver needs to
14651 * skip unsafe channels or not.
14652 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014653 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014654 *
14655 * sme_update_sta_roam_policy update sta rome policies to csr
14656 * this function will call csrUpdateChannelList as well
14657 * to include/exclude DFS channels and unsafe channels.
14658 *
14659 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14660 */
14661QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14662 enum sta_roam_policy_dfs_mode dfs_mode,
14663 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014664 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014665{
14666 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14667 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014668 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014669
14670 if (!mac_ctx) {
14671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14672 "%s: mac_ctx is null", __func__);
14673 return QDF_STATUS_E_FAILURE;
14674 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014675
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014676 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14677 if (!sme_config) {
14678 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14679 FL("failed to allocate memory for sme_config"));
14680 return QDF_STATUS_E_FAILURE;
14681 }
14682 qdf_mem_zero(sme_config, sizeof(*sme_config));
14683 sme_get_config_param(hal_handle, sme_config);
14684
14685 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014686 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014687 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014688 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014689 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014690 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014691
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014692 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014693
14694 status = csr_update_channel_list(mac_ctx);
14695 if (QDF_STATUS_SUCCESS != status) {
14696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14697 FL("failed to update the supported channel list"));
14698 }
14699 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14700 csr_roam_offload_scan(mac_ctx, session_id,
14701 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14702 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014703
14704 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014705 return status;
14706}
14707
14708/**
14709 * sme_enable_disable_chanavoidind_event - configure ca event ind
14710 * @hal: handler to hal
14711 * @set_value: enable/disable
14712 *
14713 * function to enable/disable chan avoidance indication
14714 *
14715 * Return: QDF_STATUS
14716 */
14717QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14718 uint8_t set_value)
14719{
14720 QDF_STATUS status;
14721 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014722 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014723
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014724 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014725 status = sme_acquire_global_lock(&mac_ctx->sme);
14726 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014727 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014728 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14729 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014730 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014731 sme_release_global_lock(&mac_ctx->sme);
14732 return status;
14733 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014734 return status;
14735}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014736
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014737/*
14738 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14739 * @hal: reference to the HAL
14740 * @session_id: current session ID
14741 * @ie_data: Pointer to Scan IE data
14742 * @ie_len: Length of @ie_data
14743 *
14744 * Return: QDF_STATUS
14745 */
14746QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14747 uint8_t *ie_data, uint16_t ie_len)
14748{
14749 QDF_STATUS status;
14750 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14751 struct hdd_default_scan_ie *set_ie_params;
14752
14753 status = sme_acquire_global_lock(&mac_ctx->sme);
14754 if (QDF_IS_STATUS_SUCCESS(status)) {
14755 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14756 if (!set_ie_params)
14757 status = QDF_STATUS_E_NOMEM;
14758 else {
14759 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14760 set_ie_params->length = sizeof(*set_ie_params);
14761 set_ie_params->session_id = session_id;
14762 set_ie_params->ie_len = ie_len;
14763 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014764 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014765 }
14766 sme_release_global_lock(&mac_ctx->sme);
14767 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014768 return status;
14769}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014770
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014771QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14772 struct sar_limit_cmd_params *sar_limit_cmd)
14773{
14774 void *wma_handle;
14775
14776 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14777 if (!wma_handle) {
14778 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14779 "wma handle is NULL");
14780 return QDF_STATUS_E_FAILURE;
14781 }
14782
14783 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14784}
14785
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053014786#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014787/**
14788 * sme_encrypt_decrypt_msg() - handles encrypt/decrypt mesaage
14789 * @hal: HAL handle
14790 * @encrypt_decrypt_params: struct to set encryption/decryption params.
14791 *
14792 * Return: QDF_STATUS enumeration.
14793 */
14794QDF_STATUS sme_encrypt_decrypt_msg(tHalHandle hal,
Jeff Johnsone8216e82017-01-26 15:54:51 -080014795 struct encrypt_decrypt_req_params *encrypt_decrypt_params,
14796 sme_encrypt_decrypt_callback callback,
14797 void *context)
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014798{
14799 QDF_STATUS status = QDF_STATUS_SUCCESS;
14800 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014801 struct scheduler_msg cds_msg = {0};
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014802 struct encrypt_decrypt_req_params *params;
14803 uint8_t *ptr;
14804
14805 ptr = qdf_mem_malloc(sizeof(*params) +
14806 encrypt_decrypt_params->data_len);
14807 if (ptr == NULL) {
14808 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014809 "Failed to alloc memory for encrypt/decrypt params");
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014810 return QDF_STATUS_E_NOMEM;
14811 }
14812
14813 params = (struct encrypt_decrypt_req_params *)ptr;
14814
14815 *params = *encrypt_decrypt_params;
14816
14817 if (params->data_len) {
14818 params->data = ptr + sizeof(*params);
14819
14820 qdf_mem_copy(params->data, encrypt_decrypt_params->data,
14821 params->data_len);
14822 }
14823
14824 status = sme_acquire_global_lock(&mac_ctx->sme);
14825 if (status == QDF_STATUS_SUCCESS) {
14826 /* Serialize the req through MC thread */
Jeff Johnsone8216e82017-01-26 15:54:51 -080014827 mac_ctx->sme.encrypt_decrypt_cb = callback;
14828 mac_ctx->sme.encrypt_decrypt_context = context;
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014829 cds_msg.bodyptr = params;
14830 cds_msg.type = WMA_ENCRYPT_DECRYPT_MSG;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014831 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014832
14833 if (!QDF_IS_STATUS_SUCCESS(status)) {
14834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14835 FL("Post encrypt/decrypt msg fail"));
14836 status = QDF_STATUS_E_FAILURE;
14837 qdf_mem_free(params);
14838 }
14839 sme_release_global_lock(&mac_ctx->sme);
14840 } else {
14841 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14842 FL("sme_acquire_global_lock failed"));
14843 qdf_mem_free(params);
14844 }
14845 return status;
14846
14847}
Padma, Santhosh Kumar72e7aec2016-10-12 17:23:44 +053014848#endif
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014849
Jeff Johnson6136fb92017-03-30 15:21:49 -070014850#ifdef WLAN_FEATURE_FIPS
14851QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14852 wma_fips_cb callback, void *context)
14853{
14854 void *wma_handle;
14855
14856 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14857 if (!wma_handle) {
14858 sme_err("wma handle is NULL");
14859 return QDF_STATUS_E_FAILURE;
14860 }
14861
14862 return wma_fips_request(wma_handle, param, callback, context);
14863}
14864#endif
14865
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014866QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14867{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014868 void *wma_handle;
14869
14870 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14871 if (!wma_handle) {
14872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14873 "wma_handle is NULL");
14874 return QDF_STATUS_E_FAILURE;
14875 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014876 if (QDF_STATUS_SUCCESS !=
14877 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14878 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14879 "%s: Failed to set cts2self for p2p GO to firmware",
14880 __func__);
14881 return QDF_STATUS_E_FAILURE;
14882 }
14883 return QDF_STATUS_SUCCESS;
14884}
Yingying Tang95409972016-10-20 15:16:15 +080014885
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014886/**
14887 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14888 * @hal: Handle returned by mac_open
14889 * @session_id: Session ID on which tx fail count needs to be updated to FW
14890 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14891 *
14892 * This function is used to set tx fail count threshold to firmware.
14893 * firmware will issue disocnnect with peer device once this threshold is
14894 * reached.
14895 *
14896 * Return: Return QDF_STATUS, otherwise appropriate failure code
14897 */
14898QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14899 uint8_t session_id, uint32_t tx_fail_count)
14900{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014901 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14902 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014903 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014904
14905 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14906 if (NULL == tx_fail_cnt) {
14907 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14908 "%s: fail to alloc filter_param", __func__);
14909 return QDF_STATUS_E_FAILURE;
14910 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014911 sme_debug("session_id: %d tx_fail_count: %d",
14912 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014913 tx_fail_cnt->session_id = session_id;
14914 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14915
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014916 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014917 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14918 msg.reserved = 0;
14919 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014920 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014921
14922 if (!QDF_IS_STATUS_SUCCESS(status)) {
14923 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014924 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014925 qdf_mem_free(tx_fail_cnt);
14926 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014927 return status;
14928}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014929
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014930QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14931 void (*cb)(void *, struct sir_lost_link_info *))
14932{
14933 QDF_STATUS status = QDF_STATUS_SUCCESS;
14934 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14935
14936 status = sme_acquire_global_lock(&mac->sme);
14937 if (QDF_IS_STATUS_SUCCESS(status)) {
14938 mac->sme.lost_link_info_cb = cb;
14939 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014940 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014941 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014942 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014943
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014944 return status;
14945}
Yingying Tang95409972016-10-20 15:16:15 +080014946
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014947#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014948bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014949{
14950 return roam_info->isESEAssoc;
14951}
Manjeet Singh2f785062017-03-08 18:14:18 +053014952#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014953/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014954 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014955 * params from ini.
14956 * @hal_handle: Handle returned by mac_open
14957 * @5g_pref_params: pref params from ini.
14958 *
14959 * Returns: None
14960 */
14961void sme_set_5g_band_pref(tHalHandle hal_handle,
14962 struct sme_5g_band_pref_params *pref_params)
14963{
14964
14965 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14966 struct roam_ext_params *roam_params;
14967 QDF_STATUS status = QDF_STATUS_SUCCESS;
14968
14969 if (!pref_params) {
14970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14971 "Invalid 5G pref params!");
14972 return;
14973 }
14974 status = sme_acquire_global_lock(&mac_ctx->sme);
14975 if (QDF_STATUS_SUCCESS == status) {
14976 roam_params = &mac_ctx->roam.configParam.roam_params;
14977 roam_params->raise_rssi_thresh_5g =
14978 pref_params->rssi_boost_threshold_5g;
14979 roam_params->raise_factor_5g =
14980 pref_params->rssi_boost_factor_5g;
14981 roam_params->max_raise_rssi_5g =
14982 pref_params->max_rssi_boost_5g;
14983 roam_params->drop_rssi_thresh_5g =
14984 pref_params->rssi_penalize_threshold_5g;
14985 roam_params->drop_factor_5g =
14986 pref_params->rssi_penalize_factor_5g;
14987 roam_params->max_drop_rssi_5g =
14988 pref_params->max_rssi_penalize_5g;
14989
14990 sme_release_global_lock(&mac_ctx->sme);
14991 } else
14992 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14993 "Unable to acquire global sme lock");
14994}
14995
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014996
14997bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14998{
14999 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053015000
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053015001 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
15002}
Yingying Tang95409972016-10-20 15:16:15 +080015003
15004#ifdef WLAN_FEATURE_WOW_PULSE
15005/**
15006 * sme_set_wow_pulse() - set wow pulse info
15007 * @wow_pulse_set_info: wow_pulse_mode structure pointer
15008 *
15009 * Return: QDF_STATUS
15010 */
15011QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
15012{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015013 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080015014 QDF_STATUS status;
15015 struct wow_pulse_mode *wow_pulse_set_cmd;
15016
15017 if (!wow_pulse_set_info) {
15018 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15019 "%s: invalid wow_pulse_set_info pointer", __func__);
15020 return QDF_STATUS_E_FAILURE;
15021 }
15022
15023 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
15024 if (NULL == wow_pulse_set_cmd) {
15025 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15026 "%s: fail to alloc wow_pulse_set_cmd", __func__);
15027 return QDF_STATUS_E_NOMEM;
15028 }
15029
15030 *wow_pulse_set_cmd = *wow_pulse_set_info;
15031
15032 message.type = WMA_SET_WOW_PULSE_CMD;
15033 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080015034 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080015035 &message);
15036 if (!QDF_IS_STATUS_SUCCESS(status)) {
15037 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15038 "%s: Not able to post msg to WDA!",
15039 __func__);
15040 qdf_mem_free(wow_pulse_set_cmd);
15041 status = QDF_STATUS_E_FAILURE;
15042 }
15043
15044 return status;
15045}
15046#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015047
15048/**
15049 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
15050 * different fields and IEs from bss descriptor.
15051 * @frame_buf: frame buffer to populate
15052 * @bss_descp: bss descriptor
15053 * @bssid: bssid of the beacon frame to populate
15054 * @ie_len: length of IE fields
15055 *
15056 * Return: None
15057 */
15058static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
15059 tSirBssDescription *bss_descp,
15060 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080015061 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015062{
15063 tDot11fBeacon1 *bcn_fixed;
15064 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
15065
15066 /* populate mac header first to indicate beacon */
15067 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15068 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
15069 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
15070 qdf_mem_copy((uint8_t *) mac_hdr->da,
15071 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
15072 sizeof(struct qdf_mac_addr));
15073 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15074 sizeof(struct qdf_mac_addr));
15075 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15076 sizeof(struct qdf_mac_addr));
15077
15078 /* now populate fixed params */
15079 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15080 /* populate timestamp */
15081 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15082 sizeof(bss_descp->timeStamp));
15083 /* populate beacon interval */
15084 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15085 /* populate capability */
15086 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15087 sizeof(bss_descp->capabilityInfo));
15088
15089 /* copy IEs now */
15090 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15091 + SIR_MAC_B_PR_SSID_OFFSET,
15092 &bss_descp->ieFields, ie_len);
15093}
15094
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015095QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
15096 tCsrRoamProfile *profile,
15097 const uint8_t *bssid,
15098 int8_t *rssi, int8_t *snr)
15099{
15100 tSirBssDescription *bss_descp;
15101 tCsrScanResultFilter *scan_filter;
15102 struct scan_result_list *bss_list;
15103 tScanResultHandle result_handle = NULL;
15104 QDF_STATUS status = QDF_STATUS_SUCCESS;
15105 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15106
15107 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15108 if (NULL == scan_filter) {
15109 sme_err("memory allocation failed");
15110 status = QDF_STATUS_E_NOMEM;
15111 goto free_scan_flter;
15112 }
15113
15114 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15115 profile, scan_filter);
15116 if (QDF_STATUS_SUCCESS != status) {
15117 sme_err("prepare_filter failed");
15118 goto free_scan_flter;
15119 }
15120
15121 /* update filter to get scan result with just target BSSID */
15122 if (NULL == scan_filter->BSSIDs.bssid) {
15123 scan_filter->BSSIDs.bssid =
15124 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15125 if (scan_filter->BSSIDs.bssid == NULL) {
15126 sme_err("malloc failed");
15127 status = QDF_STATUS_E_NOMEM;
15128 goto free_scan_flter;
15129 }
15130 }
15131
15132 scan_filter->BSSIDs.numOfBSSIDs = 1;
15133 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15134 bssid, sizeof(struct qdf_mac_addr));
15135
15136 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15137 if (QDF_STATUS_SUCCESS != status) {
15138 sme_err("parse_scan_result failed");
15139 goto free_scan_flter;
15140 }
15141
15142 bss_list = (struct scan_result_list *)result_handle;
15143 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15144 if (!bss_descp) {
15145 sme_err("unable to fetch bss descriptor");
15146 status = QDF_STATUS_E_FAULT;
15147 goto free_scan_flter;
15148 }
15149
15150 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15151 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15152
15153 if (rssi)
15154 *rssi = bss_descp->rssi;
15155 if (snr)
15156 *snr = bss_descp->sinr;
15157
15158free_scan_flter:
15159 /* free scan filter and exit */
15160 if (scan_filter) {
15161 csr_free_scan_filter(mac_ctx, scan_filter);
15162 qdf_mem_free(scan_filter);
15163 }
15164
15165 if (result_handle)
15166 csr_scan_result_purge(mac_ctx, result_handle);
15167
15168 return status;
15169}
15170
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015171QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
15172 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015173 uint8_t **frame_buf, uint32_t *frame_len,
15174 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015175{
15176 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015177 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015178 tCsrScanResultFilter *scan_filter;
15179 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15180 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015181 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015182 uint32_t ie_len;
15183
15184 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15185 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015186 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015187 status = QDF_STATUS_E_NOMEM;
15188 goto free_scan_flter;
15189 }
15190 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15191 profile, scan_filter);
15192 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015193 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015194 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015195 goto free_scan_flter;
15196 }
15197
15198 /* update filter to get scan result with just target BSSID */
15199 if (NULL == scan_filter->BSSIDs.bssid) {
15200 scan_filter->BSSIDs.bssid =
15201 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15202 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015203 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015204 status = QDF_STATUS_E_NOMEM;
15205 goto free_scan_flter;
15206 }
15207 }
15208 scan_filter->BSSIDs.numOfBSSIDs = 1;
15209 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15210 bssid, sizeof(struct qdf_mac_addr));
15211
15212 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15213 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015214 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015215 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015216 goto free_scan_flter;
15217 }
15218
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015219 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015220 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015221 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015222 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015223 status = QDF_STATUS_E_FAULT;
15224 goto free_scan_flter;
15225 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015226
Naveen Rawat81f058c2017-06-02 16:02:39 -070015227 /**
15228 * Length of BSS descriptor is without length of
15229 * length itself and length of pointer that holds ieFields.
15230 *
15231 * tSirBssDescription
15232 * +--------+---------------------------------+---------------+
15233 * | length | other fields | pointer to IEs|
15234 * +--------+---------------------------------+---------------+
15235 * ^
15236 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015237 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015238 ie_len = bss_descp->length + sizeof(bss_descp->length)
15239 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015240 sme_debug("found bss_descriptor ie_len: %d channel %d",
15241 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015242
15243 /* include mac header and fixed params along with IEs in frame */
15244 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15245 *frame_buf = qdf_mem_malloc(*frame_len);
15246 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015247 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015248 status = QDF_STATUS_E_NOMEM;
15249 goto free_scan_flter;
15250 }
15251
15252 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15253
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015254 if (!*channel)
15255 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015256free_scan_flter:
15257 /* free scan filter and exit */
15258 if (scan_filter) {
15259 csr_free_scan_filter(mac_ctx, scan_filter);
15260 qdf_mem_free(scan_filter);
15261 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015262 if (result_handle)
15263 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015264
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015265 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015266}
15267
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015268QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15269 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015270 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015271{
15272 QDF_STATUS status;
15273 struct wma_roam_invoke_cmd *fastreassoc;
15274 struct scheduler_msg msg = {0};
15275
15276 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15277 if (NULL == fastreassoc) {
15278 sme_err("qdf_mem_malloc failed for fastreassoc");
15279 return QDF_STATUS_E_NOMEM;
15280 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015281 /* if both are same then set the flag */
15282 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15283 fastreassoc->is_same_bssid = true;
15284 sme_debug("bssid same, bssid[%pM]", bssid);
15285 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015286 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015287 fastreassoc->bssid[0] = bssid[0];
15288 fastreassoc->bssid[1] = bssid[1];
15289 fastreassoc->bssid[2] = bssid[2];
15290 fastreassoc->bssid[3] = bssid[3];
15291 fastreassoc->bssid[4] = bssid[4];
15292 fastreassoc->bssid[5] = bssid[5];
15293
15294 status = sme_get_beacon_frm(hal, profile, bssid,
15295 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015296 &fastreassoc->frame_len,
15297 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015298
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015299 if (!channel) {
15300 sme_err("channel retrieval from BSS desc fails!");
15301 qdf_mem_free(fastreassoc);
15302 return QDF_STATUS_E_FAULT;
15303 }
15304
15305 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015306 if (QDF_STATUS_SUCCESS != status) {
15307 sme_warn("sme_get_beacon_frm failed");
15308 fastreassoc->frame_buf = NULL;
15309 fastreassoc->frame_len = 0;
15310 }
15311
15312 msg.type = SIR_HAL_ROAM_INVOKE;
15313 msg.reserved = 0;
15314 msg.bodyptr = fastreassoc;
15315 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15316 if (QDF_STATUS_SUCCESS != status) {
15317 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15318 qdf_mem_free(fastreassoc);
15319 }
15320
15321 return status;
15322}
15323
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015324QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15325 tPmkidCacheInfo *pmk_cache_info,
15326 bool is_add)
15327{
15328 struct wmi_unified_pmk_cache *pmk_cache;
15329 struct scheduler_msg msg;
15330
15331 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15332 if (!pmk_cache) {
15333 sme_err("Memory allocation failure");
15334 return QDF_STATUS_E_NOMEM;
15335 }
15336
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015337 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15338
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015339 pmk_cache->session_id = session_id;
15340
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015341 if (!pmk_cache_info)
15342 goto send_flush_cmd;
15343
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015344 if (!pmk_cache_info->ssid_len) {
15345 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15346 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15347 &pmk_cache->bssid);
15348 } else {
15349 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15350 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15351 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15352 pmk_cache_info->ssid,
15353 pmk_cache->ssid.length);
15354 }
15355 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15356 pmk_cache_info->cache_id[1]);
15357
15358 if (is_add)
15359 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15360 else
15361 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15362
15363 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15364 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15365 CSR_RSN_PMKID_SIZE);
15366
15367 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15368 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15369 pmk_cache->pmk_len);
15370
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015371send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015372 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15373 msg.reserved = 0;
15374 msg.bodyptr = pmk_cache;
15375 if (QDF_STATUS_SUCCESS !=
15376 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15377 sme_err("Not able to post message to WDA");
15378 qdf_mem_free(pmk_cache);
15379 return QDF_STATUS_E_FAILURE;
15380 }
15381
15382 return QDF_STATUS_SUCCESS;
15383}
15384
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015385/* ARP DEBUG STATS */
15386
15387/**
15388 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15389 * @hal: handle to hal
15390 * @set_stats_param: pointer to set stats param
15391 *
15392 * Return: Return QDF_STATUS.
15393 */
15394QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15395 struct set_arp_stats_params
15396 *set_stats_param)
15397{
15398 struct set_arp_stats_params *arp_set_param;
15399 struct scheduler_msg msg;
15400
15401 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15402 if (arp_set_param == NULL) {
15403 sme_err("Memory allocation failure");
15404 return QDF_STATUS_E_NOMEM;
15405 }
15406
15407 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15408
15409 msg.type = WMA_SET_ARP_STATS_REQ;
15410 msg.reserved = 0;
15411 msg.bodyptr = arp_set_param;
15412
15413 if (QDF_STATUS_SUCCESS !=
15414 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15415 sme_err("Not able to post message to WDA");
15416 qdf_mem_free(arp_set_param);
15417 return QDF_STATUS_E_FAILURE;
15418 }
15419
15420 return QDF_STATUS_SUCCESS;
15421}
15422
15423/**
15424 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15425 * @hal: handle to hal
15426 * @get_stats_param: pointer to set stats param
15427 *
15428 * Return: Return QDF_STATUS.
15429 */
15430QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15431 struct get_arp_stats_params
15432 *get_stats_param)
15433{
15434 struct get_arp_stats_params *arp_get_param;
15435 struct scheduler_msg msg;
15436
15437 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15438 if (arp_get_param == NULL) {
15439 sme_err("Memory allocation failure");
15440 return QDF_STATUS_E_NOMEM;
15441 }
15442
15443 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15444
15445 msg.type = WMA_GET_ARP_STATS_REQ;
15446 msg.reserved = 0;
15447 msg.bodyptr = arp_get_param;
15448
15449 if (QDF_STATUS_SUCCESS !=
15450 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15451 sme_err("Not able to post message to WDA");
15452 qdf_mem_free(arp_get_param);
15453 return QDF_STATUS_E_FAILURE;
15454 }
15455
15456 return QDF_STATUS_SUCCESS;
15457}
15458
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015459QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15460 uint32_t param_value, uint32_t vdev_id)
15461{
15462 void *wma_handle;
15463
15464 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15465 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015466 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015467 return QDF_STATUS_E_FAILURE;
15468 }
15469
15470 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15471 param_value, vdev_id);
15472}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015473
15474QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015475 bool (*set_connection_info_cb)(bool),
15476 bool (*get_connection_info_cb)(uint8_t *session_id,
15477 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015478{
15479 QDF_STATUS status = QDF_STATUS_SUCCESS;
15480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15481
15482 status = sme_acquire_global_lock(&pMac->sme);
15483 if (QDF_IS_STATUS_SUCCESS(status)) {
15484 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015485 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015486 sme_release_global_lock(&pMac->sme);
15487 }
15488 return status;
15489}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015490
15491QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15492 void (*cb)(void *, struct rso_cmd_status *))
15493{
15494 QDF_STATUS status = QDF_STATUS_SUCCESS;
15495 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15496
15497 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015498 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015499 return status;
15500}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015501
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015502QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15503 struct wmi_dbs_scan_sel_params *params)
15504{
15505 struct scheduler_msg message = {0};
15506 QDF_STATUS status;
15507 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15508 uint32_t i;
15509
15510 if (0 == params->num_clients) {
15511 sme_err("Num of clients is 0");
15512 return QDF_STATUS_E_FAILURE;
15513 }
15514
15515 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15516 if (!dbs_scan_params) {
15517 sme_err("fail to alloc dbs_scan_params");
15518 return QDF_STATUS_E_NOMEM;
15519 }
15520
15521 dbs_scan_params->num_clients = params->num_clients;
15522 dbs_scan_params->pdev_id = params->pdev_id;
15523 for (i = 0; i < params->num_clients; i++) {
15524 dbs_scan_params->module_id[i] = params->module_id[i];
15525 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15526 dbs_scan_params->num_non_dbs_scans[i] =
15527 params->num_non_dbs_scans[i];
15528 }
15529 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15530 message.bodyptr = dbs_scan_params;
15531 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15532 if (!QDF_IS_STATUS_SUCCESS(status)) {
15533 sme_err("Not able to post msg to WMA!");
15534 qdf_mem_free(dbs_scan_params);
15535 }
15536
15537 return status;
15538}
15539
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015540QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15541{
15542 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15543 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
15544 struct scheduler_msg msg;
15545 struct sme_rcpi_req *rcpi_req;
15546
15547 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15548 if (rcpi_req == NULL) {
15549 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15550 "%s: Not able to allocate memory for rcpi req",
15551 __func__);
15552 return QDF_STATUS_E_NOMEM;
15553 }
15554 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15555
15556 status = sme_acquire_global_lock(&pMac->sme);
15557 if (QDF_IS_STATUS_SUCCESS(status)) {
15558 msg.bodyptr = rcpi_req;
15559 msg.type = WMA_GET_RCPI_REQ;
15560 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15561 sme_release_global_lock(&pMac->sme);
15562 if (!QDF_IS_STATUS_SUCCESS(status)) {
15563 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15564 FL("post get rcpi req failed"));
15565 status = QDF_STATUS_E_FAILURE;
15566 qdf_mem_free(rcpi_req);
15567 }
15568 } else {
15569 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15570 FL("sme_acquire_global_lock failed"));
15571 qdf_mem_free(rcpi_req);
15572 }
15573
15574 return status;
15575}
15576
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015577void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15578{
15579 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15580 void *wma_handle;
15581 QDF_STATUS status;
15582
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015583 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015584 if (QDF_STATUS_SUCCESS != status) {
15585 mac_ctx->pdev = NULL;
15586 return;
15587 }
15588 mac_ctx->pdev = pdev;
15589 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15590 if (!wma_handle) {
15591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015592 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015593 return;
15594 }
15595 wma_store_pdev(wma_handle, pdev);
15596}
15597
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015598QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15599 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15600{
15601 QDF_STATUS status;
15602 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15603
15604 status = sme_acquire_global_lock(&mac->sme);
15605 if (QDF_IS_STATUS_SUCCESS(status)) {
15606 mac->sme.congestion_cb = congestion_cb;
15607 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015608 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015609 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015610 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015611 }
15612
15613 return status;
15614}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015615
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015616QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15617 uint32_t param_val)
15618{
15619 return wma_configure_smps_params(vdev_id, param_id, param_val);
15620}
15621
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015622QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15623 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15624{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015625 wma_cli_set_cmd_t *iwcmd;
15626 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015627
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015628 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15629 if (!iwcmd) {
15630 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015631 return QDF_STATUS_E_NOMEM;
15632 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015633
15634 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15635 iwcmd->param_sec_value = 0;
15636 iwcmd->param_vdev_id = vdev_id;
15637 iwcmd->param_id = param_id;
15638 iwcmd->param_vp_dev = req_cat;
15639 iwcmd->param_value = param_val;
15640 wma_ipa_uc_stat_request(iwcmd);
15641 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015642
15643 return status;
15644}
lifeng66831662017-05-19 16:01:35 +080015645
15646QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15647 struct sir_set_rx_reorder_timeout_val *req)
15648{
15649 QDF_STATUS status;
15650
15651 status = wma_set_rx_reorder_timeout_val(hal, req);
15652
15653 return status;
15654}
15655
15656QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15657 struct sir_peer_set_rx_blocksize *req)
15658{
15659 QDF_STATUS status;
15660
15661 status = wma_set_rx_blocksize(hal, req);
15662
15663 return status;
15664}
Naveen Rawat247a8682017-06-05 15:00:31 -070015665
15666int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15667{
15668 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15669}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015670
15671QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15672 void (*cb)(void *, uint32_t bt_activity))
15673{
15674 QDF_STATUS status;
15675 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15676
15677 status = sme_acquire_global_lock(&mac->sme);
15678 if (QDF_IS_STATUS_SUCCESS(status)) {
15679 mac->sme.bt_activity_info_cb = cb;
15680 sme_release_global_lock(&mac->sme);
15681 sme_debug("bt activity info callback set");
15682 } else {
15683 sme_debug("sme_acquire_global_lock failed %d", status);
15684 }
15685
15686 return status;
15687}
lifengd217d192017-05-09 19:44:16 +080015688
15689QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15690 struct get_chain_rssi_req_params *input,
15691 get_chain_rssi_callback callback,
15692 void *context)
15693{
15694 QDF_STATUS status = QDF_STATUS_SUCCESS;
15695 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15696
15697 SME_ENTER();
15698
15699 if (NULL == input) {
15700 sme_err("Invalid req params");
15701 return QDF_STATUS_E_INVAL;
15702 }
15703
15704 mac_ctx->sme.get_chain_rssi_cb = callback;
15705 mac_ctx->sme.get_chain_rssi_context = context;
15706 wma_get_chain_rssi(hal, input);
15707
15708 SME_EXIT();
15709 return status;
15710}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015711
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015712QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15713 struct scheduler_msg *msg)
15714{
15715 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15716
15717 if (msg == NULL) {
15718 sme_err("Empty message for SME Msg callback");
15719 return status;
15720 }
15721 status = sme_process_msg(hal, msg);
15722 return status;
15723}
15724
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015725void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15726{
15727 struct csr_roam_session *session;
15728 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15729
15730 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15731 sme_err("%s Invalid session id: %d", __func__, session_id);
15732 return;
15733 }
15734
15735 session = CSR_GET_SESSION(mac_ctx, session_id);
15736 if (!session) {
15737 sme_err("%s Failed to get session for id: %d",
15738 __func__, session_id);
15739 return;
15740 }
15741
15742 sme_debug("Total No. of Disconnections: %d",
15743 session->disconnect_stats.disconnection_cnt);
15744
15745 sme_debug("No. of Diconnects Triggered by Application: %d",
15746 session->disconnect_stats.disconnection_by_app);
15747
15748 sme_debug("No. of Disassoc Sent by Peer: %d",
15749 session->disconnect_stats.disassoc_by_peer);
15750
15751 sme_debug("No. of Deauth Sent by Peer: %d",
15752 session->disconnect_stats.deauth_by_peer);
15753
15754 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15755 session->disconnect_stats.bmiss);
15756
15757 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15758 session->disconnect_stats.peer_kickout);
15759}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015760
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015761 /**
15762 * sme_set_vc_mode_config() - Set voltage corner config to FW
15763 * @bitmap: Bitmap that referes to voltage corner config with
15764 * different phymode and bw configuration
15765 *
15766 * Return: QDF_STATUS
15767 */
15768QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15769{
15770 void *wma_handle;
15771
15772 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15773 if (!wma_handle) {
15774 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15775 "wma_handle is NULL");
15776 return QDF_STATUS_E_FAILURE;
15777 }
15778 if (QDF_STATUS_SUCCESS !=
15779 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15781 "%s: Failed to set Voltage Control config to FW",
15782 __func__);
15783 return QDF_STATUS_E_FAILURE;
15784 }
15785 return QDF_STATUS_SUCCESS;
15786}
15787
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015788/**
15789 * sme_set_bmiss_bcnt() - set bmiss config parameters
15790 * @vdev_id: virtual device for the command
15791 * @first_cnt: bmiss first value
15792 * @final_cnt: bmiss final value
15793 *
15794 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15795 */
15796QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15797 uint32_t final_cnt)
15798{
15799 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15800}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015801
15802QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15803 bool is_tos_active, uint32_t max_off_chan_time,
15804 uint32_t rest_time, bool skip_dfs_chan)
15805{
15806 struct sir_limit_off_chan *cmd;
15807 struct scheduler_msg msg = {0};
15808
15809 cmd = qdf_mem_malloc(sizeof(*cmd));
15810 if (!cmd) {
15811 sme_err("qdf_mem_malloc failed for limit off channel");
15812 return QDF_STATUS_E_NOMEM;
15813 }
15814
15815 cmd->vdev_id = vdev_id;
15816 cmd->is_tos_active = is_tos_active;
15817 cmd->max_off_chan_time = max_off_chan_time;
15818 cmd->rest_time = rest_time;
15819 cmd->skip_dfs_chans = skip_dfs_chan;
15820
15821 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15822 msg.reserved = 0;
15823 msg.bodyptr = cmd;
15824
15825 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15826 &msg))) {
15827 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15828 qdf_mem_free(cmd);
15829 return QDF_STATUS_E_FAILURE;
15830 }
15831
15832 return QDF_STATUS_SUCCESS;
15833}