blob: 1e00d450c8d248e53ea25d334166e3c9b6acd37e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053028/*
29 * DOC: smeApi.c
30 *
31 * Definitions for SME APIs
32 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053034/* Include Files */
Srinivas Girigowda2c263352017-03-17 17:49:53 -070035#include <sir_common.h>
36#include <ani_global.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037#include "sme_api.h"
38#include "csr_inside_api.h"
39#include "sme_inside.h"
40#include "csr_internal.h"
41#include "wma_types.h"
42#include "wma_if.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070043#include "wma_fips_api.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053044#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "sme_trace.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053046#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053047#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sap_api.h"
50#include "mac_trace.h"
51#ifdef WLAN_FEATURE_NAN
52#include "nan_api.h"
53#endif
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055#include "cfg_api.h"
56#include "sme_power_save_api.h"
57#include "wma.h"
Naveen Rawatb4d37622015-11-13 16:15:25 -080058#include "sch_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070059#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053060#include "csr_api.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070061#include "wlan_reg_services_api.h"
Abhishek Singh158fe252017-03-23 11:09:34 +053062#include <wlan_scan_ucfg_api.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070063#include "wlan_reg_ucfg_api.h"
Arif Hussainee677012017-01-26 17:50:13 -080064#include "ol_txrx.h"
Naveen Rawatd2657be2017-10-10 14:31:23 -070065#include "wifi_pos_api.h"
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053066#include "net/cfg80211.h"
67#include <qca_vendor.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053071static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053073static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
74 void *pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053076static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053078static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 void *pMsgBuf);
80
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053081static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053084QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
86#endif
87
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053089static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 uint16_t msg_type, void *pMsgBuf);
91
92/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053093QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053095 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096
97 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053098 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053099 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530100 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101 }
102
103 return status;
104}
105
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530106QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530108 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109
110 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530111 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530112 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530113 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 }
115
116 return status;
117}
118
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700119tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700120{
121 tpAniSirGlobal mac_ctx;
122 tHalHandle h_hal;
123
124 h_hal = cds_get_context(QDF_MODULE_ID_SME);
125 if (NULL == h_hal) {
126 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
127 FL("invalid h_hal"));
128 return NULL;
129 }
130
131 mac_ctx = PMAC_STRUCT(h_hal);
132 if (NULL == mac_ctx) {
133 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
134 FL("Invalid MAC context"));
135 return NULL;
136 }
137
138 return mac_ctx;
139}
140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141/**
142 * sme_process_set_hw_mode_resp() - Process set HW mode response
143 * @mac: Global MAC pointer
144 * @msg: HW mode response
145 *
146 * Processes the HW mode response and invokes the HDD callback
147 * to process further
148 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530149static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150{
Krunal Sonia8270f52017-02-23 19:51:25 -0800151 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 tSmeCmd *command = NULL;
153 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800154 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 struct sir_set_hw_mode_resp *param;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530156 enum sir_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530157 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800158 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 param = (struct sir_set_hw_mode_resp *)msg;
161 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700162 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 /* Not returning. Need to check if active command list
164 * needs to be freed
165 */
166 }
167
Krunal Sonia8270f52017-02-23 19:51:25 -0800168 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700170 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800171 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 }
173
174 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
175 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700176 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 }
179
180 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700181 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800182 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 }
184
185 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530186 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800187 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530188
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700189 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530190 command->u.set_hw_mode_cmd.reason,
191 command->u.set_hw_mode_cmd.session_id);
192
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700193 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700194 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700195 goto end;
196 }
197
198 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700199 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700200 goto end;
201 }
202
203 /* Irrespective of the reason for which the hw mode change request
204 * was issued, the policy manager connection table needs to be updated
205 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
206 * set hw mode was successful.
207 */
208 callback(param->status,
209 param->cfgd_hw_mode_index,
210 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800211 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800212 command->u.set_hw_mode_cmd.next_action,
213 command->u.set_hw_mode_cmd.reason,
214 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800215 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800216 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
217 sme_err("session %d is invalid", session_id);
218 goto end;
219 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800220 session = CSR_GET_SESSION(mac, session_id);
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700221 if (reason == SIR_UPDATE_REASON_HIDDEN_STA) {
222 /* In the case of hidden SSID, connection update
223 * (set hw mode) is done after the scan with reason
224 * code eCsrScanForSsid completes. The connect/failure
225 * needs to be handled after the response of set hw
226 * mode
227 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800228 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700229 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800230 csr_scan_handle_search_for_ssid(mac,
231 session_id);
232 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700233 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800234 csr_scan_handle_search_for_ssid_failure(mac,
235 session_id);
236 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800237 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 }
239
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530240end:
Krunal Soni72dba662017-02-15 20:13:17 -0800241 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530243 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800245 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800246
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248}
249
250/**
251 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
252 * @mac: Global MAC pointer
253 * @msg: HW mode transition response
254 *
255 * Processes the HW mode transition indication and invoke the HDD callback
256 * to process further
257 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530258static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 uint8_t *msg)
260{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 struct sir_hw_mode_trans_ind *param;
262
263 param = (struct sir_hw_mode_trans_ind *)msg;
264 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700265 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530266 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 }
268
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800269 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800270 param->new_hw_mode_index,
271 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800272 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530274 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275}
276
Naveen Rawate7d86052015-11-13 12:01:43 -0800277/**
278 * free_sme_cmds() - This function frees memory allocated for SME commands
279 * @mac_ctx: Pointer to Global MAC structure
280 *
281 * This function frees memory allocated for SME commands
282 *
283 * @Return: void
284 */
285static void free_sme_cmds(tpAniSirGlobal mac_ctx)
286{
287 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530288
Naveen Rawate7d86052015-11-13 12:01:43 -0800289 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
290 return;
291
292 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530293 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800294
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530295 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800296 mac_ctx->sme.pSmeCmdBufAddr = NULL;
297}
298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530299static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530301 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 tSmeCmd *pCmd;
303 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800304 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
306 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530310 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 goto end;
312
Naveen Rawate7d86052015-11-13 12:01:43 -0800313 /* following pointer contains array of pointers for tSmeCmd* */
314 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530315 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800316 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530317 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800318 goto end;
319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530321 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800322 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
323 /*
324 * Since total size of all commands together can be huge chunk
325 * of memory, allocate SME cmd individually. These SME CMDs are
326 * moved between pending and active queues. And these freeing of
327 * these queues just manipulates the list but does not actually
328 * frees SME CMD pointers. Hence store each SME CMD address in
329 * the array, sme.pSmeCmdBufAddr. This will later facilitate
330 * freeing up of all SME CMDs with just a for loop.
331 */
332 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530333 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800334 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530335 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800336 free_sme_cmds(pMac);
337 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800339 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
340 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
341 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 }
343
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530345 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700346 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347
348 return status;
349}
350
Krunal Sonia8270f52017-02-23 19:51:25 -0800351void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352{
Krunal Sonia8270f52017-02-23 19:51:25 -0800353 sme_cmd->command = eSmeNoCommand;
354 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530355 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356}
357
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530358static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530360 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 csr_ll_close(&pMac->sme.smeCmdFreeList);
363
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530364 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530365 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700366 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 goto done;
368 }
369
Naveen Rawate7d86052015-11-13 12:01:43 -0800370 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530372 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530373 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700374 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375done:
376 return status;
377}
378
Jeff Johnson49c02f92016-10-07 10:29:09 -0700379static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380{
381 switch (pCmd->command) {
382 case eSmeCommandScan:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700383 sme_debug("scan command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 pCmd->u.scanCmd.reason);
385 break;
386
387 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700388 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 pCmd->u.roamCmd.roamReason);
390 break;
391
392 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700393 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 pCmd->u.wmStatusChangeCmd.Type);
395 break;
396
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700398 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 pCmd->command);
400 break;
401 }
402}
403
404tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
405{
406 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
407 tListElem *pEntry;
408 static int sme_command_queue_full;
409
410 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
411
412 /* If we can get another MS Msg buffer, then we are ok. Just link */
413 /* the entry onto the linked list. (We are using the linked list */
414 /* to keep track of tfhe message buffers). */
415 if (pEntry) {
416 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
417 /* reset when free list is available */
418 sme_command_queue_full = 0;
419 } else {
420 int idx = 1;
421
422 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800423 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530424 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530426
427 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
429 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530430 if (eSmeCsrCommandMask & pTempCmd->command)
431 /* CSR command is stuck. See what the reason
432 * code is for that command
433 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 } /* if(pTempCmd) */
436
437 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800438 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800440 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441 LL_ACCESS_NOLOCK);
442 while (pEntry && !sme_command_queue_full) {
443 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
444 /* Print only 1st five commands from pending queue. */
445 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530446 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 idx, pTempCmd->command);
448 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530449 if (eSmeCsrCommandMask & pTempCmd->command)
450 /* CSR command is stuck. See what the reason
451 * code is for that command
452 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800454 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 LL_ACCESS_NOLOCK);
456 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800457 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458
Abhishek Singh5ea86532016-04-27 14:10:53 +0530459 if (pMac->roam.configParam.enable_fatal_event)
460 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
461 WLAN_LOG_INDICATOR_HOST_DRIVER,
462 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
463 false,
464 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530465 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530466 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 }
468
469 /* memset to zero */
470 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530471 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530473 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 }
477
478 return pRetCmd;
479}
480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800482 * sme_ser_handle_active_cmd() - handle command activation callback from
483 * new serialization module
484 * @cmd: pointer to new serialization command
485 *
486 * This API is to handle command activation callback from new serialization
487 * callback
488 *
489 * Return: QDF_STATUS_SUCCESS
490 */
491static
492QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
493{
494 tSmeCmd *sme_cmd;
495 tHalHandle hal;
496 tpAniSirGlobal mac_ctx;
497 QDF_STATUS status = QDF_STATUS_SUCCESS;
498 bool do_continue;
499
500 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700501 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800502 return QDF_STATUS_E_FAILURE;
503 }
504
505 hal = cds_get_context(QDF_MODULE_ID_SME);
506 mac_ctx = PMAC_STRUCT(hal);
507 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700508 sme_err("No mac_ctx found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800509 return QDF_STATUS_E_FAILURE;
510 }
511 sme_cmd = cmd->umac_cmd;
512 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700513 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800514 return QDF_STATUS_E_FAILURE;
515 }
516
517 switch (sme_cmd->command) {
518 case eSmeCommandRoam:
519 status = csr_roam_process_command(mac_ctx, sme_cmd);
520 break;
521 case eSmeCommandWmStatusChange:
522 csr_roam_process_wm_status_change_command(mac_ctx,
523 sme_cmd);
524 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800525 case eSmeCommandNdpInitiatorRequest:
526 status = csr_process_ndp_initiator_request(mac_ctx, sme_cmd);
527 break;
528 case eSmeCommandNdpResponderRequest:
529 status = csr_process_ndp_responder_request(mac_ctx, sme_cmd);
530 break;
531 case eSmeCommandNdpDataEndInitiatorRequest:
532 status = csr_process_ndp_data_end_request(mac_ctx, sme_cmd);
533 break;
Krunal Soni81f068c2017-02-23 19:51:55 -0800534 case eSmeCommandScan:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700535 sme_debug("Processing scan offload cmd");
Krunal Soni81f068c2017-02-23 19:51:55 -0800536 qdf_mc_timer_start(&sme_cmd->u.scanCmd.csr_scan_timer,
537 CSR_ACTIVE_SCAN_LIST_CMD_TIMEOUT);
538 status = csr_process_scan_command(mac_ctx, sme_cmd);
539 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800540 /*
541 * Treat standby differently here because caller may not be able
542 * to handle the failure so we do our best here
543 */
544 case eSmeCommandEnterStandby:
545 break;
546 case eSmeCommandAddTs:
547 case eSmeCommandDelTs:
548#ifndef WLAN_MDM_CODE_REDUCTION_OPT
549 do_continue = qos_process_command(mac_ctx, sme_cmd);
550 if (do_continue)
551 status = QDF_STATUS_E_FAILURE;
552#endif
553 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800554 case e_sme_command_set_hw_mode:
555 csr_process_set_hw_mode(mac_ctx, sme_cmd);
556 break;
557 case e_sme_command_nss_update:
558 csr_process_nss_update_req(mac_ctx, sme_cmd);
559 break;
560 case e_sme_command_set_dual_mac_config:
561 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
562 break;
563 case e_sme_command_set_antenna_mode:
564 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
565 break;
566 default:
567 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700568 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800569 status = QDF_STATUS_E_FAILURE;
570 break;
571 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800572 return status;
573}
574
575QDF_STATUS sme_ser_cmd_callback(void *buf,
576 enum wlan_serialization_cb_reason reason)
577{
578 struct wlan_serialization_command *cmd = buf;
579 tHalHandle hal;
580 tpAniSirGlobal mac_ctx;
581 QDF_STATUS status = QDF_STATUS_SUCCESS;
582 tSmeCmd *sme_cmd;
583
584 hal = cds_get_context(QDF_MODULE_ID_SME);
585 mac_ctx = PMAC_STRUCT(hal);
586 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700587 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800588 return QDF_STATUS_E_FAILURE;
589 }
590 /*
591 * Do not acquire lock here as sme global lock is already acquired in
592 * caller or MC thread context
593 */
594 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700595 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800596 return QDF_STATUS_E_FAILURE;
597 }
598
599 switch (reason) {
600 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700601 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800602 status = sme_ser_handle_active_cmd(cmd);
603 break;
604 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700605 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800606 sme_cmd = cmd->umac_cmd;
607 csr_cancel_command(mac_ctx, sme_cmd);
Krunal Sonia8270f52017-02-23 19:51:25 -0800608 break;
609 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700610 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800611 sme_cmd = cmd->umac_cmd;
612 csr_release_command_buffer(mac_ctx, sme_cmd);
613 break;
614 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700615 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800616 break;
617 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700618 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800619 return QDF_STATUS_E_FAILURE;
620 }
621 return status;
622}
623
624/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530625 * sme_get_sessionid_from_activelist() - gets session id
626 * @mac: mac context
627 *
628 * This function is used to get session id from sme command
629 * active list
630 *
631 * Return: returns session id
632 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700633static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530634{
635 tListElem *entry;
636 tSmeCmd *command;
637 uint32_t session_id = CSR_SESSION_ID_INVALID;
638
Krunal Sonia8270f52017-02-23 19:51:25 -0800639 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530640 if (entry) {
641 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
642 session_id = command->sessionId;
643 }
644
645 return session_id;
646}
647
648/**
649 * sme_state_info_dump() - prints state information of sme layer
650 * @buf: buffer pointer
651 * @size: size of buffer to be filled
652 *
653 * This function is used to dump state information of sme layer
654 *
655 * Return: None
656 */
657static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
658{
659 uint32_t session_id, active_session_id;
660 tHalHandle hal;
661 tpAniSirGlobal mac;
662 uint16_t len = 0;
663 char *buf = *buf_ptr;
664 eCsrConnectState connect_state;
665
666 hal = cds_get_context(QDF_MODULE_ID_SME);
667 if (hal == NULL) {
668 QDF_ASSERT(0);
669 return;
670 }
671
672 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530673
674 active_session_id = sme_get_sessionid_from_activelist(mac);
675 if (active_session_id != CSR_SESSION_ID_INVALID) {
676 len += qdf_scnprintf(buf + len, *size - len,
677 "\n active command sessionid %d", active_session_id);
678 }
679
680 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
681 if (CSR_IS_SESSION_VALID(mac, session_id)) {
682 connect_state =
683 mac->roam.roamSession[session_id].connectState;
684 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
685 connect_state)
686 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
687 connect_state)) {
688 len += qdf_scnprintf(buf + len, *size - len,
689 "\n NeighborRoamState: %d",
690 mac->roam.neighborRoamInfo[session_id].
691 neighborRoamState);
692 len += qdf_scnprintf(buf + len, *size - len,
693 "\n RoamState: %d", mac->roam.
694 curState[session_id]);
695 len += qdf_scnprintf(buf + len, *size - len,
696 "\n RoamSubState: %d", mac->roam.
697 curSubState[session_id]);
698 len += qdf_scnprintf(buf + len, *size - len,
699 "\n ConnectState: %d",
700 connect_state);
701 }
702 }
703 }
704
705 *size -= len;
706 *buf_ptr += len;
707}
708
709/**
710 * sme_register_debug_callback() - registration function sme layer
711 * to print sme state information
712 *
713 * Return: None
714 */
715static void sme_register_debug_callback(void)
716{
717 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
718}
719
720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721/* Global APIs */
722
723/**
724 * sme_open() - Initialze all SME modules and put them at idle state
725 * @hHal: The handle returned by mac_open
726 *
727 * The function initializes each module inside SME, PMC, CSR, etc. Upon
728 * successfully return, all modules are at idle state ready to start.
729 * smeOpen must be called before any other SME APIs can be involved.
730 * smeOpen must be called after mac_open.
731 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530732 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 * Other status means SME is failed to be initialized
734 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530735QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530737 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
740 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530741 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530742 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700744 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530745 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 }
747 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530748 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700749 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 return status;
751 }
752
753 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530754 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700755 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 return status;
757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758
759#ifndef WLAN_MDM_CODE_REDUCTION_OPT
760 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530761 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700762 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 return status;
764 }
765#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530767 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530771 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700772 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 return status;
774 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530776 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700777 wlan_serialization_legacy_init_callback();
778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 return status;
780}
781
782/*
783 * sme_init_chan_list, triggers channel setup based on country code.
784 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530785QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700786 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787{
788 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
789
Amar Singhala297bfa2015-10-15 15:07:29 -0700790 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
792 pmac->roam.configParam.Is11dSupportEnabled = false;
793 }
794
795 return csr_init_chan_list(pmac, alpha2);
796}
797
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530798/*
799 * sme_set11dinfo() - Set the 11d information about valid channels
800 * and there power using information from nvRAM
801 * This function is called only for AP.
802 *
803 * This is a synchronous call
804 *
805 * hHal - The handle returned by mac_open.
806 * pSmeConfigParams - a pointer to a caller allocated object of
807 * typedef struct _smeConfigParams.
808 *
809 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
810 *
811 * Other status means SME is failed to update the config parameters.
812 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530814QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530816 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530818 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
820 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700821 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 return status;
823 }
824
825 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700826 if (!QDF_IS_STATUS_SUCCESS(status))
827 sme_err("csr_set_channels failed with status: %d", status);
828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 return status;
830}
831
832/**
833 * sme_set_scan_disable() - Dynamically enable/disable scan
834 * @h_hal: Handle to HAL
835 *
836 * This command gives the user an option to dynamically
837 * enable or disable scans.
838 *
839 * Return: None
840 */
841void sme_set_scan_disable(tHalHandle h_hal, int value)
842{
843 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530844
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700845 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530846 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530848/*
849 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
850 * This is a synchronous call
851 *
852 * hHal - The handle returned by HostapdAdapter.
853 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
854 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
855 * Other status means, failed to get the current regulatory domain.
856 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530858QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
859 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530861 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
863
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530864 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
866 NO_SESSION, 0));
867 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700868 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 return status;
870 }
871
872 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530873 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874
875 return status;
876}
877
Krunal Sonie3531942016-04-12 17:43:53 -0700878/**
879 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
880 * incoming val
881 * @hal: Handle for Hal layer
882 * @val: New FTM capability value
883 *
884 * Return: None
885 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530886void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
887 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700888{
889 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530890
Naveen Rawatd2657be2017-10-10 14:31:23 -0700891 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700892
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530893 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700894 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
895 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
896 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
897 } else {
898 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
899 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
900 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
901 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530902
903 /* Inform this RRM IE change to FW */
904 csr_roam_offload_scan(mac_ctx, session_id,
905 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
906 REASON_CONNECT_IES_CHANGED);
Krunal Sonie3531942016-04-12 17:43:53 -0700907}
908
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530909/*
910 * sme_update_config() - Change configurations for all SME moduels
911 * The function updates some configuration for modules in SME, CSR, etc
912 * during SMEs close open sequence.
913 * Modules inside SME apply the new configuration at the next transaction.
914 * This is a synchronous call
915 *
916 * hHal - The handle returned by mac_open.
917 * pSmeConfigParams - a pointer to a caller allocated object of
918 * typedef struct _smeConfigParams.
919 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
920 * Other status means SME is failed to update the config parameters.
921 */
922QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
923 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530925 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
927
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530928 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
930 0));
931 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700932 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 return status;
934 }
935
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530936 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
937 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530939 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700940 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530943 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
944 rrmConfig);
945
946 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700947 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530949
950 /* For SOC, CFG is set before start We don't want to apply global CFG
951 * in connect state because that may cause some side affect
952 */
953 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
956 /*
957 * If scan offload is enabled then lim has allow the sending of
958 * scan request to firmware even in powersave mode. The firmware has
959 * to take care of exiting from power save mode
960 */
961 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
962
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530963 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530964 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530966
967 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 return status;
970}
971
972/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530973 * sme_update_scan_roam_params() - Update the scan roaming params
974 * @mac_ctx: mac ctx
975 *
976 * Return: void.
977 */
978static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
979{
980 struct roam_filter_params scan_params = {0};
981 struct roam_ext_params *roam_params_src;
982 uint8_t i;
983 QDF_STATUS status;
984
985 roam_params_src = &mac_ctx->roam.configParam.roam_params;
986
987 scan_params.num_bssid_avoid_list =
988 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530989
990 if (scan_params.num_bssid_avoid_list >
991 MAX_AVOID_LIST_BSSID)
992 scan_params.num_bssid_avoid_list =
993 MAX_AVOID_LIST_BSSID;
994
995 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
996 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
997 &roam_params_src->bssid_avoid_list[i]);
998 }
999
1000 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
1001 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001002 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +05301003 status);
1004}
1005
1006/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 * sme_update_roam_params() - Store/Update the roaming params
1008 * @hal: Handle for Hal layer
1009 * @session_id: SME Session ID
1010 * @roam_params_src: The source buffer to copy
1011 * @update_param: Type of parameter to be updated
1012 *
1013 * Return: Return the status of the updation.
1014 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301015QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001016 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 int update_param)
1018{
1019 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1020 struct roam_ext_params *roam_params_dst;
1021 uint8_t i;
1022
1023 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1024 switch (update_param) {
1025 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1026 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001027 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001029 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001031 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001033 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001035 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001037 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001039 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 roam_params_dst->is_5g_pref_enabled = true;
1041 break;
1042 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301043 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1045 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001046 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1048 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001049 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001051 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 roam_params_dst->ssid_allowed_list[i].length);
1053 }
1054 break;
1055 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301056 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1058 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001059 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301061 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001062 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 sizeof(tSirMacAddr));
1064 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001065 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 }
1067 break;
1068 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301069 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301070 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001072 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301074 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001075 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 }
1077 break;
1078 case REASON_ROAM_GOOD_RSSI_CHANGED:
1079 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001080 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 break;
1082 default:
1083 break;
1084 }
1085 csr_roam_offload_scan(mac_ctx, session_id, ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1086 update_param);
Abhishek Singh158fe252017-03-23 11:09:34 +05301087
1088 sme_update_scan_roam_params(mac_ctx);
1089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 return 0;
1091}
1092
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301093/*
1094 * sme_process_ready_to_suspend() -
1095 * On getting ready to suspend indication, this function calls
1096 * callback registered (HDD callbacks) with SME to inform ready
1097 * to suspend indication.
1098 *
1099 * hHal - Handle returned by mac_open.
1100 * pReadyToSuspend - Parameter received along with ready to suspend
1101 * indication from WMA.
1102 * Return: None
1103 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001104static void sme_process_ready_to_suspend(tHalHandle hHal,
1105 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106{
1107 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1108
1109 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 "%s: pMac is null", __func__);
1112 return;
1113 }
1114
1115 if (NULL != pMac->readyToSuspendCallback) {
1116 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1117 pReadyToSuspend->suspended);
1118 pMac->readyToSuspendCallback = NULL;
1119 }
1120}
1121
1122#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001124/**
1125 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1126 * @hHal - Handle returned by mac_open.
1127 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1128 * indication from WMA.
1129 *
1130 * On getting ready to Ext WoW indication, this function calls callback
1131 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1132 *
1133 * Return: None
1134 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001135static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1136 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137{
1138 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1139
1140 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 "%s: pMac is null", __func__);
1143 return;
1144 }
1145
1146 if (NULL != pMac->readyToExtWoWCallback) {
1147 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1148 pReadyToExtWoW->status);
1149 pMac->readyToExtWoWCallback = NULL;
1150 pMac->readyToExtWoWContext = NULL;
1151 }
1152
1153}
1154#endif
1155
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301156/*
1157 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1158 * that the NIC is ready tio run.
1159 * The function is called by HDD at the end of initialization stage so PE/HAL
1160 * can enable the NIC to running state.
1161 * This is a synchronous call
1162 *
1163 * @hHal - The handle returned by mac_open.
1164 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1165 * successfully.
1166 * Other status means SME failed to send the message to PE.
1167 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301168QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169{
Abhishek Singhde410b72017-05-22 15:25:39 +05301170 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301171 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1173
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301174 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1176 do {
1177
Abhishek Singhde410b72017-05-22 15:25:39 +05301178 msg = qdf_mem_malloc(sizeof(*msg));
1179 if (!msg) {
1180 sme_err("Memory allocation failed! for msg");
1181 return QDF_STATUS_E_NOMEM;
1182 }
1183 msg->messageType = eWNI_SME_SYS_READY_IND;
1184 msg->length = sizeof(*msg);
1185 msg->add_bssdescr_cb = csr_scan_process_single_bssdescr;
1186 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001187 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301189 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1190 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301191 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001193 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 break;
1195 }
1196
1197 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301198 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001199 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 break;
1201 }
1202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 pMac->sme.state = SME_STATE_READY;
1204 } while (0);
1205
1206 return status;
1207}
1208
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001209QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1210{
1211 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1212 QDF_STATUS status = QDF_STATUS_SUCCESS;
1213
1214 if (NULL == mac_ctx) {
1215 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1216 FL("Invalid MAC context"));
1217 return QDF_STATUS_E_FAILURE;
1218 }
1219
1220 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1221 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1222 status = QDF_STATUS_E_INVAL;
1223
1224 return status;
1225}
1226
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301227/*
1228 * sme_start() - Put all SME modules at ready state.
1229 * The function starts each module in SME, PMC, CSR, etc. . Upon
1230 * successfully return, all modules are ready to run.
1231 * This is a synchronous call
1232 *
1233 * hHal - The handle returned by mac_open.
1234 * Return QDF_STATUS_SUCCESS - SME is ready.
1235 * Other status means SME is failed to start
1236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301237QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301239 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001241 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
1243 do {
1244 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301245 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001246 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 break;
1248 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001249 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001250 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001251 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1252 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1253 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1254 sme_cbacks.sme_soc_set_dual_mac_config =
1255 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001256 sme_cbacks.sme_change_mcc_beacon_interval =
1257 sme_change_mcc_beacon_interval;
1258 sme_cbacks.sme_get_ap_channel_from_scan =
1259 sme_get_ap_channel_from_scan;
1260 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001261 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1262 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001263 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001264 status);
1265 break;
1266 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001269 /* START RRM */
1270 status = rrm_start(pMac);
1271 if (!QDF_IS_STATUS_SUCCESS(status)) {
1272 sme_err("Failed to start RRM");
1273 break;
1274 }
1275 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 return status;
1277}
1278
Arif Hussaincd151632017-02-11 16:57:19 -08001279static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1280 struct scheduler_msg *msg)
1281{
1282 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001283 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001284 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1285 uint32_t session_id = 0;
1286 eRoamCmdStatus roam_status;
1287 eCsrRoamResult roam_result;
1288
1289 switch (msg->type) {
1290 case eWNI_SME_DFS_RADAR_FOUND:
1291 {
1292 session_id = msg->bodyval;
1293 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1294 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301295 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001296 "sapdfs: Radar indication event occurred");
1297 break;
1298 }
1299 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1300 {
1301 csa_ie_tx_complete_rsp =
1302 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1303 if (!csa_ie_tx_complete_rsp) {
1304 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1305 return QDF_STATUS_E_FAILURE;
1306 }
1307 session_id = csa_ie_tx_complete_rsp->sessionId;
1308 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1309 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301310 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001311 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1312 session_id);
1313 break;
1314 }
1315 case eWNI_SME_DFS_CAC_COMPLETE:
1316 {
1317 session_id = msg->bodyval;
1318 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1319 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301320 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001321 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1322 session_id);
1323 break;
1324 }
1325 default:
1326 {
1327 sme_err("Invalid DFS message: 0x%x", msg->type);
1328 status = QDF_STATUS_E_FAILURE;
1329 return status;
1330 }
1331 }
1332
1333 /* Indicate Radar Event to SAP */
1334 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1335 roam_status, roam_result);
1336 return status;
1337}
1338
1339
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301341/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 * Handle the unprotected management frame indication from LIM and
1343 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301344 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301345QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1347{
1348 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301349 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001350 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1352
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001353 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1354 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1355 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356
1357 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001358 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1360
1361 return status;
1362}
1363#endif
1364
Kapil Gupta8878ad92017-02-13 11:56:04 +05301365QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1366{
1367 QDF_STATUS status = QDF_STATUS_SUCCESS;
1368 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001369 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301370 eRoamCmdStatus roamStatus;
1371 eCsrRoamResult roamResult;
1372
1373 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001374 if (!roamInfo) {
1375 sme_err("mem alloc failed for roam info");
1376 return QDF_STATUS_E_FAILURE;
1377 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301378 roamInfo->dfs_event.sessionId = session_id;
1379
1380 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1381 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301382 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301383 "sapdfs: Updated new channel event");
1384
1385 /* Indicate channel Event to SAP */
1386 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1387 roamStatus, roamResult);
1388
1389 qdf_mem_free(roamInfo);
1390 return status;
1391}
1392
1393
Abhishek Singh518323d2015-10-19 17:42:01 +05301394/**
1395 * sme_extended_change_channel_ind()- function to indicate ECSA
1396 * action frame is received in lim to SAP
1397 * @mac_ctx: pointer to global mac structure
1398 * @msg_buf: contain new channel and session id.
1399 *
1400 * This function is called to post ECSA action frame
1401 * receive event to SAP.
1402 *
1403 * Return: success if msg indicated to SAP else return failure
1404 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301405static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301406 void *msg_buf)
1407{
1408 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301409 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301410 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001411 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301412 eRoamCmdStatus roam_status;
1413 eCsrRoamResult roam_result;
1414
Abhishek Singh518323d2015-10-19 17:42:01 +05301415 ext_chan_ind = msg_buf;
1416 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001417 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301418 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301419 }
1420 session_id = ext_chan_ind->session_id;
1421 roamInfo.target_channel = ext_chan_ind->new_channel;
1422 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1423 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001424 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1425 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301426
1427 /* Indicate Ext Channel Change event to SAP */
1428 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1429 roam_status, roam_result);
1430 return status;
1431}
1432
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001433#ifdef FEATURE_WLAN_ESE
1434/**
1435 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1436 * @hHal: HAL handle
1437 * @sessionId: session id
1438 * @isEseIniFeatureEnabled: ese ini enabled
1439 *
1440 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1441 * isEseIniFeatureEnabled. This is a synchronous call
1442 *
1443 * Return: QDF_STATUS enumeration
1444 */
1445QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1446 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1447{
1448 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1449
1450 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1451 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301452 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001453 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1454 __func__,
1455 pMac->roam.configParam.isEseIniFeatureEnabled,
1456 isEseIniFeatureEnabled);
1457 return QDF_STATUS_SUCCESS;
1458 }
1459
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301460 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001461 "%s: EseEnabled is changed from %d to %d", __func__,
1462 pMac->roam.configParam.isEseIniFeatureEnabled,
1463 isEseIniFeatureEnabled);
1464 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001465 csr_neighbor_roam_update_fast_roaming_enabled(
1466 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001467
1468 if (true == isEseIniFeatureEnabled)
1469 sme_update_fast_transition_enabled(hHal, true);
1470
1471 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1472 csr_roam_offload_scan(pMac, sessionId,
1473 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1474 REASON_ESE_INI_CFG_CHANGED);
1475
1476 return QDF_STATUS_SUCCESS;
1477}
1478
1479/**
1480 * sme_set_plm_request() - set plm request
1481 * @hHal: HAL handle
1482 * @pPlmReq: Pointer to input plm request
1483 *
1484 * Return: QDF_STATUS enumeration
1485 */
1486QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1487{
1488 QDF_STATUS status;
1489 bool ret = false;
1490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001491 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001492 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001493 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301494 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1495 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001496
1497 status = sme_acquire_global_lock(&pMac->sme);
1498 if (!QDF_IS_STATUS_SUCCESS(status))
1499 return status;
1500
1501 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001502 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001503 sme_release_global_lock(&pMac->sme);
1504 return QDF_STATUS_E_FAILURE;
1505 }
1506
1507 if (!pSession->sessionActive) {
1508 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1509 FL("Invalid Sessionid"));
1510 sme_release_global_lock(&pMac->sme);
1511 return QDF_STATUS_E_FAILURE;
1512 }
1513
1514 if (!pPlmReq->enable)
1515 goto send_plm_start;
1516 /* validating channel numbers */
1517 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1518 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1519 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001520 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1521 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001522 pPlmReq->plmChList[count])) {
1523 /* DFS channel is provided, no PLM bursts can be
1524 * transmitted. Ignoring these channels.
1525 */
1526 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301527 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001528 FL("DFS channel %d ignored for PLM"),
1529 pPlmReq->plmChList[count]);
1530 continue;
1531 }
1532 } else if (!ret) {
1533 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301534 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001535 FL("Unsupported channel %d ignored for PLM"),
1536 pPlmReq->plmChList[count]);
1537 continue;
1538 }
1539 ch_list[valid_count] = pPlmReq->plmChList[count];
1540 valid_count++;
1541 } /* End of for () */
1542
1543 /* Copying back the valid channel list to plm struct */
1544 qdf_mem_set((void *)pPlmReq->plmChList,
1545 pPlmReq->plmNumCh, 0);
1546 if (valid_count)
1547 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1548 valid_count);
1549 /* All are invalid channels, FW need to send the PLM
1550 * report with "incapable" bit set.
1551 */
1552 pPlmReq->plmNumCh = valid_count;
1553
1554send_plm_start:
1555 /* PLM START */
1556 msg.type = WMA_SET_PLM_REQ;
1557 msg.reserved = 0;
1558 msg.bodyptr = pPlmReq;
1559
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001560 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001561 &msg))) {
1562 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1563 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1564 sme_release_global_lock(&pMac->sme);
1565 return QDF_STATUS_E_FAILURE;
1566 }
1567
1568 sme_release_global_lock(&pMac->sme);
1569 return status;
1570}
1571
1572/**
1573 * sme_tsm_ie_ind() - sme tsm ie indication
1574 * @hHal: HAL handle
1575 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 *
1577 * Handle the tsm ie indication from LIM and forward it to HDD.
1578 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001579 * Return: QDF_STATUS enumeration
1580 */
1581static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582{
1583 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301584 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001585 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301587
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001588 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1589 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1590 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001592 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301593 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 return status;
1595}
1596
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001597/**
1598 * sme_set_cckm_ie() - set cckm ie
1599 * @hHal: HAL handle
1600 * @sessionId: session id
1601 * @pCckmIe: Pointer to CCKM Ie
1602 * @cckmIeLen: Length of @pCckmIe
1603 *
1604 * Function to store the CCKM IE passed from supplicant and use
1605 * it while packing reassociation request.
1606 *
1607 * Return: QDF_STATUS enumeration
1608 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301609QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 uint8_t *pCckmIe, uint8_t cckmIeLen)
1611{
1612 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301613 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301616 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1618 sme_release_global_lock(&pMac->sme);
1619 }
1620 return status;
1621}
1622
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001623/**
1624 * sme_set_ese_beacon_request() - set ese beacon request
1625 * @hHal: HAL handle
1626 * @sessionId: session id
1627 * @pEseBcnReq: Ese beacon report
1628 *
1629 * function to set ESE beacon request parameters
1630 *
1631 * Return: QDF_STATUS enumeration
1632 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301633QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 const tCsrEseBeaconReq *pEseBcnReq)
1635{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001636 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1638 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1639 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1640 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301641 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1643
1644 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001645 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301646 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 }
1648
1649 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301650 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 sizeof(tCsrEseBeaconReq));
1652
1653 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301654 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001656 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301657 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658 }
1659
1660 pSmeRrmContext->eseBcnReqInProgress = true;
1661
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001662 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663
1664 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1665 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301666 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 pSession->connectedProfile.bssid.bytes,
1668 sizeof(tSirMacAddr));
1669 pSmeBcnReportReq->channelInfo.channelNum = 255;
1670 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1671 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1672
1673 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1674 pBeaconReq =
1675 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1676 pSmeBcnReportReq->fMeasurementtype[counter] =
1677 pBeaconReq->scanMode;
1678 pSmeBcnReportReq->measurementDuration[counter] =
1679 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1680 pSmeBcnReportReq->channelList.channelNumber[counter] =
1681 pBeaconReq->channel;
1682 }
1683
1684 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1685
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301686 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 pSmeRrmContext->eseBcnReqInProgress = false;
1688
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301689 qdf_mem_free(pSmeBcnReportReq);
1690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 return status;
1692}
1693
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001694/**
1695 * sme_get_tsm_stats() - SME get tsm stats
1696 * @hHal: HAL handle
1697 * @callback: SME sends back the requested stats using the callback
1698 * @staId: The station ID for which the stats is requested for
1699 * @bssId: bssid
1700 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001701 * @tid: Traffic id
1702 *
1703 * API register a callback to get TSM Stats.
1704 *
1705 * Return: QDF_STATUS enumeration
1706 */
1707QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1708 tCsrTsmStatsCallback callback,
1709 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001710 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001711{
1712 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1713 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1714
1715 status = sme_acquire_global_lock(&pMac->sme);
1716 if (QDF_IS_STATUS_SUCCESS(status)) {
1717 status = csr_get_tsm_stats(pMac, callback,
1718 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001719 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001720 sme_release_global_lock(&pMac->sme);
1721 }
1722 return status;
1723}
1724
1725/**
1726 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1727 * @hHal: pointer HAL handle returned by mac_open
1728 * @sessionId: sme session id
1729 * @pChannelList: Output channel list
1730 * @numChannels: Output number of channels
1731 *
1732 * This routine is called to set ese roam scan channel list.
1733 * This is a synchronous call
1734 *
1735 * Return: QDF_STATUS
1736 */
1737QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1738 uint8_t sessionId,
1739 uint8_t *pChannelList,
1740 uint8_t numChannels)
1741{
1742 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1743 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001744 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1745 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001746 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1747 uint8_t newChannelList[128] = { 0 };
1748 uint8_t i = 0, j = 0;
1749
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001750 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1752 FL("Invalid sme session id: %d"), sessionId);
1753 return QDF_STATUS_E_INVAL;
1754 }
1755
1756 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1757 curchnl_list_info =
1758 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1759
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001760 status = sme_acquire_global_lock(&pMac->sme);
1761 if (!QDF_IS_STATUS_SUCCESS(status)) {
1762 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1763 csr_roam_offload_scan(pMac, sessionId,
1764 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1765 REASON_CHANNEL_LIST_CHANGED);
1766 return status;
1767 }
1768 if (NULL != curchnl_list_info->ChannelList) {
1769 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1770 j += snprintf(oldChannelList + j,
1771 sizeof(oldChannelList) - j, "%d",
1772 curchnl_list_info->ChannelList[i]);
1773 }
1774 }
1775 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1776 pChannelList, numChannels,
1777 csr_get_current_band(hHal));
1778 if (QDF_IS_STATUS_SUCCESS(status)) {
1779 if (NULL != curchnl_list_info->ChannelList) {
1780 j = 0;
1781 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1782 j += snprintf(newChannelList + j,
1783 sizeof(newChannelList) - j, "%d",
1784 curchnl_list_info->ChannelList[i]);
1785 }
1786 }
1787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1788 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1789 newChannelList, oldChannelList,
1790 pNeighborRoamInfo->neighborRoamState);
1791 }
1792 sme_release_global_lock(&pMac->sme);
1793 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1794 csr_roam_offload_scan(pMac, sessionId,
1795 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1796 REASON_CHANNEL_LIST_CHANGED);
1797 return status;
1798}
1799
1800#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801
Jeff Johnson49c02f92016-10-07 10:29:09 -07001802static
1803QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1804 tpSirIbssGetPeerInfoRspParams
1805 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001806{
1807 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1808
1809 if (NULL == pMac) {
1810 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1811 "%s: pMac is null", __func__);
1812 return QDF_STATUS_E_FAILURE;
1813 }
1814 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1816 "%s: HDD callback is null", __func__);
1817 return QDF_STATUS_E_FAILURE;
1818 }
1819 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1820 &pIbssPeerInfoParams->
1821 ibssPeerInfoRspParams);
1822 return QDF_STATUS_SUCCESS;
1823}
1824
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1827 * @mac: Global MAC pointer
1828 * @msg: Dual mac config response
1829 *
1830 * Processes the dual mac configuration response and invokes the HDD callback
1831 * to process further
1832 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301833static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 uint8_t *msg)
1835{
1836 tListElem *entry = NULL;
1837 tSmeCmd *command = NULL;
1838 bool found;
1839 dual_mac_cb callback = NULL;
1840 struct sir_dual_mac_config_resp *param;
1841
1842 param = (struct sir_dual_mac_config_resp *)msg;
1843 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001844 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 /* Not returning. Need to check if active command list
1846 * needs to be freed
1847 */
1848 }
1849
Krunal Sonia8270f52017-02-23 19:51:25 -08001850 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001852 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301853 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 }
1855
1856 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1857 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001858 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 }
1861
1862 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001863 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301864 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 }
1866
1867 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1868 if (callback) {
1869 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001870 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001872 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 callback(param->status,
1874 command->u.set_dual_mac_cmd.scan_config,
1875 command->u.set_dual_mac_cmd.fw_mode_config);
1876 }
1877 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001878 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 }
1880
Krunal Soni72dba662017-02-15 20:13:17 -08001881 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 if (found)
1883 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001884 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301886 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887}
1888
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001889/**
1890 * sme_process_antenna_mode_resp() - Process set antenna mode
1891 * response
1892 * @mac: Global MAC pointer
1893 * @msg: antenna mode response
1894 *
1895 * Processes the antenna mode response and invokes the HDD
1896 * callback to process further
1897 */
1898static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1899 uint8_t *msg)
1900{
1901 tListElem *entry;
1902 tSmeCmd *command;
1903 bool found;
1904 antenna_mode_cb callback;
1905 struct sir_antenna_mode_resp *param;
1906
1907 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301908 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001909 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001910 /* Not returning. Need to check if active command list
1911 * needs to be freed
1912 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001913
Krunal Sonia8270f52017-02-23 19:51:25 -08001914 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001915 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001916 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001917 return QDF_STATUS_E_FAILURE;
1918 }
1919
1920 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1921 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001922 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 return QDF_STATUS_E_FAILURE;
1924 }
1925
1926 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001927 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001928 return QDF_STATUS_E_FAILURE;
1929 }
1930
1931 callback =
1932 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1933 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301934 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001935 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301936 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001937 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001938 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001939 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001940 }
1941
Krunal Soni72dba662017-02-15 20:13:17 -08001942 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001943 if (found)
1944 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001945 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001946
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001947 return QDF_STATUS_SUCCESS;
1948}
1949
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301950/*
1951 * sme_process_msg() - The main message processor for SME.
1952 * The function is called by a message dispatcher when to process a message
1953 * targeted for SME.
1954 * This is a synchronous call
1955 *
1956 * hHal - The handle returned by mac_open.
1957 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1958 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1959 * Other status means SME failed to process the message to HAL.
1960 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001961QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301963 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301965 struct sir_peer_info *peer_stats;
1966 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967
1968 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001969 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 return status;
1971 }
1972 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301973 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001974 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301976 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 return status;
1978 }
1979 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001980 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301982 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 goto release_lock;
1984 }
1985 switch (pMsg->type) {
1986#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1990 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301991 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 break;
1993#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 case WNI_CFG_SET_CNF:
1995 case WNI_CFG_DNLD_CNF:
1996 case WNI_CFG_GET_RSP:
1997 case WNI_CFG_ADD_GRP_ADDR_CNF:
1998 case WNI_CFG_DEL_GRP_ADDR_CNF:
1999 break;
2000 case eWNI_SME_ADDTS_RSP:
2001 case eWNI_SME_DELTS_RSP:
2002 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 /* QoS */
2005 if (pMsg->bodyptr) {
2006#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2007 status = sme_qos_msg_processor(pMac, pMsg->type,
2008 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302009 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010#endif
2011 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002012 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 }
2014 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 case eWNI_SME_NEIGHBOR_REPORT_IND:
2016 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 if (pMsg->bodyptr) {
2018 status = sme_rrm_msg_processor(pMac, pMsg->type,
2019 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302020 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302022 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 }
2024 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 case eWNI_SME_ADD_STA_SELF_RSP:
2026 if (pMsg->bodyptr) {
2027 status = csr_process_add_sta_session_rsp(pMac,
2028 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002031 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 }
2033 break;
2034 case eWNI_SME_DEL_STA_SELF_RSP:
2035 if (pMsg->bodyptr) {
2036 status = csr_process_del_sta_session_rsp(pMac,
2037 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302038 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002040 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 }
2042 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 case eWNI_SME_CHANGE_COUNTRY_CODE:
2044 if (pMsg->bodyptr) {
2045 status = sme_handle_change_country_code((void *)pMac,
2046 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002049 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 }
2051 break;
2052 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2053 if (pMsg->bodyptr) {
2054 status = sme_handle_generic_change_country_code(
2055 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302056 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002058 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 }
2060 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062#ifdef WLAN_FEATURE_11W
2063 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2064 if (pMsg->bodyptr) {
2065 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302066 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002068 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 }
2070 break;
2071#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002072#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 case eWNI_SME_TSM_IE_IND:
2074 if (pMsg->bodyptr) {
2075 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302076 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002078 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 }
2080 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002081#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2083 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2084 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302085 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002087 case eWNI_SME_IBSS_PEER_INFO_RSP:
2088 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002089 sme_ibss_peer_info_response_handler(pMac,
2090 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002091 qdf_mem_free(pMsg->bodyptr);
2092 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002093 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002094 }
2095 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 case eWNI_SME_READY_TO_SUSPEND_IND:
2097 if (pMsg->bodyptr) {
2098 sme_process_ready_to_suspend(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;
2104#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2105 case eWNI_SME_READY_TO_EXTWOW_IND:
2106 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002107 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002110 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 }
2112 break;
2113#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2115 case eWNI_SME_AUTO_SHUTDOWN_IND:
2116 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 FL("Auto shutdown notification"));
2119 pMac->sme.pAutoShutdownNotificationCb();
2120 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302121 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122 break;
2123#endif
2124 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002125 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002127 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302128 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 break;
2130 case eWNI_SME_CHANNEL_CHANGE_RSP:
2131 if (pMsg->bodyptr) {
2132 status = sme_process_channel_change_resp(pMac,
2133 pMsg->type,
2134 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302135 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002137 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 }
2139 break;
2140#ifdef WLAN_FEATURE_STATS_EXT
2141 case eWNI_SME_STATS_EXT_EVENT:
2142 if (pMsg->bodyptr) {
2143 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302144 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002146 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 }
2148 break;
2149#endif
Will Huang558f8082017-05-31 16:22:24 +08002150 case eWNI_SME_GET_PEER_INFO_IND:
2151 if (pMac->sme.pget_peer_info_ind_cb)
2152 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2153 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302154 if (pMsg->bodyptr) {
2155 peer_info_rsp = (struct sir_peer_info_resp *)
2156 (pMsg->bodyptr);
2157 peer_stats = (struct sir_peer_info *)
2158 (peer_info_rsp->info);
2159 if (peer_stats) {
2160 pMac->peer_rssi = peer_stats[0].rssi;
2161 pMac->peer_txrate = peer_stats[0].tx_rate;
2162 pMac->peer_rxrate = peer_stats[0].rx_rate;
2163 }
2164 }
Will Huang558f8082017-05-31 16:22:24 +08002165 qdf_mem_free(pMsg->bodyptr);
2166 break;
2167 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2168 if (pMac->sme.pget_peer_info_ext_ind_cb)
2169 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2170 pMac->sme.pget_peer_info_ext_cb_context);
2171 qdf_mem_free(pMsg->bodyptr);
2172 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 case eWNI_SME_CSA_OFFLOAD_EVENT:
2174 if (pMsg->bodyptr) {
2175 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302176 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 }
2178 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002179 case eWNI_SME_TSF_EVENT:
2180 if (pMac->sme.get_tsf_cb) {
2181 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2182 (struct stsf *)pMsg->bodyptr);
2183 }
2184 if (pMsg->bodyptr)
2185 qdf_mem_free(pMsg->bodyptr);
2186 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187#ifdef WLAN_FEATURE_NAN
2188 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302189 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2190 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191 if (pMsg->bodyptr) {
2192 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302193 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 }
2195 break;
2196#endif /* WLAN_FEATURE_NAN */
2197 case eWNI_SME_LINK_STATUS_IND:
2198 {
2199 tAniGetLinkStatus *pLinkStatus =
2200 (tAniGetLinkStatus *) pMsg->bodyptr;
2201 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302202 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 pMac->sme.linkStatusCallback(
2204 pLinkStatus->linkStatus,
2205 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 pMac->sme.linkStatusCallback = NULL;
2208 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302209 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 }
2211 break;
2212 }
2213 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302214 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2216 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 break;
2218 case eWNI_SME_SNR_IND:
2219 {
2220 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 if (pSnrReq) {
2223 if (pSnrReq->snrCallback) {
2224 ((tCsrSnrCallback)
2225 (pSnrReq->snrCallback))
2226 (pSnrReq->snr, pSnrReq->staId,
2227 pSnrReq->pDevContext);
2228 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302229 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 }
2231 break;
2232 }
2233#ifdef FEATURE_WLAN_EXTSCAN
2234 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2235 if (pMac->sme.pExtScanIndCb)
2236 pMac->sme.pExtScanIndCb(pMac->hHdd,
2237 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2238 pMsg->bodyptr);
2239 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002240 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 pMsg->type);
2242
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302243 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 break;
2245 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2246 if (pMac->sme.pExtScanIndCb)
2247 pMac->sme.pExtScanIndCb(pMac->hHdd,
2248 eSIR_EPNO_NETWORK_FOUND_IND,
2249 pMsg->bodyptr);
2250 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002251 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 pMsg->type);
2253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302254 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 break;
2256#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 case eWNI_SME_SET_HW_MODE_RESP:
2258 if (pMsg->bodyptr) {
2259 status = sme_process_set_hw_mode_resp(pMac,
2260 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302261 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002263 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 }
2265 break;
2266 case eWNI_SME_HW_MODE_TRANS_IND:
2267 if (pMsg->bodyptr) {
2268 status = sme_process_hw_mode_trans_ind(pMac,
2269 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302270 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002272 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 }
2274 break;
2275 case eWNI_SME_NSS_UPDATE_RSP:
2276 if (pMsg->bodyptr) {
2277 status = sme_process_nss_update_resp(pMac,
2278 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302279 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002281 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 }
2283 break;
2284 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302285 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 pMac->sme.ocb_set_config_callback(
2287 pMac->sme.ocb_set_config_context,
2288 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302289 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002290 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 pMac->sme.ocb_set_config_callback = NULL;
2292 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302293 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 break;
2295 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302296 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 pMac->sme.ocb_get_tsf_timer_callback(
2298 pMac->sme.ocb_get_tsf_timer_context,
2299 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302300 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002301 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2303 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302304 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 break;
2306 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302307 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 pMac->sme.dcc_get_stats_callback(
2309 pMac->sme.dcc_get_stats_context,
2310 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302311 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002312 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 pMac->sme.dcc_get_stats_callback = NULL;
2314 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302315 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 break;
2317 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302318 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 pMac->sme.dcc_update_ndl_callback(
2320 pMac->sme.dcc_update_ndl_context,
2321 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302322 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002323 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 pMac->sme.dcc_update_ndl_callback = NULL;
2325 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302326 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 break;
2328 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302329 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 pMac->sme.dcc_stats_event_callback(
2331 pMac->sme.dcc_stats_event_context,
2332 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302333 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002334 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 break;
2337 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2338 if (pMsg->bodyptr) {
2339 status = sme_process_dual_mac_config_resp(pMac,
2340 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302341 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002343 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 }
2345 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2346 if (pMac->sme.set_thermal_level_cb)
2347 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2348 pMsg->bodyval);
2349 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302350 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2351 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302352 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302353 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002354 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2355 if (pMsg->bodyptr) {
2356 status = sme_process_antenna_mode_resp(pMac,
2357 pMsg->bodyptr);
2358 qdf_mem_free(pMsg->bodyptr);
2359 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002360 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002361 }
2362 break;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002363 case eWNI_SME_NDP_CONFIRM_IND:
2364 case eWNI_SME_NDP_NEW_PEER_IND:
2365 case eWNI_SME_NDP_INITIATOR_RSP:
Abhishek Singh4fef7472016-06-06 11:36:03 -07002366 case eWNI_SME_NDP_INDICATION:
2367 case eWNI_SME_NDP_RESPONDER_RSP:
Naveen Rawatf28315c2016-06-29 18:06:02 -07002368 case eWNI_SME_NDP_END_RSP:
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07002369 case eWNI_SME_NDP_END_IND:
2370 case eWNI_SME_NDP_PEER_DEPARTED_IND:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07002371 sme_ndp_msg_processor(pMac, pMsg);
2372 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302373 case eWNI_SME_LOST_LINK_INFO_IND:
2374 if (pMac->sme.lost_link_info_cb)
2375 pMac->sme.lost_link_info_cb(pMac->hHdd,
2376 (struct sir_lost_link_info *)pMsg->bodyptr);
2377 qdf_mem_free(pMsg->bodyptr);
2378 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302379 case eWNI_SME_RSO_CMD_STATUS_IND:
2380 if (pMac->sme.rso_cmd_status_cb)
2381 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002382 qdf_mem_free(pMsg->bodyptr);
2383 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002384 case eWMI_SME_LL_STATS_IND:
2385 if (pMac->sme.link_layer_stats_ext_cb)
2386 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2387 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302388 qdf_mem_free(pMsg->bodyptr);
2389 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302390 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2391 if (pMac->sme.bt_activity_info_cb)
2392 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2393 pMsg->bodyval);
2394 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 default:
2396
2397 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2398 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2399 /* CSR */
2400 if (pMsg->bodyptr) {
2401 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302402 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302403 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002404 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002406 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302408 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 }
2410 } /* switch */
2411release_lock:
2412 sme_release_global_lock(&pMac->sme);
2413 return status;
2414}
2415
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002416QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2417{
2418 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2419
2420 if (mac_ctx == NULL) {
2421 QDF_ASSERT(0);
2422 return QDF_STATUS_E_FAILURE;
2423 }
2424
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002425 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002426}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428/**
2429 * sme_process_nss_update_resp() - Process nss update response
2430 * @mac: Global MAC pointer
2431 * @msg: nss update response
2432 *
2433 * Processes the nss update response and invokes the HDD
2434 * callback to process further
2435 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302436static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437{
2438 tListElem *entry = NULL;
2439 tSmeCmd *command = NULL;
2440 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002441 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 struct sir_beacon_tx_complete_rsp *param;
2443
2444 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302445 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002446 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 /* Not returning. Need to check if active command list
2448 * needs to be freed
2449 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450
Krunal Sonia8270f52017-02-23 19:51:25 -08002451 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002453 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 }
2456
2457 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2458 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002459 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302460 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 }
2462
2463 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002464 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302465 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 }
2467
2468 callback = command->u.nss_update_cmd.nss_update_cb;
2469 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302470 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002471 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302472 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 callback(command->u.nss_update_cmd.context,
2474 param->tx_status,
2475 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302476 command->u.nss_update_cmd.next_action,
2477 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002479 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 }
2481
Krunal Soni72dba662017-02-15 20:13:17 -08002482 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 if (found) {
2484 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002485 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302488 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489}
2490
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302491/* No need to hold the global lock here because this function can only be
2492 * called after sme_stop.
2493 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002494void sme_free_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495{
2496 if (pMsg) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302497 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302498 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 }
2500
2501}
2502
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302503/*
2504 * sme_stop() - Stop all SME modules and put them at idle state
2505 *
2506 * The function stops each module in SME, PMC, CSR, etc. . Upon
2507 * return, all modules are at idle state ready to start.
2508 * This is a synchronous call
2509 *
2510 * hHal - The handle returned by mac_open
2511 * tHalStopType - reason for stopping
2512 * Return QDF_STATUS_SUCCESS - SME is stopped.
2513 * Other status means SME is failed to stop but caller should still
2514 * consider SME is stopped.
2515 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302516QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302518 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2519 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2521
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002522 status = rrm_stop(pMac);
2523 if (!QDF_IS_STATUS_SUCCESS(status)) {
2524 sme_err("rrm_stop failed with status: %d", status);
2525 }
2526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302528 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002529 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 fail_status = status;
2531 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302533 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535
2536 pMac->sme.state = SME_STATE_STOP;
2537
2538 return status;
2539}
2540
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302541/*
2542 * sme_close() - Release all SME modules and their resources.
2543 * The function release each module in SME, PMC, CSR, etc. . Upon
2544 * return, all modules are at closed state.
2545 *
2546 * No SME APIs can be involved after smeClose except smeOpen.
2547 * smeClose must be called before mac_close.
2548 * This is a synchronous call
2549 *
2550 * hHal - The handle returned by mac_open
2551 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2552 *
2553 * Other status means SME is failed to be closed but caller still cannot
2554 * call any other SME functions except smeOpen.
2555 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302556QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302558 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2559 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2561
2562 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302563 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564
2565 /* Note: pSession will be invalid from here on, do not access */
2566 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302567 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002568 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 fail_status = status;
2570 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2572 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302573 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002574 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 fail_status = status;
2576 }
2577#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002580 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 fail_status = status;
2582 }
2583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302585 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002586 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 fail_status = status;
2588 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 free_sme_cmd_list(pMac);
2591
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302592 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302593 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302594 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302596 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598
2599 pMac->sme.state = SME_STATE_STOP;
2600
2601 return status;
2602}
2603
2604/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302605 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2606 * scan list
2607 * @hal: hal context.
2608 * @bssid: bssid to be removed
2609 *
2610 * This function remove the given bssid from scan list.
2611 *
2612 * Return: QDF status.
2613 */
2614QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2615 tSirMacAddr bssid)
2616{
2617 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2618 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2619
2620 status = sme_acquire_global_lock(&mac_ctx->sme);
2621 if (QDF_IS_STATUS_SUCCESS(status)) {
2622 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2623 sme_release_global_lock(&mac_ctx->sme);
2624 }
2625
2626 return status;
2627}
2628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302630/*
2631 * sme_scan_get_result
2632 * A wrapper function to request scan results from CSR.
2633 * This is a synchronous call
2634 *
2635 * pFilter - If pFilter is NULL, all cached results are returned
2636 * phResult - an object for the result.
2637 * Return QDF_STATUS
2638 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302639QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 tCsrScanResultFilter *pFilter,
2641 tScanResultHandle *phResult)
2642{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302643 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2645
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302646 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2648 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302650 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 status = csr_scan_get_result(hHal, pFilter, phResult);
2652 sme_release_global_lock(&pMac->sme);
2653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 return status;
2656}
2657
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302658QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2659 struct qdf_mac_addr *bssid,
2660 tCsrScanResultInfo *res)
2661{
2662 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2663 QDF_STATUS status;
2664
2665 status = sme_acquire_global_lock(&mac_ctx->sme);
2666 if (QDF_IS_STATUS_SUCCESS(status)) {
2667 status = csr_scan_get_result_for_bssid(hal_handle, bssid, res);
2668 sme_release_global_lock(&mac_ctx->sme);
2669 }
2670
2671 return status;
2672}
2673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002675 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002676 * AP's channel id from
2677 * CSR by filtering the
2678 * result which matches
2679 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002680 * @profile: SAP profile
2681 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2682 * best ap from scan cache.
2683 *
2684 * This function is written to get AP's channel id from CSR by filtering
2685 * the result which matches our roam profile. This is a synchronous call.
2686 *
2687 * Return: QDF_STATUS.
2688 */
2689QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2690 tScanResultHandle *scan_cache,
2691 uint8_t *ap_chnl_id)
2692{
2693 return sme_get_ap_channel_from_scan_cache((tCsrRoamProfile *)
2694 profile,
2695 scan_cache,
2696 ap_chnl_id);
2697}
2698
2699/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2701 * channel id from CSR by filtering the
2702 * result which matches our roam profile.
2703 * @profile: SAP adapter
2704 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2705 * best ap from scan cache.
2706 *
2707 * This function is written to get AP's channel id from CSR by filtering
2708 * the result which matches our roam profile. This is a synchronous call.
2709 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302710 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002712QDF_STATUS sme_get_ap_channel_from_scan_cache(
2713 tCsrRoamProfile *profile, tScanResultHandle *scan_cache,
2714 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302716 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002717 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 tCsrScanResultFilter *scan_filter = NULL;
2719 tScanResultHandle filtered_scan_result = NULL;
2720 tSirBssDescription first_ap_profile;
2721
2722 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302723 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302725 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302727 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302729 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302731 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302732 }
2733 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2734 if (NULL == profile) {
2735 scan_filter->EncryptionType.numEntries = 1;
2736 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302738 } else {
2739 /* Here is the profile we need to connect to */
2740 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 profile,
2742 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302743 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302745 if (QDF_STATUS_SUCCESS == status) {
2746 /* Save the WPS info */
2747 if (NULL != profile) {
2748 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302750 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302753 scan_filter->bWPSAssociation = 0;
2754 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302756 } else {
2757 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2758 FL("Preparing the profile filter failed"));
2759 qdf_mem_free(scan_filter);
2760 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 }
2762 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302763 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002764 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302766 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2768 &first_ap_profile);
2769 *scan_cache = filtered_scan_result;
2770 if (0 != first_ap_profile.channelId) {
2771 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302772 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302773 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 FL("Found best AP & its on chnl[%d]"),
2775 first_ap_profile.channelId);
2776 } else {
2777 /*
2778 * This means scan result is empty
2779 * so set the channel to zero, caller should
2780 * take of zero channel id case.
2781 */
2782 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302783 QDF_TRACE(QDF_MODULE_ID_SME,
2784 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302786 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 }
2788 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302789 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302791 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 }
2793 csr_free_scan_filter(mac_ctx, scan_filter);
2794 sme_release_global_lock(&mac_ctx->sme);
2795 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002798 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302799 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 return status;
2803}
2804
2805/**
2806 * sme_store_joinreq_param() - This function will pass station's join
2807 * request to store to csr.
2808 * @hal_handle: pointer to hal context.
2809 * @profile: pointer to station's roam profile.
2810 * @scan_cache: pointer to station's scan cache.
2811 * @roam_id: reference to roam_id variable being passed.
2812 * @session_id: station's session id.
2813 *
2814 * This function will pass station's join request further down to csr
2815 * to store it. this stored parameter will be used later.
2816 *
2817 * Return: true or false based on function's overall success.
2818 **/
2819bool sme_store_joinreq_param(tHalHandle hal_handle,
2820 tCsrRoamProfile *profile,
2821 tScanResultHandle scan_cache,
2822 uint32_t *roam_id,
2823 uint32_t session_id)
2824{
2825 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302826 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 bool ret_status = true;
2828
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302829 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2831 session_id, 0));
2832 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302833 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302835 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 sme_release_global_lock(&mac_ctx->sme);
2838 } else {
2839 ret_status = false;
2840 }
2841
2842 return ret_status;
2843}
2844
2845/**
2846 * sme_clear_joinreq_param() - This function will pass station's clear
2847 * the join request to csr.
2848 * @hal_handle: pointer to hal context.
2849 * @session_id: station's session id.
2850 *
2851 * This function will pass station's clear join request further down to csr
2852 * to cleanup.
2853 *
2854 * Return: true or false based on function's overall success.
2855 **/
2856bool sme_clear_joinreq_param(tHalHandle hal_handle,
2857 uint32_t session_id)
2858{
2859 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302860 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 bool ret_status = true;
2862
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302863 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2865 session_id, 0));
2866 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302867 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302869 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 sme_release_global_lock(&mac_ctx->sme);
2872 } else {
2873 ret_status = false;
2874 }
2875
2876 return ret_status;
2877}
2878
2879/**
2880 * sme_issue_stored_joinreq() - This function will issues station's stored
2881 * the join request to csr.
2882 * @hal_handle: pointer to hal context.
2883 * @roam_id: reference to roam_id variable being passed.
2884 * @session_id: station's session id.
2885 *
2886 * This function will issue station's stored join request further down to csr
2887 * to proceed forward.
2888 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302889 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302891QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 uint32_t *roam_id,
2893 uint32_t session_id)
2894{
2895 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302896 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2897 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302899 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2901 session_id, 0));
2902 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302903 if (QDF_STATUS_SUCCESS == status) {
2904 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 roam_id,
2906 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302907 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 }
2909 sme_release_global_lock(&mac_ctx->sme);
2910 } else {
2911 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302912 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 }
2914 return ret_status;
2915}
2916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302917/*
2918 * sme_scan_flush_result() -
2919 * A wrapper function to request CSR to clear scan results.
2920 * This is a synchronous call
2921 *
2922 * Return QDF_STATUS
2923 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302924QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302926 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2928
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302929 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2931 0, 0));
2932 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302933 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 status = csr_scan_flush_result(hHal);
2935 sme_release_global_lock(&pMac->sme);
2936 }
2937
2938 return status;
2939}
2940
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302941/*
2942 * sme_filter_scan_results() -
2943 * A wrapper function to request CSR to clear scan results.
2944 * This is a synchronous call
2945 *
2946 * tHalHandle - HAL context handle
2947 * sessionId - session id
2948 * Return QDF_STATUS
2949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302950QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302952 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2954
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302955 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2957 sessionId, 0));
2958 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302959 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 csr_scan_filter_results(pMac);
2961 sme_release_global_lock(&pMac->sme);
2962 }
2963
2964 return status;
2965}
2966
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302967QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2971
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302972 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2974 sessionId, 0));
2975 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 status = csr_scan_flush_selective_result(hHal, true);
2978 sme_release_global_lock(&pMac->sme);
2979 }
2980
2981 return status;
2982}
2983
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302984/*
2985 * sme_scan_result_get_first() -
2986 * A wrapper function to request CSR to returns the first element of
2987 * scan result.
2988 * This is a synchronous call
2989 *
2990 * hScanResult - returned from csr_scan_get_result
2991 * Return tCsrScanResultInfo * - NULL if no result
2992 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2994 tScanResultHandle hScanResult)
2995{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302996 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2998 tCsrScanResultInfo *pRet = NULL;
2999
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303000 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
3002 NO_SESSION, 0));
3003 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303004 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 pRet = csr_scan_result_get_first(pMac, hScanResult);
3006 sme_release_global_lock(&pMac->sme);
3007 }
3008
3009 return pRet;
3010}
3011
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303012/*
3013 * sme_scan_result_get_next() -
3014 * A wrapper function to request CSR to returns the next element of
3015 * scan result. It can be called without calling csr_scan_result_get_first first
3016 * This is a synchronous call
3017 *
3018 * hScanResult - returned from csr_scan_get_result
3019 * Return Null if no result or reach the end
3020 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3022 tScanResultHandle hScanResult)
3023{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303024 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3026 tCsrScanResultInfo *pRet = NULL;
3027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303029 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 pRet = csr_scan_result_get_next(pMac, hScanResult);
3031 sme_release_global_lock(&pMac->sme);
3032 }
3033
3034 return pRet;
3035}
3036
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303037/*
3038 * sme_scan_result_purge() -
3039 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3040 * in the list and free memory for each item
3041 * This is a synchronous call
3042 *
3043 * hScanResult - returned from csr_scan_get_result. hScanResult is
3044 * considered gone by
3045 * calling this function and even before this function reutrns.
3046 * Return QDF_STATUS
3047 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003048QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303050 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003051 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303053 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3055 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003056 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303057 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003058 status = csr_scan_result_purge(mac_ctx, hScanResult);
3059 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 }
3061
3062 return status;
3063}
3064
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303065/*
3066 * sme_scan_get_pmkid_candidate_list() -
3067 * A wrapper function to return the PMKID candidate list
3068 * This is a synchronous call
3069 *
3070 * pPmkidList - caller allocated buffer point to an array of
3071 * tPmkidCandidateInfo
3072 * pNumItems - pointer to a variable that has the number of
3073 * tPmkidCandidateInfo allocated when retruning, this is
3074 * either the number needed or number of items put into
3075 * pPmkidList
3076 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3077 * big enough and pNumItems
3078 * has the number of tPmkidCandidateInfo.
3079 * \Note: pNumItems is a number of tPmkidCandidateInfo,
3080 * not sizeof(tPmkidCandidateInfo) * something
3081 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303082QDF_STATUS sme_scan_get_pmkid_candidate_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 tPmkidCandidateInfo *pPmkidList,
3084 uint32_t *pNumItems)
3085{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303086 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3088
3089 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303090 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 status =
3092 csr_scan_get_pmkid_candidate_list(pMac, sessionId,
3093 pPmkidList,
3094 pNumItems);
3095 sme_release_global_lock(&pMac->sme);
3096 }
3097
3098 return status;
3099}
3100
3101eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3102{
3103 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 return pMac->roam.configParam.phyMode;
3106}
3107
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303108/*
3109 * sme_get_channel_bonding_mode5_g() -
3110 * get the channel bonding mode for 5G band
3111 *
3112 * hHal - HAL handle
3113 * Return channel bonding mode for 5G
3114 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115uint32_t sme_get_channel_bonding_mode5_g(tHalHandle hHal)
3116{
3117 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3118 tSmeConfigParams smeConfig;
3119
3120 sme_get_config_param(pMac, &smeConfig);
3121
3122 return smeConfig.csrConfig.channelBondingMode5GHz;
3123}
3124
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303125/*
3126 * sme_get_channel_bonding_mode24_g() -
3127 * get the channel bonding mode for 2.4G band
3128 *
3129 * hHal - HAL handle
3130 * Return channel bonding mode for 2.4G
3131 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132uint32_t sme_get_channel_bonding_mode24_g(tHalHandle hHal)
3133{
3134 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3135 tSmeConfigParams smeConfig;
3136
3137 sme_get_config_param(pMac, &smeConfig);
3138
3139 return smeConfig.csrConfig.channelBondingMode24GHz;
3140}
3141
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303142/*
3143 * sme_roam_connect() -
3144 * A wrapper function to request CSR to inititiate an association
3145 * This is an asynchronous call.
3146 *
3147 * sessionId - the sessionId returned by sme_open_session.
3148 * pProfile - description of the network to which to connect
3149 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3150 * from csr_scan_get_result
3151 * pRoamId - to get back the request ID
3152 * Return QDF_STATUS
3153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303154QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 tCsrRoamProfile *pProfile, uint32_t *pRoamId)
3156{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303157 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3159
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303160 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303161 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303163 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303166 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3168 status =
3169 csr_roam_connect(pMac, sessionId, pProfile,
3170 pRoamId);
3171 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003172 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303173 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
3175 sme_release_global_lock(&pMac->sme);
3176 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003177 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 }
3179
3180 return status;
3181}
3182
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303183/*
3184 * sme_set_phy_mode() -
3185 * Changes the PhyMode.
3186 *
3187 * hHal - The handle returned by mac_open.
3188 * phyMode new phyMode which is to set
3189 * Return QDF_STATUS SUCCESS.
3190 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192{
3193 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3194
3195 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303198 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 }
3200
3201 pMac->roam.configParam.phyMode = phyMode;
3202 pMac->roam.configParam.uCfgDot11Mode =
3203 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303204 pMac->roam.configParam.phyMode,
3205 pMac->roam.configParam.
3206 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303208 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209}
3210
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303211/*
3212 * sme_roam_reassoc() -
3213 * A wrapper function to request CSR to inititiate a re-association
3214 *
3215 * pProfile - can be NULL to join the currently connected AP. In that
3216 * case modProfileFields should carry the modified field(s) which could trigger
3217 * reassoc
3218 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3219 * that might need modification dynamically once STA is up & running and this
3220 * could trigger a reassoc
3221 * pRoamId - to get back the request ID
3222 * Return QDF_STATUS
3223 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303224QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 tCsrRoamProfile *pProfile,
3226 tCsrRoamModifyProfileFields modProfileFields,
3227 uint32_t *pRoamId, bool fForce)
3228{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303229 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3231
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303232 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303235 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303237 if ((NULL == pProfile) && (fForce == 1))
3238 status = csr_reassoc(pMac, sessionId,
3239 &modProfileFields, pRoamId,
3240 fForce);
3241 else
3242 status = csr_roam_reassoc(pMac, sessionId,
3243 pProfile,
3244 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303246 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 }
3248 sme_release_global_lock(&pMac->sme);
3249 }
3250
3251 return status;
3252}
3253
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303254/*
3255 * sme_roam_connect_to_last_profile() -
3256 * A wrapper function to request CSR to disconnect and reconnect with
3257 * the same profile
3258 * This is an asynchronous call.
3259 *
3260 * Return QDF_STATUS. It returns fail if currently connected
3261 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3266
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303267 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3269 sessionId, 0));
3270 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303272 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3273 status = csr_roam_connect_to_last_profile(pMac,
3274 sessionId);
3275 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 sme_release_global_lock(&pMac->sme);
3278 }
3279
3280 return status;
3281}
3282
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303283/*
3284 * sme_roam_disconnect() -
3285 * A wrapper function to request CSR to disconnect from a network
3286 * This is an asynchronous call.
3287 *
3288 * reason -- To indicate the reason for disconnecting. Currently, only
3289 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3290 * Return QDF_STATUS
3291 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 eCsrRoamDisconnectReason reason)
3294{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3297
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303298 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3300 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303302 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303303 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303305 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 sme_release_global_lock(&pMac->sme);
3308 }
3309
3310 return status;
3311}
3312
Abhishek Singhca408032016-09-13 15:26:12 +05303313/* sme_dhcp_done_ind() - send dhcp done ind
3314 * @hal: hal context
3315 * @session_id: session id
3316 *
3317 * Return: void.
3318 */
3319void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3320{
3321 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303322 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303323
3324 if (!mac_ctx)
3325 return;
3326
3327 session = CSR_GET_SESSION(mac_ctx, session_id);
3328 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003329 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303330 return;
3331 }
3332 session->dhcp_done = true;
3333}
3334
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303335/*
3336 * sme_roam_stop_bss() -
3337 * To stop BSS for Soft AP. This is an asynchronous API.
3338 *
3339 * hHal - Global structure
3340 * sessionId - sessionId of SoftAP
3341 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3342 * actual results
3343 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303344QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303346 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3348
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303350 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303351 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3352 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303353 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303354 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303355 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 sme_release_global_lock(&pMac->sme);
3357 }
3358
3359 return status;
3360}
3361
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303362/**
3363 * sme_roam_disconnect_sta() - disassociate a station
3364 * @hHal: Global structure
3365 * @sessionId: SessionId of SoftAP
3366 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3367 *
3368 * To disassociate a station. This is an asynchronous API.
3369 *
3370 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3371 * be called to indicate actual result.
3372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003374 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303376 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3378
3379 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303380 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 return status;
3382 }
3383
3384 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303385 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303386 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303388 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303389 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303390 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 sme_release_global_lock(&pMac->sme);
3392 }
3393
3394 return status;
3395}
3396
3397/**
3398 * sme_roam_deauth_sta() - deauthenticate a station
3399 * @hHal: Global structure
3400 * @sessionId: SessionId of SoftAP
3401 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3402 *
3403 * To disassociate a station. This is an asynchronous API.
3404 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303405 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 * code on error. Roam callback will be called to indicate actual
3407 * result
3408 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303409QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003410 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303412 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3414
3415 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303416 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 return status;
3418 }
3419
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303420 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303421 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3422 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303424 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303425 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 status =
3427 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3428 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303429 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303430 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 sme_release_global_lock(&pMac->sme);
3432 }
3433
3434 return status;
3435}
3436
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303437/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303438 * sme_roam_get_associated_stas() -
3439 * To probe the list of associated stations from various modules
3440 * of CORE stack.
3441 * This is an asynchronous API.
3442 *
3443 * sessionId - sessionId of SoftAP
3444 * modId - Module from whom list of associtated stations is
3445 * to be probed. If an invalid module is passed then
3446 * by default QDF_MODULE_ID_PE will be probed.
3447 * pUsrContext - Opaque HDD context
3448 * pfnSapEventCallback - Sap event callback in HDD
3449 * pAssocBuf - Caller allocated memory to be filled with associatd
3450 * stations info
3451 * Return QDF_STATUS
3452 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303453QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303454 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 void *pfnSapEventCallback,
3456 uint8_t *pAssocStasBuf)
3457{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303458 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3460
3461 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303462 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 return status;
3464 }
3465
3466 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303467 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303468 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303470 csr_roam_get_associated_stas(pMac, sessionId,
3471 modId,
3472 pUsrContext,
3473 pfnSapEventCallback,
3474 pAssocStasBuf);
3475 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 sme_release_global_lock(&pMac->sme);
3478 }
3479
3480 return status;
3481}
3482
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303483/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303484 * sme_roam_get_connect_state() -
3485 * A wrapper function to request CSR to return the current connect state
3486 * of Roaming
3487 * This is a synchronous call.
3488 *
3489 * Return QDF_STATUS
3490 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303491QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 eCsrConnectState *pState)
3493{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3496
3497 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303498 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303499 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3500 status = csr_roam_get_connect_state(pMac, sessionId,
3501 pState);
3502 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303503 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 sme_release_global_lock(&pMac->sme);
3505 }
3506
3507 return status;
3508}
3509
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303510/*
3511 * sme_roam_get_connect_profile() -
3512 * A wrapper function to request CSR to return the current connect
3513 * profile. Caller must call csr_roam_free_connect_profile after it is done
3514 * and before reuse for another csr_roam_get_connect_profile call.
3515 * This is a synchronous call.
3516 *
3517 * pProfile - pointer to a caller allocated structure
3518 * tCsrRoamConnectedProfile
3519 * eturn QDF_STATUS. Failure if not connected
3520 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 tCsrRoamConnectedProfile *pProfile)
3523{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3526
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303527 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3529 sessionId, 0));
3530 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303532 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3533 status = csr_roam_get_connect_profile(pMac, sessionId,
3534 pProfile);
3535 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303536 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 sme_release_global_lock(&pMac->sme);
3538 }
3539
3540 return status;
3541}
3542
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003543/**
3544 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3545 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3546 *
3547 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3548 *
3549 * Return: none
3550 */
3551void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303553 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3555 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003556 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557}
3558
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303559/*
3560 * sme_roam_set_pmkid_cache() -
3561 * A wrapper function to request CSR to return the PMKID candidate list
3562 * This is a synchronous call.
3563
3564 * pPMKIDCache - caller allocated buffer point to an array of
3565 * tPmkidCacheInfo
3566 * numItems - a variable that has the number of tPmkidCacheInfo
3567 * allocated when retruning, this is either the number needed
3568 * or number of items put into pPMKIDCache
3569 * update_entire_cache - this bool value specifies if the entire pmkid
3570 * cache should be overwritten or should it be
3571 * updated entry by entry.
3572 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3573 * big enough and pNumItems has the number of
3574 * tPmkidCacheInfo.
3575 * \Note: pNumItems is a number of tPmkidCacheInfo,
3576 * not sizeof(tPmkidCacheInfo) * something
3577 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303578QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 tPmkidCacheInfo *pPMKIDCache,
3580 uint32_t numItems, bool update_entire_cache)
3581{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3584
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303585 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3587 numItems));
3588 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303589 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303590 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3591 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3592 pPMKIDCache,
3593 numItems, update_entire_cache);
3594 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303595 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 sme_release_global_lock(&pMac->sme);
3597 }
3598
3599 return status;
3600}
3601
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303603 tPmkidCacheInfo *pmksa,
3604 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303608
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303609 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303610 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3611 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303613 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303614 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303616 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303617 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303618 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 sme_release_global_lock(&pMac->sme);
3620 }
3621 return status;
3622}
3623
3624#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303625/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 * \fn sme_roam_set_psk_pmk
3627 * \brief a wrapper function to request CSR to save PSK/PMK
3628 * This is a synchronous call.
3629 * \param hHal - Global structure
3630 * \param sessionId - SME sessionId
3631 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3632 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3633 * connections. Need to pass this information to
3634 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 uint8_t *pPSK_PMK, size_t pmk_len)
3639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303645 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3646 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303648 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 sme_release_global_lock(&pMac->sme);
3651 }
3652 return status;
3653}
3654#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303655/*
3656 * sme_roam_get_security_req_ie() -
3657 * A wrapper function to request CSR to return the WPA or RSN or WAPI IE CSR
3658 * passes to PE to JOIN request or START_BSS request
3659 * This is a synchronous call.
3660 *
3661 * pLen - caller allocated memory that has the length of pBuf as input.
3662 * Upon returned, *pLen has the needed or IE length in pBuf.
3663 * pBuf - Caller allocated memory that contain the IE field, if any,
3664 * upon return
3665 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3666 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3667 * big enough
3668 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303669QDF_STATUS sme_roam_get_security_req_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 uint32_t *pLen, uint8_t *pBuf,
3671 eCsrSecurityType secType)
3672{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303673 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3675
3676 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303678 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3679 status = csr_roam_get_wpa_rsn_req_ie(hHal, sessionId,
3680 pLen, pBuf);
3681 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 sme_release_global_lock(&pMac->sme);
3684 }
3685
3686 return status;
3687}
3688
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303689/*
3690 * sme_roam_get_security_rsp_ie() -
3691 * A wrapper function to request CSR to return the WPA or RSN or
3692 * WAPI IE from the beacon or probe rsp if connected
3693 * This is a synchronous call.
3694 *
3695 * pLen - caller allocated memory that has the length of pBuf as input.
3696 * Upon returned, *pLen has the needed or IE length in pBuf.
3697 * pBuf - Caller allocated memory that contain the IE field, if any,
3698 * upon return
3699 * secType - Specifies whether looking for WPA/WPA2/WAPI IE
3700 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3701 * big enough
3702 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303703QDF_STATUS sme_roam_get_security_rsp_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 uint32_t *pLen, uint8_t *pBuf,
3705 eCsrSecurityType secType)
3706{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303707 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3709
3710 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303711 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303712 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3713 status = csr_roam_get_wpa_rsn_rsp_ie(pMac, sessionId,
3714 pLen, pBuf);
3715 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303716 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 sme_release_global_lock(&pMac->sme);
3718 }
3719
3720 return status;
3721
3722}
3723
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303724/*
3725 * sme_roam_get_num_pmkid_cache() -
3726 * A wrapper function to request CSR to return number of PMKID cache
3727 * entries
3728 * This is a synchronous call.
3729 *
3730 * Return uint32_t - the number of PMKID cache entries
3731 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3733{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303734 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3736 uint32_t numPmkidCache = 0;
3737
3738 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303739 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003740 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3741 numPmkidCache =
3742 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303743 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303744 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303745 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 sme_release_global_lock(&pMac->sme);
3747 }
3748
3749 return numPmkidCache;
3750}
3751
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303752/*
3753 * sme_roam_get_pmkid_cache() -
3754 * A wrapper function to request CSR to return PMKID cache from CSR
3755 * This is a synchronous call.
3756 *
3757 * pNum - caller allocated memory that has the space of the number of
3758 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3759 * needed or actually number in tPmkidCacheInfo.
3760 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3761 * any, upon return
3762 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3763 * big enough
3764 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303765QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303766 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303768 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3770
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303771 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3773 0));
3774 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303775 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303776 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3777 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303779 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 sme_release_global_lock(&pMac->sme);
3782 }
3783
3784 return status;
3785}
3786
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303787/*
3788 * sme_get_config_param() -
3789 * A wrapper function that HDD calls to get the global settings
3790 * currently maintained by CSR.
3791 * This is a synchronous call.
3792 *
3793 * pParam - caller allocated memory
3794 * Return QDF_STATUS
3795 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303796QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303798 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3800
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303801 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3803 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303804 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303806 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003807 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 sme_release_global_lock(&pMac->sme);
3809 return status;
3810 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303811 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003812 &pMac->rrm.rrmSmeContext.rrmConfig,
3813 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303814 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 sme_release_global_lock(&pMac->sme);
3816 }
3817
3818 return status;
3819}
3820
3821/**
3822 * sme_cfg_set_int() - Sets the cfg parameter value.
3823 * @hal: Handle to hal.
3824 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003825 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 *
3827 * This function sets the string value in cfg parameter.
3828 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303829 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303831QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832{
3833 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303834 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835
3836 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303837 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838
3839 return status;
3840}
3841
3842/**
3843 * sme_cfg_set_str() - Sets the cfg parameter string.
3844 * @hal: Handle to hal.
3845 * @cfg_id: Configuration parameter ID.
3846 * @str: Pointer to the string buffer.
3847 * @length: Length of the string.
3848 *
3849 * This function sets the string value in cfg parameter.
3850 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303851 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 uint32_t length)
3855{
3856 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858
3859 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861
3862 return status;
3863}
3864
3865/**
3866 * sme_cfg_get_int() - Gets the cfg parameter value.
3867 * @hal: Handle to hal.
3868 * @cfg_id: Configuration parameter ID.
3869 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003870 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 *
3872 * This function gets the value of the cfg parameter.
3873 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303874 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303876QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877{
3878 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303879 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
3881 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303882 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883
3884 return status;
3885}
3886
3887/**
3888 * sme_cfg_get_str() - Gets the cfg parameter string.
3889 * @hal: Handle to hal.
3890 * @cfg_id: Configuration parameter ID.
3891 * @str: Pointer to the string buffer.
3892 * @length: Pointer to length of the string.
3893 *
3894 * This function gets the string value of the cfg parameter.
3895 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303896 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 uint32_t *length)
3900{
3901 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303902 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903
3904 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303905 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906
3907 return status;
3908}
3909
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303910/*
3911 * sme_get_modify_profile_fields() -
3912 * HDD or SME - QOS calls this function to get the current values of
3913 * connected profile fields, changing which can cause reassoc.
3914 * This function must be called after CFG is downloaded and STA is in connected
3915 * state. Also, make sure to call this function to get the current profile
3916 * fields before calling the reassoc. So that pModifyProfileFields will have
3917 * all the latest values plus the one(s) has been updated as part of reassoc
3918 * request.
3919 *
3920 * pModifyProfileFields - pointer to the connected profile fields
3921 * changing which can cause reassoc
3922 * Return QDF_STATUS
3923 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303924QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 tCsrRoamModifyProfileFields *
3926 pModifyProfileFields)
3927{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303928 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3930
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303931 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3933 0));
3934 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303935 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303936 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3937 status = csr_get_modify_profile_fields(pMac, sessionId,
3938 pModifyProfileFields);
3939 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303940 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 sme_release_global_lock(&pMac->sme);
3942 }
3943
3944 return status;
3945}
3946
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303947/*
3948 * sme_set_dhcp_till_power_active_flag() -
3949 * Sets/Clears DHCP related flag to disable/enable auto PS
3950 *
3951 * hal - The handle returned by mac_open.
3952 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3954{
3955 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3956 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3957
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303958 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3960 flag));
3961 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3962 ps_global_info->remain_in_power_active_till_dhcp = flag;
3963}
3964
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303965/*
3966 * sme_register11d_scan_done_callback() -
3967 * Register a routine of type csr_scan_completeCallback which is
3968 * called whenever an 11d scan is done
3969 *
3970 * hHal - The handle returned by mac_open.
3971 * callback - 11d scan complete routine to be registered
3972 * Return QDF_STATUS
3973 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303974QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303975 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303977 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3979
3980 pMac->scan.callback11dScanDone = callback;
3981
3982 return status;
3983}
3984
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303985/**
3986 * sme_deregister11d_scan_done_callback() - De-register scandone callback
3987 * @h_hal: Handler return by mac_open
3988 *
3989 * This function De-registers the scandone callback to SME
3990 *
3991 * Return: None
3992 */
3993void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
3994{
3995 tpAniSirGlobal pmac;
3996
3997 if (!h_hal) {
3998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3999 FL("hHal is not valid"));
4000 return;
4001 }
4002
4003 pmac = PMAC_STRUCT(h_hal);
4004 pmac->scan.callback11dScanDone = NULL;
4005}
4006
4007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008#ifdef FEATURE_OEM_DATA_SUPPORT
4009/**
4010 * sme_register_oem_data_rsp_callback() - Register a routine of
4011 * type send_oem_data_rsp_msg
4012 * @h_hal: Handle returned by mac_open.
4013 * @callback: Callback to send response
4014 * to oem application.
4015 *
4016 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
4017 * callback function.
4018 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304019 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304021QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 sme_send_oem_data_rsp_msg callback)
4023{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304024 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
4026
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004027 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028
4029 return status;
4030
4031}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304032
4033/**
4034 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4035 * @h_hal: Handler return by mac_open
4036 * This function De-registers the OEM data response callback to SME
4037 *
4038 * Return: None
4039 */
4040void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4041{
4042 tpAniSirGlobal pmac;
4043
4044 if (!h_hal) {
4045 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4046 FL("hHal is not valid"));
4047 return;
4048 }
4049 pmac = PMAC_STRUCT(h_hal);
4050
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004051 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304052}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053
4054/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004055 * sme_oem_update_capability() - update UMAC's oem related capability.
4056 * @hal: Handle returned by mac_open
4057 * @oem_cap: pointer to oem_capability
4058 *
4059 * This function updates OEM capability to UMAC. Currently RTT
4060 * related capabilities are updated. More capabilities can be
4061 * added in future.
4062 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004064 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304065QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004066 struct sme_oem_capability *cap)
4067{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304068 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004069 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4070 uint8_t *bytes;
4071
4072 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4073
4074 if (cap->ftm_rr)
4075 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4076 if (cap->lci_capability)
4077 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4078
4079 return status;
4080}
4081
4082/**
4083 * sme_oem_get_capability() - get oem capability
4084 * @hal: Handle returned by mac_open
4085 * @oem_cap: pointer to oem_capability
4086 *
4087 * This function is used to get the OEM capability from UMAC.
4088 * Currently RTT related capabilities are received. More
4089 * capabilities can be added in future.
4090 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304091 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004092 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304093QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004094 struct sme_oem_capability *cap)
4095{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304096 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004097 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4098 uint8_t *bytes;
4099
4100 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4101
4102 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4103 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4104
4105 return status;
4106}
Naveen Rawat910726a2017-03-06 11:42:51 -08004107#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004108
4109/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 * sme_register_ftm_msg_processor() - registers hdd ftm message processor
4111 * function to MAC/SYS
4112 *
4113 * @hal: hal handle
4114 * @callback: hdd function that has to be registered
4115 *
4116 * Return: void
4117 */
4118void sme_register_ftm_msg_processor(tHalHandle hal,
4119 hdd_ftm_msg_processor callback)
4120{
4121 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4122
4123 if (mac_ctx == NULL) {
Naveen Rawatcf684762016-06-27 15:30:24 -07004124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4125 FL("mac ctx is NULL"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 return;
4127 }
Naveen Rawatcf684762016-06-27 15:30:24 -07004128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 mac_ctx->ftm_msg_processor_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130}
4131
4132/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 * sme_enter_wowl(): SME API exposed to HDD to request enabling of WOWL mode.
4134 * @hal_ctx - The handle returned by mac_open.
4135 * @enter_wowl_callback_routine - Callback routine provided by HDD.
4136 * Used for success/failure notification by SME
4137 * @enter_wowl_callback_context - A cookie passed by HDD, that is passed
4138 * back to HDD at the time of callback.
4139 * @wake_reason_ind_cb - Callback routine provided by HDD.
4140 * Used for Wake Reason Indication by SME
4141 * @wake_reason_ind_cb_ctx - A cookie passed by HDD, that is passed
4142 * back to HDD at the time of callback.
4143 *
4144 * WoWLAN works on top of BMPS mode.
4145 * If the device is not in BMPS mode,
4146 * SME will will cache the information that
4147 * WOWL has been enabled and attempt to put the device
4148 * in BMPS. On entry into BMPS, SME will enable the
4149 * WOWL mode.
4150 * Note 1: If we exit BMPS mode (someone requests full power),
4151 * we will NOT resume WOWL when we go back to BMPS again.
4152 * Request for full power (while in WOWL mode) means disable
4153 * WOWL and go to full power.
4154 * Note 2: Both UAPSD and WOWL work on top of BMPS.
4155 * On entry into BMPS, SME will give priority to UAPSD and
4156 * enable only UAPSD if both UAPSD and WOWL are required.
4157 * Currently there is no requirement or use case to support
4158 * UAPSD and WOWL at the same time.
4159 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304160 * Return: QDF_STATUS
4161 * QDF_STATUS_SUCCESS Device is already in WoWLAN mode
4162 * QDF_STATUS_E_FAILURE Device cannot enter WoWLAN mode.
4163 * QDF_STATUS_PMC_PENDING Request accepted. SME will enable
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 * WOWL after BMPS mode is entered.
4165 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304166QDF_STATUS sme_enter_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 void (*enter_wowl_callback_routine)(void
4168 *callback_context,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304169 QDF_STATUS status),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 void *enter_wowl_callback_context,
4171#ifdef WLAN_WAKEUP_EVENTS
4172 void (*wakeIndicationCB)(void *callback_context,
4173 tpSirWakeReasonInd
4174 wake_reason_ind),
4175 void *wakeIndicationCBContext,
4176#endif /* WLAN_WAKEUP_EVENTS */
4177 tpSirSmeWowlEnterParams wowl_enter_params,
4178 uint8_t session_id)
4179{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304180 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4182 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304183
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304184 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 TRACE_CODE_SME_RX_HDD_ENTER_WOWL, session_id, 0));
4186
4187 /* cache the WOWL information */
4188 ps_global_info->ps_params[session_id].wowl_enter_params =
4189 *wowl_enter_params;
4190 ps_global_info->ps_params[session_id].enter_wowl_callback_routine =
4191 enter_wowl_callback_routine;
4192 ps_global_info->ps_params[session_id].enter_wowl_callback_context =
4193 enter_wowl_callback_context;
4194#ifdef WLAN_WAKEUP_EVENTS
4195 /* Cache the Wake Reason Indication callback information */
4196 ps_global_info->ps_params[session_id].wake_reason_ind_cb =
4197 wakeIndicationCB;
4198 ps_global_info->ps_params[session_id].wake_reason_ind_cb_ctx =
4199 wakeIndicationCBContext;
4200#endif /* WLAN_WAKEUP_EVENTS */
4201
4202 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_ENTER);
4203 return status;
4204}
4205/**
4206 *sme_exit_wowl(): SME API exposed to HDD to request exit from WoWLAN mode.
4207 * @hal_ctx - The handle returned by mac_open.
4208 * @wowl_exit_params - Carries info on which smesession
4209 * wowl exit is requested.
4210 *
4211 * SME will initiate exit from WoWLAN mode and device will be
4212 * put in BMPS mode.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304213 * Return QDF_STATUS
4214 * QDF_STATUS_E_FAILURE Device cannot exit WoWLAN mode.
4215 * QDF_STATUS_SUCCESS Request accepted to exit WoWLAN mode.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304217QDF_STATUS sme_exit_wowl(tHalHandle hal_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 tpSirSmeWowlExitParams wowl_exit_params)
4219{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304220 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
4222 uint8_t session_id;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304223
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304224 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 TRACE_CODE_SME_RX_HDD_EXIT_WOWL, NO_SESSION, 0));
4226 session_id = wowl_exit_params->sessionId;
4227 status = sme_ps_process_command(mac_ctx, session_id, SME_PS_WOWL_EXIT);
4228 return status;
4229}
4230
4231/**
4232 * sme_roam_set_key() - To set encryption key.
4233 * @hal: hal global context
4234 * @session_id: session id
4235 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4236 * @ptr_roam_id: Upon success return, this is the id caller can use to
4237 * identify the request in roamcallback
4238 *
4239 * This function should be called only when connected. This is an asynchronous
4240 * API.
4241 *
4242 * Return: Status of operation
4243 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4246{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304247 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4249 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304250 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4252
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304253 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 session_id, 0));
4255 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004256 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 }
4259 /*Once Setkey is done, we can go in BMPS */
4260 if (set_key->keyLength)
4261 ps_global_info->remain_in_power_active_till_dhcp = false;
4262
4263 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304264 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 return status;
4266
4267 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4268 if (ptr_roam_id)
4269 *ptr_roam_id = roam_id;
4270
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004271 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004273 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 session = CSR_GET_SESSION(mac_ctx, session_id);
4275 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004276 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304278 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 }
4280 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4281 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4282 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4283 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4284 set_key->encType)) {
4285 session->pCurRoamProfile->negotiatedUCEncryptionType =
4286 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4287 }
4288 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4289 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4290 set_key->encType)) {
4291 session->pCurRoamProfile->negotiatedUCEncryptionType =
4292 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4293 }
4294 }
4295 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4296 sme_release_global_lock(&mac_ctx->sme);
4297 return status;
4298}
4299
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304300/**
4301 * sme_roam_set_default_key_index - To set default wep key idx
4302 * @hal: pointer to hal handler
4303 * @session_id: session id
4304 * @default_idx: default wep key index
4305 *
4306 * This function prepares a message and post to WMA to set wep default
4307 * key index
4308 *
4309 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4310 */
4311QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4312 uint8_t default_idx)
4313{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004314 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304315 struct wep_update_default_key_idx *update_key;
4316
4317 update_key = qdf_mem_malloc(sizeof(*update_key));
4318 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004319 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304320 return QDF_STATUS_E_NOMEM;
4321 }
4322
4323 update_key->session_id = session_id;
4324 update_key->default_idx = default_idx;
4325
4326 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4327 msg.reserved = 0;
4328 msg.bodyptr = (void *)update_key;
4329
4330 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004331 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004332 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304333 qdf_mem_free(update_key);
4334 return QDF_STATUS_E_FAILURE;
4335 }
4336
4337 return QDF_STATUS_SUCCESS;
4338}
4339
4340
Jeff Johnson8bd23352017-09-26 11:39:24 -07004341/**
4342 * sme_get_rssi() - API to retrieve current RSSI
4343 * @hHal: HAL handle for device
4344 * @callback: SME sends back the requested stats using the callback
4345 * @staId: The station ID for which the RSSI is requested for
4346 * @bssid: The bssid of the connected session
4347 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4348 * RSSI, do not hold up but return this value.
4349 * @pContext: user context to be passed back along with the callback
4350 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304351 * A wrapper function that client calls to register a callback to get RSSI
4352 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004353 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304354 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304355QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304356 tCsrRssiCallback callback, uint8_t staId,
4357 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004358 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304360 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4362
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304363 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4365 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304366 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 status = csr_get_rssi(pMac, callback,
4368 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004369 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 sme_release_global_lock(&pMac->sme);
4371 }
4372 return status;
4373}
4374
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304375/*
4376 * sme_get_snr() -
4377 * A wrapper function that client calls to register a callback to get SNR
4378 *
4379 * callback - SME sends back the requested stats using the callback
4380 * staId - The station ID for which the stats is requested for
4381 * pContext - user context to be passed back along with the callback
4382 * p_cds_context - cds context
4383 * \return QDF_STATUS
4384 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304385QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304387 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304389 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4391
4392 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304393 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4395 sme_release_global_lock(&pMac->sme);
4396 }
4397 return status;
4398}
4399
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304400/*
4401 * sme_get_statistics() -
4402 * A wrapper function that client calls to register a callback to get
4403 * different PHY level statistics from CSR.
4404 *
4405 * requesterId - different client requesting for statistics,
4406 * HDD, UMA/GAN etc
4407 * statsMask - The different category/categories of stats requester
4408 * is looking for
4409 * callback - SME sends back the requested stats using the callback
4410 * periodicity - If requester needs periodic update in millisec, 0 means
4411 * it's an one time request
4412 * cache - If requester is happy with cached stats
4413 * staId - The station ID for which the stats is requested for
4414 * pContext - user context to be passed back along with the callback
4415 * sessionId - sme session interface
4416 * Return QDF_STATUS
4417 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304418QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 eCsrStatsRequesterType requesterId,
4420 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004421 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304423 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304427 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304428 status = csr_get_statistics(pMac, requesterId, statsMask,
4429 callback, staId, pContext,
4430 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 sme_release_global_lock(&pMac->sme);
4432 }
4433
4434 return status;
4435
4436}
4437
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304438QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439 tCsrLinkStatusCallback callback,
4440 void *pContext, uint8_t sessionId)
4441{
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 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004445 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446
4447 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304448 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304449 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004450 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304451 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 "%s: Not able to allocate memory for link status",
4453 __func__);
4454 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304455 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 }
4457
4458 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4459 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4460 pMsg->sessionId = sessionId;
4461 pMac->sme.linkStatusContext = pContext;
4462 pMac->sme.linkStatusCallback = callback;
4463
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004464 message.type = WMA_LINK_STATUS_GET_REQ;
4465 message.bodyptr = pMsg;
4466 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304468 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004469 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4470 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304473 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474 pMac->sme.linkStatusContext = NULL;
4475 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 }
4478
4479 sme_release_global_lock(&pMac->sme);
4480 }
4481
4482 return status;
4483}
4484
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304485/*
4486 * sme_get_country_code() -
4487 * To return the current country code. If no country code is applied,
4488 * default country code is used to fill the buffer.
4489 * If 11d supported is turned off, an error is return and the last
4490 * applied/default country code is used.
4491 * This is a synchronous API.
4492 *
4493 * pBuf - pointer to a caller allocated buffer for returned country code.
4494 * pbLen For input, this parameter indicates how big is the buffer.
4495 * Upon return, this parameter has the number of bytes for
4496 * country. If pBuf doesn't have enough space, this function
4497 * returns fail status and this parameter contains the number
4498 * that is needed.
4499 *
4500 * Return QDF_STATUS SUCCESS.
4501 *
4502 * FAILURE or RESOURCES The API finished and failed.
4503 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304504QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505{
4506 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4507
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304508 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4510
4511 return csr_get_country_code(pMac, pBuf, pbLen);
4512}
4513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514/* some support functions */
4515bool sme_is11d_supported(tHalHandle hHal)
4516{
4517 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4518
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004519 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520}
4521
4522bool sme_is11h_supported(tHalHandle hHal)
4523{
4524 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4525
4526 return csr_is11h_supported(pMac);
4527}
4528
4529bool sme_is_wmm_supported(tHalHandle hHal)
4530{
4531 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4532
4533 return csr_is_wmm_supported(pMac);
4534}
4535
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304536/*
4537 * sme_change_country_code() -
4538 * Change Country code from upperlayer during WLAN driver operation.
4539 * This is a synchronous API.
4540 *
4541 * hHal - The handle returned by mac_open.
4542 * pCountry New Country Code String
4543 * sendRegHint If we want to send reg hint to nl80211
4544 * Return QDF_STATUS SUCCESS.
4545 * FAILURE or RESOURCES The API finished and failed.
4546 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304547QDF_STATUS sme_change_country_code(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 tSmeChangeCountryCallback callback,
4549 uint8_t *pCountry,
4550 void *pContext,
4551 void *p_cds_context,
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004552 bool countryFromUserSpace,
4553 bool sendRegHint)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304555 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004557 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 tAniChangeCountryCodeReq *pMsg;
4559
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304560 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 TRACE_CODE_SME_RX_HDD_CHANGE_CNTRYCODE, NO_SESSION,
4562 0));
4563 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304564 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565 if ((pMac->roam.configParam.Is11dSupportEnabledOriginal == true)
4566 && (!pMac->roam.configParam.
4567 fSupplicantCountryCodeHasPriority)) {
4568
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004569 sme_warn("Set Country Code Fail since the STA is associated and userspace does not have priority");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570
4571 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304572 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 return status;
4574 }
4575
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304576 pMsg = qdf_mem_malloc(sizeof(tAniChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004578 sme_err("csrChangeCountryCode: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304580 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 }
4582
4583 pMsg->msgType = eWNI_SME_CHANGE_COUNTRY_CODE;
4584 pMsg->msgLen = (uint16_t) sizeof(tAniChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304585 qdf_mem_copy(pMsg->countryCode, pCountry, 3);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 pMsg->countryFromUserSpace = countryFromUserSpace;
4587 pMsg->sendRegHint = sendRegHint;
4588 pMsg->changeCCCallback = callback;
4589 pMsg->pDevContext = pContext;
4590 pMsg->p_cds_context = p_cds_context;
4591
4592 msg.type = eWNI_SME_CHANGE_COUNTRY_CODE;
4593 msg.bodyptr = pMsg;
4594 msg.reserved = 0;
4595
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304596 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004597 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004598 sme_err("sme_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304599 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304600 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 sme_release_global_lock(&pMac->sme);
4603 }
4604
4605 return status;
4606}
4607
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304608/*
4609 * sme_generic_change_country_code() -
4610 * Change Country code from upperlayer during WLAN driver operation.
4611 * This is a synchronous API.
4612 *
4613 * hHal - The handle returned by mac_open.
4614 * pCountry New Country Code String
4615 * reg_domain regulatory domain
4616 * Return QDF_STATUS SUCCESS.
4617 * FAILURE or RESOURCES The API finished and failed.
4618 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304619QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004620 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304622 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004624 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 tAniGenericChangeCountryCodeReq *pMsg;
4626
4627 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304628 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 "%s: pMac is null", __func__);
4630 return status;
4631 }
4632
4633 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304634 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304635 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636
4637 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004638 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 }
4642
4643 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4644 pMsg->msgLen =
4645 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304646 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004647 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004648
4649 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4650 msg.bodyptr = pMsg;
4651 msg.reserved = 0;
4652
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304653 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004654 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004655 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304656 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304657 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004659 sme_release_global_lock(&pMac->sme);
4660 }
4661
4662 return status;
4663}
4664
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304665/*
4666 * sme_dhcp_start_ind() -
4667 * API to signal the FW about the DHCP Start event.
4668 *
4669 * hHal - HAL handle for device.
4670 * device_mode - mode(AP,SAP etc) of the device.
4671 * macAddr - MAC address of the adapter.
4672 * sessionId - session ID.
4673 * Return QDF_STATUS SUCCESS.
4674 * FAILURE or RESOURCES The API finished and failed.
4675 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304676QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 uint8_t device_mode,
4678 uint8_t *macAddr, uint8_t sessionId)
4679{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304680 QDF_STATUS status;
4681 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004682 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004683 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304685 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686
4687 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304688 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 pSession = CSR_GET_SESSION(pMac, sessionId);
4690
4691 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004692 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304694 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 }
Arif Hussain3316f402016-11-10 13:08:03 -08004696 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304698 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304700 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 "%s: Not able to allocate memory for dhcp start",
4702 __func__);
4703 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304704 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 }
4706 pMsg->msgType = WMA_DHCP_START_IND;
4707 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4708 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304709 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304710 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304711 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004712 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004714 message.type = WMA_DHCP_START_IND;
4715 message.bodyptr = pMsg;
4716 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304717 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004718 sessionId, message.type));
4719 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4720 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304721 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304724 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304725 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 }
4727 sme_release_global_lock(&pMac->sme);
4728 }
4729 return status;
4730}
4731
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304732/*
4733 * sme_dhcp_stop_ind() -
4734 * API to signal the FW about the DHCP complete event.
4735 *
4736 * hHal - HAL handle for device.
4737 * device_mode - mode(AP, SAP etc) of the device.
4738 * macAddr - MAC address of the adapter.
4739 * sessionId - session ID.
4740 * Return QDF_STATUS SUCCESS.
4741 * FAILURE or RESOURCES The API finished and failed.
4742 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304743QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 uint8_t device_mode,
4745 uint8_t *macAddr, uint8_t sessionId)
4746{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 QDF_STATUS status;
4748 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004750 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304752 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753
4754 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304755 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 pSession = CSR_GET_SESSION(pMac, sessionId);
4757
4758 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004759 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304761 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762 }
Arif Hussain3316f402016-11-10 13:08:03 -08004763 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304765 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304767 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 "%s: Not able to allocate memory for dhcp stop",
4769 __func__);
4770 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304771 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 }
4773
4774 pMsg->msgType = WMA_DHCP_STOP_IND;
4775 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4776 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304777 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304778 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304779 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004780 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004782 message.type = WMA_DHCP_STOP_IND;
4783 message.bodyptr = pMsg;
4784 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304785 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004786 sessionId, message.type));
4787 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4788 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304789 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304790 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304792 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304793 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 }
4795
4796 sme_release_global_lock(&pMac->sme);
4797 }
4798 return status;
4799}
4800
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304801/*
4802 * sme_TXFailMonitorStopInd() -
4803 * API to signal the FW to start monitoring TX failures
4804 *
4805 * Return QDF_STATUS SUCCESS.
4806 * FAILURE or RESOURCES The API finished and failed.
4807 */
4808QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4809 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004810 void *txFailIndCallback)
4811{
4812 QDF_STATUS status;
4813 QDF_STATUS qdf_status;
4814 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004815 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004816 tAniTXFailMonitorInd *pMsg;
4817
4818 status = sme_acquire_global_lock(&pMac->sme);
4819 if (QDF_STATUS_SUCCESS == status) {
4820 pMsg = (tAniTXFailMonitorInd *)
4821 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4822 if (NULL == pMsg) {
4823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4824 "%s: Failed to allocate memory", __func__);
4825 sme_release_global_lock(&pMac->sme);
4826 return QDF_STATUS_E_NOMEM;
4827 }
4828
4829 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4830 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4831
4832 /* tx_fail_count = 0 should disable the Monitoring in FW */
4833 pMsg->tx_fail_count = tx_fail_count;
4834 pMsg->txFailIndCallback = txFailIndCallback;
4835
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004836 message.type = WMA_TX_FAIL_MONITOR_IND;
4837 message.bodyptr = pMsg;
4838 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004839
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004840 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4841 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004842 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4843 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4844 "%s: Post TX Fail monitor Start MSG fail",
4845 __func__);
4846 qdf_mem_free(pMsg);
4847 status = QDF_STATUS_E_FAILURE;
4848 }
4849 sme_release_global_lock(&pMac->sme);
4850 }
4851 return status;
4852}
4853
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304854/*
4855 * sme_set_cfg_privacy() -
4856 * API to set configure privacy parameters
4857 *
4858 * hHal - The handle returned by mac_open.
4859 * pProfile - Pointer CSR Roam profile.
4860 * fPrivacy - This parameter indicates status of privacy
4861 * Return void
4862 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863void sme_set_cfg_privacy(tHalHandle hHal,
4864 tCsrRoamProfile *pProfile, bool fPrivacy)
4865{
4866 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304867
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304868 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY, NO_SESSION, 0));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304870 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 csr_set_cfg_privacy(pMac, pProfile, fPrivacy);
4872 sme_release_global_lock(&pMac->sme);
4873 }
4874}
4875
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304876/*
4877 * sme_neighbor_report_request() -
4878 * API to request neighbor report.
4879 *
4880 * hHal - The handle returned by mac_open.
4881 * pRrmNeighborReq - Pointer to a caller allocated object of type
4882 * tRrmNeighborReq. Caller owns the memory and is
4883 * responsible for freeing it.
4884 * Return QDF_STATUS
4885 * QDF_STATUS_E_FAILURE - failure
4886 * QDF_STATUS_SUCCESS success
4887 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304888QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304890 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304892 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304894
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304895 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004896 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4897 0));
4898
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304899 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 status =
4901 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304902 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903 sme_release_global_lock(&pMac->sme);
4904 }
4905
4906 return status;
4907}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304909/*
4910 * sme_get_wcnss_wlan_compiled_version() -
4911 * This API returns the version of the WCNSS WLAN API with
4912 * which the HOST driver was built
4913 *
4914 * hHal - The handle returned by mac_open.
4915 * pVersion - Points to the Version structure to be filled
4916 * Return QDF_STATUS
4917 * QDF_STATUS_E_INVAL - failure
4918 * QDF_STATUS_SUCCESS success
4919 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304920QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 tSirVersionType *pVersion)
4922{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4925
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304926 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304928 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304930 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931
4932 sme_release_global_lock(&pMac->sme);
4933 }
4934
4935 return status;
4936}
4937
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304938/*
4939 * sme_get_wcnss_wlan_reported_version() -
4940 * This API returns the version of the WCNSS WLAN API with
4941 * which the WCNSS driver reports it was built
4942 * hHal - The handle returned by mac_open.
4943 * pVersion - Points to the Version structure to be filled
4944 * Return QDF_STATUS
4945 * QDF_STATUS_E_INVAL - failure
4946 * QDF_STATUS_SUCCESS success
4947 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304948QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 tSirVersionType *pVersion)
4950{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304951 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304954 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304956 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959
4960 sme_release_global_lock(&pMac->sme);
4961 }
4962
4963 return status;
4964}
4965
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304966/*
4967 * sme_get_wcnss_software_version() -
4968 * This API returns the version string of the WCNSS driver
4969 *
4970 * hHal - The handle returned by mac_open.
4971 * pVersion - Points to the Version string buffer to be filled
4972 * versionBufferSize - THe size of the Version string buffer
4973 * Return QDF_STATUS
4974 * QDF_STATUS_E_INVAL - failure
4975 * QDF_STATUS_SUCCESS success
4976 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 uint8_t *pVersion,
4979 uint32_t versionBufferSize)
4980{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304981 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304984 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304985 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004987 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 pVersion,
4989 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304990 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304991 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 sme_release_global_lock(&pMac->sme);
4993 }
4994
4995 return status;
4996}
4997
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304998/*
4999 * sme_get_wcnss_hardware_version() -
5000 * This API returns the version string of the WCNSS hardware
5001 *
5002 * hHal - The handle returned by mac_open.
5003 * pVersion - Points to the Version string buffer to be filled
5004 * versionBufferSize - THe size of the Version string buffer
5005 * Return QDF_STATUS
5006 * QDF_STATUS_E_INVAL - failure
5007 * QDF_STATUS_SUCCESS success
5008 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305009QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 uint8_t *pVersion,
5011 uint32_t versionBufferSize)
5012{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5015
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305016 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305018 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305020 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021
5022 sme_release_global_lock(&pMac->sme);
5023 }
5024
5025 return status;
5026}
5027
5028#ifdef FEATURE_WLAN_WAPI
5029
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305030/*
5031 * sme_scan_get_bkid_candidate_list() -
5032 * A wrapper function to return the BKID candidate list
5033 *
5034 * pBkidList - caller allocated buffer point to an array of
5035 * tBkidCandidateInfo
5036 * pNumItems - pointer to a variable that has the number of
5037 * tBkidCandidateInfo allocated when retruning, this is
5038 * either the number needed or number of items put into
5039 * pPmkidList
5040 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
5041 * big enough and pNumItems
5042 * has the number of tBkidCandidateInfo.
5043 * Note: pNumItems is a number of tBkidCandidateInfo,
5044 * not sizeof(tBkidCandidateInfo) * something
5045 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305046QDF_STATUS sme_scan_get_bkid_candidate_list(tHalHandle hHal, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 tBkidCandidateInfo *pBkidList,
5048 uint32_t *pNumItems)
5049{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305050 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5052
5053 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305054 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305056 csr_scan_get_bkid_candidate_list(pMac, sessionId,
5057 pBkidList, pNumItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 sme_release_global_lock(&pMac->sme);
5059 }
5060
5061 return status;
5062}
5063#endif /* FEATURE_WLAN_WAPI */
5064
5065#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005066/**
5067 * sme_oem_data_req() - send oem data request to WMA
5068 * @hal: HAL handle
5069 * @hdd_oem_req: OEM data request from HDD
5070 *
5071 * Return: QDF_STATUS
5072 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005073QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305075 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07005076 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005077 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005079 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005080 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
5081 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005082 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005083 return QDF_STATUS_E_FAILURE;
5084 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005086 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
5087 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005088 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005089 return QDF_STATUS_E_NOMEM;
5090 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005092 oem_data_req->data_len = hdd_oem_req->data_len;
5093 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
5094 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005095 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005096 return QDF_STATUS_E_NOMEM;
5097 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005099 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
5100 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005102 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305104 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005105 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305106 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005107 sme_debug("OEM request(length: %d) sent to WMA",
5108 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07005109
5110 if (oem_data_req->data_len)
5111 qdf_mem_free(oem_data_req->data);
5112 qdf_mem_free(oem_data_req);
5113
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005114 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 return status;
5116}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117#endif /*FEATURE_OEM_DATA_SUPPORT */
5118
Krunal Soni8d184fa2017-11-20 21:52:05 -08005119QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005120{
Arif Hussainee677012017-01-26 17:50:13 -08005121 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005122 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08005123 struct cdp_pdev *pdev;
5124 ol_txrx_peer_handle peer;
5125 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07005126 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305128 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07005129 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08005130 __func__, params->type_of_persona,
5131 params->sme_session_id, params->subtype_of_persona,
5132 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005133
Arif Hussainee677012017-01-26 17:50:13 -08005134 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
5135
5136 if (NULL == pdev) {
5137 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5138 "%s: Failed to get pdev handler", __func__);
5139 return status;
5140 }
5141
Krunal Soni8d184fa2017-11-20 21:52:05 -08005142 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005143 if (QDF_IS_STATUS_ERROR(status))
5144 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145
Krunal Soni8d184fa2017-11-20 21:52:05 -08005146 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
5147 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08005148 if (peer) {
5149 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
5150 "%s: Peer=%d exist with same MAC",
5151 __func__, peer_id);
5152 status = QDF_STATUS_E_INVAL;
5153 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005154 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08005155 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08005156 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07005157
5158 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005159 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160
5161 return status;
5162}
5163
Krunal Soni8d184fa2017-11-20 21:52:05 -08005164QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305166 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08005167 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305169 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08005170 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305172 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08005173 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005174 sme_release_global_lock(&pMac->sme);
5175 }
5176
5177 return status;
5178}
5179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305180/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305181 * sme_change_mcc_beacon_interval() -
5182 * To update P2P-GO beaconInterval. This function should be called after
5183 * disassociating all the station is done
5184 * This is an asynchronous API.
5185 *
5186 * @sessionId: Session Identifier
5187 * Return QDF_STATUS SUCCESS
5188 * FAILURE or RESOURCES
5189 * The API finished and failed.
5190 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005191QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305193 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005194 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005195
Krunal Soni3fa80e22018-01-09 14:16:02 -08005196 if (!mac_ctx) {
5197 sme_err("mac_ctx is NULL");
5198 return status;
5199 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005200 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305201 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07005202 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
5203 sessionId);
5204 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 }
5206 return status;
5207}
5208
5209/**
5210 * sme_set_host_offload(): API to set the host offload feature.
5211 * @hHal: The handle returned by mac_open.
5212 * @sessionId: Session Identifier
5213 * @request: Pointer to the offload request.
5214 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305215 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305217QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 tpSirHostOffloadReq request)
5219{
5220 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305221 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305223 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
5225 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305226 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227#ifdef WLAN_NS_OFFLOAD
5228 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
5229 status = sme_set_ps_ns_offload(hHal, request,
5230 sessionId);
5231 } else
5232#endif /* WLAN_NS_OFFLOAD */
5233 {
5234 status = sme_set_ps_host_offload(hHal, request,
5235 sessionId);
5236 }
5237 sme_release_global_lock(&pMac->sme);
5238 }
5239
5240 return status;
5241}
5242
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305243/*
5244 * sme_set_keep_alive() -
5245 * API to set the Keep Alive feature.
5246 *
5247 * hHal - The handle returned by mac_open.
5248 * request - Pointer to the Keep Alive request.
5249 * Return QDF_STATUS
5250 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305251QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 tpSirKeepAliveReq request)
5253{
5254 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005255 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305257 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 FL("WMA_SET_KEEP_ALIVE message"));
5261
5262 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305263 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005264 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305265 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305267 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305269 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305270 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305271 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 }
5273
Anurag Chouhanc5548422016-02-24 18:33:27 +05305274 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305275 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305277 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 "buff TP %d input TP %d ", request_buf->timePeriod,
5279 request->timePeriod);
5280 request_buf->sessionId = session_id;
5281
5282 msg.type = WMA_SET_KEEP_ALIVE;
5283 msg.reserved = 0;
5284 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305285 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5286 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305287 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005288 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305289 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305290 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305291 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305292 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 }
5294
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305295 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296}
5297
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305298/*
5299 * sme_get_operation_channel() -
5300 * API to get current channel on which STA is parked his function gives
5301 * channel information only of infra station or IBSS station
5302 *
5303 * hHal, pointer to memory location and sessionId
5304 * Returns QDF_STATUS_SUCCESS
5305 * QDF_STATUS_E_FAILURE
5306 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305307QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308 uint8_t sessionId)
5309{
5310 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305311 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312
5313 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5314 pSession = CSR_GET_SESSION(pMac, sessionId);
5315
5316 if ((pSession->connectedProfile.BSSType ==
5317 eCSR_BSS_TYPE_INFRASTRUCTURE)
5318 || (pSession->connectedProfile.BSSType ==
5319 eCSR_BSS_TYPE_IBSS)
5320 || (pSession->connectedProfile.BSSType ==
5321 eCSR_BSS_TYPE_INFRA_AP)
5322 || (pSession->connectedProfile.BSSType ==
5323 eCSR_BSS_TYPE_START_IBSS)) {
5324 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305325 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 }
5327 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305328 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329} /* sme_get_operation_channel ends here */
5330
Abhishek Singh7996eb72015-12-30 17:24:02 +05305331/**
5332 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5333 * management frame indication to PE.
5334 *
5335 * @hal: hal pointer
5336 * @callback: callback pointer to be registered
5337 *
5338 * This function is used to register a callback for management
5339 * frame indication to PE.
5340 *
5341 * Return: Success if msg is posted to PE else Failure.
5342 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305343QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305344 sir_mgmt_frame_ind_callback callback)
5345{
5346 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5347 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305348 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305349
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305350 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305351 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305352 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305353 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005354 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305355 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305356 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305357 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305358 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5359 msg->length = sizeof(*msg);
5360
5361 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005362 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305363 sme_release_global_lock(&mac_ctx->sme);
5364 return status;
5365 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305366 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305367}
5368
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305369/*
5370 * sme_RegisterMgtFrame() -
5371 * To register managment frame of specified type and subtype.
5372 *
5373 * frameType - type of the frame that needs to be passed to HDD.
5374 * matchData - data which needs to be matched before passing frame
5375 * to HDD.
5376 * matchDataLen - Length of matched data.
5377 * Return QDF_STATUS
5378 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305379QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 uint16_t frameType, uint8_t *matchData,
5381 uint16_t matchLen)
5382{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305383 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305387 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 tSirRegisterMgmtFrame *pMsg;
5389 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305390 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5391 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392
5393 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005394 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305396 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 }
5398
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305399 if (!CSR_IS_SESSION_ANY(sessionId) &&
5400 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305401 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 "%s Invalid Sessionid", __func__);
5403 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305404 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 }
5406
5407 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5408
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305409 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305411 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5414 pMsg->length = len;
5415 pMsg->sessionId = sessionId;
5416 pMsg->registerFrame = true;
5417 pMsg->frameType = frameType;
5418 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305419 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005420 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421 }
5422 sme_release_global_lock(&pMac->sme);
5423 }
5424 return status;
5425}
5426
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305427/*
5428 * sme_DeregisterMgtFrame() -
5429 * To De-register managment frame of specified type and subtype.
5430 *
5431 * frameType - type of the frame that needs to be passed to HDD.
5432 * matchData - data which needs to be matched before passing frame
5433 * to HDD.
5434 * matchDataLen - Length of matched data.
5435 * Return QDF_STATUS
5436 */
5437QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 uint16_t frameType, uint8_t *matchData,
5439 uint16_t matchLen)
5440{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305441 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5443
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305444 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5446 0));
5447 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305448 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 tSirRegisterMgmtFrame *pMsg;
5450 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305451 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5452 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453
5454 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005455 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305457 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 }
5459
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305460 if (!CSR_IS_SESSION_ANY(sessionId) &&
5461 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 "%s Invalid Sessionid", __func__);
5464 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305465 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 }
5467
5468 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5469
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305470 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305472 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5475 pMsg->length = len;
5476 pMsg->registerFrame = false;
5477 pMsg->frameType = frameType;
5478 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305479 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005480 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 }
5482 sme_release_global_lock(&pMac->sme);
5483 }
5484 return status;
5485}
5486
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005488/**
5489 * sme_configure_ext_wow() - configure Extr WoW
5490 * @hHal - The handle returned by mac_open.
5491 * @wlanExtParams - Depicts the wlan Ext params.
5492 * @callback - ext_wow callback to be registered.
5493 * @callback_context - ext_wow callback context
5494 *
5495 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305496 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005497 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305498QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 tpSirExtWoWParams wlanExtParams,
5500 csr_readyToExtWoWCallback callback,
5501 void *callback_context)
5502{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305503 QDF_STATUS status = QDF_STATUS_SUCCESS;
5504 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005506 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305507 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508
5509 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305510 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305512 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5514
5515 pMac->readyToExtWoWCallback = callback;
5516 pMac->readyToExtWoWContext = callback_context;
5517
5518 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305519 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520
5521 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305522 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005523 message.bodyptr = MsgPtr;
5524 message.type = WMA_WLAN_EXT_WOW;
5525 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5526 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305527 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 pMac->readyToExtWoWCallback = NULL;
5529 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305530 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305531 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 }
5533 sme_release_global_lock(&pMac->sme);
5534 } else {
5535 pMac->readyToExtWoWCallback = NULL;
5536 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305537 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 }
5539
5540 return status;
5541}
5542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305543/*
5544 * sme_configure_app_type1_params() -
5545 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5546 *
5547 * hHal - The handle returned by mac_open.
5548 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5549 * Return QDF_STATUS
5550 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305551QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 tpSirAppType1Params wlanAppType1Params)
5553{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305554 QDF_STATUS status = QDF_STATUS_SUCCESS;
5555 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005557 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305558 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559
5560 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305561 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305563 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5565 0));
5566
5567 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305568 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305570 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005571 message.bodyptr = MsgPtr;
5572 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
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)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305576 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305577 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 }
5579 sme_release_global_lock(&pMac->sme);
5580 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305581 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 }
5583
5584 return status;
5585}
5586
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305587/*
5588 * sme_configure_app_type2_params() -
5589 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5590 *
5591 * hHal - The handle returned by mac_open.
5592 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5593 * Return QDF_STATUS
5594 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305595QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305596 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305598 QDF_STATUS status = QDF_STATUS_SUCCESS;
5599 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005601 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305602 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603
5604 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305605 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305607 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5609 0));
5610
5611 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305612 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005615 message.bodyptr = MsgPtr;
5616 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5617 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5618 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305619 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305620 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305621 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622 }
5623 sme_release_global_lock(&pMac->sme);
5624 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305625 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 }
5627
5628 return status;
5629}
5630#endif
5631
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305632/*
5633 * sme_get_infra_session_id
5634 * To get the session ID for infra session, if connected
5635 * This is a synchronous API.
5636 *
5637 * hHal - The handle returned by mac_open.
5638 * sessionid, -1 if infra session is not connected
5639 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640int8_t sme_get_infra_session_id(tHalHandle hHal)
5641{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305642 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 int8_t sessionid = -1;
5644 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5645
5646 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305647 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648
5649 sessionid = csr_get_infra_session_id(pMac);
5650
5651 sme_release_global_lock(&pMac->sme);
5652 }
5653
5654 return sessionid;
5655}
5656
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305657/*
5658 * sme_get_infra_operation_channel() -
5659 * To get the operating channel for infra session, if connected
5660 * This is a synchronous API.
5661 *
5662 * hHal - The handle returned by mac_open.
5663 * sessionId - the sessionId returned by sme_open_session.
5664 * Return operating channel, 0 if infra session is not connected
5665 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5667{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305668 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5670 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305673 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674
5675 channel = csr_get_infra_operation_channel(pMac, sessionId);
5676
5677 sme_release_global_lock(&pMac->sme);
5678 }
5679
5680 return channel;
5681}
5682
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305683/* This routine will return poerating channel on which other BSS is operating
5684 * to be used for concurrency mode. If other BSS is not up or not connected it
5685 * will return 0
5686 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5688{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305689 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005690 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5691 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305694 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695
5696 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305697 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5698 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 sme_release_global_lock(&pMac->sme);
5700 }
5701
5702 return channel;
5703}
5704
5705#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5706uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5707 eCsrPhyMode sapPhyMode,
5708 uint8_t cc_switch_mode)
5709{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305710 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5712 uint16_t channel = 0;
5713
5714 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305715 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305717 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5718 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719 cc_switch_mode);
5720 sme_release_global_lock(&pMac->sme);
5721 }
5722
5723 return channel;
5724}
5725#endif
5726
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305727/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005728 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005729 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005730 * @cb_fn: Callback function pointer
5731 * @db_ctx: Callback data
5732 *
5733 * Return: QDF_STATUS
5734 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005735QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005736 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5737{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005738 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005739 QDF_STATUS status;
5740
Manikandan Mohan976e7562016-03-15 16:33:31 -07005741 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005742 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005743 mac->sme.get_tsf_cb = cb_fn;
5744 mac->sme.get_tsf_cxt = cb_ctx;
5745 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005746 }
5747 return status;
5748}
5749
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305750/**
5751 * sme_reset_tsfcb() - Reset callback for TSF capture
5752 * @h_hal: Handler return by mac_open
5753 *
5754 * This function reset the tsf capture callback to SME
5755 *
5756 * Return: QDF_STATUS
5757 */
5758QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5759{
5760 tpAniSirGlobal mac;
5761 QDF_STATUS status;
5762
5763 if (!h_hal) {
5764 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5765 FL("h_hal is not valid"));
5766 return QDF_STATUS_E_INVAL;
5767 }
5768 mac = PMAC_STRUCT(h_hal);
5769
5770 status = sme_acquire_global_lock(&mac->sme);
5771 if (QDF_IS_STATUS_SUCCESS(status)) {
5772 mac->sme.get_tsf_cb = NULL;
5773 mac->sme.get_tsf_cxt = NULL;
5774 sme_release_global_lock(&mac->sme);
5775 }
5776 return status;
5777}
5778
Manikandan Mohan976e7562016-03-15 16:33:31 -07005779#ifdef WLAN_FEATURE_TSF
5780/*
5781 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5782 * @h_hal: Handler return by mac_open
5783 * @pinvalue: gpio pin id
5784 *
5785 * Return: QDF_STATUS
5786 */
5787QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5788{
5789 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005790 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005791 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5792
5793 status = sme_acquire_global_lock(&mac->sme);
5794 if (QDF_IS_STATUS_SUCCESS(status)) {
5795 tsf_msg.type = WMA_TSF_GPIO_PIN;
5796 tsf_msg.reserved = 0;
5797 tsf_msg.bodyval = pinvalue;
5798
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005799 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005800 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005801 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005802 status = QDF_STATUS_E_FAILURE;
5803 }
5804 sme_release_global_lock(&mac->sme);
5805 }
5806 return status;
5807}
5808#endif
5809
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005810QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 uint32_t *len)
5812{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305813 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005814 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005815
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005816 if (NULL == mac_ctx) {
5817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5818 FL("Invalid MAC context"));
5819 return QDF_STATUS_E_FAILURE;
5820 }
5821
5822 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305823 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005824 status = csr_get_cfg_valid_channels(mac_ctx,
5825 aValidChannels, len);
5826 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 }
5828
5829 return status;
5830}
5831
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005832static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5833{
5834 switch (src) {
5835 case SOURCE_CORE:
5836 return "WORLD MODE";
5837
5838 case SOURCE_DRIVER:
5839 return "BDF file";
5840
5841 case SOURCE_USERSPACE:
5842 return "user-space";
5843
5844 case SOURCE_11D:
5845 return "802.11D IEs in beacons";
5846
5847 default:
5848 return "unknown";
5849 }
5850}
5851
Amar Singhal6edf9732016-11-20 21:43:40 -08005852void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5853{
5854 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5855
5856 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005857
5858 sme_debug("Country source is %s",
5859 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005860}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305861/*
5862 * sme_handle_change_country_code() -
5863 * Change Country code, Reg Domain and channel list
5864 *
5865 * Details Country Code Priority
5866 * If Supplicant country code is priority than 11d is disabled.
5867 * If 11D is enabled, we update the country code after every scan.
5868 * Hence when Supplicant country code is priority, we don't need 11D info.
5869 * Country code from Supplicant is set as current courtry code.
5870 * User can send reset command XX (instead of country code) to reset the
5871 * country code to default values. If 11D is priority,
5872 * Than Supplicant country code code is set to default code. But 11D code
5873 * is set as current country code
5874 *
5875 * pMac - The handle returned by mac_open.
5876 * pMsgBuf - MSG Buffer
5877 * Return QDF_STATUS
5878 */
5879static QDF_STATUS sme_handle_change_country_code(tpAniSirGlobal pMac,
5880 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005881{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305882 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 tAniChangeCountryCodeReq *pMsg;
5884 v_REGDOMAIN_t domainIdIoctl;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305885 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Amar Singhala297bfa2015-10-15 15:07:29 -07005886 static uint8_t default_country[CDS_COUNTRY_CODE_LEN + 1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305888 pMsg = (tAniChangeCountryCodeReq *) pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889 /*
5890 * if the reset Supplicant country code command is triggered,
5891 * enable 11D, reset the country code and return
5892 */
Ankit Guptaa5076012016-09-14 11:32:19 -07005893 if (!qdf_mem_cmp(pMsg->countryCode, SME_INVALID_COUNTRY_CODE, 2)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005894 pMac->roam.configParam.Is11dSupportEnabled =
5895 pMac->roam.configParam.Is11dSupportEnabledOriginal;
5896
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -07005897 qdf_status = ucfg_reg_get_default_country(pMac->psoc,
5898 default_country);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899
5900 /* read the country code and use it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305901 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305902 qdf_mem_copy(pMsg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 default_country,
5904 WNI_CFG_COUNTRY_CODE_LEN);
5905 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305906 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 return status;
5908 }
5909 /*
5910 * Update the 11d country to default country so that when
5911 * callback is received for this default country, driver will
5912 * not disable the 11d taking it as valid country by user.
5913 */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005914 sme_debug(
5915 "Set default country code (%c%c) as invalid country received",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916 pMsg->countryCode[0], pMsg->countryCode[1]);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305917 qdf_mem_copy(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 pMsg->countryCode,
5919 WNI_CFG_COUNTRY_CODE_LEN);
5920 } else {
5921 /* if Supplicant country code has priority, disable 11d */
5922 if (pMac->roam.configParam.fSupplicantCountryCodeHasPriority &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305923 pMsg->countryFromUserSpace)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 }
5926
5927 if (pMac->roam.configParam.Is11dSupportEnabled)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305928 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929
5930 /* Set Current Country code and Current Regulatory domain */
5931 status = csr_set_country_code(pMac, pMsg->countryCode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305932 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 /* Supplicant country code failed. So give 11D priority */
5934 pMac->roam.configParam.Is11dSupportEnabled =
5935 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005936 sme_err("Set Country Code Fail %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005937 return status;
5938 }
5939
5940 /* overwrite the defualt country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305941 qdf_mem_copy(pMac->scan.countryCodeDefault,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
5943
5944 /* Get Domain ID from country code */
5945 status = csr_get_regulatory_domain_for_country(pMac,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305946 pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 (v_REGDOMAIN_t *) &
Amar Singhala297bfa2015-10-15 15:07:29 -07005948 domainIdIoctl,
5949 SOURCE_QUERY);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305950 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005951 sme_err("Fail to get regId %d", domainIdIoctl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 return status;
5953 } else if (REGDOMAIN_WORLD == domainIdIoctl) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305954 /* Supplicant country code is invalid, so we are on world mode
5955 * now. So give 11D chance to update
5956 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957 pMac->roam.configParam.Is11dSupportEnabled =
5958 pMac->roam.configParam.Is11dSupportEnabledOriginal;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005959 sme_warn("Country Code unrecognized by driver");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005960 }
5961
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005962 if (domainIdIoctl >= REGDOMAIN_COUNT) {
5963 sme_err("Invalid regId %d", domainIdIoctl);
5964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005965 } else {
5966 /* if 11d has priority, clear currentCountryBssid & countryCode11d to get */
5967 /* set again if we find AP with 11d info during scan */
5968 if (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005969 sme_warn("Clearing currentCountryBssid, countryCode11d");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305970 qdf_mem_zero(&pMac->scan.currentCountryBssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305971 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305972 qdf_mem_zero(pMac->scan.countryCode11d,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 sizeof(pMac->scan.countryCode11d));
5974 }
5975 }
5976
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305977 if (pMsg->changeCCCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 ((tSmeChangeCountryCallback) (pMsg->changeCCCallback))((void *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305979 pMsg->pDevContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305981 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982}
5983
5984/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005985 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 * @mac_ctx: mac global context
5987 * @msg: request msg packet
5988 *
5989 * If Supplicant country code is priority than 11d is disabled.
5990 * If 11D is enabled, we update the country code after every scan.
5991 * Hence when Supplicant country code is priority, we don't need 11D info.
5992 * Country code from Supplicant is set as current country code.
5993 *
5994 * Return: status of operation
5995 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305996static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005997sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5998 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306000 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006001 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006002 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006004 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005
Amar Singhal6edf9732016-11-20 21:43:40 -08006006 if (SOURCE_11D != mac_ctx->reg_hint_src) {
6007 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
6008 if (user_ctry_priority)
6009 mac_ctx->roam.configParam.Is11dSupportEnabled =
6010 false;
6011 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306012 if (mac_ctx->roam.configParam.
6013 Is11dSupportEnabled &&
6014 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006016 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006017
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306018 status =
6019 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08006020 mac_ctx,
6021 mac_ctx->scan.countryCode11d,
6022 &reg_domain_id,
6023 SOURCE_11D);
6024 return QDF_STATUS_E_FAILURE;
6025 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006026 }
6027 }
6028 } else {
6029 /* if kernel gets invalid country code; it
6030 * resets the country code to world
6031 */
6032 if (('0' != msg->countryCode[0]) ||
6033 ('0' != msg->countryCode[1]))
6034 qdf_mem_copy(mac_ctx->scan.countryCode11d,
6035 msg->countryCode,
6036 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07006038
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006039 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
6040 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 /* get the channels based on new cc */
6044 status = csr_get_channel_and_power_list(mac_ctx);
6045
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306046 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006047 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 return status;
6049 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 /* reset info based on new cc, and we are done */
6052 csr_apply_channel_power_info_wrapper(mac_ctx);
6053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006054 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006055
6056 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 * Country IE
6058 */
6059 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07006060
Amar Singhal6edf9732016-11-20 21:43:40 -08006061 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
6062
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006063 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07006064
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306065 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066}
6067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068static bool
6069sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
6070{
6071 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306072 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 ch_lst_info = &mac_ctx->scan.base_channels;
6075 for (i = 0; i < ch_lst_info->numChannels; i++) {
6076 if (ch_lst_info->channelList[i] == curr_ch)
6077 return true;
6078 }
6079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 return false;
6081}
6082/**
6083 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
6084 * if channel is not supported
6085 * @mac_ctx: mac global context
6086 *
6087 * If new country code does not support the channel on which STA/P2P client
6088 * is connetced, it sends the disconnect to the AP/P2P GO
6089 *
6090 * Return: void
6091 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306092static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093{
6094 uint8_t session_id, found = false;
6095 uint8_t curr_ch;
6096
6097 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
6098 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
6099 continue;
6100 found = false;
6101 /* Session is connected.Check the channel */
6102 curr_ch = csr_get_infra_operation_channel(mac_ctx,
6103 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006104 sme_debug("Current Operating channel : %d, session :%d",
6105 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
6107 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006108 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109 csr_roam_disconnect(mac_ctx, session_id,
6110 eCSR_DISCONNECT_REASON_UNSPECIFIED);
6111 }
6112 }
6113}
6114
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306116QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006117 tpSirRcvFltMcAddrList pMulticastAddrs)
6118{
6119 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006120 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306122 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306124 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
6125 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006127 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006129 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07006130 pSession = CSR_GET_SESSION(pMac, sessionId);
6131 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
6132 (!csr_is_conn_state_infra(pMac, sessionId) &&
6133 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306134 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08006135 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306137 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 }
6139
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306140 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306143 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306145 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 }
6147
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006148 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
6149 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306150 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07006151 "%s: Request ignored, session %d is not connected or started",
6152 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306153 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306154 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 }
6156
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306157 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006158 sizeof(tSirRcvFltMcAddrList));
6159
Anurag Chouhanc5548422016-02-24 18:33:27 +05306160 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
6161 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08006162 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006163
6164 msg.type = WMA_8023_MULTICAST_LIST_REQ;
6165 msg.reserved = 0;
6166 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306167 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6168 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006169 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006170 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306171 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306172 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306174 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306175 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 }
6177
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306178 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006180#endif /* WLAN_FEATURE_PACKET_FILTERING */
6181
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306182/*
6183 * sme_is_channel_valid() -
6184 * To check if the channel is valid for currently established domain
6185 * This is a synchronous API.
6186 *
6187 * hHal - The handle returned by mac_open.
6188 * channel - channel to verify
6189 * Return true/false, true if channel is valid
6190 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006191bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
6192{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306193 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006194 bool valid = false;
6195 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6196
6197 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306198 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199
6200 valid = csr_roam_is_channel_valid(pMac, channel);
6201
6202 sme_release_global_lock(&pMac->sme);
6203 }
6204
6205 return valid;
6206}
6207
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306208/*
6209 * sme_set_freq_band() -
6210 * Used to set frequency band.
6211 *
6212 * hHal
6213 * sessionId - Session Identifier
6214 * band value to be configured
6215 * Return QDF_STATUS
6216 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006217QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
6218 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306220 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006221 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6222
6223 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306224 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225 status = csr_set_band(hHal, sessionId, eBand);
6226 sme_release_global_lock(&pMac->sme);
6227 }
6228 return status;
6229}
6230
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306231/*
6232 * sme_get_freq_band() -
6233 * Used to get the current band settings.
6234 *
6235 * hHal
6236 * pBand pointer to hold band value
6237 * Return QDF_STATUS
6238 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006239QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306241 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006242 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6243
6244 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306245 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006246 *pBand = csr_get_current_band(hHal);
6247 sme_release_global_lock(&pMac->sme);
6248 }
6249 return status;
6250}
6251
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306252/*
6253 * sme_set_max_tx_power_per_band() -
6254 * Set the Maximum Transmit Power specific to band dynamically.
6255 * Note: this setting will not persist over reboots.
6256 *
6257 * band
6258 * power to set in dB
6259 * Return QDF_STATUS
6260 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08006261QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006263 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006264 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
6265
6266 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306267 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006268 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306269 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
6271 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306272 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006273 }
6274
6275 pMaxTxPowerPerBandParams->power = dB;
6276 pMaxTxPowerPerBandParams->bandInfo = band;
6277
6278 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
6279 msg.reserved = 0;
6280 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306281 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
6282 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006283 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006284 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306285 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
6287 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306288 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306289 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006290 }
6291
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306292 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006293}
6294
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306295/*
6296 * sme_set_max_tx_power() -
6297 * Set the Maximum Transmit Power dynamically. Note: this setting will
6298 * not persist over reboots.
6299 *
6300 * hHal
6301 * pBssid BSSID to set the power cap for
6302 * pBssid pSelfMacAddress self MAC Address
6303 * pBssid power to set in dB
6304 * Return QDF_STATUS
6305 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05306306QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
6307 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006308{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006309 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006310 tpMaxTxPowerParams pMaxTxParams = NULL;
6311
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306312 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006313 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306314 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006317 "%s: Not able to allocate memory for pMaxTxParams",
6318 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306319 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 }
6321
Anurag Chouhanc5548422016-02-24 18:33:27 +05306322 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6323 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006324 pMaxTxParams->power = dB;
6325
6326 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6327 msg.reserved = 0;
6328 msg.bodyptr = pMaxTxParams;
6329
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006330 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006331 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306332 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6334 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306335 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306336 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006337 }
6338
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306339 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006340}
6341
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306342/*
6343 * sme_set_custom_mac_addr() -
6344 * Set the customer Mac Address.
6345 *
6346 * customMacAddr customer MAC Address
6347 * Return QDF_STATUS
6348 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306349QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006351 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352 tSirMacAddr *pBaseMacAddr;
6353
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306354 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 if (NULL == pBaseMacAddr) {
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 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306358 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 }
6360
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306361 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362
6363 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6364 msg.reserved = 0;
6365 msg.bodyptr = pBaseMacAddr;
6366
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006367 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006368 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306369 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306370 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306371 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306372 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006373 }
6374
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306375 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376}
6377
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306378/*
6379 * sme_set_tx_power() -
6380 * Set Transmit Power dynamically.
6381 *
6382 * hHal
6383 * sessionId Target Session ID
6384 * BSSID
6385 * dev_mode dev_mode such as station, P2PGO, SAP
6386 * dBm power to set
6387 * Return QDF_STATUS
6388 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306389QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306390 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006391 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006392{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006393 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 tpMaxTxPowerParams pTxParams = NULL;
6395 int8_t power = (int8_t) dBm;
6396
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306397 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006398 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6399
6400 /* make sure there is no overflow */
6401 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306402 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006403 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306404 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006405 }
6406
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306407 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006408 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306409 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006410 "%s: Not able to allocate memory for pTxParams",
6411 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306412 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006413 }
6414
Anurag Chouhanc5548422016-02-24 18:33:27 +05306415 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 pTxParams->power = power; /* unit is dBm */
6417 pTxParams->dev_mode = dev_mode;
6418 msg.type = WMA_SET_TX_POWER_REQ;
6419 msg.reserved = 0;
6420 msg.bodyptr = pTxParams;
6421
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006422 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006423 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306424 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006425 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6426 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306427 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 }
6430
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306431 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006432}
6433
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306434QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6435 uint8_t param_val)
6436{
6437 QDF_STATUS status;
6438 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6439
6440 pMac->roam.configParam.is_fils_enabled = !param_val;
6441
6442 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6443 status = wma_cli_set_command((int)session_id,
6444 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6445 !param_val, VDEV_CMD);
6446 if (status)
6447 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6448 "%s: Failed to set enable bcast probe setting",
6449 __func__);
6450
6451 return status;
6452}
6453
6454QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306455 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006456{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306457 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306458 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006459 uint16_t len;
6460
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306461 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306462 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306463 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306464 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6465 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306467 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006468 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306469 sme_release_global_lock(&mac_ctx->sme);
6470 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006471 }
6472
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306473 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6474 mac_ctx->ignore_assoc_disallowed = param_val;
6475
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306476 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306477 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006478
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306479 len = sizeof(*msg);
6480 msg = qdf_mem_malloc(len);
6481 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306482 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006483 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306484 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6485 msg->length = len;
6486 msg->session_id = session_id;
6487 msg->param_type = param_type;
6488 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006489 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306491 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006492 }
6493 return status;
6494}
6495
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306496/*
6497 * sme_set_tm_level() -
6498 * Set Thermal Mitigation Level to RIVA
6499 *
6500 * hHal - The handle returned by mac_open.
6501 * newTMLevel - new Thermal Mitigation Level
6502 * tmMode - Thermal Mitigation handle mode, default 0
6503 * Return QDF_STATUS
6504 */
6505QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6506 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006507{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306508 QDF_STATUS status = QDF_STATUS_SUCCESS;
6509 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006510 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006511 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006512 tAniSetTmLevelReq *setTmLevelReq = NULL;
6513
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306514 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6516 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306517 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006518 setTmLevelReq =
6519 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306520 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006521 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306522 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006523 "%s: Not able to allocate memory for sme_set_tm_level",
6524 __func__);
6525 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306526 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 }
6528
6529 setTmLevelReq->tmMode = tmMode;
6530 setTmLevelReq->newTmLevel = newTMLevel;
6531
6532 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006533 message.bodyptr = setTmLevelReq;
6534 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306535 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006536 NO_SESSION, message.type));
6537 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6538 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306539 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306540 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006541 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306542 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306543 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 }
6545 sme_release_global_lock(&pMac->sme);
6546 }
6547 return status;
6548}
6549
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306550/*
6551 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6552 * Host and FW.
6553 *
6554 * hHal - HAL handle for device
6555 * Return NONE
6556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006557void sme_feature_caps_exchange(tHalHandle hHal)
6558{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306559 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306560 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6561 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562}
6563
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306564/*
6565 * sme_disable_feature_capablity() - SME interface to disable Active mode
6566 * offload capablity in Host.
6567 *
6568 * hHal - HAL handle for device
6569 * Return NONE
6570 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571void sme_disable_feature_capablity(uint8_t feature_index)
6572{
6573}
6574
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306575/*
6576 * sme_reset_power_values_for5_g
6577 * Reset the power values for 5G band with default power values.
6578 *
6579 * hHal - HAL handle for device
6580 * Return NONE
6581 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582void sme_reset_power_values_for5_g(tHalHandle hHal)
6583{
6584 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306585
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306586 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006587 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6588 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306589 /* Store the channel+power info in the global place: Cfg */
6590 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006591}
6592
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306593/*
6594 * sme_update_roam_prefer5_g_hz() -
6595 * Enable/disable Roam prefer 5G runtime option
6596 * This function is called through dynamic setConfig callback function
6597 * to configure the Roam prefer 5G runtime option
6598 *
6599 * hHal - HAL handle for device
6600 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6601 * Return Success or failure
6602 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306604QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6605 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006606{
6607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306608 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006609
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_UPDATE_RP5G, NO_SESSION, 0));
6612 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306613 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306614 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615 "%s: gRoamPrefer5GHz is changed from %d to %d",
6616 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6617 nRoamPrefer5GHz);
6618 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6619 sme_release_global_lock(&pMac->sme);
6620 }
6621
6622 return status;
6623}
6624
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306625/*
6626 * sme_set_roam_intra_band() -
6627 * enable/disable Intra band roaming
6628 * This function is called through dynamic setConfig callback function
6629 * to configure the intra band roaming
6630 * hHal - HAL handle for device
6631 * nRoamIntraBand Enable/Disable Intra band roaming
6632 * Return Success or failure
6633 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306634QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635{
6636 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306637 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306639 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006640 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6641 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306642 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306643 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006644 "%s: gRoamIntraBand is changed from %d to %d",
6645 __func__, pMac->roam.configParam.nRoamIntraBand,
6646 nRoamIntraBand);
6647 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6648 sme_release_global_lock(&pMac->sme);
6649 }
6650
6651 return status;
6652}
6653
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306654/*
6655 * sme_update_roam_scan_n_probes() -
6656 * Function to update roam scan N probes
6657 * This function is called through dynamic setConfig callback function
6658 * to update roam scan N probes
6659 * hHal - HAL handle for device
6660 * sessionId - Session Identifier
6661 * nProbes number of probe requests to be sent out
6662 * Return Success or failure
6663 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306664QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006665 const uint8_t nProbes)
6666{
6667 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306668 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306670 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6672 NO_SESSION, 0));
6673 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306674 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676 "%s: gRoamScanNProbes is changed from %d to %d",
6677 __func__, pMac->roam.configParam.nProbes, nProbes);
6678 pMac->roam.configParam.nProbes = nProbes;
6679 sme_release_global_lock(&pMac->sme);
6680 }
6681 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6682 csr_roam_offload_scan(pMac, sessionId,
6683 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6684 REASON_NPROBES_CHANGED);
6685 }
6686 return status;
6687}
6688
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306689/*
6690 * sme_update_roam_scan_home_away_time() -
6691 * Function to update roam scan Home away time
6692 * This function is called through dynamic setConfig callback function
6693 * to update roam scan home away time
6694 *
6695 * hHal - HAL handle for device
6696 * sessionId - Session Identifier
6697 * nRoamScanAwayTime Scan home away time
6698 * bSendOffloadCmd If true then send offload command to firmware
6699 * If false then command is not sent to firmware
6700 * Return Success or failure
6701 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306702QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006703 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306704 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006705 const bool bSendOffloadCmd)
6706{
6707 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306708 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006709
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306710 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6712 NO_SESSION, 0));
6713 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306714 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006716 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6717 __func__,
6718 pMac->roam.configParam.nRoamScanHomeAwayTime,
6719 nRoamScanHomeAwayTime);
6720 pMac->roam.configParam.nRoamScanHomeAwayTime =
6721 nRoamScanHomeAwayTime;
6722 sme_release_global_lock(&pMac->sme);
6723 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306724 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6725 bSendOffloadCmd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726 csr_roam_offload_scan(pMac, sessionId,
6727 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6728 REASON_HOME_AWAY_TIME_CHANGED);
6729 }
6730 return status;
6731}
6732
Abhishek Singh518323d2015-10-19 17:42:01 +05306733/**
6734 * sme_ext_change_channel()- function to post send ECSA
6735 * action frame to csr.
6736 * @hHal: Hal context
6737 * @channel: new channel to switch
6738 * @session_id: senssion it should be sent on.
6739 *
6740 * This function is called to post ECSA frame to csr.
6741 *
6742 * Return: success if msg is sent else return failure
6743 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306744QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306745 uint8_t session_id)
6746{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306747 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306748 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6749 uint8_t channel_state;
6750
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006751 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306752 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006753 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306754
6755 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006756 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306757 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306758 }
6759
6760 status = sme_acquire_global_lock(&mac_ctx->sme);
6761
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306762 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306763 /* update the channel list to the firmware */
6764 status = csr_send_ext_change_channel(mac_ctx,
6765 channel, session_id);
6766 sme_release_global_lock(&mac_ctx->sme);
6767 }
6768
6769 return status;
6770}
6771
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306772/*
6773 * sme_get_roam_intra_band() -
6774 * get Intra band roaming
6775 *
6776 * hHal - HAL handle for device
6777 * Return Success or failure
6778 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006779bool sme_get_roam_intra_band(tHalHandle hHal)
6780{
6781 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306782
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306783 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006784 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6785 return pMac->roam.configParam.nRoamIntraBand;
6786}
6787
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306788/*
6789 * sme_get_roam_scan_n_probes() -
6790 * get N Probes
6791 *
6792 * hHal - HAL handle for device
6793 * Return Success or failure
6794 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6796{
6797 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306798
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006799 return pMac->roam.configParam.nProbes;
6800}
6801
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306802/*
6803 * sme_get_roam_scan_home_away_time() -
6804 * get Roam scan home away time
6805 *
6806 * hHal - HAL handle for device
6807 * Return Success or failure
6808 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6810{
6811 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6814}
6815
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306816/*
6817 * sme_update_roam_rssi_diff() -
6818 * Update RoamRssiDiff
6819 * This function is called through dynamic setConfig callback function
6820 * to configure RoamRssiDiff
6821 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6822 *
6823 * hHal - HAL handle for device
6824 * sessionId - Session Identifier
6825 * RoamRssiDiff - minimum rssi difference between potential
6826 * candidate and current AP.
6827 * Return Success or failure
6828 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306830QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006831 uint8_t RoamRssiDiff)
6832{
6833 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306834 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006835
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006836 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6837 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6838 FL("Invalid sme session id: %d"), sessionId);
6839 return QDF_STATUS_E_INVAL;
6840 }
6841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006842 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306843 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6846 RoamRssiDiff,
6847 pMac->roam.configParam.RoamRssiDiff,
6848 mac_trace_get_neighbour_roam_state(pMac->roam.
6849 neighborRoamInfo
6850 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306851 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
6853 sme_release_global_lock(&pMac->sme);
6854 }
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006855
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306856 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 csr_roam_offload_scan(pMac, sessionId,
6858 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6859 REASON_RSSI_DIFF_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860 return status;
6861}
6862
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306863#ifdef WLAN_FEATURE_FILS_SK
6864QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
6865 tCsrRoamProfile *src_profile)
6866{
6867 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6868 QDF_STATUS status = QDF_STATUS_SUCCESS;
6869 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6870 &mac->roam.neighborRoamInfo[session_id];
6871
6872 if (session_id >= CSR_ROAM_SESSION_MAX) {
6873 sme_err("Invalid sme session id: %d", session_id);
6874 return QDF_STATUS_E_INVAL;
6875 }
6876
6877 if (!src_profile) {
6878 sme_err("src roam profile NULL");
6879 return QDF_STATUS_E_INVAL;
6880 }
6881
6882 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6883 (neighbor_roam_info->neighborRoamState !=
6884 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6885 sme_info("Fast roam is disabled or not connected(%d)",
6886 neighbor_roam_info->neighborRoamState);
6887 return QDF_STATUS_E_PERM;
6888 }
6889
6890 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306891 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306892 sme_debug("Updating fils config to fw");
6893 csr_roam_offload_scan(mac, session_id,
6894 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6895 REASON_FILS_PARAMS_CHANGED);
6896 } else {
6897 sme_info("LFR3 not enabled");
6898 return QDF_STATUS_E_INVAL;
6899 }
6900
6901 return status;
6902}
6903
6904void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6905 tCsrRoamProfile *profile, uint32_t if_addr)
6906{
6907 int i;
6908 struct scheduler_msg msg;
6909 QDF_STATUS status;
6910 struct hlp_params *params;
6911 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6912 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6913 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6914 &mac->roam.neighborRoamInfo[session_id];
6915
6916 if (!session) {
6917 sme_err("session NULL");
6918 return;
6919 }
6920
6921 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6922 (neighbor_roam_info->neighborRoamState !=
6923 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6924 sme_debug("Fast roam is disabled or not connected(%d)",
6925 neighbor_roam_info->neighborRoamState);
6926 return;
6927 }
6928
6929 params = qdf_mem_malloc(sizeof(*params));
6930 if (!params) {
6931 sme_err("Mem alloc for HLP IE fails");
6932 return;
6933 }
6934 if ((profile->hlp_ie_len +
6935 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6936 sme_err("HLP IE len exceeds %d",
6937 profile->hlp_ie_len);
6938 qdf_mem_free(params);
6939 return;
6940 }
6941
6942 params->vdev_id = session_id;
6943 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6944
6945 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6946 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6947
6948 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6949 profile->hlp_ie, profile->hlp_ie_len);
6950
6951 msg.type = SIR_HAL_HLP_IE_INFO;
6952 msg.reserved = 0;
6953 msg.bodyptr = params;
6954 status = sme_acquire_global_lock(&mac->sme);
6955 if (status != QDF_STATUS_SUCCESS) {
6956 sme_err("sme lock acquire fails");
6957 qdf_mem_free(params);
6958 return;
6959 }
6960
6961 if (!QDF_IS_STATUS_SUCCESS
6962 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6963 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6964 sme_release_global_lock(&mac->sme);
6965 qdf_mem_free(params);
6966 return;
6967 }
6968
6969 sme_release_global_lock(&mac->sme);
6970}
6971
Jeff Johnson172237b2017-11-07 15:32:59 -08006972void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306973{
6974 struct fils_join_rsp_params *roam_fils_params;
6975
6976 if (!roam_info) {
6977 sme_err("FILS Roam Info NULL");
6978 return;
6979 }
6980
6981 roam_fils_params = roam_info->fils_join_rsp;
6982 if (!roam_fils_params) {
6983 sme_err("FILS Roam Param NULL");
6984 return;
6985 }
6986
6987 if (roam_fils_params->fils_pmk)
6988 qdf_mem_free(roam_fils_params->fils_pmk);
6989
6990 qdf_mem_free(roam_fils_params);
6991
6992 roam_info->fils_join_rsp = NULL;
6993}
6994
6995#else
6996inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
6997 tCsrRoamProfile *profile, uint32_t if_addr)
6998{}
6999#endif
7000
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307001/*
7002 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
7003 * support at runtime
7004 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7005 * isFastTransitionEnabled.
7006 * This is a synchronous call
7007 *
7008 * hHal - The handle returned by mac_open.
7009 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
7010 * successfully.
7011 * Other status means SME is failed to update isFastTransitionEnabled.
7012 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307013QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007014 bool isFastTransitionEnabled)
7015{
7016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307017 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007018
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307019 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007020 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
7021 0));
7022 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307023 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307024 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007025 "%s: FastTransitionEnabled is changed from %d to %d",
7026 __func__,
7027 pMac->roam.configParam.isFastTransitionEnabled,
7028 isFastTransitionEnabled);
7029 pMac->roam.configParam.isFastTransitionEnabled =
7030 isFastTransitionEnabled;
7031 sme_release_global_lock(&pMac->sme);
7032 }
7033
7034 return status;
7035}
7036
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307037/*
7038 * sme_update_wes_mode() -
7039 * Update WES Mode
7040 * This function is called through dynamic setConfig callback function
7041 * to configure isWESModeEnabled
7042 *
7043 * hHal - HAL handle for device
7044 * isWESModeEnabled - WES mode
7045 * sessionId - Session Identifier
7046 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
7047 * Other status means SME is failed to update isWESModeEnabled.
7048 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007049
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307050QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007051 uint8_t sessionId)
7052{
7053 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007056 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7058 FL("Invalid sme session id: %d"), sessionId);
7059 return QDF_STATUS_E_INVAL;
7060 }
7061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307063 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007065 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
7066 isWESModeEnabled,
7067 pMac->roam.configParam.isWESModeEnabled,
7068 mac_trace_get_neighbour_roam_state(pMac->roam.
7069 neighborRoamInfo
7070 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307071 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007072 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
7073 sme_release_global_lock(&pMac->sme);
7074 }
7075
7076 return status;
7077}
7078
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307079/*
7080 * sme_set_roam_scan_control() -
7081 * Set roam scan control
7082 * This function is called to set roam scan control
7083 * if roam scan control is set to 0, roaming scan cache is cleared
7084 * any value other than 0 is treated as invalid value
7085 * hHal - HAL handle for device
7086 * sessionId - Session Identifier
7087 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7088 * Other status means SME failure to update
7089 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307090QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007091 bool roamScanControl)
7092{
7093 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307094 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307096 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007098
7099 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7100 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7101 FL("Invalid sme session id: %d"), sessionId);
7102 return QDF_STATUS_E_INVAL;
7103 }
7104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007105 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307106 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307107 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007108 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
7109 roamScanControl,
7110 pMac->roam.configParam.nRoamScanControl,
7111 mac_trace_get_neighbour_roam_state(pMac->roam.
7112 neighborRoamInfo
7113 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307114 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115 pMac->roam.configParam.nRoamScanControl = roamScanControl;
7116 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307119 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
7120 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007121 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7122 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307123 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7124 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125 }
7126 }
7127 sme_release_global_lock(&pMac->sme);
7128 }
7129 return status;
7130}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007131
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307132/*
7133 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
7134 * support at runtime
7135 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7136 * isFastRoamIniFeatureEnabled.
7137 * This is a synchronous call
7138 *
7139 * hHal - The handle returned by mac_open.
7140 * sessionId - Session Identifier
7141 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
7142 * successfully.
7143 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
7144 */
7145QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
7146 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
7147{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007148 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
7149
7150 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
7151 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307152 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007153 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
7154 __func__,
7155 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7156 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307157 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007158 }
7159
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307160 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161 "%s: FastRoamEnabled is changed from %d to %d", __func__,
7162 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
7163 isFastRoamIniFeatureEnabled);
7164 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
7165 isFastRoamIniFeatureEnabled;
7166 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307167 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307169 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170}
7171
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307172/**
7173 * sme_config_fast_roaming() - enable/disable LFR support at runtime
7174 * @hal - The handle returned by macOpen.
7175 * @session_id - Session Identifier
7176 * @is_fast_roam_enabled - flag to enable/disable roaming
7177 *
7178 * When Supplicant issues enabled/disable fast roaming on the basis
7179 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
7180 *
7181 * Return: QDF_STATUS
7182 */
7183
7184QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
7185 const bool is_fast_roam_enabled)
7186{
7187 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307188 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307189 QDF_STATUS status;
7190
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007191 /*
7192 * supplicant_disabled_roaming flag is set to true in
7193 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
7194 * request with BSSID. This flag is reset when supplicant sends
7195 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007196 *
7197 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007198 * if roaming is disabled using driver command or INI and
7199 * supplicant_disabled_roaming flag remains set. So make sure to set
7200 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
7201 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08007202 */
7203 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007204 session->pCurRoamProfile->supplicant_disabled_roaming =
7205 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08007206
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307207 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007208 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307209 if (!is_fast_roam_enabled)
7210 return QDF_STATUS_SUCCESS;
7211 return QDF_STATUS_E_FAILURE;
7212 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307213
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307214 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
7215 session_id, is_fast_roam_enabled);
7216 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07007217 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05307218 return QDF_STATUS_E_FAILURE;
7219 }
7220
7221 return QDF_STATUS_SUCCESS;
7222}
7223
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307224/*
7225 * sme_update_is_mawc_ini_feature_enabled() -
7226 * Enable/disable LFR MAWC support at runtime
7227 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7228 * isMAWCIniFeatureEnabled.
7229 * This is a synchronous call
7230 *
7231 * hHal - The handle returned by mac_open.
7232 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
7233 * Other status means SME is failed to update MAWCEnabled.
7234 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307235QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 const bool MAWCEnabled)
7237{
7238 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307239 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007240
7241 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307242 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05307243 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007244 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07007245 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
7246 MAWCEnabled);
7247 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
7248 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007249 sme_release_global_lock(&pMac->sme);
7250 }
7251
7252 return status;
7253
7254}
7255
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007256/**
7257 * sme_stop_roaming() - Stop roaming for a given sessionId
7258 * This is a synchronous call
7259 *
7260 * @hHal - The handle returned by mac_open
7261 * @sessionId - Session Identifier
7262 *
7263 * Return QDF_STATUS_SUCCESS on success
7264 * Other status on failure
7265 */
7266QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007267{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007268 struct scheduler_msg wma_msg = {0};
7269 tSirRetStatus status;
7270 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007271 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7272 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007273 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007274
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007275 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007276 sme_err("incorrect session/vdev ID");
7277 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007278 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07007279
7280 session = CSR_GET_SESSION(mac_ctx, session_id);
7281 if (session->pCurRoamProfile &&
7282 !session->pCurRoamProfile->roaming_allowed_on_iface) {
7283 sme_debug("Roaming was never started on session %d",
7284 session_id);
7285 return QDF_STATUS_SUCCESS;
7286 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007287 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007288 req = qdf_mem_malloc(sizeof(*req));
7289 if (!req) {
7290 sme_err("failed to allocated memory");
7291 return QDF_STATUS_E_NOMEM;
7292 }
7293
7294 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Abhishek Singh533c9da2017-05-04 10:23:34 +05307295 if (reason == eCsrForcedDisassoc)
7296 req->reason = REASON_ROAM_STOP_ALL;
7297 else
7298 req->reason = REASON_ROAM_SYNCH_FAILED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007299 req->sessionId = session_id;
7300 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007301 req->middle_of_roaming = 1;
7302 else
7303 csr_roam_reset_roam_params(mac_ctx);
7304
7305 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7306 wma_msg.bodyptr = req;
7307
7308 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7309 if (eSIR_SUCCESS != status) {
7310 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007311 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007312 qdf_mem_free(req);
7313 return QDF_STATUS_E_FAULT;
7314 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007315 roam_info->b_roam_scan_offload_started = false;
7316 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007317
7318 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007319}
7320
Abhishek Singhd5686472017-09-20 15:18:50 +05307321void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7322{
7323 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7324 QDF_STATUS status = QDF_STATUS_SUCCESS;
7325 struct csr_roam_session *session;
7326
7327 status = sme_acquire_global_lock(&mac_ctx->sme);
7328 if (QDF_IS_STATUS_SUCCESS(status)) {
7329 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7330 session = CSR_GET_SESSION(mac_ctx, session_id);
7331 if (session)
7332 session->discon_in_progress = true;
7333 }
7334 sme_release_global_lock(&mac_ctx->sme);
7335 }
7336}
7337
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307338/*
7339 * sme_start_roaming() - Start roaming for a given sessionId
7340 * This is a synchronous call
7341 *
7342 * hHal - The handle returned by mac_open
7343 * sessionId - Session Identifier
7344 * Return QDF_STATUS_SUCCESS on success
7345 * Other status on failure
7346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307347QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007348{
7349 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007351
7352 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307353 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007354 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7355 reason);
7356 sme_release_global_lock(&pMac->sme);
7357 }
7358
7359 return status;
7360}
7361
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307362/*
7363 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7364 * Concurrent session exists
7365 * This is a synchronuous call
7366 *
7367 * hHal - The handle returned by mac_open.
7368 * Return QDF_STATUS_SUCCESS
7369 * Other status means SME is failed
7370 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307371QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007372 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307373 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007374{
7375
7376 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307377 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007378
7379 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307380 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7382 bFastRoamInConIniFeatureEnabled;
7383 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7384 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7385 0;
7386 }
7387 sme_release_global_lock(&pMac->sme);
7388 }
7389
7390 return status;
7391}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007392
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307393/*
7394 * sme_update_config_fw_rssi_monitoring() - enable/disable firmware RSSI
7395 * Monitoring at runtime
7396 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7397 * fEnableFwRssiMonitoring.
7398 * This is a synchronous call
7399 *
7400 * hHal - The handle returned by mac_open.
7401 * Return QDF_STATUS_SUCCESS - SME update fEnableFwRssiMonitoring.
7402 * config successfully.
7403 * Other status means SME is failed to update fEnableFwRssiMonitoring.
7404 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307405QDF_STATUS sme_update_config_fw_rssi_monitoring(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007406 bool fEnableFwRssiMonitoring)
7407{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307408 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007409
7410 if (sme_cfg_set_int (hHal, WNI_CFG_PS_ENABLE_RSSI_MONITOR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307411 fEnableFwRssiMonitoring) ==
7412 QDF_STATUS_E_FAILURE) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307413 qdf_ret_status = QDF_STATUS_E_FAILURE;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307414 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415 "Could not pass on WNI_CFG_PS_RSSI_MONITOR to CFG");
7416 }
7417
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307418 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007419}
7420
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307421/*
7422 * sme_set_roam_opportunistic_scan_threshold_diff() -
7423 * Update Opportunistic Scan threshold diff
7424 * This function is called through dynamic setConfig callback function
7425 * to configure nOpportunisticThresholdDiff
7426 *
7427 * hHal - HAL handle for device
7428 * sessionId - Session Identifier
7429 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7430 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7431 * successfully.
7432 * else SME is failed to update nOpportunisticThresholdDiff.
7433 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307434QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007435 uint8_t sessionId,
7436 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307437 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438{
7439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307440 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007441
7442 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307443 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007444 status = csr_neighbor_roam_update_config(pMac, sessionId,
7445 nOpportunisticThresholdDiff,
7446 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307447 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007448 pMac->roam.configParam.neighborRoamConfig.
7449 nOpportunisticThresholdDiff =
7450 nOpportunisticThresholdDiff;
7451 }
7452 sme_release_global_lock(&pMac->sme);
7453 }
7454 return status;
7455}
7456
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307457/*
7458 * sme_get_roam_opportunistic_scan_threshold_diff()
7459 * gets Opportunistic Scan threshold diff
7460 * This is a synchronous call
7461 *
7462 * hHal - The handle returned by mac_open
7463 * Return uint8_t - nOpportunisticThresholdDiff
7464 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7466{
7467 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007469 return pMac->roam.configParam.neighborRoamConfig.
7470 nOpportunisticThresholdDiff;
7471}
7472
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307473/*
7474 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7475 * This function is called through dynamic setConfig callback function
7476 * to configure nRoamRescanRssiDiff
7477 *
7478 * hHal - HAL handle for device
7479 * sessionId - Session Identifier
7480 * nRoamRescanRssiDiff - roam rescan rssi diff
7481 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7482 * successfully.
7483 * else SME is failed to update nRoamRescanRssiDiff.
7484 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307485QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007486 uint8_t sessionId,
7487 const uint8_t nRoamRescanRssiDiff)
7488{
7489 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307490 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491
7492 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307493 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007494 status = csr_neighbor_roam_update_config(pMac, sessionId,
7495 nRoamRescanRssiDiff,
7496 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307497 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007498 pMac->roam.configParam.neighborRoamConfig.
7499 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7500 }
7501 sme_release_global_lock(&pMac->sme);
7502 }
7503 return status;
7504}
7505
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307506/*
7507 * sme_get_roam_rescan_rssi_diff()
7508 * gets roam rescan rssi diff
7509 * This is a synchronous call
7510 *
7511 * hHal - The handle returned by mac_open
7512 * Return int8_t - nRoamRescanRssiDiff
7513 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007514uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7515{
7516 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007518 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7519}
7520
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307521/*
7522 * sme_set_roam_bmiss_first_bcnt() -
7523 * Update Roam count for first beacon miss
7524 * This function is called through dynamic setConfig callback function
7525 * to configure nRoamBmissFirstBcnt
7526 * hHal - HAL handle for device
7527 * sessionId - Session Identifier
7528 * nRoamBmissFirstBcnt - Roam first bmiss count
7529 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7530 * successfully.
7531 * else SME is failed to update nRoamBmissFirstBcnt
7532 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307533QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007534 uint8_t sessionId,
7535 const uint8_t nRoamBmissFirstBcnt)
7536{
7537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307538 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539
7540 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307541 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007542 status = csr_neighbor_roam_update_config(pMac, sessionId,
7543 nRoamBmissFirstBcnt,
7544 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307545 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007546 pMac->roam.configParam.neighborRoamConfig.
7547 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7548 }
7549 sme_release_global_lock(&pMac->sme);
7550 }
7551 return status;
7552}
7553
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307554/*
7555 * sme_get_roam_bmiss_first_bcnt() -
7556 * get neighbor roam beacon miss first count
7557 *
7558 * hHal - The handle returned by mac_open.
7559 * Return uint8_t - neighbor roam beacon miss first count
7560 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007561uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7562{
7563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307564
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7566}
7567
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307568/*
7569 * sme_set_roam_bmiss_final_bcnt() -
7570 * Update Roam count for final beacon miss
7571 * This function is called through dynamic setConfig callback function
7572 * to configure nRoamBmissFinalBcnt
7573 * hHal - HAL handle for device
7574 * sessionId - Session Identifier
7575 * nRoamBmissFinalBcnt - Roam final bmiss count
7576 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7577 * successfully.
7578 * else SME is failed to update nRoamBmissFinalBcnt
7579 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307580QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 uint8_t sessionId,
7582 const uint8_t nRoamBmissFinalBcnt)
7583{
7584 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307585 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007586
7587 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307588 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007589 status = csr_neighbor_roam_update_config(pMac, sessionId,
7590 nRoamBmissFinalBcnt,
7591 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307592 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007593 pMac->roam.configParam.neighborRoamConfig.
7594 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7595 }
7596 sme_release_global_lock(&pMac->sme);
7597 }
7598 return status;
7599}
7600
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307601/*
7602 * sme_get_roam_bmiss_final_bcnt() -
7603 * gets Roam count for final beacon miss
7604 * This is a synchronous call
7605 *
7606 * hHal - The handle returned by mac_open
7607 * Return uint8_t - nRoamBmissFinalBcnt
7608 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007609uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7610{
7611 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007613 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7614}
7615
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307616/*
7617 * sme_set_roam_beacon_rssi_weight() -
7618 * Update Roam beacon rssi weight
7619 * This function is called through dynamic setConfig callback function
7620 * to configure nRoamBeaconRssiWeight
7621 *
7622 * hHal - HAL handle for device
7623 * sessionId - Session Identifier
7624 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7625 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7626 * successfully.
7627 * else SME is failed to update nRoamBeaconRssiWeight
7628 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307629QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007630 uint8_t sessionId,
7631 const uint8_t nRoamBeaconRssiWeight)
7632{
7633 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307634 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007635
7636 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307637 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007638 status = csr_neighbor_roam_update_config(pMac, sessionId,
7639 nRoamBeaconRssiWeight,
7640 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307641 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007642 pMac->roam.configParam.neighborRoamConfig.
7643 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7644 }
7645 sme_release_global_lock(&pMac->sme);
7646 }
7647 return status;
7648}
7649
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307650/*
7651 * sme_get_roam_beacon_rssi_weight() -
7652 * gets Roam beacon rssi weight
7653 * This is a synchronous call
7654 *
7655 * hHal - The handle returned by mac_open
7656 * Return uint8_t - nRoamBeaconRssiWeight
7657 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007658uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7659{
7660 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7663}
7664
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307665/*
7666 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7667 * rssi threshold
7668 * This is a synchronous call
7669 *
7670 * hHal - The handle returned by mac_open.
7671 * sessionId - Session Identifier
7672 * Return QDF_STATUS_SUCCESS - SME update config successful.
7673 * Other status means SME is failed to update
7674 */
7675QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7676 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7677{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680
7681 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307682 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007683 status = csr_neighbor_roam_update_config(pMac,
7684 sessionId, neighborLookupRssiThreshold,
7685 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307686 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007687 pMac->roam.configParam.neighborRoamConfig.
7688 nNeighborLookupRssiThreshold =
7689 neighborLookupRssiThreshold;
7690 }
7691 sme_release_global_lock(&pMac->sme);
7692 }
7693 return status;
7694}
7695
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307696/*
7697 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7698 * This is a synchronous call
7699 *
7700 * hal - The handle returned by macOpen.
7701 * session_id - Session Identifier
7702 * delay_before_vdev_stop - value to be set
7703 * Return QDF_STATUS_SUCCESS - SME update config successful.
7704 * Other status means SME is failed to update
7705 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307706QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707 uint8_t session_id,
7708 uint8_t delay_before_vdev_stop)
7709{
7710 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307711 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007712
7713 if (session_id >= CSR_ROAM_SESSION_MAX) {
7714 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7715 FL("Invalid sme session id: %d"), session_id);
7716 return QDF_STATUS_E_INVAL;
7717 }
7718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007719 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307720 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307721 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7722 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007723 pMac->roam.configParam.neighborRoamConfig.
7724 delay_before_vdev_stop,
7725 delay_before_vdev_stop);
7726 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7727 delay_before_vdev_stop = delay_before_vdev_stop;
7728 pMac->roam.configParam.neighborRoamConfig.
7729 delay_before_vdev_stop = delay_before_vdev_stop;
7730 sme_release_global_lock(&pMac->sme);
7731 }
7732 return status;
7733}
7734
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307735/*
7736 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7737 * rssi threshold
7738 * This is a synchronous call
7739 *
7740 * hHal - The handle returned by mac_open.
7741 * Return QDF_STATUS_SUCCESS - SME update config successful.
7742 * Other status means SME is failed to update
7743 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007744uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7745{
7746 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007748 return pMac->roam.configParam.neighborRoamConfig.
7749 nNeighborLookupRssiThreshold;
7750}
7751
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307752/*
7753 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7754 * refresh period
7755 * This is a synchronous call
7756 *
7757 * hHal - The handle returned by mac_open.
7758 * sessionId - Session Identifier
7759 * Return QDF_STATUS_SUCCESS - SME update config successful.
7760 * Other status means SME is failed to update
7761 */
7762QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7763 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7764{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307766 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307767 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007768 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7769
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007770 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7772 FL("Invalid sme session id: %d"), sessionId);
7773 return QDF_STATUS_E_INVAL;
7774 }
7775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307777 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007778 pNeighborRoamConfig =
7779 &pMac->roam.configParam.neighborRoamConfig;
7780 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307781 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007782 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7783 neighborScanResultsRefreshPeriod,
7784 pMac->roam.configParam.neighborRoamConfig.
7785 nNeighborResultsRefreshPeriod,
7786 mac_trace_get_neighbour_roam_state(pMac->roam.
7787 neighborRoamInfo
7788 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307789 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7791 neighborScanResultsRefreshPeriod;
7792 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7793 neighborScanResultsRefreshPeriod;
7794
7795 sme_release_global_lock(&pMac->sme);
7796 }
7797 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7798 csr_roam_offload_scan(pMac, sessionId,
7799 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307800 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801 }
7802 return status;
7803}
7804
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307805/*
7806 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7807 * offload feaure
7808 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7809 * gRoamScanOffloadEnabled.
7810 * This is a synchronous call
7811 *
7812 * hHal - The handle returned by mac_open.
7813 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7814 * Other status means SME is failed to update.
7815 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307816QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817 bool nRoamScanOffloadEnabled)
7818{
7819 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307820 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007821
7822 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307823 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307824 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307825 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826 pMac->roam.configParam.isRoamOffloadScanEnabled,
7827 nRoamScanOffloadEnabled);
7828 pMac->roam.configParam.isRoamOffloadScanEnabled =
7829 nRoamScanOffloadEnabled;
7830 sme_release_global_lock(&pMac->sme);
7831 }
7832
7833 return status;
7834}
7835
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307836/*
7837 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7838 * refresh period
7839 * This is a synchronous call
7840 *
7841 * \param hHal - The handle returned by mac_open.
7842 * \return uint16_t - Neighbor scan results refresh period value
7843 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7845{
7846 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007848 return pMac->roam.configParam.neighborRoamConfig.
7849 nNeighborResultsRefreshPeriod;
7850}
7851
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307852/*
7853 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7854 * This is a synchronuous call
7855 *
7856 * hHal - The handle returned by mac_open.
7857 * Return QDF_STATUS_SUCCESS - SME update config successful.
7858 * Other status means SME is failed to update
7859 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007860uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7861{
7862 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307863
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 return pMac->roam.configParam.neighborRoamConfig.
7865 nEmptyScanRefreshPeriod;
7866}
7867
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307868/*
7869 * sme_update_empty_scan_refresh_period
7870 * Update nEmptyScanRefreshPeriod
7871 * This function is called through dynamic setConfig callback function
7872 * to configure nEmptyScanRefreshPeriod
7873 * Usage: adb shell iwpriv wlan0 setConfig
7874 * nEmptyScanRefreshPeriod=[0 .. 60]
7875 *
7876 * hHal - HAL handle for device
7877 * sessionId - Session Identifier
7878 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7879 * Return Success or failure
7880 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307882QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7883 sessionId, uint16_t
7884 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007885{
7886 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307887 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307888 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007889 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7890
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007891 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7892 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7893 FL("Invalid sme session id: %d"), sessionId);
7894 return QDF_STATUS_E_INVAL;
7895 }
7896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007897 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307898 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007899 pNeighborRoamConfig =
7900 &pMac->roam.configParam.neighborRoamConfig;
7901 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307902 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007903 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7904 nEmptyScanRefreshPeriod,
7905 pMac->roam.configParam.neighborRoamConfig.
7906 nEmptyScanRefreshPeriod,
7907 mac_trace_get_neighbour_roam_state(pMac->roam.
7908 neighborRoamInfo
7909 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307910 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007911 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7912 nEmptyScanRefreshPeriod;
7913 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7914 nEmptyScanRefreshPeriod;
7915 sme_release_global_lock(&pMac->sme);
7916 }
7917 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7918 csr_roam_offload_scan(pMac, sessionId,
7919 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7920 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7921 }
7922 return status;
7923}
7924
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307925/*
7926 * sme_set_neighbor_scan_min_chan_time() -
7927 * Update nNeighborScanMinChanTime
7928 * This function is called through dynamic setConfig callback function
7929 * to configure gNeighborScanChannelMinTime
7930 * Usage: adb shell iwpriv wlan0 setConfig
7931 * gNeighborScanChannelMinTime=[0 .. 60]
7932 *
7933 * hHal - HAL handle for device
7934 * nNeighborScanMinChanTime - Channel minimum dwell time
7935 * sessionId - Session Identifier
7936 * Return Success or failure
7937 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307938QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007939 const uint16_t
7940 nNeighborScanMinChanTime,
7941 uint8_t sessionId)
7942{
7943 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307944 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007945
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007946 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7948 FL("Invalid sme session id: %d"), sessionId);
7949 return QDF_STATUS_E_INVAL;
7950 }
7951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307953 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307954 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007955 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7956 nNeighborScanMinChanTime,
7957 pMac->roam.configParam.neighborRoamConfig.
7958 nNeighborScanMinChanTime,
7959 mac_trace_get_neighbour_roam_state(pMac->roam.
7960 neighborRoamInfo
7961 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307962 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007963
7964 pMac->roam.configParam.neighborRoamConfig.
7965 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7966 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7967 minChannelScanTime = nNeighborScanMinChanTime;
7968 sme_release_global_lock(&pMac->sme);
7969 }
7970
7971 return status;
7972}
7973
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307974/*
7975 * sme_set_neighbor_scan_max_chan_time() -
7976 * Update nNeighborScanMaxChanTime
7977 * This function is called through dynamic setConfig callback function
7978 * to configure gNeighborScanChannelMaxTime
7979 * Usage: adb shell iwpriv wlan0 setConfig
7980 * gNeighborScanChannelMaxTime=[0 .. 60]
7981 *
7982 * hHal - HAL handle for device
7983 * sessionId - Session Identifier
7984 * nNeighborScanMinChanTime - Channel maximum dwell time
7985 * Return Success or failure
7986 */
7987QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7988 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989 const uint16_t
7990 nNeighborScanMaxChanTime)
7991{
7992 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307993 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307994 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007995 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7996
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007997 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7999 FL("Invalid sme session id: %d"), sessionId);
8000 return QDF_STATUS_E_INVAL;
8001 }
8002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008003 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308004 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008005 pNeighborRoamConfig =
8006 &pMac->roam.configParam.neighborRoamConfig;
8007 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308008 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008009 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
8010 nNeighborScanMaxChanTime,
8011 pMac->roam.configParam.neighborRoamConfig.
8012 nNeighborScanMaxChanTime,
8013 mac_trace_get_neighbour_roam_state(pMac->roam.
8014 neighborRoamInfo
8015 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308016 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017 pNeighborRoamConfig->nNeighborScanMaxChanTime =
8018 nNeighborScanMaxChanTime;
8019 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
8020 nNeighborScanMaxChanTime;
8021 sme_release_global_lock(&pMac->sme);
8022 }
8023 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8024 csr_roam_offload_scan(pMac, sessionId,
8025 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8026 REASON_SCAN_CH_TIME_CHANGED);
8027 }
8028
8029 return status;
8030}
8031
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308032/*
8033 * sme_get_neighbor_scan_min_chan_time() -
8034 * get neighbor scan min channel time
8035 *
8036 * hHal - The handle returned by mac_open.
8037 * sessionId - Session Identifier
8038 * Return uint16_t - channel min time value
8039 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
8041{
8042 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008043
8044 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8045 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8046 FL("Invalid sme session id: %d"), sessionId);
8047 return 0;
8048 }
8049
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8051 minChannelScanTime;
8052}
8053
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308054/*
8055 * sme_get_neighbor_roam_state() -
8056 * get neighbor roam state
8057 *
8058 * hHal - The handle returned by mac_open.
8059 * sessionId - Session Identifier
8060 * Return uint32_t - neighbor roam state
8061 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008062uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
8063{
8064 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008065
8066 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8067 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8068 FL("Invalid sme session id: %d"), sessionId);
8069 return 0;
8070 }
8071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
8073}
8074
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308075/*
8076 * sme_get_current_roam_state() -
8077 * get current roam state
8078 *
8079 * hHal - The handle returned by mac_open.
8080 * sessionId - Session Identifier
8081 * Return uint32_t - current roam state
8082 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008083uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
8084{
8085 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308086
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008087 return pMac->roam.curState[sessionId];
8088}
8089
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308090/*
8091 * sme_get_current_roam_sub_state() -
8092 * \brief get neighbor roam sub state
8093 *
8094 * hHal - The handle returned by mac_open.
8095 * sessionId - Session Identifier
8096 * Return uint32_t - current roam sub state
8097 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008098uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
8099{
8100 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008102 return pMac->roam.curSubState[sessionId];
8103}
8104
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308105/*
8106 * sme_get_lim_sme_state() -
8107 * get Lim Sme state
8108 *
8109 * hHal - The handle returned by mac_open.
8110 * Return uint32_t - Lim Sme state
8111 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112uint32_t sme_get_lim_sme_state(tHalHandle hHal)
8113{
8114 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308115
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008116 return pMac->lim.gLimSmeState;
8117}
8118
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308119/*
8120 * sme_get_lim_mlm_state() -
8121 * get Lim Mlm state
8122 *
8123 * hHal - The handle returned by mac_open.
8124 * Return uint32_t - Lim Mlm state
8125 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008126uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
8127{
8128 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130 return pMac->lim.gLimMlmState;
8131}
8132
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308133/*
8134 * sme_is_lim_session_valid() -
8135 * is Lim session valid
8136 *
8137 * hHal - The handle returned by mac_open.
8138 * sessionId - Session Identifier
8139 * Return bool - true or false
8140 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008141bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
8142{
8143 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05308144
8145 if (sessionId > pMac->lim.maxBssId)
8146 return false;
8147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008148 return pMac->lim.gpSession[sessionId].valid;
8149}
8150
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308151/*
8152 * sme_get_lim_sme_session_state() -
8153 * get Lim Sme session state
8154 *
8155 * hHal - The handle returned by mac_open.
8156 * sessionId - Session Identifier
8157 * Return uint32_t - Lim Sme session state
8158 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
8160{
8161 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308162
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008163 return pMac->lim.gpSession[sessionId].limSmeState;
8164}
8165
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308166/*
8167 * sme_get_lim_mlm_session_state() -
8168 * \brief get Lim Mlm session state
8169 *
8170 * hHal - The handle returned by mac_open.
8171 * sessionId - Session Identifier
8172 * Return uint32_t - Lim Mlm session state
8173 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
8175{
8176 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 return pMac->lim.gpSession[sessionId].limMlmState;
8179}
8180
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308181/*
8182 * sme_get_neighbor_scan_max_chan_time() -
8183 * get neighbor scan max channel time
8184 *
8185 * hHal - The handle returned by mac_open.
8186 * sessionId - Session Identifier
8187 * Return uint16_t - channel max time value
8188 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008189uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
8190{
8191 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008192
8193 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8195 FL("Invalid sme session id: %d"), sessionId);
8196 return 0;
8197 }
8198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008199 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8200 maxChannelScanTime;
8201}
8202
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308203/*
8204 * sme_set_neighbor_scan_period() -
8205 * Update nNeighborScanPeriod
8206 * This function is called through dynamic setConfig callback function
8207 * to configure nNeighborScanPeriod
8208 * Usage: adb shell iwpriv wlan0 setConfig
8209 * nNeighborScanPeriod=[0 .. 1000]
8210 *
8211 * hHal - HAL handle for device
8212 * sessionId - Session Identifier
8213 * nNeighborScanPeriod - neighbor scan period
8214 * Return Success or failure
8215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308216QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008217 const uint16_t nNeighborScanPeriod)
8218{
8219 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308220 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308221 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008222 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8223
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008224 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8226 FL("Invalid sme session id: %d"), sessionId);
8227 return QDF_STATUS_E_INVAL;
8228 }
8229
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008230 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308231 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232 pNeighborRoamConfig =
8233 &pMac->roam.configParam.neighborRoamConfig;
8234 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308235 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308236 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 nNeighborScanPeriod,
8238 pMac->roam.configParam.neighborRoamConfig.
8239 nNeighborScanTimerPeriod,
8240 mac_trace_get_neighbour_roam_state(pMac->roam.
8241 neighborRoamInfo
8242 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308243 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008244 pNeighborRoamConfig->nNeighborScanTimerPeriod =
8245 nNeighborScanPeriod;
8246 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
8247 nNeighborScanPeriod;
8248 sme_release_global_lock(&pMac->sme);
8249 }
8250 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
8251 csr_roam_offload_scan(pMac, sessionId,
8252 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8253 REASON_SCAN_HOME_TIME_CHANGED);
8254 }
8255
8256 return status;
8257}
8258
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308259/*
8260 * sme_get_neighbor_scan_period() -
8261 * get neighbor scan period
8262 *
8263 * hHal - The handle returned by mac_open.
8264 * sessionId - Session Identifier
8265 * Return uint16_t - neighbor scan period
8266 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
8268{
8269 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008270
8271 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8272 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8273 FL("Invalid sme session id: %d"), sessionId);
8274 return 0;
8275 }
8276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008277 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
8278 neighborScanPeriod;
8279}
8280
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308281/**
8282 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
8283 * This function is called through dynamic setConfig callback function
8284 * to configure neighbor_scan_min_period
8285 *
8286 * @hal - HAL handle for device
8287 * @session_id - Session Identifier
8288 * @neighbor_scan_min_period - neighbor scan min period
8289 *
8290 * Return - QDF_STATUS
8291 */
8292QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
8293 uint8_t session_id,
8294 const uint16_t
8295 neighbor_scan_min_period)
8296{
8297 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
8298 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308299 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308300 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008301
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05308302 if (session_id >= CSR_ROAM_SESSION_MAX) {
8303 sme_err("Invalid sme session id: %d", session_id);
8304 return QDF_STATUS_E_INVAL;
8305 }
8306
8307 status = sme_acquire_global_lock(&pmac->sme);
8308 if (QDF_IS_STATUS_SUCCESS(status)) {
8309 p_neighbor_roam_config =
8310 &pmac->roam.configParam.neighborRoamConfig;
8311 p_neighbor_roam_info = &pmac->
8312 roam.neighborRoamInfo[session_id];
8313 sme_debug("LFR:set neighbor scan min period, old:%d, "
8314 "new: %d, state: %s",
8315 pmac->roam.configParam.neighborRoamConfig.
8316 neighbor_scan_min_timer_period,
8317 neighbor_scan_min_period,
8318 mac_trace_get_neighbour_roam_state(pmac->roam.
8319 neighborRoamInfo[session_id].
8320 neighborRoamState));
8321 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8322 neighbor_scan_min_period;
8323 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8324 neighbor_scan_min_period;
8325 sme_release_global_lock(&pmac->sme);
8326 }
8327
8328 return status;
8329}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308331/*
8332 * sme_get_roam_rssi_diff() - get Roam rssi diff
8333 * This is a synchronous call
8334 *
8335 * hHal - The handle returned by mac_open.
8336 * Return uint16_t - Rssi diff value
8337 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008338uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8339{
8340 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008342 return pMac->roam.configParam.RoamRssiDiff;
8343}
8344
8345/**
8346 * sme_change_roam_scan_channel_list() - to change scan channel list
8347 * @hHal: pointer HAL handle returned by mac_open
8348 * @sessionId: sme session id
8349 * @pChannelList: Output channel list
8350 * @numChannels: Output number of channels
8351 *
8352 * This routine is called to Change roam scan channel list.
8353 * This is a synchronous call
8354 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308355 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008356 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308357QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008358 uint8_t *pChannelList,
8359 uint8_t numChannels)
8360{
8361 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308362 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008363 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008364 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8365 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8366 uint8_t i = 0, j = 0;
8367 tCsrChannelInfo *chan_info;
8368
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008369 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8370 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8371 FL("Invalid sme session id: %d"), sessionId);
8372 return QDF_STATUS_E_INVAL;
8373 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008375 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008376 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308377 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008378 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8379 csr_roam_offload_scan(pMac, sessionId,
8380 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8381 REASON_CHANNEL_LIST_CHANGED);
8382 return status;
8383 }
8384 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8385
8386 if (NULL != chan_info->ChannelList) {
8387 for (i = 0; i < chan_info->numOfChannels; i++) {
8388 if (j < sizeof(oldChannelList))
8389 j += snprintf(oldChannelList + j,
8390 sizeof(oldChannelList) -
8391 j, "%d",
8392 chan_info->ChannelList[i]);
8393 else
8394 break;
8395 }
8396 }
8397 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8398 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8399 numChannels);
8400 sme_set_roam_scan_control(hHal, sessionId, 1);
8401 if (NULL != chan_info->ChannelList) {
8402 j = 0;
8403 for (i = 0; i < chan_info->numOfChannels; i++) {
8404 if (j < sizeof(newChannelList))
8405 j += snprintf(newChannelList + j,
8406 sizeof(newChannelList) -
8407 j, " %d",
8408 chan_info->ChannelList[i]);
8409 else
8410 break;
8411 }
8412 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308413 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308414 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008415 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308416 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008417 sme_release_global_lock(&pMac->sme);
8418
8419 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8420 csr_roam_offload_scan(pMac, sessionId,
8421 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8422 REASON_CHANNEL_LIST_CHANGED);
8423 return status;
8424}
8425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008426/**
8427 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8428 * @hHal: HAL pointer
8429 * @pChannelList: Output channel list
8430 * @pNumChannels: Output number of channels
8431 * @sessionId: Session Identifier
8432 *
8433 * To get roam scan channel list This is a synchronous call
8434 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308435 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008436 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308437QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008438 uint8_t *pChannelList, uint8_t *pNumChannels,
8439 uint8_t sessionId)
8440{
8441 int i = 0;
8442 uint8_t *pOutPtr = pChannelList;
8443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008444 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308445 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008447 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8449 FL("Invalid sme session id: %d"), sessionId);
8450 return QDF_STATUS_E_INVAL;
8451 }
8452
8453 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008454 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308455 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456 return status;
8457 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308458 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 FL("Roam Scan channel list is NOT yet initialized"));
8460 *pNumChannels = 0;
8461 sme_release_global_lock(&pMac->sme);
8462 return status;
8463 }
8464
8465 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308466 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008467 pOutPtr[i] =
8468 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470 pOutPtr[i] = '\0';
8471 sme_release_global_lock(&pMac->sme);
8472 return status;
8473}
8474
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308475/*
8476 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8477 * This is a synchronuous call
8478 *
8479 * hHal - The handle returned by mac_open.
8480 * Return true (1) - if the ESE feature is enabled
8481 * false (0) - if feature is disabled (compile or runtime)
8482 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008483bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8484{
8485#ifdef FEATURE_WLAN_ESE
8486 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488 return csr_roam_is_ese_ini_feature_enabled(pMac);
8489#else
8490 return false;
8491#endif
8492}
8493
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308494/*
8495 * sme_get_wes_mode() - get WES Mode
8496 * This is a synchronous call
8497 *
8498 * hHal - The handle returned by mac_open
8499 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8500 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008501bool sme_get_wes_mode(tHalHandle hHal)
8502{
8503 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008505 return pMac->roam.configParam.isWESModeEnabled;
8506}
8507
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308508/*
8509 * sme_get_roam_scan_control() - get scan control
8510 * This is a synchronous call
8511 *
8512 * hHal - The handle returned by mac_open.
8513 * Return bool - Enabled(1)/Disabled(0)
8514 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515bool sme_get_roam_scan_control(tHalHandle hHal)
8516{
8517 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519 return pMac->roam.configParam.nRoamScanControl;
8520}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008521
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308522/*
8523 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8524 * This is a synchronuous call
8525 * hHal - The handle returned by mac_open.
8526 * Return true (1) - if the feature is enabled
8527 * false (0) - if feature is disabled (compile or runtime)
8528 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008529bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8530{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008531 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308532
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008533 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534}
8535
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308536/*
8537 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8538 * This is a synchronuous call
8539 *
8540 * hHal - The handle returned by mac_open.
8541 * Return true (1) - if the feature is enabled
8542 * false (0) - if feature is disabled (compile or runtime)
8543 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008544bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8545{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008546 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008548 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549}
8550
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008551/**
8552 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8553 * @feature: enum value of requested feature.
8554 *
8555 * Retrun: 1 if supported; 0 otherwise
8556 */
8557bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008559 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008560}
8561
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308562QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008563 void *plsContext,
8564 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8565 void *pContext))
8566{
8567
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308568 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008569 tpAniSirGlobal pMac;
8570 tSirLinkSpeedInfo *req;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308571 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008572
Jeff Johnsona5317a62017-01-26 08:51:25 -08008573 if (!hHal || !pCallbackfn || !lsReq) {
8574 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8575 FL("Invalid parameter"));
8576 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008577 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008578
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308579 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8580 if (!wma_handle) {
8581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8582 "wma handle is NULL");
8583 return QDF_STATUS_E_FAILURE;
8584 }
8585
Jeff Johnsona5317a62017-01-26 08:51:25 -08008586 pMac = PMAC_STRUCT(hHal);
8587 req = qdf_mem_malloc(sizeof(*req));
8588 if (!req) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008589 sme_err("Failed to allocate memory");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008590 return QDF_STATUS_E_NOMEM;
8591 }
8592 *req = *lsReq;
8593
8594 status = sme_acquire_global_lock(&pMac->sme);
8595 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008596 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008597 qdf_mem_free(req);
8598 return QDF_STATUS_E_FAILURE;
8599 }
8600
8601 pMac->sme.pLinkSpeedCbContext = plsContext;
8602 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308603 status = wma_get_link_speed(wma_handle, req);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008604 sme_release_global_lock(&pMac->sme);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008606 return status;
8607}
8608
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308609QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8610 struct sir_peer_info_req req)
8611{
8612 QDF_STATUS qdf_status;
8613 struct scheduler_msg message = {0};
8614
8615 qdf_status = sme_acquire_global_lock(&mac->sme);
8616 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8617 sme_debug("Failed to get Lock");
8618 return qdf_status;
8619 }
8620 /* serialize the req through MC thread */
8621 message.bodyptr = qdf_mem_malloc(sizeof(req));
8622 if (NULL == message.bodyptr) {
8623 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8624 "%s: Memory allocation failed.", __func__);
8625 sme_release_global_lock(&mac->sme);
8626 return QDF_STATUS_E_NOMEM;
8627 }
8628 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8629 message.type = WMA_GET_PEER_INFO;
8630 message.reserved = 0;
8631 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8632 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8633 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8634 "%s: Post get peer info msg fail", __func__);
8635 qdf_mem_free(message.bodyptr);
8636 qdf_status = QDF_STATUS_E_FAILURE;
8637 }
8638 sme_release_global_lock(&mac->sme);
8639 return qdf_status;
8640}
8641
Will Huang558f8082017-05-31 16:22:24 +08008642QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8643 void *context,
8644 void (*callbackfn)(struct sir_peer_info_resp *param,
8645 void *pcontext))
8646{
8647
8648 QDF_STATUS status;
8649 QDF_STATUS qdf_status;
8650 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008651 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008652
8653 status = sme_acquire_global_lock(&mac->sme);
8654 if (QDF_STATUS_SUCCESS == status) {
8655 if (NULL == callbackfn) {
8656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8657 "%s: Indication Call back is NULL",
8658 __func__);
8659 sme_release_global_lock(&mac->sme);
8660 return QDF_STATUS_E_FAILURE;
8661 }
8662
8663 mac->sme.pget_peer_info_ind_cb = callbackfn;
8664 mac->sme.pget_peer_info_cb_context = context;
8665
8666 /* serialize the req through MC thread */
8667 message.bodyptr = qdf_mem_malloc(sizeof(req));
8668 if (NULL == message.bodyptr) {
8669 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8670 "%s: Memory allocation failed.", __func__);
8671 sme_release_global_lock(&mac->sme);
8672 return QDF_STATUS_E_NOMEM;
8673 }
8674 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8675 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308676 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008677 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8678 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8679 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8680 "%s: Post get peer info msg fail", __func__);
8681 qdf_mem_free(message.bodyptr);
8682 status = QDF_STATUS_E_FAILURE;
8683 }
8684 sme_release_global_lock(&mac->sme);
8685 }
8686 return status;
8687}
8688
8689QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8690 struct sir_peer_info_ext_req *req,
8691 void *context,
8692 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8693 void *pcontext))
8694{
8695 QDF_STATUS status;
8696 QDF_STATUS qdf_status;
8697 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008698 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008699
8700 status = sme_acquire_global_lock(&mac->sme);
8701 if (QDF_STATUS_SUCCESS == status) {
8702 if (NULL == callbackfn) {
8703 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8704 "%s: Indication Call back is NULL",
8705 __func__);
8706 sme_release_global_lock(&mac->sme);
8707 return QDF_STATUS_E_FAILURE;
8708 }
8709
8710 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8711 mac->sme.pget_peer_info_ext_cb_context = context;
8712
8713 /* serialize the req through MC thread */
8714 message.bodyptr =
8715 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8716 if (NULL == message.bodyptr) {
8717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8718 "%s: Memory allocation failed.", __func__);
8719 sme_release_global_lock(&mac->sme);
8720 return QDF_STATUS_E_NOMEM;
8721 }
8722 qdf_mem_copy(message.bodyptr,
8723 req,
8724 sizeof(struct sir_peer_info_ext_req));
8725 message.type = WMA_GET_PEER_INFO_EXT;
8726 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8727 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8729 "%s: Post get rssi msg fail", __func__);
8730 qdf_mem_free(message.bodyptr);
8731 status = QDF_STATUS_E_FAILURE;
8732 }
8733 sme_release_global_lock(&mac->sme);
8734 }
8735 return status;
8736}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008737
8738/*
8739 * SME API to enable/disable WLAN driver initiated SSR
8740 */
8741void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8742{
8743 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308744 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008745
8746 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308747 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008748 sme_debug("SSR level is changed %d", enableSSR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 /* not serializing this messsage, as this is only going
8750 * to set a variable in WMA/WDI
8751 */
8752 WMA_SetEnableSSR(enableSSR);
8753 sme_release_global_lock(&pMac->sme);
8754 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755}
8756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008757/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8758ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8759{
8760 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8761}
8762
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308763/*
8764 * sme_set_curr_device_mode() - Sets the current operating device mode.
8765 *
8766 * hHal - The handle returned by mac_open.
8767 * currDeviceMode - Current operating device mode.
8768 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008769void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008770 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008771{
8772 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008774 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008775}
8776
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308777/*
8778 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8779 * This is a synchronous call
8780 *
8781 * hHal - The handle returned by mac_open
8782 * sessionId - Session Identifier
8783 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8784 * BSSID, channel etc.)
8785 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8786 * Other status means SME is failed to send the request.
8787 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008788
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308789QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008790 uint8_t sessionId,
8791 tCsrHandoffRequest *pHandoffInfo)
8792{
8793 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308794 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008795
8796 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308797 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008799 "%s: invoked", __func__);
8800 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8801 sme_release_global_lock(&pMac->sme);
8802 }
8803
8804 return status;
8805}
8806
8807#ifdef IPA_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308808/*
8809 * sme_ipa_offload_enable_disable() -
8810 * API to enable/disable IPA offload
8811 *
8812 * hal - The handle returned by macOpen.
8813 * session_id - Session Identifier
8814 * request - Pointer to the offload request.
8815 * Return QDF_STATUS
8816 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308817QDF_STATUS sme_ipa_offload_enable_disable(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008818 struct sir_ipa_offload_enable_disable *request)
8819{
8820 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308821 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008822 struct sir_ipa_offload_enable_disable *request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008823 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008824
8825 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308826 if (QDF_STATUS_SUCCESS == status) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308827 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008828 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308829 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308830 "Not able to allocate memory for IPA_OFFLOAD_ENABLE_DISABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008831 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308832 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 }
8834
8835 request_buf->offload_type = request->offload_type;
8836 request_buf->vdev_id = request->vdev_id;
8837 request_buf->enable = request->enable;
8838
8839 msg.type = WMA_IPA_OFFLOAD_ENABLE_DISABLE;
8840 msg.reserved = 0;
8841 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308842 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008843 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308845 "Not able to post WMA_IPA_OFFLOAD_ENABLE_DISABLE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308846 qdf_mem_free(request_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308848 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008849 }
8850
8851 sme_release_global_lock(&pMac->sme);
8852 }
8853
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308854 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008855}
8856#endif /* IPA_OFFLOAD */
8857
8858/*
8859 * SME API to check if there is any infra station or
8860 * P2P client is connected
8861 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308862QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863{
8864 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308865
8866 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308868
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308869 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870}
8871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008872/**
8873 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8874 * @hal: global hal handle
8875 * @addPeriodicTxPtrnParams: request message
8876 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308877 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308879QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880sme_add_periodic_tx_ptrn(tHalHandle hal,
8881 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8882{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308883 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008884 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8885 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008886 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008888 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008889
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308890 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008891 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008892 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308893 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 }
8895
8896 *req_msg = *addPeriodicTxPtrnParams;
8897
8898 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308899 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008900 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008901 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308902 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008903 return status;
8904 }
8905
8906 /* Serialize the req through MC thread */
8907 msg.bodyptr = req_msg;
8908 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308909 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8910 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008911 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308912 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008913 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008914 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308915 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008916 }
8917 sme_release_global_lock(&mac->sme);
8918 return status;
8919}
8920
8921/**
8922 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8923 * @hal: global hal handle
8924 * @delPeriodicTxPtrnParams: request message
8925 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308926 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008927 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308928QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008929sme_del_periodic_tx_ptrn(tHalHandle hal,
8930 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8931{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308932 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8934 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008935 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008936
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008937 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008938
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308939 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008940 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008941 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308942 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943 }
8944
8945 *req_msg = *delPeriodicTxPtrnParams;
8946
8947 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308948 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008949 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008950 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308951 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008952 return status;
8953 }
8954
8955 /* Serialize the req through MC thread */
8956 msg.bodyptr = req_msg;
8957 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308958 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8959 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008960 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308961 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008962 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008963 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308964 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008965 }
8966 sme_release_global_lock(&mac->sme);
8967 return status;
8968}
8969
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308970/*
8971 * sme_enable_rmc() - enables RMC
8972 * @hHal : Pointer to global HAL handle
8973 * @sessionId : Session ID
8974 *
8975 * Return: QDF_STATUS
8976 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008977QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8978{
8979 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8980 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008981 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008982 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8983
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008984 SME_ENTER();
8985
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008986 status = sme_acquire_global_lock(&pMac->sme);
8987 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008988 message.bodyptr = NULL;
8989 message.type = WMA_RMC_ENABLE_IND;
8990 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8991 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008992 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8994 "%s: failed to post message to WMA",
8995 __func__);
8996 status = QDF_STATUS_E_FAILURE;
8997 }
8998 sme_release_global_lock(&pMac->sme);
8999 }
9000 return status;
9001}
9002
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309003/*
9004 * sme_disable_rmc() - disables RMC
9005 * @hHal : Pointer to global HAL handle
9006 * @sessionId : Session ID
9007 *
9008 * Return: QDF_STATUS
9009 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009010QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
9011{
9012 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9013 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009014 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009015 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9016
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009017 SME_ENTER();
9018
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009019 status = sme_acquire_global_lock(&pMac->sme);
9020 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009021 message.bodyptr = NULL;
9022 message.type = WMA_RMC_DISABLE_IND;
9023 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9024 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009025 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9027 "%s: failed to post message to WMA",
9028 __func__);
9029 status = QDF_STATUS_E_FAILURE;
9030 }
9031 sme_release_global_lock(&pMac->sme);
9032 }
9033 return status;
9034}
9035
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309036/*
9037 * sme_send_rmc_action_period() - sends RMC action period param to target
9038 * @hHal : Pointer to global HAL handle
9039 * @sessionId : Session ID
9040 *
9041 * Return: QDF_STATUS
9042 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009043QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
9044{
9045 QDF_STATUS status = QDF_STATUS_SUCCESS;
9046 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009048 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009049
9050 status = sme_acquire_global_lock(&pMac->sme);
9051 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009052 message.bodyptr = NULL;
9053 message.type = WMA_RMC_ACTION_PERIOD_IND;
9054 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9055 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009056 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9058 "%s: failed to post message to WMA",
9059 __func__);
9060 status = QDF_STATUS_E_FAILURE;
9061 }
9062 sme_release_global_lock(&pMac->sme);
9063 }
9064
9065 return status;
9066}
9067
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309068/*
9069 * sme_request_ibss_peer_info() - request ibss peer info
9070 * @hHal : Pointer to global HAL handle
9071 * @pUserData : Pointer to user data
9072 * @peerInfoCbk : Peer info callback
9073 * @allPeerInfoReqd : All peer info required or not
9074 * @staIdx : sta index
9075 *
9076 * Return: QDF_STATUS
9077 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009078QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
9079 pIbssPeerInfoCb peerInfoCbk,
9080 bool allPeerInfoReqd, uint8_t staIdx)
9081{
9082 QDF_STATUS status = QDF_STATUS_E_FAILURE;
9083 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
9084 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009085 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009086 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
9087
9088 status = sme_acquire_global_lock(&pMac->sme);
9089 if (QDF_STATUS_SUCCESS == status) {
9090 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
9091 pMac->sme.peerInfoParams.pUserData = pUserData;
9092
9093 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309094 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009095 if (NULL == pIbssInfoReqParams) {
9096 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9097 "%s: Not able to allocate memory for dhcp start",
9098 __func__);
9099 sme_release_global_lock(&pMac->sme);
9100 return QDF_STATUS_E_NOMEM;
9101 }
9102 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
9103 pIbssInfoReqParams->staIdx = staIdx;
9104
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009105 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
9106 message.bodyptr = pIbssInfoReqParams;
9107 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009108
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009109 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9110 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009111 if (QDF_STATUS_SUCCESS != qdf_status) {
9112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9113 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
9114 __func__);
9115 qdf_mem_free(pIbssInfoReqParams);
9116 qdf_status = QDF_STATUS_E_FAILURE;
9117 }
9118 sme_release_global_lock(&pMac->sme);
9119 }
9120
9121 return qdf_status;
9122}
9123
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309124/*
9125 * sme_send_cesium_enable_ind() -
9126 * Used to send proprietary cesium enable indication to fw
9127 *
9128 * hHal
9129 * sessionId
9130 * Return QDF_STATUS
9131 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009132QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
9133{
9134 QDF_STATUS status = QDF_STATUS_SUCCESS;
9135 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
9136 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009137 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009138
9139 status = sme_acquire_global_lock(&pMac->sme);
9140 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009141 message.bodyptr = NULL;
9142 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
9143 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
9144 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08009145 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
9146 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9147 "%s: failed to post message to WMA",
9148 __func__);
9149 status = QDF_STATUS_E_FAILURE;
9150 }
9151 sme_release_global_lock(&pMac->sme);
9152 }
9153
9154 return status;
9155}
9156
Paul Zhang99fe8842017-12-08 14:43:46 +08009157QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
9158 uint16_t latency_level)
9159{
9160 QDF_STATUS status;
9161 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9162 struct wlm_latency_level_param params;
9163 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
9164
9165 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
9166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9167 "%s: WLM latency level setting is disabled",
9168 __func__);
9169 return QDF_STATUS_E_FAILURE;
9170 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08009171 if (!wma) {
9172 sme_err("wma is NULL");
9173 return QDF_STATUS_E_FAILURE;
9174 }
Paul Zhang99fe8842017-12-08 14:43:46 +08009175
9176 params.wlm_latency_level = latency_level;
9177 params.wlm_latency_flags =
9178 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
9179 params.vdev_id = session_id;
9180
9181 status = wma_set_wlm_latency_level(wma, &params);
9182 if (!QDF_IS_STATUS_SUCCESS(status))
9183 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9184 "%s: failed to set latency level",
9185 __func__);
9186
9187 return status;
9188}
9189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009190void sme_get_command_q_status(tHalHandle hHal)
9191{
9192 tSmeCmd *pTempCmd = NULL;
9193 tListElem *pEntry;
9194 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9195
9196 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309197 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009198 "%s: pMac is NULL", __func__);
9199 return;
9200 }
9201
Krunal Sonia8270f52017-02-23 19:51:25 -08009202 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309203 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309205
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009206 sme_err("Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009207 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
9208 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309209 if (eSmeCsrCommandMask & pTempCmd->command)
9210 /* CSR command is stuck. See what the reason code is
9211 * for that command
9212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009214 } /* if(pTempCmd) */
9215
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009216 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08009217 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009220/**
9221 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
9222 * @hal: The handle returned by macOpen
9223 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
9224 */
9225void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
9226 bool sta_prefer_80MHz_over_160MHz)
9227{
9228 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309229
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07009230 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
9231}
9232
Agrawal Ashishb141b092016-09-02 19:59:26 +05309233#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009234/**
9235 * sme_set_dot11p_config() - API to set the 802.11p config
9236 * @hHal: The handle returned by macOpen
9237 * @enable_dot11p: 802.11p config param
9238 */
9239void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
9240{
9241 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009243 pMac->enable_dot11p = enable_dot11p;
9244}
9245
9246/**
9247 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
9248 * @src: the source configuration
9249 *
9250 * Return: pointer to the copied OCB configuration
9251 */
9252static struct sir_ocb_config *sme_copy_sir_ocb_config(
9253 struct sir_ocb_config *src)
9254{
9255 struct sir_ocb_config *dst;
9256 uint32_t length;
9257 void *cursor;
9258
9259 length = sizeof(*src) +
9260 src->channel_count * sizeof(*src->channels) +
9261 src->schedule_size * sizeof(*src->schedule) +
9262 src->dcc_ndl_chan_list_len +
9263 src->dcc_ndl_active_state_list_len;
9264
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309265 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 if (!dst)
9267 return NULL;
9268
9269 *dst = *src;
9270
9271 cursor = dst;
9272 cursor += sizeof(*dst);
9273 dst->channels = cursor;
9274 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309275 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009276 src->channel_count * sizeof(*src->channels));
9277 dst->schedule = cursor;
9278 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309279 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009280 src->schedule_size * sizeof(*src->schedule));
9281 dst->dcc_ndl_chan_list = cursor;
9282 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309283 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009284 src->dcc_ndl_chan_list_len);
9285 dst->dcc_ndl_active_state_list = cursor;
9286 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309287 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009288 src->dcc_ndl_active_state_list,
9289 src->dcc_ndl_active_state_list_len);
9290 return dst;
9291}
9292
9293/**
9294 * sme_ocb_set_config() - Set the OCB configuration
9295 * @hHal: reference to the HAL
9296 * @context: the context of the call
9297 * @callback: the callback to hdd
9298 * @config: the OCB configuration
9299 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309300 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009301 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309302QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303 ocb_callback callback,
9304 struct sir_ocb_config *config)
9305{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309306 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009308 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 struct sir_ocb_config *msg_body;
9310
9311 /* Lock the SME structure */
9312 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309313 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314 return status;
9315
9316 /*
9317 * Check if there is a pending request and return an error if one
9318 * exists
9319 */
9320 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309321 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 goto end;
9323 }
9324
9325 msg_body = sme_copy_sir_ocb_config(config);
9326
9327 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309328 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009329 goto end;
9330 }
9331
9332 msg.type = WMA_OCB_SET_CONFIG_CMD;
9333 msg.bodyptr = msg_body;
9334
9335 /* Set the request callback and context */
9336 pMac->sme.ocb_set_config_callback = callback;
9337 pMac->sme.ocb_set_config_context = context;
9338
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009339 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309340 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309341 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342 FL("Error posting message to WDA: %d"), status);
9343 pMac->sme.ocb_set_config_callback = callback;
9344 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309345 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009346 goto end;
9347 }
9348
9349end:
9350 sme_release_global_lock(&pMac->sme);
9351
9352 return status;
9353}
9354
9355/**
9356 * sme_ocb_set_utc_time() - Set the OCB UTC time
9357 * @hHal: reference to the HAL
9358 * @utc: the UTC time struct
9359 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309360 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009361 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309362QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309364 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009366 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009367 struct sir_ocb_utc *sme_utc;
9368
9369 /* Lock the SME structure */
9370 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309371 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009372 return status;
9373
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309374 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009375 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309376 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009377 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309378 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 goto end;
9380 }
9381 *sme_utc = *utc;
9382
9383 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9384 msg.reserved = 0;
9385 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009386 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309387 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009389 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309390 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009391 goto end;
9392 }
9393
9394end:
9395 sme_release_global_lock(&pMac->sme);
9396
9397 return status;
9398}
9399
9400/**
9401 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9402 * @hHal: reference to the HAL
9403 * @timing_advert: the timing advertisement struct
9404 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309405 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309407QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009408 struct sir_ocb_timing_advert *timing_advert)
9409{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309410 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009411 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009412 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009413 void *buf;
9414 struct sir_ocb_timing_advert *sme_timing_advert;
9415
9416 /* Lock the SME structure */
9417 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309418 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009419 return status;
9420
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309421 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422 timing_advert->template_length);
9423 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309424 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009425 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309426 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009427 goto end;
9428 }
9429
9430 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9431 *sme_timing_advert = *timing_advert;
9432 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309433 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009434 timing_advert->template_value, timing_advert->template_length);
9435
9436 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9437 msg.reserved = 0;
9438 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009439 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309440 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309441 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442 FL("Not able to post msg to WDA"));
9443 goto end;
9444 }
9445
9446end:
9447 sme_release_global_lock(&pMac->sme);
9448
9449 return status;
9450}
9451
9452/**
9453 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9454 * @hHal: reference to the HAL
9455 * @timing_advert: the timing advertisement struct
9456 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309457 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009458 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309459QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 struct sir_ocb_timing_advert *timing_advert)
9461{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309462 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009464 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009465 struct sir_ocb_timing_advert *sme_timing_advert;
9466
9467 /* Lock the SME structure */
9468 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309469 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009470 return status;
9471
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309472 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009473 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309474 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009475 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309476 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 goto end;
9478 }
9479 *sme_timing_advert = *timing_advert;
9480
9481 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9482 msg.reserved = 0;
9483 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009484 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309485 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309486 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009487 FL("Not able to post msg to WDA"));
9488 goto end;
9489 }
9490
9491end:
9492 sme_release_global_lock(&pMac->sme);
9493
9494 return status;
9495}
9496
9497/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009498 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9499 * @hal_handle: reference to the HAL
9500 * @self_addr: the self MAC address
9501 * @buf: the buffer that will contain the frame
9502 * @timestamp_offset: return for the offset of the timestamp field
9503 * @time_value_offset: return for the time_value field in the TA IE
9504 *
9505 * Return: the length of the buffer.
9506 */
9507int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9508 tSirMacAddr self_addr, uint8_t **buf,
9509 uint32_t *timestamp_offset,
9510 uint32_t *time_value_offset)
9511{
9512 int template_length;
9513 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9514
9515 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9516 timestamp_offset,
9517 time_value_offset);
9518 return template_length;
9519}
9520/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9522 * @hHal: reference to the HAL
9523 * @context: the context of the call
9524 * @callback: the callback to hdd
9525 * @request: the TSF timer request
9526 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309527 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009528 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309529QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009530 ocb_callback callback,
9531 struct sir_ocb_get_tsf_timer *request)
9532{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309533 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009534 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009535 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 struct sir_ocb_get_tsf_timer *msg_body;
9537
9538 /* Lock the SME structure */
9539 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309540 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009541 return status;
9542
9543 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309544 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009545 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309546 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009547 goto end;
9548 }
9549 *msg_body = *request;
9550
9551 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9552 msg.bodyptr = msg_body;
9553
9554 /* Set the request callback and the context */
9555 pMac->sme.ocb_get_tsf_timer_callback = callback;
9556 pMac->sme.ocb_get_tsf_timer_context = context;
9557
9558 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009559 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309560 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309561 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 FL("Error posting message to WDA: %d"), status);
9563 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9564 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309565 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009566 goto end;
9567 }
9568
9569end:
9570 sme_release_global_lock(&pMac->sme);
9571
9572 return status;
9573}
9574
9575/**
9576 * sme_dcc_get_stats() - Get the DCC stats
9577 * @hHal: reference to the HAL
9578 * @context: the context of the call
9579 * @callback: the callback to hdd
9580 * @request: the get DCC stats request
9581 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309582 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309584QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009585 ocb_callback callback,
9586 struct sir_dcc_get_stats *request)
9587{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309588 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009589 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009590 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009591 struct sir_dcc_get_stats *msg_body;
9592
9593 /* Lock the SME structure */
9594 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309595 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009596 return status;
9597
9598 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309599 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009600 request->request_array_len);
9601 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309602 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009603 goto end;
9604 }
9605 *msg_body = *request;
9606 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309607 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009608 request->request_array_len);
9609
9610 msg.type = WMA_DCC_GET_STATS_CMD;
9611 msg.bodyptr = msg_body;
9612
9613 /* Set the request callback and context */
9614 pMac->sme.dcc_get_stats_callback = callback;
9615 pMac->sme.dcc_get_stats_context = context;
9616
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009617 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309618 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 FL("Error posting message to WDA: %d"), status);
9621 pMac->sme.dcc_get_stats_callback = callback;
9622 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309623 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009624 goto end;
9625 }
9626
9627end:
9628 sme_release_global_lock(&pMac->sme);
9629
9630 return status;
9631}
9632
9633/**
9634 * sme_dcc_clear_stats() - Clear the DCC stats
9635 * @hHal: reference to the HAL
9636 * @vdev_id: vdev id for OCB interface
9637 * @dcc_stats_bitmap: the entries in the stats to clear
9638 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309639 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009640 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309641QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009642 uint32_t dcc_stats_bitmap)
9643{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309644 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009646 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 struct sir_dcc_clear_stats *request;
9648
9649 /* Lock the SME structure */
9650 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309651 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 return status;
9653
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309654 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009655 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309658 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659 goto end;
9660 }
9661
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009662 request->vdev_id = vdev_id;
9663 request->dcc_stats_bitmap = dcc_stats_bitmap;
9664
9665 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9666 msg.bodyptr = request;
9667
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009668 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309669 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309670 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009671 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309672 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009673 goto end;
9674 }
9675
9676end:
9677 sme_release_global_lock(&pMac->sme);
9678
9679 return status;
9680}
9681
9682/**
9683 * sme_dcc_update_ndl() - Update the DCC settings
9684 * @hHal: reference to the HAL
9685 * @context: the context of the call
9686 * @callback: the callback to hdd
9687 * @request: the update DCC request
9688 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309689 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009690 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309691QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009692 ocb_callback callback,
9693 struct sir_dcc_update_ndl *request)
9694{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309695 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009696 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009697 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009698 struct sir_dcc_update_ndl *msg_body;
9699
9700 /* Lock the SME structure */
9701 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309702 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009703 return status;
9704
9705 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309706 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009707 request->dcc_ndl_chan_list_len +
9708 request->dcc_ndl_active_state_list_len);
9709 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309710 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009711 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309712 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009713 goto end;
9714 }
9715
9716 *msg_body = *request;
9717
9718 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9719 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9720 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309721 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309723 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009724 request->dcc_ndl_active_state_list,
9725 request->dcc_ndl_active_state_list_len);
9726
9727 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9728 msg.bodyptr = msg_body;
9729
9730 /* Set the request callback and the context */
9731 pMac->sme.dcc_update_ndl_callback = callback;
9732 pMac->sme.dcc_update_ndl_context = context;
9733
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009734 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309735 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009737 FL("Error posting message to WDA: %d"), status);
9738 pMac->sme.dcc_update_ndl_callback = NULL;
9739 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309740 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009741 goto end;
9742 }
9743
9744end:
9745 sme_release_global_lock(&pMac->sme);
9746
9747 return status;
9748}
9749
9750/**
9751 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9752 * event
9753 * @hHal: reference to the HAL
9754 * @context: the context of the call
9755 * @callback: the callback to hdd
9756 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309757 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009758 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309759QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009760 ocb_callback callback)
9761{
9762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309763 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009764
9765 status = sme_acquire_global_lock(&pMac->sme);
9766 pMac->sme.dcc_stats_event_callback = callback;
9767 pMac->sme.dcc_stats_event_context = context;
9768 sme_release_global_lock(&pMac->sme);
9769
9770 return 0;
9771}
9772
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309773/**
9774 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9775 * event
9776 * @h_hal: Hal Handle
9777 *
9778 * This function de-registers the DCC perioc stats callback
9779 *
9780 * Return: QDF_STATUS Enumeration
9781 */
9782QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9783{
9784 tpAniSirGlobal mac;
9785 QDF_STATUS status;
9786
9787 if (!h_hal) {
9788 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9789 FL("h_hal is not valid"));
9790 return QDF_STATUS_E_INVAL;
9791 }
9792 mac = PMAC_STRUCT(h_hal);
9793
9794 status = sme_acquire_global_lock(&mac->sme);
9795 if (!QDF_IS_STATUS_SUCCESS(status)) {
9796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9797 FL("Failed to acquire global lock"));
9798 return status;
9799 }
9800 mac->sme.dcc_stats_event_callback = NULL;
9801 mac->sme.dcc_stats_event_context = NULL;
9802 sme_release_global_lock(&mac->sme);
9803
9804 return status;
9805}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309806#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009808void sme_get_recovery_stats(tHalHandle hHal)
9809{
9810 uint8_t i;
9811
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309812 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009813 "Self Recovery Stats");
9814 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9815 if (eSmeNoCommand !=
9816 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009818 "timestamp %llu: command 0x%0X: reason %d: session %d",
9819 g_self_recovery_stats.activeCmdStats[i].
9820 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309821 g_self_recovery_stats.activeCmdStats[i].command,
9822 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009823 g_self_recovery_stats.activeCmdStats[i].
9824 sessionId);
9825 }
9826 }
9827}
9828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309829QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009830{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009831 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009832 tpSirModemPowerStateInd request_buf;
9833 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9834
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309835 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309836 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009837
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309838 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009839 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309840 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009841 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9842 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309843 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009844 }
9845
9846 request_buf->param = value;
9847
9848 msg.type = WMA_MODEM_POWER_STATE_IND;
9849 msg.reserved = 0;
9850 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309851 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009852 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309853 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309854 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9855 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309856 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309857 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009858 }
9859
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309860 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009861}
9862
9863#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309864QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309865 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009866 uint8_t sessionId,
9867 uint8_t channel_type)
9868{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009869 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870 tUpdateVHTOpMode *pHtOpMode = NULL;
9871 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9872
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309873 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309876 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009877 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309878 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009879 "%s: Not able to allocate memory for setting OP mode",
9880 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309881 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009882 }
9883
9884 switch (channel_type) {
9885 case eHT_CHAN_HT20:
9886 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9887 break;
9888
9889 case eHT_CHAN_HT40MINUS:
9890 case eHT_CHAN_HT40PLUS:
9891 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9892 break;
9893
9894 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309895 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009896 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309897 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009898 }
9899
9900 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309901 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009902 sizeof(tSirMacAddr));
9903 pHtOpMode->smesessionId = sessionId;
9904
9905 msg.type = WMA_UPDATE_OP_MODE;
9906 msg.reserved = 0;
9907 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309908 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009909 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309910 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309911 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9912 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309913 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309914 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009915 }
9916
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009918 "%s: Notifed FW about OP mode: %d for staId=%d",
9919 __func__, pHtOpMode->opMode, staId);
9920
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309921 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009922}
9923
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309924/*
9925 * sme_set_ht2040_mode() -
9926 * To update HT Operation beacon IE.
9927 *
9928 * Return QDF_STATUS SUCCESS
9929 * FAILURE or RESOURCES
9930 * The API finished and failed.
9931 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309932QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933 uint8_t channel_type, bool obssEnabled)
9934{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309935 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009936 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9937 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309938 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009939
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309940 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9941 sme_err("Session not valid for session id %d", sessionId);
9942 return QDF_STATUS_E_INVAL;
9943 }
9944 session = CSR_GET_SESSION(pMac, sessionId);
9945 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9946 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009947
9948 switch (channel_type) {
9949 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309950 if (!session->bssParams.cbMode)
9951 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009952 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9953 break;
9954 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309955 if (session->bssParams.cbMode)
9956 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009957 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9958 break;
9959 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309960 if (session->bssParams.cbMode)
9961 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009962 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9963 break;
9964 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309965 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309966 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009967 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309968 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009969 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309970 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971 status = csr_set_ht2040_mode(pMac, sessionId,
9972 cbMode, obssEnabled);
9973 sme_release_global_lock(&pMac->sme);
9974 }
9975 return status;
9976}
9977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978#endif
9979
9980/*
9981 * SME API to enable/disable idle mode powersave
9982 * This should be called only if powersave offload
9983 * is enabled
9984 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309985QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009986{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309987 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009988
9989 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309990 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009991 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309992 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009993 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995 " Idle Ps Set Value %d", value);
9996
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309997 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309998 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009999 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010000 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010001 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +053010002
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010003 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004}
10005
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010006int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
10007 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010008{
10009 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010010 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010011
10012 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010013 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010014 "%s: pSession is NULL", __func__);
10015 return -EIO;
10016 }
10017 switch (ht_capab) {
10018 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10019 return pSession->htConfig.ht_rx_ldpc;
10020 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10021 return pSession->htConfig.ht_tx_stbc;
10022 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10023 return pSession->htConfig.ht_rx_stbc;
10024 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010025 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010026 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010027 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010028 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010029 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010030 "invalid ht capability");
10031 return -EIO;
10032 }
10033}
10034
10035int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
10036 int value)
10037{
10038 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010039 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010040
10041 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010042 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010043 "%s: pSession is NULL", __func__);
10044 return -EIO;
10045 }
10046
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010047 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010049 "Failed to set ht capability in target");
10050 return -EIO;
10051 }
10052
10053 switch (htCapab) {
10054 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
10055 pSession->htConfig.ht_rx_ldpc = value;
10056 break;
10057 case WNI_CFG_HT_CAP_INFO_TX_STBC:
10058 pSession->htConfig.ht_tx_stbc = value;
10059 break;
10060 case WNI_CFG_HT_CAP_INFO_RX_STBC:
10061 pSession->htConfig.ht_rx_stbc = value;
10062 break;
10063 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010064 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010065 pSession->htConfig.ht_sgi20 = value;
10066 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010067 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -080010068 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -070010069 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070 break;
10071 }
10072
Naveen Rawat8029a402017-06-01 10:54:19 -070010073 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010074 return 0;
10075}
10076
10077#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010078/*
10079 * sme_send_rate_update_ind() -
10080 * API to Update rate
10081 *
10082 * hHal - The handle returned by mac_open
10083 * rateUpdateParams - Pointer to rate update params
10084 * Return QDF_STATUS
10085 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010086QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010087 tSirRateUpdateInd *rateUpdateParams)
10088{
10089 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010090 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010091 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010092 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010093
10094 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010095 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010096 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010097 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010098 }
10099 *rate_upd = *rateUpdateParams;
10100
10101 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
10102 rate_upd->mcastDataRate24GHzTxFlag =
10103 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10104 else if (rate_upd->reliableMcastDataRate ==
10105 HT20_SHORT_GI_MCS7_RATE)
10106 rate_upd->reliableMcastDataRateTxFlag =
10107 eHAL_TX_RATE_HT20 | eHAL_TX_RATE_SGI;
10108
10109 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010110 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010111 msg.type = WMA_RATE_UPDATE_IND;
10112 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053010113 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
10114 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010115 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010116 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010118 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119 __func__);
10120
10121 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010122 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010123 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010124 }
10125
10126 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010127 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010128 }
10129
10130 return status;
10131}
10132
10133/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010134 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
10135 * @hal: Pointer to the mac context
10136 * @session_id: sme session id
10137 * @vendor_ie: vendor ie
10138 * @access_policy: vendor ie access policy
10139 *
10140 * This function updates the vendor ie and access policy to lim.
10141 *
10142 * Return: success or failure.
10143 */
10144QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
10145 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
10146{
10147 struct sme_update_access_policy_vendor_ie *msg;
10148 uint16_t msg_len;
10149 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010150
10151 msg_len = sizeof(*msg);
10152
10153 msg = qdf_mem_malloc(msg_len);
10154 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010155 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010156 return QDF_STATUS_E_FAILURE;
10157 }
10158
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010159 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
10160 msg->length = (uint16_t)msg_len;
10161
10162 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
10163
10164 msg->sme_session_id = session_id;
10165 msg->access_policy = access_policy;
10166
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010167 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
10168 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010169
Rajeev Kumard138ac52017-01-30 18:38:37 -080010170 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +053010171
10172 return status;
10173}
10174
10175/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010176 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
10177 * @hal: Handle returned by mac_open
10178 * @session_id: Session ID on which short frame retry limit needs to be
10179 * updated to FW
10180 * @short_limit_count_th: Retry count TH to retry short frame.
10181 *
10182 * This function is used to configure count to retry short frame.
10183 *
10184 * Return: QDF_STATUS
10185 */
10186QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10187 struct sme_short_retry_limit *short_retry_limit_th)
10188{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010189 QDF_STATUS status = QDF_STATUS_SUCCESS;
10190 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010191 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010192
10193 srl = qdf_mem_malloc(sizeof(*srl));
10194 if (NULL == srl) {
10195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10196 "%s: fail to alloc short retry limit", __func__);
10197 return QDF_STATUS_E_FAILURE;
10198 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010199 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010200 short_retry_limit_th->session_id,
10201 short_retry_limit_th->short_retry_limit);
10202
10203 srl->session_id = short_retry_limit_th->session_id;
10204 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10205
10206 qdf_mem_zero(&msg, sizeof(msg));
10207 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10208 msg.reserved = 0;
10209 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010210 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010211 if (status != QDF_STATUS_SUCCESS) {
10212 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10213 FL("Not able to post short retry limit count to WDA"));
10214 qdf_mem_free(srl);
10215 return QDF_STATUS_E_FAILURE;
10216 }
10217
10218 return status;
10219}
10220
10221/**
10222 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10223 * @hal: Handle returned by mac_open
10224 * @session_id: Session ID on which long frames retry TH needs to be updated
10225 * to FW
10226 * @long_limit_count_th: Retry count to retry long frame.
10227 *
10228 * This function is used to configure TH to retry long frame.
10229 *
10230 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010231 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010232QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10233 struct sme_long_retry_limit *long_retry_limit_th)
10234{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010235 QDF_STATUS status = QDF_STATUS_SUCCESS;
10236 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010237 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010238
10239 lrl = qdf_mem_malloc(sizeof(*lrl));
10240 if (NULL == lrl) {
10241 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10242 "%s: fail to alloc long retry limit", __func__);
10243 return QDF_STATUS_E_FAILURE;
10244 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010245 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010246 long_retry_limit_th->session_id,
10247 long_retry_limit_th->long_retry_limit);
10248
10249 lrl->session_id = long_retry_limit_th->session_id;
10250 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10251
10252 qdf_mem_zero(&msg, sizeof(msg));
10253 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10254 msg.reserved = 0;
10255 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010256 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010257
10258 if (status != QDF_STATUS_SUCCESS) {
10259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10260 FL("Not able to post long retry limit count to WDA"));
10261 qdf_mem_free(lrl);
10262 return QDF_STATUS_E_FAILURE;
10263 }
10264
10265 return status;
10266}
10267
10268/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010269 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10270 * @hal: Handle returned by mac_open
10271 * @session_id: Session ID on which sta_inactivity_timeout needs
10272 * to be updated to FW
10273 * @sta_inactivity_timeout: sta inactivity timeout.
10274 *
10275 * If a station does not send anything in sta_inactivity_timeout seconds, an
10276 * empty data frame is sent to it in order to verify whether it is
10277 * still in range. If this frame is not ACKed, the station will be
10278 * disassociated and then deauthenticated.
10279 *
10280 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010281 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010282QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10283 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10284{
10285 struct sme_sta_inactivity_timeout *inactivity_time;
10286 void *wma_handle;
10287
10288 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10289 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10290 if (NULL == inactivity_time) {
10291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10292 "%s: fail to alloc inactivity_time", __func__);
10293 return QDF_STATUS_E_FAILURE;
10294 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010295 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010296 FL("sta_inactivity_timeout: %d"),
10297 sta_inactivity_timer->sta_inactivity_timeout);
10298 inactivity_time->session_id = sta_inactivity_timer->session_id;
10299 inactivity_time->sta_inactivity_timeout =
10300 sta_inactivity_timer->sta_inactivity_timeout;
10301
10302 wma_update_sta_inactivity_timeout(wma_handle,
10303 inactivity_time);
10304 return QDF_STATUS_SUCCESS;
10305}
10306
10307/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308 * sme_get_reg_info() - To get registration info
10309 * @hHal: HAL context
10310 * @chanId: channel id
10311 * @regInfo1: first reg info to fill
10312 * @regInfo2: second reg info to fill
10313 *
10314 * This routine will give you reg info
10315 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010316 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010317 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010318QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010319 uint32_t *regInfo1, uint32_t *regInfo2)
10320{
10321 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010322 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010323 uint8_t i;
10324 bool found = false;
10325
10326 status = sme_acquire_global_lock(&pMac->sme);
10327 *regInfo1 = 0;
10328 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010329 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010330 return status;
10331
10332 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010333 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010335 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010336
10337 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010338 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 found = true;
10340 break;
10341 }
10342 }
10343 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010344 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345
10346 sme_release_global_lock(&pMac->sme);
10347 return status;
10348}
10349
10350#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010351/*
10352 * sme_auto_shutdown_cb() -
10353 * Used to plug in callback function for receiving auto shutdown evt
10354 *
10355 * hHal
10356 * pCallbackfn : callback function pointer should be plugged in
10357 * Return QDF_STATUS
10358 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010359QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010360 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010361 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10363
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010364 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010365 "%s: Plug in Auto shutdown event callback", __func__);
10366
10367 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010368 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010369 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010370 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010371 sme_release_global_lock(&pMac->sme);
10372 }
10373
10374 return status;
10375}
10376
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010377/*
10378 * sme_set_auto_shutdown_timer() -
10379 * API to set auto shutdown timer value in FW.
10380 *
10381 * hHal - The handle returned by mac_open
10382 * timer_val - The auto shutdown timer value to be set
10383 * Return Configuration message posting status, SUCCESS or Fail
10384 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010385QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010386{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010387 QDF_STATUS status = QDF_STATUS_SUCCESS;
10388 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10390 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010391 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010392
10393 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010394 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010396 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010397 if (auto_sh_cmd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010398 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010399 "%s Request Buffer Alloc Fail", __func__);
10400 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010401 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402 }
10403
10404 auto_sh_cmd->timer_val = timer_val;
10405
10406 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010407 message.bodyptr = auto_sh_cmd;
10408 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10409 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10410 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010411 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010412 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010413 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010414 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010415 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010416 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010417 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010418 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010419 "%s: Posted Auto shutdown MSG", __func__);
10420 sme_release_global_lock(&pMac->sme);
10421 }
10422
10423 return status;
10424}
10425#endif
10426
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010427/*
10428 * sme_ch_avoid_update_req() -
10429 * API to request channel avoidance update from FW.
10430 *
10431 * hHal - The handle returned by mac_open
10432 * update_type - The udpate_type parameter of this request call
10433 * Return Configuration message posting status, SUCCESS or Fail
10434 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010435QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010436{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010437 QDF_STATUS status = QDF_STATUS_SUCCESS;
10438 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10440 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010441 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010442
10443 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010444 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010445 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010446 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010447 if (NULL == cauReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010448 QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449 "%s Request Buffer Alloc Fail", __func__);
10450 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010451 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010452 }
10453
10454 cauReq->reserved_param = 0;
10455
10456 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010457 message.bodyptr = cauReq;
10458 message.type = WMA_CH_AVOID_UPDATE_REQ;
10459 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10460 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010461 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010463 "%s: Post Ch Avoid Update MSG fail",
10464 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010465 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010466 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010467 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010469 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010470 "%s: Posted Ch Avoid Update MSG", __func__);
10471 sme_release_global_lock(&pMac->sme);
10472 }
10473
10474 return status;
10475}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010476
10477/**
10478 * sme_set_miracast() - Function to set miracast value to UMAC
10479 * @hal: Handle returned by macOpen
10480 * @filter_type: 0-Disabled, 1-Source, 2-sink
10481 *
10482 * This function passes down the value of miracast set by
10483 * framework to UMAC
10484 *
10485 * Return: Configuration message posting status, SUCCESS or Fail
10486 *
10487 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010488QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010489{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010490 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010491 uint32_t *val;
10492 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10493
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010494 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010497 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010498 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 }
10500
10501 *val = filter_type;
10502
10503 msg.type = SIR_HAL_SET_MIRACAST;
10504 msg.reserved = 0;
10505 msg.bodyptr = val;
10506
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010507 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010508 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010509 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010510 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10511 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010512 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010513 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514 }
10515
10516 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010517 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518}
10519
10520/**
10521 * sme_set_mas() - Function to set MAS value to UMAC
10522 * @val: 1-Enable, 0-Disable
10523 *
10524 * This function passes down the value of MAS to the UMAC. A
10525 * value of 1 will enable MAS and a value of 0 will disable MAS
10526 *
10527 * Return: Configuration message posting status, SUCCESS or Fail
10528 *
10529 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010530QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010531{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010532 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010533 uint32_t *ptr_val;
10534
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010535 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010537 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010538 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010539 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010540 }
10541
10542 *ptr_val = val;
10543
10544 msg.type = SIR_HAL_SET_MAS;
10545 msg.reserved = 0;
10546 msg.bodyptr = ptr_val;
10547
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010548 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010549 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010550 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010551 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10552 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010553 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010554 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010555 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010556 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010557}
10558
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010559/**
10560 * sme_roam_channel_change_req() - Channel change to new target channel
10561 * @hHal: handle returned by mac_open
10562 * @bssid: mac address of BSS
10563 * @ch_params: target channel information
10564 * @profile: CSR profile
10565 *
10566 * API to Indicate Channel change to new target channel
10567 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010568 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010569 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010570QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010571 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010572 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010573 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010575 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010577
10578 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010579 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010580
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010581 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582 profile);
10583 sme_release_global_lock(&pMac->sme);
10584 }
10585 return status;
10586}
10587
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010588/*
10589 * sme_process_channel_change_resp() -
10590 * API to Indicate Channel change response message to SAP.
10591 *
10592 * Return QDF_STATUS
10593 */
10594static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010595 uint16_t msg_type, void *pMsgBuf)
10596{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010597 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010598 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010599 eCsrRoamResult roamResult;
10600 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10601 uint32_t SessionId = pChnlParams->peSessionId;
10602
10603 proam_info.channelChangeRespEvent =
10604 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010605 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010606 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010607 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010608 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 return status;
10610 }
10611 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10612 proam_info.channelChangeRespEvent->sessionId = SessionId;
10613 proam_info.channelChangeRespEvent->newChannelNumber =
10614 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010616 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010618 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10619 SessionId);
10620 proam_info.channelChangeRespEvent->channelChangeStatus =
10621 1;
10622 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10623 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010624 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010625 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10626 SessionId);
10627 proam_info.channelChangeRespEvent->channelChangeStatus =
10628 0;
10629 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10630 }
10631
10632 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10633 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10634
10635 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010636 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010637 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010638 status);
10639 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010640 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010641
10642 return status;
10643}
10644
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010645/*
10646 * sme_roam_start_beacon_req() -
10647 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10648 *
10649 * hHal - The handle returned by mac_open
10650 * sessionId - session ID
10651 * dfsCacWaitStatus - CAC WAIT status flag
10652 * Return QDF_STATUS
10653 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010654QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010655 uint8_t dfsCacWaitStatus)
10656{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010657 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010658 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660 status = sme_acquire_global_lock(&pMac->sme);
10661
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010662 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010663 status = csr_roam_start_beacon_req(pMac, bssid,
10664 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665 sme_release_global_lock(&pMac->sme);
10666 }
10667 return status;
10668}
10669
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010670/**
10671 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10672 * @hHal: handle returned by mac_open
10673 * @bssid: SAP bssid
10674 * @targetChannel: target channel information
10675 * @csaIeReqd: CSA IE Request
10676 * @ch_params: channel information
10677 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010678 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010679 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010680QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010681 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010682 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010684 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010685 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010688 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010689 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10690 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 sme_release_global_lock(&pMac->sme);
10692 }
10693 return status;
10694}
10695
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010696/*
10697 * sme_init_thermal_info() -
10698 * SME API to initialize the thermal mitigation parameters
10699 *
10700 * hHal
10701 * thermalParam : thermal mitigation parameters
10702 * Return QDF_STATUS
10703 */
10704QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10705 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010706{
10707 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010708 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10710
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010711 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010712 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010713 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010714 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010715 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 }
10717
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010718 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10719 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010720
10721 pWmaParam->throttle_duty_cycle_tbl[0] =
10722 thermalParam.sme_throttle_duty_cycle_tbl[0];
10723 pWmaParam->throttle_duty_cycle_tbl[1] =
10724 thermalParam.sme_throttle_duty_cycle_tbl[1];
10725 pWmaParam->throttle_duty_cycle_tbl[2] =
10726 thermalParam.sme_throttle_duty_cycle_tbl[2];
10727 pWmaParam->throttle_duty_cycle_tbl[3] =
10728 thermalParam.sme_throttle_duty_cycle_tbl[3];
10729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010730 pWmaParam->thermalLevels[0].minTempThreshold =
10731 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10732 pWmaParam->thermalLevels[0].maxTempThreshold =
10733 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10734 pWmaParam->thermalLevels[1].minTempThreshold =
10735 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10736 pWmaParam->thermalLevels[1].maxTempThreshold =
10737 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10738 pWmaParam->thermalLevels[2].minTempThreshold =
10739 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10740 pWmaParam->thermalLevels[2].maxTempThreshold =
10741 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10742 pWmaParam->thermalLevels[3].minTempThreshold =
10743 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10744 pWmaParam->thermalLevels[3].maxTempThreshold =
10745 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10746
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010747 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010748 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10749 msg.bodyptr = pWmaParam;
10750
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010751 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010752 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010753 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010754 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10755 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010756 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010757 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010758 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010759 }
10760 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010761 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010763 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010764 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010765}
10766
10767/**
10768 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10769 * @hal: Handle returned by macOpen
10770 * @callback: sme_set_thermal_level_callback
10771 *
10772 * Plug in set thermal level callback
10773 *
10774 * Return: none
10775 */
10776void sme_add_set_thermal_level_callback(tHalHandle hal,
10777 sme_set_thermal_level_callback callback)
10778{
10779 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10780
10781 pMac->sme.set_thermal_level_cb = callback;
10782}
10783
10784/**
10785 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10786 * @hal: Handler to HAL
10787 * @level: Thermal mitigation level
10788 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010789 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010790 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010791QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010792{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010793 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010794 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010795 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010796
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010797 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010798 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 msg.type = WMA_SET_THERMAL_LEVEL;
10800 msg.bodyval = level;
10801
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010802 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010803 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010804 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010805 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10806 __func__);
10807 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010808 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010809 }
10810 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010811 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010812 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010813 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010814}
10815
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010816/*
10817 * sme_txpower_limit() -
10818 * SME API to set txpower limits
10819 *
10820 * hHal
10821 * psmetx : power limits for 2g/5g
10822 * Return QDF_STATUS
10823 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010824QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010825{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010826 QDF_STATUS status = QDF_STATUS_SUCCESS;
10827 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010828 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010829 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010830 tSirTxPowerLimit *tx_power_limit;
10831
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010832 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010833 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010834 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010835 "%s: Memory allocation for TxPowerLimit failed!",
10836 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010837 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010838 }
10839
10840 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010841
10842 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010843 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010844 message.type = WMA_TX_POWER_LIMIT;
10845 message.reserved = 0;
10846 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010848 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10849 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010850 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010851 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010852 "%s: not able to post WMA_TX_POWER_LIMIT",
10853 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010854 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010855 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010856 }
10857 sme_release_global_lock(&pMac->sme);
10858 }
10859 return status;
10860}
10861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010862QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010863{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010864 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010865 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010867 pMac->fEnableDebugLog = set_value;
10868 return status;
10869}
10870
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010871/*
10872 * sme_ap_disable_intra_bss_fwd() -
10873 * SME will send message to WMA to set Intra BSS in txrx
10874 *
10875 * hHal - The handle returned by mac_open
10876 * sessionId - session id ( vdev id)
10877 * disablefwd - bool value that indicate disable intrabss fwd disable
10878 * Return QDF_STATUS
10879 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010880QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010881 bool disablefwd)
10882{
10883 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010884 int status = QDF_STATUS_SUCCESS;
10885 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010886 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010887 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10888
10889 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010890 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010891 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010892 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010893 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010894 }
10895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896 pSapDisableIntraFwd->sessionId = sessionId;
10897 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10898
10899 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010900 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010901 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010902 message.bodyptr = pSapDisableIntraFwd;
10903 message.type = WMA_SET_SAP_INTRABSS_DIS;
10904 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10905 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010906 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10907 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010908 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010909 }
10910 sme_release_global_lock(&pMac->sme);
10911 }
10912 return status;
10913}
10914
10915#ifdef WLAN_FEATURE_STATS_EXT
10916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010917/*
10918 * sme_stats_ext_register_callback() -
10919 * This function called to register the callback that send vendor event for
10920 * stats ext
10921 *
10922 * callback - callback to be registered
10923 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10925{
10926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10927
10928 pMac->sme.StatsExtCallback = callback;
10929}
10930
lifeng66831662017-05-19 16:01:35 +080010931void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10932 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10933{
10934 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10935
10936 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10937}
10938
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010939/**
10940 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10941 * @h_hal: Hal Handle
10942 *
10943 * This function is called to de initialize the HDD NAN feature. Currently
10944 * the only operation required is to de-register a callback with SME.
10945 *
10946 * Return: None
10947 */
10948void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10949{
10950 tpAniSirGlobal pmac;
10951
10952 if (!h_hal) {
10953 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10954 FL("hHal is not valid"));
10955 return;
10956 }
10957
10958 pmac = PMAC_STRUCT(h_hal);
10959 pmac->sme.StatsExtCallback = NULL;
10960}
10961
10962
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010963/*
10964 * sme_stats_ext_request() -
10965 * Function called when HDD receives STATS EXT vendor command from userspace
10966 *
10967 * sessionID - vdevID for the stats ext request
10968 * input - Stats Ext Request structure ptr
10969 * Return QDF_STATUS
10970 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010971QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010972{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010973 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010974 tpStatsExtRequest data;
10975 size_t data_len;
10976
10977 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010978 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010979
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010980 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010981 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 data->vdev_id = session_id;
10984 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010985 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010986 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010987 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010988
10989 msg.type = WMA_STATS_EXT_REQUEST;
10990 msg.reserved = 0;
10991 msg.bodyptr = data;
10992
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010993 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010994 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010995 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010996 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10997 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010998 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010999 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011000 }
11001
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011002 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011003}
11004
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011005/*
11006 * sme_stats_ext_event() -
11007 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
11008 * response from WMA
11009 *
11010 * hHal - HAL handle for device
11011 * pMsg - Message body passed from WMA; includes NAN header
11012 * Return QDF_STATUS
11013 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011014QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015{
11016 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011017 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011018
11019 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011020 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011021 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011022 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011023 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011024 pMac->sme.StatsExtCallback(pMac->hHdd,
11025 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011026 }
11027
11028 return status;
11029}
11030
11031#endif
11032
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011033/*
11034 * sme_update_dfs_scan_mode() -
11035 * Update DFS roam scan mode
11036 * This function is called through dynamic setConfig callback function
11037 * to configure allowDFSChannelRoam.
11038 * hHal - HAL handle for device
11039 * sessionId - Session Identifier
11040 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
11041 * 1 (passive), 2 (active)
11042 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
11043 * successfully.
11044 * Other status means SME failed to update DFS roaming scan config.
11045 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011046QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011047 uint8_t allowDFSChannelRoam)
11048{
11049 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011050 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011051
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080011052 if (sessionId >= CSR_ROAM_SESSION_MAX) {
11053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11054 FL("Invalid sme session id: %d"), sessionId);
11055 return QDF_STATUS_E_INVAL;
11056 }
11057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011058 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011059 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011060 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011061 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011062 allowDFSChannelRoam,
11063 pMac->roam.configParam.allowDFSChannelRoam,
11064 mac_trace_get_neighbour_roam_state(pMac->roam.
11065 neighborRoamInfo
11066 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011067 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011068 pMac->roam.configParam.allowDFSChannelRoam =
11069 allowDFSChannelRoam;
11070 sme_release_global_lock(&pMac->sme);
11071 }
11072 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11073 csr_roam_offload_scan(pMac, sessionId,
11074 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
11075 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
11076 }
11077
11078 return status;
11079}
11080
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011081/*
11082 * sme_get_dfs_scan_mode() - get DFS roam scan mode
11083 * This is a synchronous call
11084 *
11085 * hHal - The handle returned by mac_open.
11086 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
11087 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011088uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
11089{
11090 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 return pMac->roam.configParam.allowDFSChannelRoam;
11093}
11094
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011095/*
11096 * sme_modify_add_ie() -
11097 * This function sends msg to updates the additional IE buffers in PE
11098 *
11099 * hHal - global structure
11100 * pModifyIE - pointer to tModifyIE structure
11101 * updateType - type of buffer
11102 * Return Success or failure
11103 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011104QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011105 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
11106{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011107 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011110 status = sme_acquire_global_lock(&pMac->sme);
11111
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011112 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
11114 sme_release_global_lock(&pMac->sme);
11115 }
11116 return status;
11117}
11118
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011119/*
11120 * sme_update_add_ie() -
11121 * This function sends msg to updates the additional IE buffers in PE
11122 *
11123 * hHal - global structure
11124 * pUpdateIE - pointer to structure tUpdateIE
11125 * updateType - type of buffer
11126 * Return Success or failure
11127 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011128QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011129 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
11130{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011131 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011132 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 status = sme_acquire_global_lock(&pMac->sme);
11135
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011136 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011137 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
11138 sme_release_global_lock(&pMac->sme);
11139 }
11140 return status;
11141}
11142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011143/**
11144 * sme_update_dsc_pto_up_mapping()
11145 * @hHal: HAL context
11146 * @dscpmapping: pointer to DSCP mapping structure
11147 * @sessionId: SME session id
11148 *
11149 * This routine is called to update dscp mapping
11150 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011151 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011153QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053011154 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155 uint8_t sessionId)
11156{
11157 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011158 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011160 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 tpPESession pSession = NULL;
11162
11163 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011164 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011165 return status;
11166 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
11167 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011168 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011169 FL("Session lookup fails for CSR session"));
11170 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011171 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011172 }
11173 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011174 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011175 FL("Invalid session Id %u"), sessionId);
11176 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011178 }
11179
11180 pSession = pe_find_session_by_bssid(pMac,
11181 pCsrSession->connectedProfile.bssid.bytes,
11182 &peSessionId);
11183
11184 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011185 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011186 FL(" Session lookup fails for BSSID"));
11187 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011188 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011189 }
11190
11191 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011192 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011193 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 }
11196 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11197 for (j = pSession->QosMapSet.dscp_range[i][0];
11198 j <= pSession->QosMapSet.dscp_range[i][1];
11199 j++) {
11200 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11201 && (pSession->QosMapSet.dscp_range[i][1] ==
11202 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011203 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011204 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011205 FL("User Priority %d isn't used"), i);
11206 break;
11207 } else {
11208 dscpmapping[j] = i;
11209 }
11210 }
11211 }
11212 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11213 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11214 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11215 pSession->QosMapSet.dscp_exceptions[i][1];
11216
11217 sme_release_global_lock(&pMac->sme);
11218 return status;
11219}
11220
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011221/*
11222 * sme_abort_roam_scan() -
11223 * API to abort current roam scan cycle by roam scan offload module.
11224 *
11225 * hHal - The handle returned by mac_open.
11226 * sessionId - Session Identifier
11227 * Return QDF_STATUS
11228 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011229
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011230QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011231{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011232 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011233 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11234
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11236 /* acquire the lock for the sme object */
11237 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011238 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011239 csr_roam_offload_scan(pMac, sessionId,
11240 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11241 REASON_ROAM_ABORT_ROAM_SCAN);
11242 /* release the lock for the sme object */
11243 sme_release_global_lock(&pMac->sme);
11244 }
11245 }
11246
11247 return status;
11248}
11249
11250#ifdef FEATURE_WLAN_EXTSCAN
11251/**
11252 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11253 * @hHal: HAL context
11254 * @wifiBand: RF band information
11255 * @aValidChannels: output array to store channel info
11256 * @pNumChannels: output number of channels
11257 *
11258 * SME API to fetch all valid channels filtered by band
11259 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011260 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011262QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011263 uint8_t wifiBand,
11264 uint32_t *aValidChannels,
11265 uint8_t *pNumChannels)
11266{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011267 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011269 uint8_t numChannels = 0;
11270 uint8_t i = 0;
11271 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011272 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011273
11274 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011275 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011276 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011277 }
11278
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011279 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011280 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011281 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011282 }
11283
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011284 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011285 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011286 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011287 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011288 return status;
11289 }
11290
11291 switch (wifiBand) {
11292 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011293 sme_debug("Unspec Band, return all %d valid channels",
11294 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011295 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011296 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011297 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011298 break;
11299
11300 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011301 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011302 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011303 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011304 aValidChannels[numChannels++] =
11305 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011306 }
11307 break;
11308
11309 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011310 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011311 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011312 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011313 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011314 aValidChannels[numChannels++] =
11315 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011316 }
11317 break;
11318
11319 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011320 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011321 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011322 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11323 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011324 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011325 aValidChannels[numChannels++] =
11326 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327 }
11328 break;
11329
11330 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011331 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011333 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011334 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011335 aValidChannels[numChannels++] =
11336 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011337 }
11338 break;
11339
11340 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011341 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011343 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011344 aValidChannels[numChannels++] =
11345 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011346 }
11347 break;
11348
11349 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011350 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011352 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011353 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011354 aValidChannels[numChannels++] =
11355 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011356 }
11357 break;
11358
11359 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011360 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011361 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011362 }
11363 *pNumChannels = numChannels;
11364
11365 return status;
11366}
11367
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011368/*
11369 * sme_ext_scan_get_capabilities() -
11370 * SME API to fetch extscan capabilities
11371 *
11372 * hHal
11373 * pReq: extscan capabilities structure
11374 * Return QDF_STATUS
11375 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011376QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 tSirGetExtScanCapabilitiesReqParams *
11378 pReq)
11379{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011380 QDF_STATUS status = QDF_STATUS_SUCCESS;
11381 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011382 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011383 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011384
11385 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011386 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011388 message.bodyptr = pReq;
11389 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011390 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011391 NO_SESSION, message.type));
11392 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11393 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011394 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11395 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011396
11397 sme_release_global_lock(&pMac->sme);
11398 }
11399 return status;
11400}
11401
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011402/*
11403 * sme_ext_scan_start() -
11404 * SME API to issue extscan start
11405 *
11406 * hHal
11407 * pStartCmd: extscan start structure
11408 * Return QDF_STATUS
11409 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011410QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011411 tSirWifiScanCmdReqParams *pStartCmd)
11412{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011413 QDF_STATUS status = QDF_STATUS_SUCCESS;
11414 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011415 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011416 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011417
11418 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011419 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011420 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011421 message.bodyptr = pStartCmd;
11422 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011423 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011424 NO_SESSION, message.type));
11425 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11426 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011427 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11428 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011429
11430 sme_release_global_lock(&pMac->sme);
11431 }
11432 return status;
11433}
11434
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011435/*
11436 * sme_ext_scan_stop() -
11437 * SME API to issue extscan stop
11438 *
11439 * hHal
11440 * pStopReq: extscan stop structure
11441 * Return QDF_STATUS
11442 */
11443QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11444 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011445{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011446 QDF_STATUS status = QDF_STATUS_SUCCESS;
11447 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011448 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011449 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011450
11451 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011452 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011453 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011454 message.bodyptr = pStopReq;
11455 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011456 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011457 NO_SESSION, message.type));
11458 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11459 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011460 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11461 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011462 sme_release_global_lock(&pMac->sme);
11463 }
11464 return status;
11465}
11466
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011467/*
11468 * sme_set_bss_hotlist() -
11469 * SME API to set BSSID hotlist
11470 *
11471 * hHal
11472 * pSetHotListReq: extscan set hotlist structure
11473 * Return QDF_STATUS
11474 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011475QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011476 tSirExtScanSetBssidHotListReqParams *
11477 pSetHotListReq)
11478{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011479 QDF_STATUS status = QDF_STATUS_SUCCESS;
11480 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011482 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483
11484 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011485 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011486 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011487 message.bodyptr = pSetHotListReq;
11488 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011489 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011490 NO_SESSION, message.type));
11491 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11492 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011493 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11494 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011495
11496 sme_release_global_lock(&pMac->sme);
11497 }
11498 return status;
11499}
11500
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011501/*
11502 * sme_reset_bss_hotlist() -
11503 * SME API to reset BSSID hotlist
11504 *
11505 * hHal
11506 * pSetHotListReq: extscan set hotlist structure
11507 * Return QDF_STATUS
11508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011509QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011510 tSirExtScanResetBssidHotlistReqParams *
11511 pResetReq)
11512{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011513 QDF_STATUS status = QDF_STATUS_SUCCESS;
11514 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011515 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011516 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011517
11518 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011519 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011521 message.bodyptr = pResetReq;
11522 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011523 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011524 NO_SESSION, message.type));
11525 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11526 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011527 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11528 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011529
11530 sme_release_global_lock(&pMac->sme);
11531 }
11532 return status;
11533}
11534
Manikandan Mohan80dea792016-04-28 16:36:48 -070011535/**
11536 * sme_send_wisa_params(): Pass WISA mode to WMA
11537 * @hal: HAL context
11538 * @wisa_params: pointer to WISA params struct
11539 * @sessionId: SME session id
11540 *
11541 * Pass WISA params to WMA
11542 *
11543 * Return: QDF_STATUS
11544 */
11545QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11546 struct sir_wisa_params *wisa_params)
11547{
11548 QDF_STATUS status = QDF_STATUS_SUCCESS;
11549 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011550 struct scheduler_msg message = {0};
Manikandan Mohan80dea792016-04-28 16:36:48 -070011551 struct sir_wisa_params *cds_msg_wisa_params;
11552
11553 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11554 if (!cds_msg_wisa_params)
11555 return QDF_STATUS_E_NOMEM;
11556
11557 *cds_msg_wisa_params = *wisa_params;
11558 status = sme_acquire_global_lock(&mac->sme);
11559 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011560 message.bodyptr = cds_msg_wisa_params;
11561 message.type = WMA_SET_WISA_PARAMS;
11562 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Manikandan Mohan80dea792016-04-28 16:36:48 -070011563 sme_release_global_lock(&mac->sme);
11564 }
11565 return status;
11566}
11567
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011568/*
11569 * sme_set_significant_change() -
11570 * SME API to set significant change
11571 *
11572 * hHal
11573 * pSetSignificantChangeReq: extscan set significant change structure
11574 * Return QDF_STATUS
11575 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011576QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011577 tSirExtScanSetSigChangeReqParams *
11578 pSetSignificantChangeReq)
11579{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011580 QDF_STATUS status = QDF_STATUS_SUCCESS;
11581 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011583 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011584
11585 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011586 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011588 message.bodyptr = pSetSignificantChangeReq;
11589 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011590 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011591 NO_SESSION, message.type));
11592 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11593 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011594 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11595 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596
11597 sme_release_global_lock(&pMac->sme);
11598 }
11599 return status;
11600}
11601
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011602/*
11603 * sme_reset_significant_change
11604 * SME API to reset significant change
11605 *
11606 * hHal
11607 * pResetReq: extscan reset significant change structure
11608 * Return QDF_STATUS
11609 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011610QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011611 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 *pResetReq)
11613{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011614 QDF_STATUS status = QDF_STATUS_SUCCESS;
11615 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011616 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011617 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011618
11619 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011620 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011621 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011622 message.bodyptr = pResetReq;
11623 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011624 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011625 NO_SESSION, message.type));
11626 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11627 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011628 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11629 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011630
11631 sme_release_global_lock(&pMac->sme);
11632 }
11633 return status;
11634}
11635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011636/*
11637 * sme_get_cached_results() -
11638 * SME API to get cached results
11639 *
11640 * hHal
11641 * pCachedResultsReq: extscan get cached results structure
11642 * Return QDF_STATUS
11643 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011644QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011645 tSirExtScanGetCachedResultsReqParams *
11646 pCachedResultsReq)
11647{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011648 QDF_STATUS status = QDF_STATUS_SUCCESS;
11649 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011650 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011651 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011652
11653 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011654 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011655 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011656 message.bodyptr = pCachedResultsReq;
11657 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011658 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011659 NO_SESSION, message.type));
11660 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11661 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011662 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11663 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664
11665 sme_release_global_lock(&pMac->sme);
11666 }
11667 return status;
11668}
11669
11670/**
11671 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011672 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011673 * @input: request message
11674 *
11675 * This function constructs the cds message and fill in message type,
11676 * bodyptr with %input and posts it to WDA queue.
11677 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011678 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011679 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011680QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011681 struct wifi_epno_params *input)
11682{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011683 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011684 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011685 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011686 struct wifi_epno_params *req_msg;
11687 int len, i;
11688
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011689 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011690 len = sizeof(*req_msg) +
11691 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011692
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011693 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011694 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011695 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011696 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011697 }
11698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011699 req_msg->num_networks = input->num_networks;
11700 req_msg->request_id = input->request_id;
11701 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011702
11703 /* Fill only when num_networks are non zero */
11704 if (req_msg->num_networks) {
11705 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11706 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11707 req_msg->initial_score_max = input->initial_score_max;
11708 req_msg->same_network_bonus = input->same_network_bonus;
11709 req_msg->secure_bonus = input->secure_bonus;
11710 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11711 req_msg->current_connection_bonus =
11712 input->current_connection_bonus;
11713
11714 for (i = 0; i < req_msg->num_networks; i++) {
11715 req_msg->networks[i].flags = input->networks[i].flags;
11716 req_msg->networks[i].auth_bit_field =
11717 input->networks[i].auth_bit_field;
11718 req_msg->networks[i].ssid.length =
11719 input->networks[i].ssid.length;
11720 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11721 input->networks[i].ssid.ssId,
11722 req_msg->networks[i].ssid.length);
11723 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011724 }
11725
11726 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011727 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011728 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011729 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011730 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011731 return status;
11732 }
11733
11734 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011735 message.bodyptr = req_msg;
11736 message.type = WMA_SET_EPNO_LIST_REQ;
11737 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011738 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011739 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011741 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011742 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743 }
11744 sme_release_global_lock(&mac->sme);
11745 return status;
11746}
11747
11748/**
11749 * sme_set_passpoint_list() - set passpoint network list
11750 * @hal: global hal handle
11751 * @input: request message
11752 *
11753 * This function constructs the cds message and fill in message type,
11754 * bodyptr with @input and posts it to WDA queue.
11755 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011756 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011757 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011758QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011759 struct wifi_passpoint_req *input)
11760{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011761 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011762 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011763 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011764 struct wifi_passpoint_req *req_msg;
11765 int len, i;
11766
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011767 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011768 len = sizeof(*req_msg) +
11769 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011770 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011772 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011773 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011774 }
11775
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011776 req_msg->num_networks = input->num_networks;
11777 req_msg->request_id = input->request_id;
11778 req_msg->session_id = input->session_id;
11779 for (i = 0; i < req_msg->num_networks; i++) {
11780 req_msg->networks[i].id =
11781 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011782 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011783 input->networks[i].realm,
11784 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011785 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011786 input->networks[i].plmn,
11787 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011788 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011789 input->networks[i].roaming_consortium_ids,
11790 sizeof(req_msg->networks[i].roaming_consortium_ids));
11791 }
11792
11793 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011794 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011795 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011797 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011798 return status;
11799 }
11800
11801 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011802 message.bodyptr = req_msg;
11803 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11804 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011805 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011806 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011808 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011809 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011810 }
11811 sme_release_global_lock(&mac->sme);
11812 return status;
11813}
11814
11815/**
11816 * sme_reset_passpoint_list() - reset passpoint network list
11817 * @hHal: global hal handle
11818 * @input: request message
11819 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011820 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011821 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011822QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011823 struct wifi_passpoint_req *input)
11824{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011825 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011826 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011827 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011828 struct wifi_passpoint_req *req_msg;
11829
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011830 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011831 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011832 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011833 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011834 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011835 }
11836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011837 req_msg->request_id = input->request_id;
11838 req_msg->session_id = input->session_id;
11839
11840 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011841 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011842 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011843 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011844 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011845 return status;
11846 }
11847
11848 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011849 message.bodyptr = req_msg;
11850 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11851 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011852 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011853 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011854 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011855 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011856 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011857 }
11858 sme_release_global_lock(&mac->sme);
11859 return status;
11860}
11861
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011862QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011863 void (*pExtScanIndCb)(void *,
11864 const uint16_t,
11865 void *))
11866{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011867 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11869
11870 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011871 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011872 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11873 sme_release_global_lock(&pMac->sme);
11874 }
11875 return status;
11876}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011877#endif /* FEATURE_WLAN_EXTSCAN */
11878
11879#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011881/*
11882 * sme_ll_stats_clear_req() -
11883 * SME API to clear Link Layer Statistics
11884 *
11885 * hHal
11886 * pclearStatsReq: Link Layer clear stats request params structure
11887 * Return QDF_STATUS
11888 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011889QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011890 tSirLLStatsClearReq *pclearStatsReq)
11891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011892 QDF_STATUS status = QDF_STATUS_SUCCESS;
11893 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011894 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011895 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896 tSirLLStatsClearReq *clear_stats_req;
11897
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011899 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011901 "statsClearReqMask = 0x%X",
11902 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011903 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011904 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011905 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11906 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11907 "%s: invalid staId %d",
11908 __func__, pclearStatsReq->staId);
11909 return QDF_STATUS_E_INVAL;
11910 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011911
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011912 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011913
11914 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011915 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011916 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11917 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011918 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 }
11920
11921 *clear_stats_req = *pclearStatsReq;
11922
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011923 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011925 message.bodyptr = clear_stats_req;
11926 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011927 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011928 NO_SESSION, message.type));
11929 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11930 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011931 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011932 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011933 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11934 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011935 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011936 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011937 }
11938 sme_release_global_lock(&pMac->sme);
11939 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011940 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11941 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011942 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011943 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011944 }
11945
11946 return status;
11947}
11948
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011949/*
11950 * sme_ll_stats_set_req() -
11951 * SME API to set the Link Layer Statistics
11952 *
11953 * hHal
11954 * psetStatsReq: Link Layer set stats request params structure
11955 * Return QDF_STATUS
11956 */
11957QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11958 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011959{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011960 QDF_STATUS status = QDF_STATUS_SUCCESS;
11961 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011962 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011963 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011964 tSirLLStatsSetReq *set_stats_req;
11965
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011966 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011967 "%s: MPDU Size = %u", __func__,
11968 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011969 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011970 " Aggressive Stats Collections = %u",
11971 psetStatsReq->aggressiveStatisticsGathering);
11972
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011973 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011974
11975 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011976 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011977 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11978 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011979 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011980 }
11981
11982 *set_stats_req = *psetStatsReq;
11983
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011984 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011985 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011986 message.bodyptr = set_stats_req;
11987 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011988 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011989 NO_SESSION, message.type));
11990 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11991 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011992 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011994 "%s: not able to post WMA_LL_STATS_SET_REQ",
11995 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011996 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011997 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011998 }
11999 sme_release_global_lock(&pMac->sme);
12000 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012001 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12002 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012003 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012004 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012005 }
12006
12007 return status;
12008}
12009
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012010/*
12011 * sme_ll_stats_get_req() -
12012 * SME API to get the Link Layer Statistics
12013 *
12014 * hHal
12015 * pgetStatsReq: Link Layer get stats request params structure
12016 * Return QDF_STATUS
12017 */
12018QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
12019 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012020{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012021 QDF_STATUS status = QDF_STATUS_SUCCESS;
12022 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012023 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012024 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012025 tSirLLStatsGetReq *get_stats_req;
12026
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012027 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012028
12029 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012030 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012031 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
12032 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012033 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012034 }
12035
12036 *get_stats_req = *pgetStatsReq;
12037
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012038 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012039 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012040 message.bodyptr = get_stats_req;
12041 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053012042 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012043 NO_SESSION, message.type));
12044 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12045 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012046 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012047 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012048 "%s: not able to post WMA_LL_STATS_GET_REQ",
12049 __func__);
12050
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012051 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012052 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012053
12054 }
12055 sme_release_global_lock(&pMac->sme);
12056 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012057 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12058 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012059 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012060 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012061 }
12062
12063 return status;
12064}
12065
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012066/*
12067 * sme_set_link_layer_stats_ind_cb() -
12068 * SME API to trigger the stats are available after get request
12069 *
12070 * hHal
12071 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012072 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012073 * Return QDF_STATUS
12074 */
12075QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
12076 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
12077{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012078 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012079 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12080
12081 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012082 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012083 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
12084 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012085 } else
12086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12087 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012088
12089 return status;
12090}
12091
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012092/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080012093 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
12094 * @hal: Mac global handle
12095 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
12096 * status notification from FW
12097 *
12098 * Return: eHalStatus
12099 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012100QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
12101 (tHddHandle callback_ctx, tSirLLStatsResults
12102 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080012103{
12104 QDF_STATUS status;
12105 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12106
12107 status = sme_acquire_global_lock(&mac->sme);
12108 if (status == QDF_STATUS_SUCCESS) {
12109 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
12110 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012111 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080012112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12113 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080012114 return status;
12115}
12116
12117/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012118 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
12119 * indication
12120 * @h_hal: Hal Handle
12121 *
12122 * This function reset's the link layer stats indication
12123 *
12124 * Return: QDF_STATUS Enumeration
12125 */
12126
12127QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
12128{
12129 QDF_STATUS status;
12130 tpAniSirGlobal pmac;
12131
12132 if (!h_hal) {
12133 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12134 FL("hHal is not valid"));
12135 return QDF_STATUS_E_INVAL;
12136 }
12137 pmac = PMAC_STRUCT(h_hal);
12138
12139 status = sme_acquire_global_lock(&pmac->sme);
12140 if (QDF_IS_STATUS_SUCCESS(status)) {
12141 pmac->sme.pLinkLayerStatsIndCallback = NULL;
12142 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012143 } else
12144 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12145 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012146
12147 return status;
12148}
12149
Zhang Qian73c348a2017-03-13 16:15:55 +080012150/**
12151 * sme_ll_stats_set_thresh - set threshold for mac counters
12152 * @hal, hal layer handle
12153 * @threshold, threshold for mac counters
12154 *
12155 * Return: QDF_STATUS Enumeration
12156 */
12157QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
12158 struct sir_ll_ext_stats_threshold *threshold)
12159{
12160 QDF_STATUS status;
12161 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080012162 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080012163 struct sir_ll_ext_stats_threshold *thresh;
12164
12165 if (!threshold) {
12166 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12167 FL("threshold is not valid"));
12168 return QDF_STATUS_E_INVAL;
12169 }
12170
12171 if (!hal) {
12172 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12173 FL("hal is not valid"));
12174 return QDF_STATUS_E_INVAL;
12175 }
12176 mac = PMAC_STRUCT(hal);
12177
12178 thresh = qdf_mem_malloc(sizeof(*thresh));
12179 if (!thresh) {
12180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12181 "%s: Fail to alloc mem", __func__);
12182 return QDF_STATUS_E_NOMEM;
12183 }
12184 *thresh = *threshold;
12185
12186 status = sme_acquire_global_lock(&mac->sme);
12187 if (QDF_IS_STATUS_SUCCESS(status)) {
12188 /* Serialize the req through MC thread */
12189 message.bodyptr = thresh;
12190 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12191 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12192 NO_SESSION, message.type));
12193 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12194 if (!QDF_IS_STATUS_SUCCESS(status)) {
12195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12196 "%s: not able to post WDA_LL_STATS_GET_REQ",
12197 __func__);
12198 qdf_mem_free(thresh);
12199 }
12200 sme_release_global_lock(&mac->sme);
12201 } else {
12202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12203 FL("sme_acquire_global_lock error"));
12204 qdf_mem_free(thresh);
12205 }
12206 return status;
12207}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012209#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12210
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012211#ifdef WLAN_POWER_DEBUGFS
12212/**
12213 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12214 * @callback_fn: Pointer to the callback function for Power stats event
12215 * @power_stats_context: Pointer to context
12216 *
12217 * Return: QDF_STATUS
12218 */
12219QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12220 (struct power_stats_response *response,
12221 void *context), void *power_stats_context)
12222{
12223 QDF_STATUS status = QDF_STATUS_SUCCESS;
12224 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012225 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012226
12227 status = sme_acquire_global_lock(&mac_ctx->sme);
12228 if (QDF_IS_STATUS_SUCCESS(status)) {
12229 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012230 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012231 sme_release_global_lock(&mac_ctx->sme);
12232 return QDF_STATUS_E_FAILURE;
12233 }
12234
12235 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12236 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12237 msg.bodyptr = NULL;
12238 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012239 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012240 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012241 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012242 sme_release_global_lock(&mac_ctx->sme);
12243 }
12244 return status;
12245}
12246#endif
12247
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012248#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012249/*
12250 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12251 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12252 *
12253 * hHal - The handle returned by mac_open.
12254 * nRoamOffloadEnabled - The bool to update with
12255 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12256 * Other status means SME is failed to update.
12257 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012258
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012259QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012260 bool nRoamOffloadEnabled)
12261{
12262 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012263 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264
12265 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012266 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012267 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012268 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12269 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12270 nRoamOffloadEnabled);
12271 pMac->roam.configParam.isRoamOffloadEnabled =
12272 nRoamOffloadEnabled;
12273 sme_release_global_lock(&pMac->sme);
12274 }
12275
12276 return status;
12277}
12278
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012279/**
12280 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12281 * This is a synchronous call
12282 * @hal_ctx: The handle returned by mac_open.
12283 * @session_id: Session Identifier
12284 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012285 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012286 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12287 * Other status means SME is failed to update.
12288 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012289
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012290QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012291 uint8_t session_id,
12292 bool key_mgmt_offload_enabled,
12293 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012294{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012295 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012296 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012297
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012298 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012299 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012300 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012301 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012302 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12303 __func__, key_mgmt_offload_enabled);
12304 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12305 session_id,
12306 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012307 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012308 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012309 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012310 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012311 }
12312
12313 return status;
12314}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012315#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012316
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012317/*
12318 * sme_get_temperature() -
12319 * SME API to get the pdev temperature
12320 *
12321 * hHal
12322 * temperature context
12323 * pCallbackfn: callback fn with response (temperature)
12324 * Return QDF_STATUS
12325 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012326QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012327 void *tempContext,
12328 void (*pCallbackfn)(int temperature,
12329 void *pContext))
12330{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012331 QDF_STATUS status = QDF_STATUS_SUCCESS;
12332 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012333 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012334 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012335
12336 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012337 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 if ((NULL == pCallbackfn) &&
12339 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012340 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012341 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012342 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012343 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012344 } else if (NULL != pCallbackfn) {
12345 pMac->sme.pTemperatureCbContext = tempContext;
12346 pMac->sme.pGetTemperatureCb = pCallbackfn;
12347 }
12348 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012349 message.bodyptr = NULL;
12350 message.type = WMA_GET_TEMPERATURE_REQ;
12351 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12352 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012353 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012354 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012355 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012356 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012357 }
12358 sme_release_global_lock(&pMac->sme);
12359 }
12360 return status;
12361}
12362
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012363/*
12364 * sme_set_scanning_mac_oui() -
12365 * SME API to set scanning mac oui
12366 *
12367 * hHal
12368 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12369 * Return QDF_STATUS
12370 */
12371QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12372 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012373{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012374 QDF_STATUS status = QDF_STATUS_SUCCESS;
12375 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012376 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012377 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012378
12379 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012380 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012381 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012382 message.bodyptr = pScanMacOui;
12383 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12384 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12385 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012386 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012387 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012388 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012389 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012390 }
12391 sme_release_global_lock(&pMac->sme);
12392 }
12393 return status;
12394}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012395
12396#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012397/*
12398 * sme_set_dhcp_srv_offload() -
12399 * SME API to set DHCP server offload info
12400 *
12401 * hHal
12402 * pDhcpSrvInfo : DHCP server offload info struct
12403 * Return QDF_STATUS
12404 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012405QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012406 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12407{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012408 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012409 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012410 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012411 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12412
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012413 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012414
12415 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012416 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012417 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12418 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012419 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012420 }
12421
12422 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12423
12424 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012425 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012427 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12428 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012429
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012430 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012431 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12432 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012433 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012434 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012435 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012436 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012437 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438 }
12439 sme_release_global_lock(&pMac->sme);
12440 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012441 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012442 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012443 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012444 }
12445
12446 return status;
12447}
12448#endif /* DHCP_SERVER_OFFLOAD */
12449
Krunal Soniaadaa272017-10-04 16:42:55 -070012450QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12451 uint32_t arg_count, uint32_t *arg)
12452{
12453 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12454 arg_count, arg);
12455}
12456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012457#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012458/*
12459 * sme_set_led_flashing() -
12460 * API to set the Led flashing parameters.
12461 *
12462 * hHal - The handle returned by mac_open.
12463 * x0, x1 - led flashing parameters
12464 * Return QDF_STATUS
12465 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012466QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012467 uint32_t x0, uint32_t x1)
12468{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012469 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012470 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012471 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012472 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012474 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012475 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012476 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012477 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012478 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012479 }
12480
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012481 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012482 ledflashing->pattern_id = type;
12483 ledflashing->led_x0 = x0;
12484 ledflashing->led_x1 = x1;
12485
12486 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012487 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012488 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012489 message.bodyptr = ledflashing;
12490 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012491 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012492 sme_release_global_lock(&pMac->sme);
12493 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012494 if (!QDF_IS_STATUS_SUCCESS(status))
12495 qdf_mem_free(ledflashing);
12496
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012497 return status;
12498}
12499#endif
12500
12501/**
12502 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12503 * @h_hal: corestack handler
12504 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012505 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012506 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012507QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012508{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012509 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012510 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12511
12512 status = sme_acquire_global_lock(&mac->sme);
12513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012514 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012515
12516 mac->scan.fEnableDFSChnlScan = dfs_flag;
12517
12518 /* update the channel list to the firmware */
12519 status = csr_update_channel_list(mac);
12520
12521 sme_release_global_lock(&mac->sme);
12522 }
12523
12524 return status;
12525}
12526
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012527#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12528/**
12529 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12530 * concurreny rules set to avoid channel interference.
12531 * @hal - Hal context
12532 * @sap_ch - channel to switch
12533 * @sap_phy_mode - phy mode of SAP
12534 * @cc_switch_mode - concurreny switch mode
12535 * @session_id - sme session id.
12536 *
12537 * Return: true if there is no channel interference else return false
12538 */
12539bool sme_validate_sap_channel_switch(tHalHandle hal,
12540 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12541 uint8_t session_id)
12542{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012543 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012544 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012545 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012546 uint16_t intf_channel = 0;
12547
12548 if (!session)
12549 return false;
12550
12551 session->ch_switch_in_progress = true;
12552 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012553 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012554 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12555 sap_phy_mode,
12556 cc_switch_mode);
12557 sme_release_global_lock(&mac->sme);
12558 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012559 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012560 FL("sme_acquire_global_lock error!"));
12561 session->ch_switch_in_progress = false;
12562 return false;
12563 }
12564
12565 session->ch_switch_in_progress = false;
12566 return (intf_channel == 0) ? true : false;
12567}
12568#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012569
12570/**
12571 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12572 * @hal: hal
12573 * @session_id: session ID
12574 * @stats_avg_factor: average stats factor
12575 *
12576 * This function configures the stats avg factor in firmware
12577 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012578 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012579 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012580QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012581 uint16_t stats_avg_factor)
12582{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012583 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012584 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012585 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12586 struct sir_stats_avg_factor *stats_factor;
12587
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012588 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012589
12590 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012591 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12593 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012594 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012595 }
12596
12597 status = sme_acquire_global_lock(&mac->sme);
12598
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012599 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012600
12601 stats_factor->vdev_id = session_id;
12602 stats_factor->stats_avg_factor = stats_avg_factor;
12603
12604 /* serialize the req through MC thread */
12605 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12606 msg.bodyptr = stats_factor;
12607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012608 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012609 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012610 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012611 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12612 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012613 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012614 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012615 }
12616 sme_release_global_lock(&mac->sme);
12617 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012618 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619 "%s: sme_acquire_global_lock error!",
12620 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012621 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012622 }
12623
12624 return status;
12625}
12626
12627/**
12628 * sme_configure_guard_time() - function to configure guard time
12629 * @hal: hal
12630 * @session_id: session id
12631 * @guard_time: guard time
12632 *
12633 * This function configures the guard time in firmware
12634 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012635 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012636 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012637QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012638 uint32_t guard_time)
12639{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012640 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012641 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012642 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12643 struct sir_guard_time_request *g_time;
12644
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012645 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012646
12647 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012649 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12650 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012651 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012652 }
12653
12654 status = sme_acquire_global_lock(&mac->sme);
12655
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012656 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012657
12658 g_time->vdev_id = session_id;
12659 g_time->guard_time = guard_time;
12660
12661 /* serialize the req through MC thread */
12662 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12663 msg.bodyptr = g_time;
12664
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012665 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012666 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012668 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12669 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012670 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012671 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012672 }
12673 sme_release_global_lock(&mac->sme);
12674 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012676 "%s: sme_acquire_global_lock error!",
12677 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012678 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012679 }
12680
12681 return status;
12682}
12683
12684/**
12685 * sme_configure_modulated_dtim() - function to configure modulated dtim
12686 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12687 * @session_id: session ID
12688 * @modulated_dtim: modulated dtim value
12689 *
12690 * This function configures the modulated dtim in firmware
12691 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012692 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012693 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012694QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012695 uint32_t modulated_dtim)
12696{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012697 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012698 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012699 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12700 wma_cli_set_cmd_t *iwcmd;
12701
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012702 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012703 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012704 QDF_TRACE(QDF_MODULE_ID_SME,
12705 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012706 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012707 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012708 }
12709
12710 status = sme_acquire_global_lock(&mac->sme);
12711
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012712 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012714 iwcmd->param_value = modulated_dtim;
12715 iwcmd->param_vdev_id = session_id;
12716 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12717 iwcmd->param_vp_dev = GEN_CMD;
12718 msg.type = WMA_CLI_SET_CMD;
12719 msg.reserved = 0;
12720 msg.bodyptr = (void *)iwcmd;
12721
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012722 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012723 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012724 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012725 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12726 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012727 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012728 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729 }
12730 sme_release_global_lock(&mac->sme);
12731 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012732 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012733 "%s: sme_acquire_global_lock error!",
12734 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012735 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012736 }
12737
12738 return status;
12739}
12740
Mukul Sharma6398b252017-05-01 17:58:12 +053012741/**
12742 * sme_override_listen_interval() - function to override static LI
12743 * @h_hal: SME API to override listen interval
12744 * @session_id: session ID
12745 * @override_li: new LI value passed by user
12746 *
12747 * This function override (enable/disable) static a.k.a ini based LI
12748 *
12749 * Return: QDF_STATUS
12750 */
12751QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12752 uint32_t override_li)
12753{
12754 struct scheduler_msg msg = {0};
12755 QDF_STATUS status = QDF_STATUS_SUCCESS;
12756 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12757 wma_cli_set_cmd_t *iwcmd;
12758
12759 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12760 if (!iwcmd) {
12761 QDF_TRACE(QDF_MODULE_ID_SME,
12762 QDF_TRACE_LEVEL_FATAL,
12763 "%s: qdf_mem_malloc failed", __func__);
12764 return QDF_STATUS_E_NOMEM;
12765 }
12766
12767 status = sme_acquire_global_lock(&mac->sme);
12768
12769 if (status == QDF_STATUS_SUCCESS) {
12770
12771 iwcmd->param_value = override_li;
12772 iwcmd->param_vdev_id = session_id;
12773 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12774 iwcmd->param_vp_dev = GEN_CMD;
12775 msg.type = WMA_CLI_SET_CMD;
12776 msg.reserved = 0;
12777 msg.bodyptr = (void *)iwcmd;
12778
12779 if (!QDF_IS_STATUS_SUCCESS(
12780 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12781 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12782 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12783 __func__);
12784 qdf_mem_free(iwcmd);
12785 status = QDF_STATUS_E_FAILURE;
12786 }
12787 sme_release_global_lock(&mac->sme);
12788 } else {
12789 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12790 "%s: sme_acquire_global_lock error!",
12791 __func__);
12792 qdf_mem_free(iwcmd);
12793 }
12794
12795 return status;
12796}
12797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012798/*
12799 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12800 * to either start/stop logging
12801 * @hal: HAL context
12802 * @start_log: Structure containing the wifi start logger params
12803 *
12804 * This function sends the start/stop logging command to WMA
12805 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012806 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012807 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012808QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809 struct sir_wifi_start_log start_log)
12810{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012811 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012812 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012813 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012814 struct sir_wifi_start_log *req_msg;
12815 uint32_t len;
12816
12817 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012818 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012819 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012820 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012821 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012822 }
12823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012824 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012825 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012826 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012827 req_msg->ini_triggered = start_log.ini_triggered;
12828 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012829 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012830 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012831
12832 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012833 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012834 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012835 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012836 return status;
12837 }
12838
12839 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012840 message.bodyptr = req_msg;
12841 message.type = SIR_HAL_START_STOP_LOGGING;
12842 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012843 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012844 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012845 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012846 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012847 }
12848 sme_release_global_lock(&mac->sme);
12849
12850 return status;
12851}
12852
12853/**
12854 * sme_neighbor_middle_of_roaming() - Function to know if
12855 * STA is in the middle of roaming states
12856 * @hal: Handle returned by macOpen
12857 * @sessionId: sessionId of the STA session
12858 *
12859 * This function is a wrapper to call
12860 * csr_neighbor_middle_of_roaming to know STA is in the
12861 * middle of roaming states
12862 *
12863 * Return: True or False
12864 *
12865 */
12866bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12867{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012868 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12869 bool val = false;
12870
12871 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12872 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12873 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012874 sme_err("Invalid Session: %d", sessionId);
12875
Sandeep Puligillaca631612016-11-08 11:53:52 -080012876 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012877}
12878
12879/*
12880 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12881 * @mac: MAC handle
12882 *
12883 * This function is used to send the command that will
12884 * be used to flush the logs in the firmware
12885 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012886 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012887 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012888QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012889{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012890 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012891 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012892
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012893 /* Serialize the req through MC thread */
12894 message.bodyptr = NULL;
12895 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012896 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012897 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012898 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012899 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012900 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012901 return status;
12902}
12903
Jeff Johnsona1e92612017-09-24 15:33:44 -070012904QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012905 sme_ac_enum_type ac, uint8_t tid,
12906 uint8_t pri, uint32_t srvc_int,
12907 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012908 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012909 uint8_t psb, uint32_t sessionId,
12910 uint32_t delay_interval)
12911{
12912 void *wma_handle;
12913 t_wma_trigger_uapsd_params uapsd_params;
12914 enum uapsd_ac access_category;
12915
12916 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012918 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012919 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012920 }
12921
Anurag Chouhan6d760662016-02-20 16:05:43 +053012922 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012923 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012924 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012925 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012926 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012927 }
12928
12929 switch (ac) {
12930 case SME_AC_BK:
12931 access_category = UAPSD_BK;
12932 break;
12933 case SME_AC_BE:
12934 access_category = UAPSD_BE;
12935 break;
12936 case SME_AC_VI:
12937 access_category = UAPSD_VI;
12938 break;
12939 case SME_AC_VO:
12940 access_category = UAPSD_VO;
12941 break;
12942 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012943 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012944 }
12945
12946 uapsd_params.wmm_ac = access_category;
12947 uapsd_params.user_priority = pri;
12948 uapsd_params.service_interval = srvc_int;
12949 uapsd_params.delay_interval = delay_interval;
12950 uapsd_params.suspend_interval = sus_int;
12951
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012952 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012953 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012954 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012955 "Failed to Trigger Uapsd params for sessionId %d",
12956 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012957 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012958 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012959 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012960}
12961
Jeff Johnsona1e92612017-09-24 15:33:44 -070012962QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012963 sme_ac_enum_type ac,
12964 uint32_t sessionId)
12965{
12966 void *wma_handle;
12967 enum uapsd_ac access_category;
12968
12969 switch (ac) {
12970 case SME_AC_BK:
12971 access_category = UAPSD_BK;
12972 break;
12973 case SME_AC_BE:
12974 access_category = UAPSD_BE;
12975 break;
12976 case SME_AC_VI:
12977 access_category = UAPSD_VI;
12978 break;
12979 case SME_AC_VO:
12980 access_category = UAPSD_VO;
12981 break;
12982 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012983 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012984 }
12985
Anurag Chouhan6d760662016-02-20 16:05:43 +053012986 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012987 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012989 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012991 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012992 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012993 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012995 "Failed to disable uapsd for ac %d for sessionId %d",
12996 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012997 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012998 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012999 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013000}
13001
13002/**
13003 * sme_update_nss() - SME API to change the number for spatial streams
13004 * (1 or 2)
13005 * @hal: Handle returned by mac open
13006 * @nss: Number of spatial streams
13007 *
13008 * This function is used to update the number of spatial streams supported.
13009 *
13010 * Return: Success upon successfully changing nss else failure
13011 *
13012 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013013QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013014{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013015 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013016 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
13017 uint32_t i, value = 0;
13018 union {
13019 uint16_t cfg_value16;
13020 tSirMacHTCapabilityInfo ht_cap_info;
13021 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013022 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013023
13024 status = sme_acquire_global_lock(&mac_ctx->sme);
13025
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013026 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013027 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
13028
13029 /* get the HT capability info*/
13030 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
13031 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
13032
13033 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
13034 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
13035 csr_session = &mac_ctx->roam.roamSession[i];
13036 csr_session->htConfig.ht_tx_stbc =
13037 uHTCapabilityInfo.ht_cap_info.txSTBC;
13038 }
13039 }
13040
13041 sme_release_global_lock(&mac_ctx->sme);
13042 }
13043 return status;
13044}
13045
13046/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070013047 * sme_update_user_configured_nss() - sets the nss based on user request
13048 * @hal: Pointer to HAL
13049 * @nss: number of streams
13050 *
13051 * Return: None
13052 */
13053void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
13054{
13055 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13056
13057 mac_ctx->user_configured_nss = nss;
13058}
13059
13060/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013061 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13062 * @hal: global hal handle
13063 * @cb: callback function pointer
13064 *
13065 * This function stores nud debug stats callback function.
13066 *
13067 * Return: QDF_STATUS enumeration.
13068 */
13069QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
13070 void (*cb)(void *, struct rsp_stats *))
13071{
13072 QDF_STATUS status = QDF_STATUS_SUCCESS;
13073 tpAniSirGlobal mac;
13074
13075 if (!hal) {
13076 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13077 FL("hal is not valid"));
13078 return QDF_STATUS_E_INVAL;
13079 }
13080 mac = PMAC_STRUCT(hal);
13081
13082 status = sme_acquire_global_lock(&mac->sme);
13083 if (!QDF_IS_STATUS_SUCCESS(status)) {
13084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13085 FL("sme_acquire_global_lock failed!(status=%d)"),
13086 status);
13087 return status;
13088 }
13089
13090 mac->sme.get_arp_stats_cb = cb;
13091 sme_release_global_lock(&mac->sme);
13092 return status;
13093}
13094
13095/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013096 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013097 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013098 * @cb: callback function pointer
13099 *
13100 * This function stores the rssi threshold breached callback function.
13101 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013102 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013103 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013104QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013105 void (*cb)(void *, struct rssi_breach_event *))
13106{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013107 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013108 tpAniSirGlobal mac;
13109
13110 if (!h_hal) {
13111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13112 FL("hHal is not valid"));
13113 return QDF_STATUS_E_INVAL;
13114 }
13115 mac = PMAC_STRUCT(h_hal);
13116
13117 status = sme_acquire_global_lock(&mac->sme);
13118 if (!QDF_IS_STATUS_SUCCESS(status)) {
13119 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13120 FL("sme_acquire_global_lock failed!(status=%d)"),
13121 status);
13122 return status;
13123 }
13124
13125 mac->sme.rssi_threshold_breached_cb = cb;
13126 sme_release_global_lock(&mac->sme);
13127 return status;
13128}
13129
13130/**
13131 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13132 * @hal: global hal handle
13133 *
13134 * This function de-registers the rssi threshold breached callback function.
13135 *
13136 * Return: QDF_STATUS enumeration.
13137 */
13138QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13139{
13140 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013141 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13142
13143 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013144 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013145 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013146 return status;
13147 }
13148
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013149 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013150 sme_release_global_lock(&mac->sme);
13151 return status;
13152}
13153
13154/**
13155 * sme_is_any_session_in_connected_state() - SME wrapper API to
13156 * check if any session is in connected state or not.
13157 *
13158 * @hal: Handle returned by mac open
13159 *
13160 * This function is used to check if any valid sme session is in
13161 * connected state or not.
13162 *
13163 * Return: true if any session is connected, else false.
13164 *
13165 */
13166bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13167{
13168 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013169 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013170 bool ret = false;
13171
13172 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013173 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013174 ret = csr_is_any_session_in_connect_state(mac_ctx);
13175 sme_release_global_lock(&mac_ctx->sme);
13176 }
13177 return ret;
13178}
13179
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013180QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13181 void (*cb)(void *,
13182 struct chip_pwr_save_fail_detected_params *)) {
13183
13184 QDF_STATUS status = QDF_STATUS_SUCCESS;
13185 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13186
13187 status = sme_acquire_global_lock(&mac->sme);
13188 if (status != QDF_STATUS_SUCCESS) {
13189 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13190 return status;
13191 }
13192 mac->sme.chip_power_save_fail_cb = cb;
13193 sme_release_global_lock(&mac->sme);
13194 return status;
13195}
13196
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013197/**
13198 * sme_set_rssi_monitoring() - set rssi monitoring
13199 * @hal: global hal handle
13200 * @input: request message
13201 *
13202 * This function constructs the vos message and fill in message type,
13203 * bodyptr with @input and posts it to WDA queue.
13204 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013205 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013206 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013207QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013208 struct rssi_monitor_req *input)
13209{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013210 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013211 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013212 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013213 struct rssi_monitor_req *req_msg;
13214
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013215 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013216 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013217 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013218 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013219 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013220 }
13221
13222 *req_msg = *input;
13223
13224 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013225 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013226 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013227 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013228 return status;
13229 }
13230
13231 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013232 message.bodyptr = req_msg;
13233 message.type = WMA_SET_RSSI_MONITOR_REQ;
13234 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013235 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013236 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013237 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013238 }
13239 sme_release_global_lock(&mac->sme);
13240
13241 return status;
13242}
13243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013244/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013245 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013246 * @hal: Handle returned by macOpen
13247 * @msg: PCL channel list and length structure
13248 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013249 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013250 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013251 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013252QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013253{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013254 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013255 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013256 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013257 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013258 uint32_t len, i;
13259
Krunal Soni3fa80e22018-01-09 14:16:02 -080013260 if (!mac) {
13261 sme_err("mac is NULL");
13262 return QDF_STATUS_E_FAILURE;
13263 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013264 len = sizeof(*req_msg);
13265
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013266 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013267 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013268 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013269 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013270 }
13271
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013272 for (i = 0; i < msg.pcl_len; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013273 req_msg->pcl_list[i] = msg.pcl_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013274 req_msg->weight_list[i] = msg.weight_list[i];
13275 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013276
13277 req_msg->pcl_len = msg.pcl_len;
13278
13279 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013280 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013281 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013282 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013283 return status;
13284 }
13285
13286 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013287 message.bodyptr = req_msg;
13288 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13289 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013290 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013291 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013292 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013293 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 }
13295 sme_release_global_lock(&mac->sme);
13296
13297 return status;
13298}
13299
13300/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013301 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013302 * @hal: Handle returned by macOpen
13303 * @msg: HW mode structure containing hw mode and callback details
13304 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013305 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013306 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013307 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013308QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013309{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013310 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013311 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013312 tSmeCmd *cmd = NULL;
13313
Krunal Soni3fa80e22018-01-09 14:16:02 -080013314 if (!mac) {
13315 sme_err("mac is NULL");
13316 return QDF_STATUS_E_FAILURE;
13317 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013318 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013319 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013320 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013321 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013322 }
13323
Krunal Soni78618d92017-02-14 21:46:31 -080013324 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013325 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013326 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013327 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013328 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013329 }
13330
13331 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013332 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013333 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13334 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013335 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13336 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013337 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013338 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013339
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013340 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013341 cmd->u.set_hw_mode_cmd.session_id,
13342 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013343 csr_queue_sme_command(mac, cmd, false);
13344
13345 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013346 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013347}
13348
13349/**
13350 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13351 * @hal: Handle returned by macOpen
13352 * @callback: HDD callback to be registered
13353 *
13354 * Registers the HDD callback with SME. This callback will be invoked when
13355 * HW mode transition event is received from the FW
13356 *
13357 * Return: None
13358 */
13359void sme_register_hw_mode_trans_cb(tHalHandle hal,
13360 hw_mode_transition_cb callback)
13361{
13362 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13363
13364 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013365}
13366
13367/**
13368 * sme_nss_update_request() - Send beacon templete update to FW with new
13369 * nss value
13370 * @hal: Handle returned by macOpen
13371 * @vdev_id: the session id
13372 * @new_nss: the new nss value
13373 * @cback: hdd callback
13374 * @next_action: next action to happen at policy mgr after beacon update
13375 *
13376 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013377 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013379QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13380 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13381 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13382 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013383{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013384 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013385 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013386 tSmeCmd *cmd = NULL;
13387
Krunal Soni3fa80e22018-01-09 14:16:02 -080013388 if (!mac) {
13389 sme_err("mac is null");
13390 return status;
13391 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013392 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013393 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013394 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013395 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013396 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013397 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013398 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013399 }
13400 cmd->command = e_sme_command_nss_update;
13401 /* Sessionized modules may require this info */
13402 cmd->sessionId = vdev_id;
13403 cmd->u.nss_update_cmd.new_nss = new_nss;
13404 cmd->u.nss_update_cmd.session_id = vdev_id;
13405 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013406 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013407 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013408 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013409
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013410 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013411 csr_queue_sme_command(mac, cmd, false);
13412 sme_release_global_lock(&mac->sme);
13413 }
13414 return status;
13415}
13416
13417/**
13418 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13419 * @hal: Handle returned by macOpen
13420 * @msg: Structure containing the dual mac config parameters
13421 *
13422 * Queues configuration information to CSR to configure
13423 * WLAN firmware for the dual MAC features
13424 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013425 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013426 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013427QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013428{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013429 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013430 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013431 tSmeCmd *cmd;
13432
Krunal Soni3fa80e22018-01-09 14:16:02 -080013433 if (!mac) {
13434 sme_err("mac is null");
13435 return QDF_STATUS_E_FAILURE;
13436 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013437 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013438 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013439 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013440 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013441 }
13442
Krunal Soni78618d92017-02-14 21:46:31 -080013443 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013444 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013445 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013446 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013447 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013448 }
13449
13450 cmd->command = e_sme_command_set_dual_mac_config;
13451 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13452 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13453 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13454
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013455 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013456 cmd->u.set_dual_mac_cmd.scan_config,
13457 cmd->u.set_dual_mac_cmd.fw_mode_config);
13458 csr_queue_sme_command(mac, cmd, false);
13459
13460 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013461 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013462}
13463
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013464#ifdef FEATURE_LFR_SUBNET_DETECTION
13465/**
13466 * sme_gateway_param_update() - to update gateway parameters with WMA
13467 * @Hal: hal handle
13468 * @gw_params: request parameters from HDD
13469 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013470 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013471 *
13472 * This routine will update gateway parameters to WMA
13473 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013474QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013475 struct gateway_param_update_req *gw_params)
13476{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013477 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013478 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013479 struct gateway_param_update_req *request_buf;
13480
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013481 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013482 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013483 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013484 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013485 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013486 }
13487
13488 *request_buf = *gw_params;
13489
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013490 message.type = WMA_GW_PARAM_UPDATE_REQ;
13491 message.reserved = 0;
13492 message.bodyptr = request_buf;
13493 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013494 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013495 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013496 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013497 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013498 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013499 }
13500
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013501 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013502}
13503#endif /* FEATURE_LFR_SUBNET_DETECTION */
13504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013505/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013506 * sme_soc_set_antenna_mode() - set antenna mode
13507 * @hal: Handle returned by macOpen
13508 * @msg: Structure containing the antenna mode parameters
13509 *
13510 * Send the command to CSR to send
13511 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13512 *
13513 * Return: QDF_STATUS
13514 */
13515QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13516 struct sir_antenna_mode_param *msg)
13517{
13518 QDF_STATUS status = QDF_STATUS_SUCCESS;
13519 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13520 tSmeCmd *cmd;
13521
13522 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013523 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013524 return QDF_STATUS_E_FAILURE;
13525 }
13526
13527 status = sme_acquire_global_lock(&mac->sme);
13528 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013529 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013530 return QDF_STATUS_E_RESOURCES;
13531 }
13532
Krunal Soni78618d92017-02-14 21:46:31 -080013533 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013534 if (!cmd) {
13535 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013536 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013537 return QDF_STATUS_E_NULL_VALUE;
13538 }
13539
13540 cmd->command = e_sme_command_set_antenna_mode;
13541 cmd->u.set_antenna_mode_cmd = *msg;
13542
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013543 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013544 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13545 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13546
13547 csr_queue_sme_command(mac, cmd, false);
13548 sme_release_global_lock(&mac->sme);
13549
13550 return QDF_STATUS_SUCCESS;
13551}
13552
13553/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013554 * sme_set_peer_authorized() - call peer authorized callback
13555 * @peer_addr: peer mac address
13556 * @auth_cb: auth callback
13557 * @vdev_id: vdev id
13558 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013559 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013560 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013561QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013562 sme_peer_authorized_fp auth_cb,
13563 uint32_t vdev_id)
13564{
13565 void *wma_handle;
13566
Anurag Chouhan6d760662016-02-20 16:05:43 +053013567 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013568 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013569 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013570 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013571 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013572 }
13573
13574 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13575 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13576 1, vdev_id);
13577}
13578
13579/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013580 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013581 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013582 * @fcc_constraint: flag to enable/disable the constraint
13583 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013584 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013585 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013586 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013587QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13588 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013590 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013591 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13592
13593 status = sme_acquire_global_lock(&mac_ptr->sme);
13594
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013595 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013596
13597 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13598 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013599 if (scan_pending)
13600 mac_ptr->scan.defer_update_channel_list = true;
13601 else
13602 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013603 }
13604
13605 sme_release_global_lock(&mac_ptr->sme);
13606 }
13607
13608 return status;
13609}
13610/**
13611 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13612 * @hal: Global MAC pointer
13613 *
13614 * Return: NULL.
13615 */
13616void sme_setdef_dot11mode(tHalHandle hal)
13617{
13618 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013620 csr_set_default_dot11_mode(mac_ctx);
13621}
13622
13623/**
13624 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13625 * params
13626 * @hal_handle - The handle returned by macOpen.
13627 * @session_id - Session Identifier
13628 * @notify_id - Identifies 1 of the 4 parameters to be modified
13629 * @val New value of the parameter
13630 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013631 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013632 * Other status means SME failed to update
13633 */
13634
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013635QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013636 uint8_t session_id,
13637 uint32_t notify_id,
13638 int32_t val)
13639{
13640 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013641 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013642 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013643 tpCsrNeighborRoamControlInfo nr_info = NULL;
13644 uint32_t reason = 0;
13645
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013646 if (session_id >= CSR_ROAM_SESSION_MAX) {
13647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13648 FL("Invalid sme session id: %d"), session_id);
13649 return QDF_STATUS_E_INVAL;
13650 }
13651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013652 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013653 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013654 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13655 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13656 switch (notify_id) {
13657 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013658 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013659 "%s: gRoamScanHirssiMaxCount %d => %d",
13660 __func__, nr_config->nhi_rssi_scan_max_count,
13661 val);
13662 nr_config->nhi_rssi_scan_max_count = val;
13663 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13664 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13665 break;
13666
13667 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013668 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669 FL("gRoamScanHiRssiDelta %d => %d"),
13670 nr_config->nhi_rssi_scan_rssi_delta,
13671 val);
13672 nr_config->nhi_rssi_scan_rssi_delta = val;
13673 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13674 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13675 break;
13676
13677 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013678 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013679 FL("gRoamScanHiRssiDelay %d => %d"),
13680 nr_config->nhi_rssi_scan_delay,
13681 val);
13682 nr_config->nhi_rssi_scan_delay = val;
13683 nr_info->cfgParams.hi_rssi_scan_delay = val;
13684 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13685 break;
13686
13687 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013688 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013689 FL("gRoamScanHiRssiUpperBound %d => %d"),
13690 nr_config->nhi_rssi_scan_rssi_ub,
13691 val);
13692 nr_config->nhi_rssi_scan_rssi_ub = val;
13693 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13694 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13695 break;
13696
13697 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013698 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013699 FL("invalid parameter notify_id %d"),
13700 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013701 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013702 break;
13703 }
13704 sme_release_global_lock(&mac_ctx->sme);
13705 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013706 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013707 status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013708 csr_roam_offload_scan(mac_ctx, session_id,
13709 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13710 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013711
13712 return status;
13713}
13714
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013715/**
13716 * sme_update_tgt_services() - update the target services config.
13717 * @hal: HAL pointer.
13718 * @cfg: wma_tgt_services parameters.
13719 *
13720 * update the target services config.
13721 *
13722 * Return: None.
13723 */
13724void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13725{
13726 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13727
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013728 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013729 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013730 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013731 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013732 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013733 mac_ctx->is_fils_roaming_supported =
13734 cfg->is_fils_roaming_supported;
13735 sme_debug("mac_ctx->pmf_offload: %d fils_roam support %d",
13736 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013737
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013738}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013739
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013740/**
13741 * sme_is_session_id_valid() - Check if the session id is valid
13742 * @hal: Pointer to HAL
13743 * @session_id: Session id
13744 *
13745 * Checks if the session id is valid or not
13746 *
13747 * Return: True is the session id is valid, false otherwise
13748 */
13749bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13750{
13751 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013752
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013753 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13755 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013756 return false;
13757 }
13758
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013759 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013760 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013761
13762 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013763}
13764
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013765#ifdef FEATURE_WLAN_TDLS
13766
13767/**
13768 * sme_get_opclass() - determine operating class
13769 * @hal: Pointer to HAL
13770 * @channel: channel id
13771 * @bw_offset: bandwidth offset
13772 * @opclass: pointer to operating class
13773 *
13774 * Function will determine operating class from regdm_get_opclass_from_channel
13775 *
13776 * Return: none
13777 */
13778void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13779 uint8_t *opclass)
13780{
13781 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13782
13783 /* redgm opclass table contains opclass for 40MHz low primary,
13784 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13785 * first we will check if bit for 40MHz is set and if so find
13786 * matching opclass either with low primary or high primary
13787 * (a channel would never be in both) and then search for opclass
13788 * matching 20MHz, else for any BW.
13789 */
13790 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013791 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013792 mac_ctx->scan.countryCodeCurrent,
13793 channel, BW40_LOW_PRIMARY);
13794 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013795 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013796 mac_ctx->scan.countryCodeCurrent,
13797 channel, BW40_HIGH_PRIMARY);
13798 }
13799 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013800 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013801 mac_ctx->scan.countryCodeCurrent,
13802 channel, BW20);
13803 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013804 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013805 mac_ctx->scan.countryCodeCurrent,
13806 channel, BWALL);
13807 }
13808}
13809#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013810
Sandeep Puligillae0875662016-02-12 16:09:21 -080013811/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013812 * sme_set_fw_test() - set fw test
13813 * @fw_test: fw test param
13814 *
13815 * Return: Return QDF_STATUS, otherwise appropriate failure code
13816 */
13817QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13818{
13819 void *wma_handle;
13820
13821 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13822 if (!wma_handle) {
13823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13824 "wma handle is NULL");
13825 return QDF_STATUS_E_FAILURE;
13826 }
13827 wma_process_fw_test_cmd(wma_handle, fw_test);
13828 return QDF_STATUS_SUCCESS;
13829}
13830
13831/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013832 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13833 * @hal: mac handel
13834 * @vdev_id: vdev identifier
13835 *
13836 * Return: Return QDF_STATUS, otherwise appropriate failure code
13837 */
13838QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13839{
13840 void *wma_handle;
13841
13842 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13843 if (!wma_handle) {
13844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13845 "wma handle is NULL");
13846 return QDF_STATUS_E_FAILURE;
13847 }
13848 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13849 return QDF_STATUS_SUCCESS;
13850}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013851
13852/**
13853 * sme_update_mimo_power_save() - Update MIMO power save
13854 * configuration
13855 * @hal: The handle returned by macOpen
13856 * @is_ht_smps_enabled: enable/disable ht smps
13857 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013858 * @send_smps_action: flag to send smps force mode command
13859 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013860 *
13861 * Return: QDF_STATUS if SME update mimo power save
13862 * configuration sucsess else failue status
13863 */
13864QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13865 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013866 uint8_t ht_smps_mode,
13867 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013868{
13869 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013870
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013871 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013872 is_ht_smps_enabled, ht_smps_mode,
13873 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013874 mac_ctx->roam.configParam.enableHtSmps =
13875 is_ht_smps_enabled;
13876 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013877 mac_ctx->roam.configParam.send_smps_action =
13878 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013879
13880 return QDF_STATUS_SUCCESS;
13881}
13882
13883/**
13884 * sme_is_sta_smps_allowed() - check if the supported nss for
13885 * the session is greater than 1x1 to enable sta SMPS
13886 * @hal: The handle returned by macOpen
13887 * @session_id: session id
13888 *
13889 * Return: bool returns true if supported nss is greater than
13890 * 1x1 else false
13891 */
13892bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13893{
13894 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013895 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013896
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013897 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13898 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013899 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013900 return false;
13901 }
13902
13903 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013904 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013905 return false;
13906 }
13907
13908 return (csr_session->supported_nss_1x1 == true) ? false : true;
13909}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013910
13911/**
13912 * sme_add_beacon_filter() - set the beacon filter configuration
13913 * @hal: The handle returned by macOpen
13914 * @session_id: session id
13915 * @ie_map: bitwise array of IEs
13916 *
13917 * Return: Return QDF_STATUS, otherwise appropriate failure code
13918 */
13919QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13920 uint32_t session_id,
13921 uint32_t *ie_map)
13922{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013923 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013924 QDF_STATUS qdf_status;
13925 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13926 struct beacon_filter_param *filter_param;
13927
13928 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013929 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013930 return QDF_STATUS_E_FAILURE;
13931 }
13932
13933 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13934 if (NULL == filter_param) {
13935 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13936 "%s: fail to alloc filter_param", __func__);
13937 return QDF_STATUS_E_FAILURE;
13938 }
13939
13940 filter_param->vdev_id = session_id;
13941
13942 qdf_mem_copy(filter_param->ie_map, ie_map,
13943 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
13944
13945 message.type = WMA_ADD_BCN_FILTER_CMDID;
13946 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013947 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013948 &message);
13949 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13950 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13951 "%s: Not able to post msg to WDA!",
13952 __func__);
13953
13954 qdf_mem_free(filter_param);
13955 }
13956 return qdf_status;
13957}
13958
13959/**
13960 * sme_remove_beacon_filter() - set the beacon filter configuration
13961 * @hal: The handle returned by macOpen
13962 * @session_id: session id
13963 *
13964 * Return: Return QDF_STATUS, otherwise appropriate failure code
13965 */
13966QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
13967{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013968 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013969 QDF_STATUS qdf_status;
13970 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13971 struct beacon_filter_param *filter_param;
13972
13973 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013974 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013975 return QDF_STATUS_E_FAILURE;
13976 }
13977
13978 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13979 if (NULL == filter_param) {
13980 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13981 "%s: fail to alloc filter_param", __func__);
13982 return QDF_STATUS_E_FAILURE;
13983 }
13984
13985 filter_param->vdev_id = session_id;
13986
13987 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
13988 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013989 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013990 &message);
13991 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13992 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13993 "%s: Not able to post msg to WDA!",
13994 __func__);
13995
13996 qdf_mem_free(filter_param);
13997 }
13998 return qdf_status;
13999}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014000
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014001/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014002 * sme_send_disassoc_req_frame - send disassoc req
14003 * @hal: handler to hal
14004 * @session_id: session id
14005 * @peer_mac: peer mac address
14006 * @reason: reason for disassociation
14007 * wait_for_ack: wait for acknowledgment
14008 *
14009 * function to send disassoc request to lim
14010 *
14011 * return: none
14012 */
14013void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14014 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14015{
14016 struct sme_send_disassoc_frm_req *msg;
14017 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14018 A_UINT8 *buf;
14019 A_UINT16 tmp;
14020
14021 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14022
14023 if (NULL == msg)
14024 qdf_status = QDF_STATUS_E_FAILURE;
14025 else
14026 qdf_status = QDF_STATUS_SUCCESS;
14027
14028 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14029 return;
14030
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014031 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14032
14033 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14034
14035 buf = &msg->session_id;
14036
14037 /* session id */
14038 *buf = (A_UINT8) session_id;
14039 buf += sizeof(A_UINT8);
14040
14041 /* transaction id */
14042 *buf = 0;
14043 *(buf + 1) = 0;
14044 buf += sizeof(A_UINT16);
14045
14046 /* Set the peer MAC address before sending the message to LIM */
14047 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14048
14049 buf += QDF_MAC_ADDR_SIZE;
14050
14051 /* reasoncode */
14052 tmp = (uint16_t) reason;
14053 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14054 buf += sizeof(uint16_t);
14055
14056 *buf = wait_for_ack;
14057 buf += sizeof(uint8_t);
14058
Rajeev Kumard138ac52017-01-30 18:38:37 -080014059 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014060
14061 if (qdf_status != QDF_STATUS_SUCCESS)
14062 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14063 FL("cds_send_mb_message Failed"));
14064}
14065
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014066QDF_STATUS sme_get_bpf_offload_capabilities(tHalHandle hal,
14067 bpf_get_offload_cb callback,
14068 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014069{
14070 QDF_STATUS status = QDF_STATUS_SUCCESS;
14071 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014072 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014073
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014074 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014075
14076 status = sme_acquire_global_lock(&mac_ctx->sme);
14077 if (QDF_STATUS_SUCCESS == status) {
14078 /* Serialize the req through MC thread */
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014079 mac_ctx->sme.bpf_get_offload_cb = callback;
14080 mac_ctx->sme.bpf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014081 cds_msg.bodyptr = NULL;
14082 cds_msg.type = WDA_BPF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014083 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014084 if (!QDF_IS_STATUS_SUCCESS(status)) {
14085 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14086 FL("Post bpf get offload msg fail"));
14087 status = QDF_STATUS_E_FAILURE;
14088 }
14089 sme_release_global_lock(&mac_ctx->sme);
14090 } else {
14091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14092 FL("sme_acquire_global_lock error"));
14093 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014094 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014095 return status;
14096}
14097
14098
14099/**
14100 * sme_set_bpf_instructions() - Set BPF bpf filter instructions.
14101 * @hal: HAL handle
14102 * @bpf_set_offload: struct to set bpf filter instructions.
14103 *
14104 * Return: QDF_STATUS enumeration.
14105 */
14106QDF_STATUS sme_set_bpf_instructions(tHalHandle hal,
14107 struct sir_bpf_set_offload *req)
14108{
14109 QDF_STATUS status = QDF_STATUS_SUCCESS;
14110 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014111 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014112 struct sir_bpf_set_offload *set_offload;
14113
Arun Khandavallica198b52016-04-26 20:53:35 +053014114 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14115 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014116
14117 if (NULL == set_offload) {
14118 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14119 FL("Failed to alloc set_offload"));
14120 return QDF_STATUS_E_NOMEM;
14121 }
14122
14123 set_offload->session_id = req->session_id;
14124 set_offload->filter_id = req->filter_id;
14125 set_offload->current_offset = req->current_offset;
14126 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014127 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014128 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014129 set_offload->program = ((uint8_t *)set_offload) +
14130 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014131 qdf_mem_copy(set_offload->program, req->program,
14132 set_offload->current_length);
14133 }
14134 status = sme_acquire_global_lock(&mac_ctx->sme);
14135 if (QDF_STATUS_SUCCESS == status) {
14136 /* Serialize the req through MC thread */
14137 cds_msg.bodyptr = set_offload;
14138 cds_msg.type = WDA_BPF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014139 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014140
14141 if (!QDF_IS_STATUS_SUCCESS(status)) {
14142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14143 FL("Post BPF set offload msg fail"));
14144 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014145 qdf_mem_free(set_offload);
14146 }
14147 sme_release_global_lock(&mac_ctx->sme);
14148 } else {
14149 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14150 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014151 qdf_mem_free(set_offload);
14152 }
14153 return status;
14154}
14155
14156/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014157 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14158 * @hal: hal pointer
14159 *
14160 * Return: wni dot11 mode.
14161 */
14162uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14163{
14164 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14165
14166 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14167 mac_ctx->roam.configParam.uCfgDot11Mode);
14168}
14169
14170/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014171 * sme_create_mon_session() - post message to create PE session for monitormode
14172 * operation
14173 * @hal_handle: Handle to the HAL
14174 * @bssid: pointer to bssid
14175 *
14176 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14177 */
14178QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14179{
14180 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14181 struct sir_create_session *msg;
14182
14183 msg = qdf_mem_malloc(sizeof(*msg));
14184 if (NULL != msg) {
14185 msg->type = eWNI_SME_MON_INIT_SESSION;
14186 msg->msg_len = sizeof(*msg);
14187 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014188 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014189 }
14190 return status;
14191}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014192
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014193void sme_set_chan_info_callback(tHalHandle hal_handle,
14194 void (*callback)(struct scan_chan_info *chan_info))
14195{
14196 tpAniSirGlobal mac;
14197
14198 if (hal_handle == NULL) {
14199 QDF_ASSERT(0);
14200 return;
14201 }
14202 mac = PMAC_STRUCT(hal_handle);
14203 mac->chan_info_cb = callback;
14204}
14205
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014206/**
14207 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14208 * @hal: The handle returned by macOpen
14209 * @params: adaptive_dwelltime_params config
14210 *
14211 * Return: QDF_STATUS if adaptive dwell time update
14212 * configuration sucsess else failure status
14213 */
14214QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14215 struct adaptive_dwelltime_params *params)
14216{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014217 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014218 QDF_STATUS status;
14219 struct adaptive_dwelltime_params *dwelltime_params;
14220
14221 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14222 if (NULL == dwelltime_params) {
14223 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14224 "%s: fail to alloc dwelltime_params", __func__);
14225 return QDF_STATUS_E_NOMEM;
14226 }
14227
14228 dwelltime_params->is_enabled = params->is_enabled;
14229 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14230 dwelltime_params->lpf_weight = params->lpf_weight;
14231 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14232 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14233
14234 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14235 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014237 if (!QDF_IS_STATUS_SUCCESS(status)) {
14238 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14239 "%s: Not able to post msg to WMA!", __func__);
14240
14241 qdf_mem_free(dwelltime_params);
14242 }
14243 return status;
14244}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014245
14246/**
14247 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14248 * @hal: Pointer to HAL
14249 * @vdev_id: vdev_id for which IE is targeted
14250 *
14251 * Return: None
14252 */
14253void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14254{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014255 struct sir_set_vdev_ies_per_band *p_msg;
14256 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14257
14258 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14259 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014260 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014261 return;
14262 }
14263
14264 p_msg->vdev_id = vdev_id;
14265 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14266 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014267 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014268 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014269 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014270 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014271 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014272}
14273
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014274/**
14275 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14276 * @hal: Pointer to HAL
14277 * @enable2x2: 1x1 or 2x2 mode.
14278 *
14279 * Sends the set pdev IE req with Nss value.
14280 *
14281 * Return: None
14282 */
14283void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14284{
14285 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14286 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14287 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14288
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014289 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14290 eCSR_CFG_DOT11_MODE_AUTO) ||
14291 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14292 eCSR_CFG_DOT11_MODE_11N) ||
14293 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14294 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14295 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14296 eCSR_CFG_DOT11_MODE_11AC) ||
14297 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14298 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14299 return;
14300
14301 status = sme_acquire_global_lock(&mac_ctx->sme);
14302 if (QDF_STATUS_SUCCESS == status) {
14303 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14304 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014305 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014306 sme_release_global_lock(&mac_ctx->sme);
14307 return;
14308 }
14309
14310 ht_vht_cfg->pdev_id = 0;
14311 if (enable2x2)
14312 ht_vht_cfg->nss = 2;
14313 else
14314 ht_vht_cfg->nss = 1;
14315 ht_vht_cfg->dot11mode =
14316 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14317 mac_ctx->roam.configParam.uCfgDot11Mode);
14318
14319 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14320 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014321 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14322 ht_vht_cfg->nss,
14323 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014324 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014325 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014326 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014327
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014328 sme_release_global_lock(&mac_ctx->sme);
14329 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014330}
14331
14332/**
14333 * sme_update_vdev_type_nss() - sets the nss per vdev type
14334 * @hal: Pointer to HAL
14335 * @max_supp_nss: max_supported Nss
14336 * @band: 5G or 2.4G band
14337 *
14338 * Sets the per band Nss for each vdev type based on INI and configured
14339 * chain mask value.
14340 *
14341 * Return: None
14342 */
14343void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014344 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014345{
14346 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14347 struct vdev_type_nss *vdev_nss;
14348
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014349 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014350 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14351 else
14352 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14353
14354 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14355 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14356 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14357 CFG_P2P_GO_NSS(vdev_type_nss));
14358 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14359 CFG_P2P_CLI_NSS(vdev_type_nss));
14360 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14361 CFG_P2P_DEV_NSS(vdev_type_nss));
14362 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14363 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14364 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14365
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014366 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 -070014367 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14368 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14369 vdev_nss->tdls, vdev_nss->ocb);
14370}
Peng Xu8fdaa492016-06-22 10:20:47 -070014371
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014372#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14373#define MAX_BSS_COLOR_VAL 63
14374#define MIN_BSS_COLOR_VAL 1
14375
14376QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14377 uint8_t bss_color)
14378
14379{
14380 struct sir_set_he_bss_color *bss_color_msg;
14381 uint8_t len;
14382
14383 if (!hal) {
14384 sme_err("Invalid hal pointer");
14385 return QDF_STATUS_E_FAULT;
14386 }
14387
14388 sme_debug("Set HE bss_color %d", bss_color);
14389
14390 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14391 sme_debug("Invalid HE bss_color %d", bss_color);
14392 return QDF_STATUS_E_INVAL;
14393 }
14394 len = sizeof(*bss_color_msg);
14395 bss_color_msg = qdf_mem_malloc(len);
14396 if (!bss_color_msg) {
14397 sme_err("mem alloc failed");
14398 return QDF_STATUS_E_NOMEM;
14399 }
14400 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14401 bss_color_msg->length = len;
14402 bss_color_msg->session_id = session_id;
14403 bss_color_msg->bss_color = bss_color;
14404 return umac_send_mb_message_to_mac(bss_color_msg);
14405}
14406#endif
14407
Peng Xu8fdaa492016-06-22 10:20:47 -070014408/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014409 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14410 * @hal: Pointer to HAL
14411 * @hw_dbs_capable: HW DBS capability
14412 *
14413 * Sets HW DBS capability based on INI and fw capability.
14414 *
14415 * Return: None
14416 */
14417void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14418{
14419 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014420
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014421 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14422}
14423
14424/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014425 * sme_register_p2p_lo_event() - Register for the p2p lo event
14426 * @hHal: reference to the HAL
14427 * @context: the context of the call
14428 * @callback: the callback to hdd
14429 *
14430 * This function registers the callback function for P2P listen
14431 * offload stop event.
14432 *
14433 * Return: none
14434 */
14435void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14436 p2p_lo_callback callback)
14437{
14438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14439 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14440
14441 status = sme_acquire_global_lock(&pMac->sme);
14442 pMac->sme.p2p_lo_event_callback = callback;
14443 pMac->sme.p2p_lo_event_context = context;
14444 sme_release_global_lock(&pMac->sme);
14445}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014446
14447/**
14448 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14449 * @hal: The handle returned by macOpen
14450 * @session_id: session id
14451 * @dbg_args: args for mac pwr debug command
14452 * Return: Return QDF_STATUS, otherwise appropriate failure code
14453 */
14454QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14455 struct sir_mac_pwr_dbg_cmd*
14456 dbg_args)
14457{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014458 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014459 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14460 struct sir_mac_pwr_dbg_cmd *req;
14461 int i;
14462
14463 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014464 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014465 return QDF_STATUS_E_FAILURE;
14466 }
14467
14468 req = qdf_mem_malloc(sizeof(*req));
14469 if (NULL == req) {
14470 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14471 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14472 return QDF_STATUS_E_FAILURE;
14473 }
14474 req->module_id = dbg_args->module_id;
14475 req->pdev_id = dbg_args->pdev_id;
14476 req->num_args = dbg_args->num_args;
14477 for (i = 0; i < req->num_args; i++)
14478 req->args[i] = dbg_args->args[i];
14479
14480 message.type = SIR_HAL_POWER_DBG_CMD;
14481 message.bodyptr = req;
14482
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014483 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014484 (QDF_MODULE_ID_WMA, &message))) {
14485 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14486 "%s: Not able to post msg to WDA!",
14487 __func__);
14488 qdf_mem_free(req);
14489 }
14490 return QDF_STATUS_SUCCESS;
14491}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014492/**
14493 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014494 * @dev_mode: connection type.
14495 * @nss2g: Pointer to the 2G Nss parameter.
14496 * @nss5g: Pointer to the 5G Nss parameter.
14497 *
14498 * Fills the 2G and 5G Nss values based on connection type.
14499 *
14500 * Return: None
14501 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014502void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14503 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014504{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014505 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14506
14507 if (NULL == mac_ctx) {
14508 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14509 FL("Invalid MAC context"));
14510 return;
14511 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014512 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14513}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014514
14515/**
14516 * sme_update_sta_roam_policy() - update sta roam policy for
14517 * unsafe and DFS channels.
14518 * @hal_handle: hal handle for getting global mac struct
14519 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14520 * skipped or not
14521 * @skip_unsafe_channels: Param to tell if driver needs to
14522 * skip unsafe channels or not.
14523 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014524 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014525 *
14526 * sme_update_sta_roam_policy update sta rome policies to csr
14527 * this function will call csrUpdateChannelList as well
14528 * to include/exclude DFS channels and unsafe channels.
14529 *
14530 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14531 */
14532QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14533 enum sta_roam_policy_dfs_mode dfs_mode,
14534 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014535 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014536{
14537 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14538 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014539 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014540
14541 if (!mac_ctx) {
14542 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14543 "%s: mac_ctx is null", __func__);
14544 return QDF_STATUS_E_FAILURE;
14545 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014546
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014547 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14548 if (!sme_config) {
14549 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14550 FL("failed to allocate memory for sme_config"));
14551 return QDF_STATUS_E_FAILURE;
14552 }
14553 qdf_mem_zero(sme_config, sizeof(*sme_config));
14554 sme_get_config_param(hal_handle, sme_config);
14555
14556 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014557 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014558 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014559 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014560 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014561 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014562
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014563 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014564
14565 status = csr_update_channel_list(mac_ctx);
14566 if (QDF_STATUS_SUCCESS != status) {
14567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14568 FL("failed to update the supported channel list"));
14569 }
14570 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled)
14571 csr_roam_offload_scan(mac_ctx, session_id,
14572 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14573 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014574
14575 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014576 return status;
14577}
14578
14579/**
14580 * sme_enable_disable_chanavoidind_event - configure ca event ind
14581 * @hal: handler to hal
14582 * @set_value: enable/disable
14583 *
14584 * function to enable/disable chan avoidance indication
14585 *
14586 * Return: QDF_STATUS
14587 */
14588QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14589 uint8_t set_value)
14590{
14591 QDF_STATUS status;
14592 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014593 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014594
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014595 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014596 status = sme_acquire_global_lock(&mac_ctx->sme);
14597 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014598 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014599 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14600 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014601 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014602 sme_release_global_lock(&mac_ctx->sme);
14603 return status;
14604 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014605 return status;
14606}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014607
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014608/*
14609 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14610 * @hal: reference to the HAL
14611 * @session_id: current session ID
14612 * @ie_data: Pointer to Scan IE data
14613 * @ie_len: Length of @ie_data
14614 *
14615 * Return: QDF_STATUS
14616 */
14617QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14618 uint8_t *ie_data, uint16_t ie_len)
14619{
14620 QDF_STATUS status;
14621 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14622 struct hdd_default_scan_ie *set_ie_params;
14623
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014624 if (!ie_data)
14625 return QDF_STATUS_E_INVAL;
14626
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014627 status = sme_acquire_global_lock(&mac_ctx->sme);
14628 if (QDF_IS_STATUS_SUCCESS(status)) {
14629 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14630 if (!set_ie_params)
14631 status = QDF_STATUS_E_NOMEM;
14632 else {
14633 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14634 set_ie_params->length = sizeof(*set_ie_params);
14635 set_ie_params->session_id = session_id;
14636 set_ie_params->ie_len = ie_len;
14637 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014638 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014639 }
14640 sme_release_global_lock(&mac_ctx->sme);
14641 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014642 return status;
14643}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014644
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014645QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14646 struct sar_limit_cmd_params *sar_limit_cmd)
14647{
14648 void *wma_handle;
14649
14650 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14651 if (!wma_handle) {
14652 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14653 "wma handle is NULL");
14654 return QDF_STATUS_E_FAILURE;
14655 }
14656
14657 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14658}
14659
Jeff Johnson6136fb92017-03-30 15:21:49 -070014660#ifdef WLAN_FEATURE_FIPS
14661QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14662 wma_fips_cb callback, void *context)
14663{
14664 void *wma_handle;
14665
14666 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14667 if (!wma_handle) {
14668 sme_err("wma handle is NULL");
14669 return QDF_STATUS_E_FAILURE;
14670 }
14671
14672 return wma_fips_request(wma_handle, param, callback, context);
14673}
14674#endif
14675
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014676QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14677{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014678 void *wma_handle;
14679
14680 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14681 if (!wma_handle) {
14682 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14683 "wma_handle is NULL");
14684 return QDF_STATUS_E_FAILURE;
14685 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014686 if (QDF_STATUS_SUCCESS !=
14687 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14688 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14689 "%s: Failed to set cts2self for p2p GO to firmware",
14690 __func__);
14691 return QDF_STATUS_E_FAILURE;
14692 }
14693 return QDF_STATUS_SUCCESS;
14694}
Yingying Tang95409972016-10-20 15:16:15 +080014695
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014696/**
14697 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14698 * @hal: Handle returned by mac_open
14699 * @session_id: Session ID on which tx fail count needs to be updated to FW
14700 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14701 *
14702 * This function is used to set tx fail count threshold to firmware.
14703 * firmware will issue disocnnect with peer device once this threshold is
14704 * reached.
14705 *
14706 * Return: Return QDF_STATUS, otherwise appropriate failure code
14707 */
14708QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14709 uint8_t session_id, uint32_t tx_fail_count)
14710{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014711 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14712 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014713 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014714
14715 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14716 if (NULL == tx_fail_cnt) {
14717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14718 "%s: fail to alloc filter_param", __func__);
14719 return QDF_STATUS_E_FAILURE;
14720 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014721 sme_debug("session_id: %d tx_fail_count: %d",
14722 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014723 tx_fail_cnt->session_id = session_id;
14724 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14725
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014726 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014727 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14728 msg.reserved = 0;
14729 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014730 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014731
14732 if (!QDF_IS_STATUS_SUCCESS(status)) {
14733 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014734 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014735 qdf_mem_free(tx_fail_cnt);
14736 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014737 return status;
14738}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014739
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014740QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14741 void (*cb)(void *, struct sir_lost_link_info *))
14742{
14743 QDF_STATUS status = QDF_STATUS_SUCCESS;
14744 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14745
14746 status = sme_acquire_global_lock(&mac->sme);
14747 if (QDF_IS_STATUS_SUCCESS(status)) {
14748 mac->sme.lost_link_info_cb = cb;
14749 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014750 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014751 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014752 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014753
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014754 return status;
14755}
Yingying Tang95409972016-10-20 15:16:15 +080014756
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014757#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014758bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014759{
14760 return roam_info->isESEAssoc;
14761}
Manjeet Singh2f785062017-03-08 18:14:18 +053014762#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014763/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014764 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014765 * params from ini.
14766 * @hal_handle: Handle returned by mac_open
14767 * @5g_pref_params: pref params from ini.
14768 *
14769 * Returns: None
14770 */
14771void sme_set_5g_band_pref(tHalHandle hal_handle,
14772 struct sme_5g_band_pref_params *pref_params)
14773{
14774
14775 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14776 struct roam_ext_params *roam_params;
14777 QDF_STATUS status = QDF_STATUS_SUCCESS;
14778
14779 if (!pref_params) {
14780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14781 "Invalid 5G pref params!");
14782 return;
14783 }
14784 status = sme_acquire_global_lock(&mac_ctx->sme);
14785 if (QDF_STATUS_SUCCESS == status) {
14786 roam_params = &mac_ctx->roam.configParam.roam_params;
14787 roam_params->raise_rssi_thresh_5g =
14788 pref_params->rssi_boost_threshold_5g;
14789 roam_params->raise_factor_5g =
14790 pref_params->rssi_boost_factor_5g;
14791 roam_params->max_raise_rssi_5g =
14792 pref_params->max_rssi_boost_5g;
14793 roam_params->drop_rssi_thresh_5g =
14794 pref_params->rssi_penalize_threshold_5g;
14795 roam_params->drop_factor_5g =
14796 pref_params->rssi_penalize_factor_5g;
14797 roam_params->max_drop_rssi_5g =
14798 pref_params->max_rssi_penalize_5g;
14799
14800 sme_release_global_lock(&mac_ctx->sme);
14801 } else
14802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14803 "Unable to acquire global sme lock");
14804}
14805
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014806
14807bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14808{
14809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014810
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014811 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14812}
Yingying Tang95409972016-10-20 15:16:15 +080014813
14814#ifdef WLAN_FEATURE_WOW_PULSE
14815/**
14816 * sme_set_wow_pulse() - set wow pulse info
14817 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14818 *
14819 * Return: QDF_STATUS
14820 */
14821QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14822{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014823 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014824 QDF_STATUS status;
14825 struct wow_pulse_mode *wow_pulse_set_cmd;
14826
14827 if (!wow_pulse_set_info) {
14828 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14829 "%s: invalid wow_pulse_set_info pointer", __func__);
14830 return QDF_STATUS_E_FAILURE;
14831 }
14832
14833 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14834 if (NULL == wow_pulse_set_cmd) {
14835 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14836 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14837 return QDF_STATUS_E_NOMEM;
14838 }
14839
14840 *wow_pulse_set_cmd = *wow_pulse_set_info;
14841
14842 message.type = WMA_SET_WOW_PULSE_CMD;
14843 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014844 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014845 &message);
14846 if (!QDF_IS_STATUS_SUCCESS(status)) {
14847 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14848 "%s: Not able to post msg to WDA!",
14849 __func__);
14850 qdf_mem_free(wow_pulse_set_cmd);
14851 status = QDF_STATUS_E_FAILURE;
14852 }
14853
14854 return status;
14855}
14856#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014857
14858/**
14859 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14860 * different fields and IEs from bss descriptor.
14861 * @frame_buf: frame buffer to populate
14862 * @bss_descp: bss descriptor
14863 * @bssid: bssid of the beacon frame to populate
14864 * @ie_len: length of IE fields
14865 *
14866 * Return: None
14867 */
14868static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14869 tSirBssDescription *bss_descp,
14870 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014871 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014872{
14873 tDot11fBeacon1 *bcn_fixed;
14874 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14875
14876 /* populate mac header first to indicate beacon */
14877 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14878 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14879 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14880 qdf_mem_copy((uint8_t *) mac_hdr->da,
14881 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14882 sizeof(struct qdf_mac_addr));
14883 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
14884 sizeof(struct qdf_mac_addr));
14885 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
14886 sizeof(struct qdf_mac_addr));
14887
14888 /* now populate fixed params */
14889 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
14890 /* populate timestamp */
14891 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
14892 sizeof(bss_descp->timeStamp));
14893 /* populate beacon interval */
14894 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
14895 /* populate capability */
14896 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
14897 sizeof(bss_descp->capabilityInfo));
14898
14899 /* copy IEs now */
14900 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
14901 + SIR_MAC_B_PR_SSID_OFFSET,
14902 &bss_descp->ieFields, ie_len);
14903}
14904
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014905QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
14906 tCsrRoamProfile *profile,
14907 const uint8_t *bssid,
14908 int8_t *rssi, int8_t *snr)
14909{
14910 tSirBssDescription *bss_descp;
14911 tCsrScanResultFilter *scan_filter;
14912 struct scan_result_list *bss_list;
14913 tScanResultHandle result_handle = NULL;
14914 QDF_STATUS status = QDF_STATUS_SUCCESS;
14915 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14916
14917 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14918 if (NULL == scan_filter) {
14919 sme_err("memory allocation failed");
14920 status = QDF_STATUS_E_NOMEM;
14921 goto free_scan_flter;
14922 }
14923
14924 status = csr_roam_prepare_filter_from_profile(mac_ctx,
14925 profile, scan_filter);
14926 if (QDF_STATUS_SUCCESS != status) {
14927 sme_err("prepare_filter failed");
14928 goto free_scan_flter;
14929 }
14930
14931 /* update filter to get scan result with just target BSSID */
14932 if (NULL == scan_filter->BSSIDs.bssid) {
14933 scan_filter->BSSIDs.bssid =
14934 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
14935 if (scan_filter->BSSIDs.bssid == NULL) {
14936 sme_err("malloc failed");
14937 status = QDF_STATUS_E_NOMEM;
14938 goto free_scan_flter;
14939 }
14940 }
14941
14942 scan_filter->BSSIDs.numOfBSSIDs = 1;
14943 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
14944 bssid, sizeof(struct qdf_mac_addr));
14945
14946 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
14947 if (QDF_STATUS_SUCCESS != status) {
14948 sme_err("parse_scan_result failed");
14949 goto free_scan_flter;
14950 }
14951
14952 bss_list = (struct scan_result_list *)result_handle;
14953 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
14954 if (!bss_descp) {
14955 sme_err("unable to fetch bss descriptor");
14956 status = QDF_STATUS_E_FAULT;
14957 goto free_scan_flter;
14958 }
14959
14960 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
14961 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
14962
14963 if (rssi)
14964 *rssi = bss_descp->rssi;
14965 if (snr)
14966 *snr = bss_descp->sinr;
14967
14968free_scan_flter:
14969 /* free scan filter and exit */
14970 if (scan_filter) {
14971 csr_free_scan_filter(mac_ctx, scan_filter);
14972 qdf_mem_free(scan_filter);
14973 }
14974
14975 if (result_handle)
14976 csr_scan_result_purge(mac_ctx, result_handle);
14977
14978 return status;
14979}
14980
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014981QDF_STATUS sme_get_beacon_frm(tHalHandle hal, tCsrRoamProfile *profile,
14982 const tSirMacAddr bssid,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053014983 uint8_t **frame_buf, uint32_t *frame_len,
14984 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014985{
14986 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080014987 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014988 tCsrScanResultFilter *scan_filter;
14989 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14990 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053014991 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014992 uint32_t ie_len;
14993
14994 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14995 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014996 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014997 status = QDF_STATUS_E_NOMEM;
14998 goto free_scan_flter;
14999 }
15000 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15001 profile, scan_filter);
15002 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015003 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015004 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015005 goto free_scan_flter;
15006 }
15007
15008 /* update filter to get scan result with just target BSSID */
15009 if (NULL == scan_filter->BSSIDs.bssid) {
15010 scan_filter->BSSIDs.bssid =
15011 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15012 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015013 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015014 status = QDF_STATUS_E_NOMEM;
15015 goto free_scan_flter;
15016 }
15017 }
15018 scan_filter->BSSIDs.numOfBSSIDs = 1;
15019 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15020 bssid, sizeof(struct qdf_mac_addr));
15021
15022 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15023 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015024 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015025 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015026 goto free_scan_flter;
15027 }
15028
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015029 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015030 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015031 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015032 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015033 status = QDF_STATUS_E_FAULT;
15034 goto free_scan_flter;
15035 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015036
Naveen Rawat81f058c2017-06-02 16:02:39 -070015037 /**
15038 * Length of BSS descriptor is without length of
15039 * length itself and length of pointer that holds ieFields.
15040 *
15041 * tSirBssDescription
15042 * +--------+---------------------------------+---------------+
15043 * | length | other fields | pointer to IEs|
15044 * +--------+---------------------------------+---------------+
15045 * ^
15046 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015047 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015048 ie_len = bss_descp->length + sizeof(bss_descp->length)
15049 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015050 sme_debug("found bss_descriptor ie_len: %d channel %d",
15051 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015052
15053 /* include mac header and fixed params along with IEs in frame */
15054 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15055 *frame_buf = qdf_mem_malloc(*frame_len);
15056 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015057 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015058 status = QDF_STATUS_E_NOMEM;
15059 goto free_scan_flter;
15060 }
15061
15062 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15063
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015064 if (!*channel)
15065 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015066free_scan_flter:
15067 /* free scan filter and exit */
15068 if (scan_filter) {
15069 csr_free_scan_filter(mac_ctx, scan_filter);
15070 qdf_mem_free(scan_filter);
15071 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015072 if (result_handle)
15073 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015074
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015075 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015076}
15077
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015078#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015079QDF_STATUS sme_fast_reassoc(tHalHandle hal, tCsrRoamProfile *profile,
15080 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015081 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015082{
15083 QDF_STATUS status;
15084 struct wma_roam_invoke_cmd *fastreassoc;
15085 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015086 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015087
15088 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15089 if (NULL == fastreassoc) {
15090 sme_err("qdf_mem_malloc failed for fastreassoc");
15091 return QDF_STATUS_E_NOMEM;
15092 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015093 /* if both are same then set the flag */
15094 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15095 fastreassoc->is_same_bssid = true;
15096 sme_debug("bssid same, bssid[%pM]", bssid);
15097 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015098 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015099 fastreassoc->bssid[0] = bssid[0];
15100 fastreassoc->bssid[1] = bssid[1];
15101 fastreassoc->bssid[2] = bssid[2];
15102 fastreassoc->bssid[3] = bssid[3];
15103 fastreassoc->bssid[4] = bssid[4];
15104 fastreassoc->bssid[5] = bssid[5];
15105
15106 status = sme_get_beacon_frm(hal, profile, bssid,
15107 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015108 &fastreassoc->frame_len,
15109 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015110
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015111 if (!channel) {
15112 sme_err("channel retrieval from BSS desc fails!");
15113 qdf_mem_free(fastreassoc);
15114 return QDF_STATUS_E_FAULT;
15115 }
15116
15117 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015118 if (QDF_STATUS_SUCCESS != status) {
15119 sme_warn("sme_get_beacon_frm failed");
15120 fastreassoc->frame_buf = NULL;
15121 fastreassoc->frame_len = 0;
15122 }
15123
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015124 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15125 connectedProfile.AuthType)) {
15126 sme_debug("Beacon is not required for ESE");
15127 if (fastreassoc->frame_len) {
15128 qdf_mem_free(fastreassoc->frame_buf);
15129 fastreassoc->frame_buf = NULL;
15130 fastreassoc->frame_len = 0;
15131 }
15132 }
15133
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015134 msg.type = SIR_HAL_ROAM_INVOKE;
15135 msg.reserved = 0;
15136 msg.bodyptr = fastreassoc;
15137 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15138 if (QDF_STATUS_SUCCESS != status) {
15139 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15140 qdf_mem_free(fastreassoc);
15141 }
15142
15143 return status;
15144}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015145#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015146
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015147QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15148 tPmkidCacheInfo *pmk_cache_info,
15149 bool is_add)
15150{
15151 struct wmi_unified_pmk_cache *pmk_cache;
15152 struct scheduler_msg msg;
15153
15154 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15155 if (!pmk_cache) {
15156 sme_err("Memory allocation failure");
15157 return QDF_STATUS_E_NOMEM;
15158 }
15159
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015160 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15161
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015162 pmk_cache->session_id = session_id;
15163
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015164 if (!pmk_cache_info)
15165 goto send_flush_cmd;
15166
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015167 if (!pmk_cache_info->ssid_len) {
15168 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15169 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15170 &pmk_cache->bssid);
15171 } else {
15172 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15173 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15174 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15175 pmk_cache_info->ssid,
15176 pmk_cache->ssid.length);
15177 }
15178 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15179 pmk_cache_info->cache_id[1]);
15180
15181 if (is_add)
15182 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15183 else
15184 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15185
15186 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15187 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15188 CSR_RSN_PMKID_SIZE);
15189
15190 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15191 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15192 pmk_cache->pmk_len);
15193
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015194send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015195 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15196 msg.reserved = 0;
15197 msg.bodyptr = pmk_cache;
15198 if (QDF_STATUS_SUCCESS !=
15199 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15200 sme_err("Not able to post message to WDA");
15201 qdf_mem_free(pmk_cache);
15202 return QDF_STATUS_E_FAILURE;
15203 }
15204
15205 return QDF_STATUS_SUCCESS;
15206}
15207
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015208/* ARP DEBUG STATS */
15209
15210/**
15211 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15212 * @hal: handle to hal
15213 * @set_stats_param: pointer to set stats param
15214 *
15215 * Return: Return QDF_STATUS.
15216 */
15217QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15218 struct set_arp_stats_params
15219 *set_stats_param)
15220{
15221 struct set_arp_stats_params *arp_set_param;
15222 struct scheduler_msg msg;
15223
15224 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15225 if (arp_set_param == NULL) {
15226 sme_err("Memory allocation failure");
15227 return QDF_STATUS_E_NOMEM;
15228 }
15229
15230 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15231
15232 msg.type = WMA_SET_ARP_STATS_REQ;
15233 msg.reserved = 0;
15234 msg.bodyptr = arp_set_param;
15235
15236 if (QDF_STATUS_SUCCESS !=
15237 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15238 sme_err("Not able to post message to WDA");
15239 qdf_mem_free(arp_set_param);
15240 return QDF_STATUS_E_FAILURE;
15241 }
15242
15243 return QDF_STATUS_SUCCESS;
15244}
15245
15246/**
15247 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15248 * @hal: handle to hal
15249 * @get_stats_param: pointer to set stats param
15250 *
15251 * Return: Return QDF_STATUS.
15252 */
15253QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15254 struct get_arp_stats_params
15255 *get_stats_param)
15256{
15257 struct get_arp_stats_params *arp_get_param;
15258 struct scheduler_msg msg;
15259
15260 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15261 if (arp_get_param == NULL) {
15262 sme_err("Memory allocation failure");
15263 return QDF_STATUS_E_NOMEM;
15264 }
15265
15266 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15267
15268 msg.type = WMA_GET_ARP_STATS_REQ;
15269 msg.reserved = 0;
15270 msg.bodyptr = arp_get_param;
15271
15272 if (QDF_STATUS_SUCCESS !=
15273 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15274 sme_err("Not able to post message to WDA");
15275 qdf_mem_free(arp_get_param);
15276 return QDF_STATUS_E_FAILURE;
15277 }
15278
15279 return QDF_STATUS_SUCCESS;
15280}
15281
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015282QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15283 uint32_t param_value, uint32_t vdev_id)
15284{
15285 void *wma_handle;
15286
15287 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15288 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015289 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015290 return QDF_STATUS_E_FAILURE;
15291 }
15292
15293 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15294 param_value, vdev_id);
15295}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015296
15297QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015298 bool (*set_connection_info_cb)(bool),
15299 bool (*get_connection_info_cb)(uint8_t *session_id,
15300 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015301{
15302 QDF_STATUS status = QDF_STATUS_SUCCESS;
15303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15304
15305 status = sme_acquire_global_lock(&pMac->sme);
15306 if (QDF_IS_STATUS_SUCCESS(status)) {
15307 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015308 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015309 sme_release_global_lock(&pMac->sme);
15310 }
15311 return status;
15312}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015313
15314QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15315 void (*cb)(void *, struct rso_cmd_status *))
15316{
15317 QDF_STATUS status = QDF_STATUS_SUCCESS;
15318 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15319
15320 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015321 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015322 return status;
15323}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015324
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015325QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15326 struct wmi_dbs_scan_sel_params *params)
15327{
15328 struct scheduler_msg message = {0};
15329 QDF_STATUS status;
15330 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15331 uint32_t i;
15332
15333 if (0 == params->num_clients) {
15334 sme_err("Num of clients is 0");
15335 return QDF_STATUS_E_FAILURE;
15336 }
15337
15338 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15339 if (!dbs_scan_params) {
15340 sme_err("fail to alloc dbs_scan_params");
15341 return QDF_STATUS_E_NOMEM;
15342 }
15343
15344 dbs_scan_params->num_clients = params->num_clients;
15345 dbs_scan_params->pdev_id = params->pdev_id;
15346 for (i = 0; i < params->num_clients; i++) {
15347 dbs_scan_params->module_id[i] = params->module_id[i];
15348 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15349 dbs_scan_params->num_non_dbs_scans[i] =
15350 params->num_non_dbs_scans[i];
15351 }
15352 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15353 message.bodyptr = dbs_scan_params;
15354 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15355 if (!QDF_IS_STATUS_SUCCESS(status)) {
15356 sme_err("Not able to post msg to WMA!");
15357 qdf_mem_free(dbs_scan_params);
15358 }
15359
15360 return status;
15361}
15362
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015363QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15364{
15365 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15366 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015367 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015368 struct sme_rcpi_req *rcpi_req;
15369
15370 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15371 if (rcpi_req == NULL) {
15372 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15373 "%s: Not able to allocate memory for rcpi req",
15374 __func__);
15375 return QDF_STATUS_E_NOMEM;
15376 }
15377 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15378
15379 status = sme_acquire_global_lock(&pMac->sme);
15380 if (QDF_IS_STATUS_SUCCESS(status)) {
15381 msg.bodyptr = rcpi_req;
15382 msg.type = WMA_GET_RCPI_REQ;
15383 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15384 sme_release_global_lock(&pMac->sme);
15385 if (!QDF_IS_STATUS_SUCCESS(status)) {
15386 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15387 FL("post get rcpi req failed"));
15388 status = QDF_STATUS_E_FAILURE;
15389 qdf_mem_free(rcpi_req);
15390 }
15391 } else {
15392 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15393 FL("sme_acquire_global_lock failed"));
15394 qdf_mem_free(rcpi_req);
15395 }
15396
15397 return status;
15398}
15399
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015400void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15401{
15402 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15403 void *wma_handle;
15404 QDF_STATUS status;
15405
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015406 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015407 if (QDF_STATUS_SUCCESS != status) {
15408 mac_ctx->pdev = NULL;
15409 return;
15410 }
15411 mac_ctx->pdev = pdev;
15412 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15413 if (!wma_handle) {
15414 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015415 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015416 return;
15417 }
15418 wma_store_pdev(wma_handle, pdev);
15419}
15420
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015421QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15422 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15423{
15424 QDF_STATUS status;
15425 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15426
15427 status = sme_acquire_global_lock(&mac->sme);
15428 if (QDF_IS_STATUS_SUCCESS(status)) {
15429 mac->sme.congestion_cb = congestion_cb;
15430 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015431 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015432 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015433 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015434 }
15435
15436 return status;
15437}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015438
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015439QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15440 uint32_t param_val)
15441{
15442 return wma_configure_smps_params(vdev_id, param_id, param_val);
15443}
15444
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015445QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15446 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15447{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015448 wma_cli_set_cmd_t *iwcmd;
15449 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015450
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015451 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15452 if (!iwcmd) {
15453 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015454 return QDF_STATUS_E_NOMEM;
15455 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015456
15457 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15458 iwcmd->param_sec_value = 0;
15459 iwcmd->param_vdev_id = vdev_id;
15460 iwcmd->param_id = param_id;
15461 iwcmd->param_vp_dev = req_cat;
15462 iwcmd->param_value = param_val;
15463 wma_ipa_uc_stat_request(iwcmd);
15464 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015465
15466 return status;
15467}
lifeng66831662017-05-19 16:01:35 +080015468
15469QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15470 struct sir_set_rx_reorder_timeout_val *req)
15471{
15472 QDF_STATUS status;
15473
15474 status = wma_set_rx_reorder_timeout_val(hal, req);
15475
15476 return status;
15477}
15478
15479QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15480 struct sir_peer_set_rx_blocksize *req)
15481{
15482 QDF_STATUS status;
15483
15484 status = wma_set_rx_blocksize(hal, req);
15485
15486 return status;
15487}
Naveen Rawat247a8682017-06-05 15:00:31 -070015488
15489int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15490{
15491 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15492}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015493
15494QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15495 void (*cb)(void *, uint32_t bt_activity))
15496{
15497 QDF_STATUS status;
15498 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15499
15500 status = sme_acquire_global_lock(&mac->sme);
15501 if (QDF_IS_STATUS_SUCCESS(status)) {
15502 mac->sme.bt_activity_info_cb = cb;
15503 sme_release_global_lock(&mac->sme);
15504 sme_debug("bt activity info callback set");
15505 } else {
15506 sme_debug("sme_acquire_global_lock failed %d", status);
15507 }
15508
15509 return status;
15510}
lifengd217d192017-05-09 19:44:16 +080015511
15512QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15513 struct get_chain_rssi_req_params *input,
15514 get_chain_rssi_callback callback,
15515 void *context)
15516{
15517 QDF_STATUS status = QDF_STATUS_SUCCESS;
15518 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15519
15520 SME_ENTER();
15521
15522 if (NULL == input) {
15523 sme_err("Invalid req params");
15524 return QDF_STATUS_E_INVAL;
15525 }
15526
15527 mac_ctx->sme.get_chain_rssi_cb = callback;
15528 mac_ctx->sme.get_chain_rssi_context = context;
15529 wma_get_chain_rssi(hal, input);
15530
15531 SME_EXIT();
15532 return status;
15533}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015534
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015535QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15536 struct scheduler_msg *msg)
15537{
15538 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15539
15540 if (msg == NULL) {
15541 sme_err("Empty message for SME Msg callback");
15542 return status;
15543 }
15544 status = sme_process_msg(hal, msg);
15545 return status;
15546}
15547
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015548void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15549{
15550 struct csr_roam_session *session;
15551 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15552
15553 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15554 sme_err("%s Invalid session id: %d", __func__, session_id);
15555 return;
15556 }
15557
15558 session = CSR_GET_SESSION(mac_ctx, session_id);
15559 if (!session) {
15560 sme_err("%s Failed to get session for id: %d",
15561 __func__, session_id);
15562 return;
15563 }
15564
15565 sme_debug("Total No. of Disconnections: %d",
15566 session->disconnect_stats.disconnection_cnt);
15567
15568 sme_debug("No. of Diconnects Triggered by Application: %d",
15569 session->disconnect_stats.disconnection_by_app);
15570
15571 sme_debug("No. of Disassoc Sent by Peer: %d",
15572 session->disconnect_stats.disassoc_by_peer);
15573
15574 sme_debug("No. of Deauth Sent by Peer: %d",
15575 session->disconnect_stats.deauth_by_peer);
15576
15577 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15578 session->disconnect_stats.bmiss);
15579
15580 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15581 session->disconnect_stats.peer_kickout);
15582}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015583
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015584 /**
15585 * sme_set_vc_mode_config() - Set voltage corner config to FW
15586 * @bitmap: Bitmap that referes to voltage corner config with
15587 * different phymode and bw configuration
15588 *
15589 * Return: QDF_STATUS
15590 */
15591QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15592{
15593 void *wma_handle;
15594
15595 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15596 if (!wma_handle) {
15597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15598 "wma_handle is NULL");
15599 return QDF_STATUS_E_FAILURE;
15600 }
15601 if (QDF_STATUS_SUCCESS !=
15602 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15603 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15604 "%s: Failed to set Voltage Control config to FW",
15605 __func__);
15606 return QDF_STATUS_E_FAILURE;
15607 }
15608 return QDF_STATUS_SUCCESS;
15609}
15610
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015611/**
15612 * sme_set_bmiss_bcnt() - set bmiss config parameters
15613 * @vdev_id: virtual device for the command
15614 * @first_cnt: bmiss first value
15615 * @final_cnt: bmiss final value
15616 *
15617 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15618 */
15619QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15620 uint32_t final_cnt)
15621{
15622 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15623}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015624
15625QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15626 bool is_tos_active, uint32_t max_off_chan_time,
15627 uint32_t rest_time, bool skip_dfs_chan)
15628{
15629 struct sir_limit_off_chan *cmd;
15630 struct scheduler_msg msg = {0};
15631
15632 cmd = qdf_mem_malloc(sizeof(*cmd));
15633 if (!cmd) {
15634 sme_err("qdf_mem_malloc failed for limit off channel");
15635 return QDF_STATUS_E_NOMEM;
15636 }
15637
15638 cmd->vdev_id = vdev_id;
15639 cmd->is_tos_active = is_tos_active;
15640 cmd->max_off_chan_time = max_off_chan_time;
15641 cmd->rest_time = rest_time;
15642 cmd->skip_dfs_chans = skip_dfs_chan;
15643
15644 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15645 msg.reserved = 0;
15646 msg.bodyptr = cmd;
15647
15648 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15649 &msg))) {
15650 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15651 qdf_mem_free(cmd);
15652 return QDF_STATUS_E_FAILURE;
15653 }
15654
15655 return QDF_STATUS_SUCCESS;
15656}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015657
15658/**
15659 * sme_get_status_for_candidate() - Get bss transition status for candidate
15660 * @hal: Handle for HAL
15661 * @conn_bss_desc: connected bss descriptor
15662 * @bss_desc: candidate bss descriptor
15663 * @info: candiadate bss information
15664 * @trans_reason: transition reason code
15665 * @is_bt_in_progress: bt activity indicator
15666 *
15667 * Return : true if candidate is rejected and reject reason is filled
15668 * @info->status. Otherwise returns false.
15669 */
15670static bool sme_get_status_for_candidate(tHalHandle *hal,
15671 tSirBssDescription *conn_bss_desc,
15672 tSirBssDescription *bss_desc,
15673 struct bss_candidate_info *info,
15674 uint8_t trans_reason,
15675 bool is_bt_in_progress)
15676{
15677 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15678
15679 /*
15680 * Low RSSI based rejection
15681 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15682 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15683 * candidate with MBO reason code 4.
15684 */
15685 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15686 mbo_candidate_rssi_thres) &&
15687 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15688 mbo_current_rssi_thres)) {
15689 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15690 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15691 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15692 return true;
15693 }
15694
15695 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15696 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15697 /*
15698 * MCC rejection
15699 * If moving to candidate's channel will result in MCC scenario
15700 * and the rssi of connected bss is greater than
15701 * mbo_current_rssi_mss_thres, then reject the candidate with
15702 * MBO reason code 3.
15703 */
15704 if ((conn_bss_desc->rssi >
15705 mac_ctx->roam.configParam.mbo_thresholds.
15706 mbo_current_rssi_mcc_thres) &&
15707 csr_is_mcc_channel(hal, bss_desc->channelId)) {
15708 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15709 MAC_ADDR_ARRAY(bss_desc->bssId));
15710 info->status =
15711 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15712 return true;
15713 }
15714
15715 /*
15716 * BT coex rejection
15717 * If AP is trying to move the client from 5G to 2.4G and moving
15718 * to 2.4G will result in BT coex and candidate channel rssi is
15719 * less than mbo_candidate_rssi_btc_thres, then reject the
15720 * candidate with MBO reason code 2.
15721 */
15722 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15723 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15724 is_bt_in_progress &&
15725 (bss_desc->rssi <
15726 mac_ctx->roam.configParam.mbo_thresholds.
15727 mbo_candidate_rssi_btc_thres)) {
15728 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15729 MAC_ADDR_ARRAY(bss_desc->bssId));
15730 info->status =
15731 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15732 return true;
15733 }
15734
15735 /*
15736 * LTE coex rejection
15737 * If moving to candidate's channel can cause LTE coex, then
15738 * reject the candidate with MBO reason code 5.
15739 */
15740 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15741 conn_bss_desc->channelId) &&
15742 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
15743 bss_desc->channelId))) {
15744 sme_err("High interference expected if transitioned to BSS "
15745 MAC_ADDRESS_STR" hence reject",
15746 MAC_ADDR_ARRAY(bss_desc->bssId));
15747 info->status =
15748 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
15749 return true;
15750 }
15751 }
15752
15753 return false;
15754}
15755
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015756uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15757 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15758 bool append_ie)
15759{
15760 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15761
15762 return sir_unpack_rsn_ie(mac_ctx, buf, buf_len, rsn_ie, append_ie);
15763}
15764
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015765/**
15766 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
15767 * @adapter : Pointer to adapter
15768 * @transition_reason : Transition reason
15769 * @info : bss candidate information
15770 * @n_candidates : number of candidates
15771 *
15772 * Return : 0 on success otherwise errno
15773 */
15774int sme_get_bss_transition_status(tHalHandle hal,
15775 uint8_t transition_reason,
15776 struct qdf_mac_addr *bssid,
15777 struct bss_candidate_info *info,
15778 uint16_t n_candidates,
15779 bool is_bt_in_progress)
15780{
15781 QDF_STATUS status = QDF_STATUS_SUCCESS;
15782 tSirBssDescription *bss_desc, *conn_bss_desc;
15783 tCsrScanResultInfo *res, *conn_res;
15784 uint16_t i;
15785
15786 if (!n_candidates || !info) {
15787 sme_err("No candidate info available");
15788 return QDF_STATUS_E_INVAL;
15789 }
15790
15791 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15792 if (!conn_res) {
15793 sme_err("Failed to allocate memory for conn_res");
15794 return QDF_STATUS_E_NOMEM;
15795 }
15796
15797 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15798 if (!res) {
15799 sme_err("Failed to allocate memory for conn_res");
15800 status = QDF_STATUS_E_NOMEM;
15801 goto free;
15802 }
15803
15804 /* Get the connected BSS descriptor */
15805 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
15806 if (!QDF_IS_STATUS_SUCCESS(status)) {
15807 sme_err("Failed to find connected BSS in scan list");
15808 goto free;
15809 }
15810 conn_bss_desc = &conn_res->BssDescriptor;
15811
15812 for (i = 0; i < n_candidates; i++) {
15813 /* Get candidate BSS descriptors */
15814 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
15815 res);
15816 if (!QDF_IS_STATUS_SUCCESS(status)) {
15817 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
15818 MAC_ADDR_ARRAY(info[i].bssid.bytes));
15819 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
15820 continue;
15821 }
15822
15823 bss_desc = &res->BssDescriptor;
15824 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
15825 &info[i], transition_reason, is_bt_in_progress)) {
15826 /*
15827 * If status is not over written, it means it is a
15828 * candidate for accept.
15829 */
15830 info[i].status = QCA_STATUS_ACCEPT;
15831 }
15832 }
15833
15834 /* success */
15835 status = QDF_STATUS_SUCCESS;
15836
15837free:
15838 /* free allocated memory */
15839 if (conn_res)
15840 qdf_mem_free(conn_res);
15841 if (res)
15842 qdf_mem_free(res);
15843
15844 return status;
15845}
15846