blob: 53898ac77a86a348df4107aedca0088f120b08ea [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 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053020 * DOC: smeApi.c
21 *
22 * Definitions for SME APIs
23 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080024
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053025/* Include Files */
Srinivas Girigowda2c263352017-03-17 17:49:53 -070026#include <sir_common.h>
27#include <ani_global.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080028#include "sme_api.h"
29#include "csr_inside_api.h"
30#include "sme_inside.h"
31#include "csr_internal.h"
32#include "wma_types.h"
33#include "wma_if.h"
Jeff Johnson6136fb92017-03-30 15:21:49 -070034#include "wma_fips_api.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053035#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "sme_trace.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053037#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053038#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "cds_utils.h"
40#include "sap_api.h"
41#include "mac_trace.h"
42#ifdef WLAN_FEATURE_NAN
43#include "nan_api.h"
44#endif
Naveen Rawat3b6068c2016-04-14 19:01:06 -070045#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "cfg_api.h"
47#include "sme_power_save_api.h"
48#include "wma.h"
Naveen Rawatb4d37622015-11-13 16:15:25 -080049#include "sch_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070050#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053051#include "csr_api.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Abhishek Singh158fe252017-03-23 11:09:34 +053053#include <wlan_scan_ucfg_api.h>
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -070054#include "wlan_reg_ucfg_api.h"
Arif Hussainee677012017-01-26 17:50:13 -080055#include "ol_txrx.h"
Naveen Rawatd2657be2017-10-10 14:31:23 -070056#include "wifi_pos_api.h"
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053057#include "net/cfg80211.h"
58#include <qca_vendor.h>
Sandeep Puligilla063a4342018-01-10 02:50:14 -080059#include <wlan_spectral_utils_api.h>
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053060#include "wlan_mlme_public_struct.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053064static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053066static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053068static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069 void *pMsgBuf);
70
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053071static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053074static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 uint16_t msg_type, void *pMsgBuf);
76
Jeff Johnsonfdecd512018-06-10 09:18:32 -070077static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
Jeff Johnson45843652018-07-04 12:47:34 -070078 struct stats_ext_event *msg);
Jeff Johnsonfdecd512018-06-10 09:18:32 -070079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053081QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053083 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084
85 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053086 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053087 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053088 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 }
90
91 return status;
92}
93
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053094QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053096 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097
98 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053099 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530100 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530101 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 }
103
104 return status;
105}
106
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700107tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700108{
109 tpAniSirGlobal mac_ctx;
110 tHalHandle h_hal;
111
112 h_hal = cds_get_context(QDF_MODULE_ID_SME);
113 if (NULL == h_hal) {
114 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
115 FL("invalid h_hal"));
116 return NULL;
117 }
118
119 mac_ctx = PMAC_STRUCT(h_hal);
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700120
121 return mac_ctx;
122}
123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/**
125 * sme_process_set_hw_mode_resp() - Process set HW mode response
126 * @mac: Global MAC pointer
127 * @msg: HW mode response
128 *
129 * Processes the HW mode response and invokes the HDD callback
130 * to process further
131 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133{
Krunal Sonia8270f52017-02-23 19:51:25 -0800134 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 tSmeCmd *command = NULL;
136 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800137 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700139 enum policy_mgr_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530140 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800141 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 param = (struct sir_set_hw_mode_resp *)msg;
144 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700145 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 /* Not returning. Need to check if active command list
147 * needs to be freed
148 */
149 }
150
Krunal Sonia8270f52017-02-23 19:51:25 -0800151 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700153 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800154 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 }
156
157 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
158 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700159 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 }
162
163 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700164 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800165 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 }
167
168 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530169 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800170 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530171
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700172 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530173 command->u.set_hw_mode_cmd.reason,
174 command->u.set_hw_mode_cmd.session_id);
175
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700176 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700177 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700178 goto end;
179 }
180
181 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700182 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700183 goto end;
184 }
185
186 /* Irrespective of the reason for which the hw mode change request
187 * was issued, the policy manager connection table needs to be updated
188 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
189 * set hw mode was successful.
190 */
191 callback(param->status,
192 param->cfgd_hw_mode_index,
193 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800194 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800195 command->u.set_hw_mode_cmd.next_action,
196 command->u.set_hw_mode_cmd.reason,
197 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800198 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800199 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
200 sme_err("session %d is invalid", session_id);
201 goto end;
202 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800203 session = CSR_GET_SESSION(mac, session_id);
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700204 if (reason == POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700205 /* In the case of hidden SSID, connection update
206 * (set hw mode) is done after the scan with reason
207 * code eCsrScanForSsid completes. The connect/failure
208 * needs to be handled after the response of set hw
209 * mode
210 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800211 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700212 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800213 csr_scan_handle_search_for_ssid(mac,
214 session_id);
215 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700216 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800217 csr_scan_handle_search_for_ssid_failure(mac,
218 session_id);
219 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800220 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 }
222
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530223end:
Krunal Soni72dba662017-02-15 20:13:17 -0800224 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530226 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800228 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800229
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530230 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231}
232
233/**
234 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
235 * @mac: Global MAC pointer
236 * @msg: HW mode transition response
237 *
238 * Processes the HW mode transition indication and invoke the HDD callback
239 * to process further
240 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530241static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 uint8_t *msg)
243{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 struct sir_hw_mode_trans_ind *param;
245
246 param = (struct sir_hw_mode_trans_ind *)msg;
247 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700248 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 }
251
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800252 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800253 param->new_hw_mode_index,
254 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800255 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530257 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258}
259
Naveen Rawate7d86052015-11-13 12:01:43 -0800260/**
261 * free_sme_cmds() - This function frees memory allocated for SME commands
262 * @mac_ctx: Pointer to Global MAC structure
263 *
264 * This function frees memory allocated for SME commands
265 *
266 * @Return: void
267 */
268static void free_sme_cmds(tpAniSirGlobal mac_ctx)
269{
270 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530271
Naveen Rawate7d86052015-11-13 12:01:43 -0800272 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
273 return;
274
275 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530276 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800277
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530278 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800279 mac_ctx->sme.pSmeCmdBufAddr = NULL;
280}
281
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530282static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530284 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 tSmeCmd *pCmd;
286 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800287 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288
289 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291
Jeff Johnson616417f2018-06-27 10:20:53 -0700292 status = csr_ll_open(&pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530293 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 goto end;
295
Naveen Rawate7d86052015-11-13 12:01:43 -0800296 /* following pointer contains array of pointers for tSmeCmd* */
297 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530298 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800299 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530300 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800301 goto end;
302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530304 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800305 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
306 /*
307 * Since total size of all commands together can be huge chunk
308 * of memory, allocate SME cmd individually. These SME CMDs are
309 * moved between pending and active queues. And these freeing of
310 * these queues just manipulates the list but does not actually
311 * frees SME CMD pointers. Hence store each SME CMD address in
312 * the array, sme.pSmeCmdBufAddr. This will later facilitate
313 * freeing up of all SME CMDs with just a for loop.
314 */
315 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530316 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800317 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530318 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800319 free_sme_cmds(pMac);
320 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800322 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
323 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
324 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 }
326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530328 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700329 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330
331 return status;
332}
333
Krunal Sonia8270f52017-02-23 19:51:25 -0800334void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335{
Krunal Sonia8270f52017-02-23 19:51:25 -0800336 sme_cmd->command = eSmeNoCommand;
337 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530338 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339}
340
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530341static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530343 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 csr_ll_close(&pMac->sme.smeCmdFreeList);
346
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530347 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530348 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700349 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 goto done;
351 }
352
Naveen Rawate7d86052015-11-13 12:01:43 -0800353 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530355 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530356 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700357 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358done:
359 return status;
360}
361
Jeff Johnson49c02f92016-10-07 10:29:09 -0700362static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363{
364 switch (pCmd->command) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700366 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 pCmd->u.roamCmd.roamReason);
368 break;
369
370 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700371 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 pCmd->u.wmStatusChangeCmd.Type);
373 break;
374
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +0530375 case e_sme_command_del_sta_session:
376 sme_debug("Issue del STA command for session:%d",
377 pCmd->sessionId);
378 break;
379
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700381 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 pCmd->command);
383 break;
384 }
385}
386
387tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
388{
389 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
390 tListElem *pEntry;
391 static int sme_command_queue_full;
392
393 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
394
395 /* If we can get another MS Msg buffer, then we are ok. Just link */
396 /* the entry onto the linked list. (We are using the linked list */
397 /* to keep track of tfhe message buffers). */
398 if (pEntry) {
399 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
400 /* reset when free list is available */
401 sme_command_queue_full = 0;
402 } else {
403 int idx = 1;
404
405 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800406 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530407 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530409
410 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
412 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530413 if (eSmeCsrCommandMask & pTempCmd->command)
414 /* CSR command is stuck. See what the reason
415 * code is for that command
416 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 } /* if(pTempCmd) */
419
420 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800421 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800423 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 LL_ACCESS_NOLOCK);
425 while (pEntry && !sme_command_queue_full) {
426 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
427 /* Print only 1st five commands from pending queue. */
428 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530429 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 idx, pTempCmd->command);
431 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530432 if (eSmeCsrCommandMask & pTempCmd->command)
433 /* CSR command is stuck. See what the reason
434 * code is for that command
435 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800437 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 LL_ACCESS_NOLOCK);
439 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800440 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441
Vignesh Viswanathana1f3a1a2018-10-04 13:10:46 +0530442 if (pMac->mlme_cfg->gen.fatal_event_trigger)
Abhishek Singh5ea86532016-04-27 14:10:53 +0530443 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
444 WLAN_LOG_INDICATOR_HOST_DRIVER,
445 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
446 false,
Vignesh Viswanathana1f3a1a2018-10-04 13:10:46 +0530447 pMac->mlme_cfg->gen.self_recovery);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530448 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530449 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 }
451
452 /* memset to zero */
453 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530454 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530456 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530458 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 }
460
461 return pRetCmd;
462}
463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800465 * sme_ser_handle_active_cmd() - handle command activation callback from
466 * new serialization module
467 * @cmd: pointer to new serialization command
468 *
469 * This API is to handle command activation callback from new serialization
470 * callback
471 *
472 * Return: QDF_STATUS_SUCCESS
473 */
474static
475QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
476{
477 tSmeCmd *sme_cmd;
478 tHalHandle hal;
479 tpAniSirGlobal mac_ctx;
480 QDF_STATUS status = QDF_STATUS_SUCCESS;
481 bool do_continue;
482
483 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700484 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800485 return QDF_STATUS_E_FAILURE;
486 }
487
488 hal = cds_get_context(QDF_MODULE_ID_SME);
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +0530489 if (NULL != hal) {
490 mac_ctx = PMAC_STRUCT(hal);
491 } else {
492 sme_err("No hal found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800493 return QDF_STATUS_E_FAILURE;
494 }
495 sme_cmd = cmd->umac_cmd;
496 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700497 sme_err("No SME command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800498 return QDF_STATUS_E_FAILURE;
499 }
500
501 switch (sme_cmd->command) {
502 case eSmeCommandRoam:
503 status = csr_roam_process_command(mac_ctx, sme_cmd);
504 break;
505 case eSmeCommandWmStatusChange:
506 csr_roam_process_wm_status_change_command(mac_ctx,
507 sme_cmd);
508 break;
Pragaspathi Thilagarajb37dad32018-07-01 16:48:01 +0530509 case e_sme_command_del_sta_session:
510 csr_process_del_sta_session_command(mac_ctx, sme_cmd);
511 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800512 case eSmeCommandAddTs:
513 case eSmeCommandDelTs:
514#ifndef WLAN_MDM_CODE_REDUCTION_OPT
515 do_continue = qos_process_command(mac_ctx, sme_cmd);
516 if (do_continue)
517 status = QDF_STATUS_E_FAILURE;
518#endif
519 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800520 case e_sme_command_set_hw_mode:
521 csr_process_set_hw_mode(mac_ctx, sme_cmd);
522 break;
523 case e_sme_command_nss_update:
524 csr_process_nss_update_req(mac_ctx, sme_cmd);
525 break;
526 case e_sme_command_set_dual_mac_config:
527 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
528 break;
529 case e_sme_command_set_antenna_mode:
530 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
531 break;
532 default:
533 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700534 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800535 status = QDF_STATUS_E_FAILURE;
536 break;
537 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800538 return status;
539}
540
541QDF_STATUS sme_ser_cmd_callback(void *buf,
542 enum wlan_serialization_cb_reason reason)
543{
544 struct wlan_serialization_command *cmd = buf;
545 tHalHandle hal;
546 tpAniSirGlobal mac_ctx;
547 QDF_STATUS status = QDF_STATUS_SUCCESS;
548 tSmeCmd *sme_cmd;
549
550 hal = cds_get_context(QDF_MODULE_ID_SME);
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +0530551 if (hal != NULL) {
552 mac_ctx = PMAC_STRUCT(hal);
553 } else {
554 sme_err("hal is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800555 return QDF_STATUS_E_FAILURE;
556 }
557 /*
558 * Do not acquire lock here as sme global lock is already acquired in
559 * caller or MC thread context
560 */
561 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700562 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800563 return QDF_STATUS_E_FAILURE;
564 }
565
566 switch (reason) {
567 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700568 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800569 status = sme_ser_handle_active_cmd(cmd);
570 break;
571 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700572 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800573 break;
574 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700575 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Vignesh Viswanathan062b5162018-10-11 17:18:41 +0530576 if (cmd->vdev)
577 wlan_objmgr_vdev_release_ref(cmd->vdev,
578 WLAN_LEGACY_SME_ID);
Krunal Sonia8270f52017-02-23 19:51:25 -0800579 sme_cmd = cmd->umac_cmd;
580 csr_release_command_buffer(mac_ctx, sme_cmd);
581 break;
582 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700583 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800584 break;
585 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700586 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800587 return QDF_STATUS_E_FAILURE;
588 }
589 return status;
590}
591
Wen Gong3f003382018-05-14 14:26:37 +0800592#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Krunal Sonia8270f52017-02-23 19:51:25 -0800593/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530594 * sme_get_sessionid_from_activelist() - gets session id
595 * @mac: mac context
596 *
597 * This function is used to get session id from sme command
598 * active list
599 *
600 * Return: returns session id
601 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700602static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530603{
604 tListElem *entry;
605 tSmeCmd *command;
606 uint32_t session_id = CSR_SESSION_ID_INVALID;
607
Krunal Sonia8270f52017-02-23 19:51:25 -0800608 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530609 if (entry) {
610 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
611 session_id = command->sessionId;
612 }
613
614 return session_id;
615}
616
617/**
618 * sme_state_info_dump() - prints state information of sme layer
619 * @buf: buffer pointer
620 * @size: size of buffer to be filled
621 *
622 * This function is used to dump state information of sme layer
623 *
624 * Return: None
625 */
626static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
627{
628 uint32_t session_id, active_session_id;
629 tHalHandle hal;
630 tpAniSirGlobal mac;
631 uint16_t len = 0;
632 char *buf = *buf_ptr;
633 eCsrConnectState connect_state;
634
635 hal = cds_get_context(QDF_MODULE_ID_SME);
636 if (hal == NULL) {
637 QDF_ASSERT(0);
638 return;
639 }
640
641 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530642
643 active_session_id = sme_get_sessionid_from_activelist(mac);
644 if (active_session_id != CSR_SESSION_ID_INVALID) {
645 len += qdf_scnprintf(buf + len, *size - len,
646 "\n active command sessionid %d", active_session_id);
647 }
648
649 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
650 if (CSR_IS_SESSION_VALID(mac, session_id)) {
651 connect_state =
652 mac->roam.roamSession[session_id].connectState;
653 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
654 connect_state)
655 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
656 connect_state)) {
657 len += qdf_scnprintf(buf + len, *size - len,
658 "\n NeighborRoamState: %d",
659 mac->roam.neighborRoamInfo[session_id].
660 neighborRoamState);
661 len += qdf_scnprintf(buf + len, *size - len,
662 "\n RoamState: %d", mac->roam.
663 curState[session_id]);
664 len += qdf_scnprintf(buf + len, *size - len,
665 "\n RoamSubState: %d", mac->roam.
666 curSubState[session_id]);
667 len += qdf_scnprintf(buf + len, *size - len,
668 "\n ConnectState: %d",
669 connect_state);
670 }
671 }
672 }
673
674 *size -= len;
675 *buf_ptr += len;
676}
677
678/**
679 * sme_register_debug_callback() - registration function sme layer
680 * to print sme state information
681 *
682 * Return: None
683 */
684static void sme_register_debug_callback(void)
685{
686 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
687}
Wen Gong3f003382018-05-14 14:26:37 +0800688#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800689static void sme_register_debug_callback(void)
690{
691}
Wen Gong3f003382018-05-14 14:26:37 +0800692#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694/* Global APIs */
695
696/**
697 * sme_open() - Initialze all SME modules and put them at idle state
698 * @hHal: The handle returned by mac_open
699 *
700 * The function initializes each module inside SME, PMC, CSR, etc. Upon
701 * successfully return, all modules are at idle state ready to start.
702 * smeOpen must be called before any other SME APIs can be involved.
703 * smeOpen must be called after mac_open.
704 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530705 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 * Other status means SME is failed to be initialized
707 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530708QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530710 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712
713 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530714 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530715 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda09625b02018-09-10 15:28:09 -0700717 sme_err("Init lock failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530718 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 }
720 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530721 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700722 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 return status;
724 }
725
726 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530727 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700728 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 return status;
730 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731
732#ifndef WLAN_MDM_CODE_REDUCTION_OPT
733 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530734 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700735 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 return status;
737 }
738#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530740 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530744 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700745 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 return status;
747 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530749 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700750 wlan_serialization_legacy_init_callback();
751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 return status;
753}
754
755/*
756 * sme_init_chan_list, triggers channel setup based on country code.
757 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530758QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700759 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760{
761 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
762
Amar Singhala297bfa2015-10-15 15:07:29 -0700763 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
765 pmac->roam.configParam.Is11dSupportEnabled = false;
766 }
767
768 return csr_init_chan_list(pmac, alpha2);
769}
770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530771/*
772 * sme_set11dinfo() - Set the 11d information about valid channels
773 * and there power using information from nvRAM
774 * This function is called only for AP.
775 *
776 * This is a synchronous call
777 *
778 * hHal - The handle returned by mac_open.
779 * pSmeConfigParams - a pointer to a caller allocated object of
780 * typedef struct _smeConfigParams.
781 *
782 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
783 *
784 * Other status means SME is failed to update the config parameters.
785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786
Jeff Johnsonff26c612018-06-10 20:57:13 -0700787QDF_STATUS sme_set11dinfo(tHalHandle hal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788{
Jeff Johnsonff26c612018-06-10 20:57:13 -0700789 tpAniSirGlobal mac_ctx = MAC_CONTEXT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530790 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530792 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
794 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700795 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 return status;
797 }
798
Jeff Johnsonff26c612018-06-10 20:57:13 -0700799 status = csr_set_channels(mac_ctx, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700800 if (!QDF_IS_STATUS_SUCCESS(status))
801 sme_err("csr_set_channels failed with status: %d", status);
802
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 return status;
804}
805
806/**
807 * sme_set_scan_disable() - Dynamically enable/disable scan
808 * @h_hal: Handle to HAL
809 *
810 * This command gives the user an option to dynamically
811 * enable or disable scans.
812 *
813 * Return: None
814 */
815void sme_set_scan_disable(tHalHandle h_hal, int value)
816{
817 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530818
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700819 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530820 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530822/*
823 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
824 * This is a synchronous call
825 *
826 * hHal - The handle returned by HostapdAdapter.
827 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
828 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
829 * Other status means, failed to get the current regulatory domain.
830 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530832QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
833 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530835 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
837
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530838 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
840 NO_SESSION, 0));
841 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700842 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 return status;
844 }
845
846 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530847 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
849 return status;
850}
851
Krunal Sonie3531942016-04-12 17:43:53 -0700852/**
853 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
854 * incoming val
855 * @hal: Handle for Hal layer
856 * @val: New FTM capability value
857 *
858 * Return: None
859 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530860void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
861 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700862{
863 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530864 QDF_STATUS status;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530865
Naveen Rawatd2657be2017-10-10 14:31:23 -0700866 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700867
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530868 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700869 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
870 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
871 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
872 } else {
873 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
874 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
875 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
876 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530877
878 /* Inform this RRM IE change to FW */
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530879 status = sme_acquire_global_lock(&mac_ctx->sme);
880 if (QDF_IS_STATUS_SUCCESS(status)) {
881 csr_roam_offload_scan(mac_ctx, session_id,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530882 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
883 REASON_CONNECT_IES_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530884 sme_release_global_lock(&mac_ctx->sme);
885 } else {
886 sme_err("Failed to acquire SME lock");
887 }
Krunal Sonie3531942016-04-12 17:43:53 -0700888}
889
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530890/*
891 * sme_update_config() - Change configurations for all SME moduels
892 * The function updates some configuration for modules in SME, CSR, etc
893 * during SMEs close open sequence.
894 * Modules inside SME apply the new configuration at the next transaction.
895 * This is a synchronous call
896 *
897 * hHal - The handle returned by mac_open.
898 * pSmeConfigParams - a pointer to a caller allocated object of
899 * typedef struct _smeConfigParams.
900 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
901 * Other status means SME is failed to update the config parameters.
902 */
903QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
904 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530906 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
908
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530909 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
911 0));
912 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700913 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 return status;
915 }
916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530917 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
918 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530920 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700921 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923
Jeff Johnson711fe942018-06-09 23:37:01 -0700924 status = rrm_change_default_config_param(pMac, &pSmeConfigParams->
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530925 rrmConfig);
926
927 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700928 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530930
931 /* For SOC, CFG is set before start We don't want to apply global CFG
932 * in connect state because that may cause some side affect
933 */
934 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /*
938 * If scan offload is enabled then lim has allow the sending of
939 * scan request to firmware even in powersave mode. The firmware has
940 * to take care of exiting from power save mode
941 */
942 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
943
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530944 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530945 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530947
948 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 return status;
951}
952
953/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530954 * sme_update_scan_roam_params() - Update the scan roaming params
955 * @mac_ctx: mac ctx
956 *
957 * Return: void.
958 */
959static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
960{
961 struct roam_filter_params scan_params = {0};
962 struct roam_ext_params *roam_params_src;
963 uint8_t i;
964 QDF_STATUS status;
965
966 roam_params_src = &mac_ctx->roam.configParam.roam_params;
967
968 scan_params.num_bssid_avoid_list =
969 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530970
971 if (scan_params.num_bssid_avoid_list >
972 MAX_AVOID_LIST_BSSID)
973 scan_params.num_bssid_avoid_list =
974 MAX_AVOID_LIST_BSSID;
975
976 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
977 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
978 &roam_params_src->bssid_avoid_list[i]);
979 }
980
981 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
982 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700983 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530984 status);
985}
986
987/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 * sme_update_roam_params() - Store/Update the roaming params
989 * @hal: Handle for Hal layer
990 * @session_id: SME Session ID
991 * @roam_params_src: The source buffer to copy
992 * @update_param: Type of parameter to be updated
993 *
994 * Return: Return the status of the updation.
995 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530996QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -0700997 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 int update_param)
999{
1000 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
1001 struct roam_ext_params *roam_params_dst;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301002 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 uint8_t i;
1004
1005 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
1006 switch (update_param) {
1007 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
Wu Gaoca416ff2018-09-17 11:05:07 +08001008 mac_ctx->mlme_cfg->lfr.rssi_boost_threshold_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001009 roam_params_src->raise_rssi_thresh_5g;
Wu Gaoca416ff2018-09-17 11:05:07 +08001010 mac_ctx->mlme_cfg->lfr.rssi_penalize_threshold_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001011 roam_params_src->drop_rssi_thresh_5g;
Wu Gaoca416ff2018-09-17 11:05:07 +08001012 mac_ctx->mlme_cfg->lfr.rssi_boost_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001013 roam_params_src->raise_factor_5g;
Wu Gaoca416ff2018-09-17 11:05:07 +08001014 mac_ctx->mlme_cfg->lfr.rssi_penalize_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001015 roam_params_src->drop_factor_5g;
Wu Gaoca416ff2018-09-17 11:05:07 +08001016 mac_ctx->mlme_cfg->lfr.max_rssi_boost_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001017 roam_params_src->max_raise_rssi_5g;
Wu Gaoca416ff2018-09-17 11:05:07 +08001018 mac_ctx->mlme_cfg->lfr.max_rssi_penalize_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001019 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001021 roam_params_src->alert_rssi_threshold;
Wu Gaoca416ff2018-09-17 11:05:07 +08001022 mac_ctx->mlme_cfg->lfr.enable_5g_band_pref = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 break;
1024 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301025 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1027 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001028 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1030 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001031 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301032 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001033 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 roam_params_dst->ssid_allowed_list[i].length);
1035 }
1036 break;
1037 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301038 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1040 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001041 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301043 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001044 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 sizeof(tSirMacAddr));
1046 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001047 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 }
1049 break;
1050 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301052 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001054 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301056 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001057 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 }
1059 break;
1060 case REASON_ROAM_GOOD_RSSI_CHANGED:
1061 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001062 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 break;
1064 default:
1065 break;
1066 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301067
1068 status = sme_acquire_global_lock(&mac_ctx->sme);
1069 if (QDF_IS_STATUS_SUCCESS(status)) {
1070 csr_roam_offload_scan(mac_ctx, session_id,
1071 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1072 update_param);
1073 sme_release_global_lock(&mac_ctx->sme);
1074 } else {
1075 sme_err("Failed to acquire SME lock");
1076 }
Abhishek Singh158fe252017-03-23 11:09:34 +05301077
1078 sme_update_scan_roam_params(mac_ctx);
1079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 return 0;
1081}
1082
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001083/**
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301084 * sme_process_ready_to_suspend() -
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001085 * @mac: Global MAC context
1086 * @pReadyToSuspend: Parameter received along with ready to suspend
1087 * indication from WMA.
1088 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301089 * On getting ready to suspend indication, this function calls
1090 * callback registered (HDD callbacks) with SME to inform ready
1091 * to suspend indication.
1092 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301093 * Return: None
1094 */
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001095static void sme_process_ready_to_suspend(tpAniSirGlobal mac,
Jeff Johnson49c02f92016-10-07 10:29:09 -07001096 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097{
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001098 if (NULL == mac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001100 "%s: mac is null", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 return;
1102 }
1103
Jeff Johnson8131a9d2018-06-10 08:53:09 -07001104 if (NULL != mac->readyToSuspendCallback) {
1105 mac->readyToSuspendCallback(mac->readyToSuspendContext,
1106 pReadyToSuspend->suspended);
1107 mac->readyToSuspendCallback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 }
1109}
1110
1111#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001113/**
1114 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001115 * @mac: Global MAC context
1116 * @indication: ready to Ext WoW indication from lower layer
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001117 *
1118 * On getting ready to Ext WoW indication, this function calls callback
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001119 * registered (HDD callback) with SME to inform ready to ExtWoW indication.
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001120 *
1121 * Return: None
1122 */
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001123static void sme_process_ready_to_ext_wow(tpAniSirGlobal mac,
1124 tpSirReadyToExtWoWInd indication)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125{
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001126 if (!mac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301127 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001128 "%s: mac is null", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 return;
1130 }
1131
Jeff Johnson9d7c99e2018-06-28 15:36:00 -07001132 if (NULL != mac->readyToExtWoWCallback) {
1133 mac->readyToExtWoWCallback(mac->readyToExtWoWContext,
1134 indication->status);
1135 mac->readyToExtWoWCallback = NULL;
1136 mac->readyToExtWoWContext = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 }
1138
1139}
1140#endif
1141
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301142/*
1143 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1144 * that the NIC is ready tio run.
1145 * The function is called by HDD at the end of initialization stage so PE/HAL
1146 * can enable the NIC to running state.
1147 * This is a synchronous call
1148 *
1149 * @hHal - The handle returned by mac_open.
1150 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1151 * successfully.
1152 * Other status means SME failed to send the message to PE.
1153 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301154QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155{
Abhishek Singhde410b72017-05-22 15:25:39 +05301156 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301157 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1159
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301160 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1162 do {
1163
Abhishek Singhde410b72017-05-22 15:25:39 +05301164 msg = qdf_mem_malloc(sizeof(*msg));
1165 if (!msg) {
1166 sme_err("Memory allocation failed! for msg");
1167 return QDF_STATUS_E_NOMEM;
1168 }
1169 msg->messageType = eWNI_SME_SYS_READY_IND;
1170 msg->length = sizeof(*msg);
Abhishek Singhde410b72017-05-22 15:25:39 +05301171 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001172 msg->sme_msg_cb = sme_process_msg_callback;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301173 msg->stop_roaming_cb = sme_stop_roaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001175 status = u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)msg);
1176 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001177 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 break;
1179 }
1180
1181 status = csr_ready(pMac);
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001182 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001183 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 break;
1185 }
1186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 pMac->sme.state = SME_STATE_READY;
1188 } while (0);
1189
1190 return status;
1191}
1192
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001193QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1194{
1195 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001196
1197 if (NULL == mac_ctx) {
1198 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1199 FL("Invalid MAC context"));
1200 return QDF_STATUS_E_FAILURE;
1201 }
1202
Jeff Johnsonc09caa42018-06-07 22:58:55 -07001203 return wlan_cfg_get_str(mac_ctx, WNI_CFG_VALID_CHANNEL_LIST,
1204 chan_list, list_len);
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001205}
1206
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001207#ifdef WLAN_CONV_SPECTRAL_ENABLE
1208static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1209{
1210 struct spectral_legacy_cbacks spectral_cb;
1211 QDF_STATUS status;
1212
1213 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1214 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1215 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1216 status = spectral_register_legacy_cb(mac_ctx->psoc, &spectral_cb);
1217
1218 return status;
1219}
1220#else
1221static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1222{
1223 return QDF_STATUS_SUCCESS;
1224}
1225#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301226/*
1227 * sme_start() - Put all SME modules at ready state.
1228 * The function starts each module in SME, PMC, CSR, etc. . Upon
1229 * successfully return, all modules are ready to run.
1230 * This is a synchronous call
1231 *
1232 * hHal - The handle returned by mac_open.
1233 * Return QDF_STATUS_SUCCESS - SME is ready.
1234 * Other status means SME is failed to start
1235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301236QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301238 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001240 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241
1242 do {
1243 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301244 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001245 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 break;
1247 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001248 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001249 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001250 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1251 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1252 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1253 sme_cbacks.sme_soc_set_dual_mac_config =
1254 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001255 sme_cbacks.sme_change_mcc_beacon_interval =
1256 sme_change_mcc_beacon_interval;
1257 sme_cbacks.sme_get_ap_channel_from_scan =
1258 sme_get_ap_channel_from_scan;
1259 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001260 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1261 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001262 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001263 status);
1264 break;
1265 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001266 sme_register_spectral_cb(pMac);
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 }
Abhishek Singh20a8e442018-09-12 15:50:44 +05301325 case eWNI_SME_CSA_RESTART_RSP:
1326 {
1327 session_id = msg->bodyval;
1328 roam_status = 0;
1329 roam_result = eCSR_ROAM_RESULT_CSA_RESTART_RSP;
1330 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1331 "sapdfs: Received eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_REQ vdevid%d",
1332 session_id);
1333 break;
1334 }
Arif Hussaincd151632017-02-11 16:57:19 -08001335 default:
1336 {
1337 sme_err("Invalid DFS message: 0x%x", msg->type);
1338 status = QDF_STATUS_E_FAILURE;
1339 return status;
1340 }
1341 }
1342
1343 /* Indicate Radar Event to SAP */
1344 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1345 roam_status, roam_result);
1346 return status;
1347}
1348
1349
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301351/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 * Handle the unprotected management frame indication from LIM and
1353 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301354 */
Jeff Johnson2ef47442018-06-09 23:43:40 -07001355static QDF_STATUS
1356sme_unprotected_mgmt_frm_ind(tpAniSirGlobal mac,
1357 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301359 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001360 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1362
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001363 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1364 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1365 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366
1367 /* forward the mgmt frame to HDD */
Jeff Johnson2ef47442018-06-09 23:43:40 -07001368 csr_roam_call_callback(mac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1370
1371 return status;
1372}
1373#endif
1374
Kapil Gupta8878ad92017-02-13 11:56:04 +05301375QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1376{
1377 QDF_STATUS status = QDF_STATUS_SUCCESS;
1378 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001379 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301380 eRoamCmdStatus roamStatus;
1381 eCsrRoamResult roamResult;
1382
1383 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001384 if (!roamInfo) {
1385 sme_err("mem alloc failed for roam info");
1386 return QDF_STATUS_E_FAILURE;
1387 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301388 roamInfo->dfs_event.sessionId = session_id;
1389
1390 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1391 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301392 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301393 "sapdfs: Updated new channel event");
1394
1395 /* Indicate channel Event to SAP */
1396 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1397 roamStatus, roamResult);
1398
1399 qdf_mem_free(roamInfo);
1400 return status;
1401}
1402
1403
Abhishek Singh518323d2015-10-19 17:42:01 +05301404/**
1405 * sme_extended_change_channel_ind()- function to indicate ECSA
1406 * action frame is received in lim to SAP
1407 * @mac_ctx: pointer to global mac structure
1408 * @msg_buf: contain new channel and session id.
1409 *
1410 * This function is called to post ECSA action frame
1411 * receive event to SAP.
1412 *
1413 * Return: success if msg indicated to SAP else return failure
1414 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301415static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301416 void *msg_buf)
1417{
1418 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301419 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301420 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001421 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301422 eRoamCmdStatus roam_status;
1423 eCsrRoamResult roam_result;
1424
Abhishek Singh518323d2015-10-19 17:42:01 +05301425 ext_chan_ind = msg_buf;
1426 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001427 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301428 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301429 }
1430 session_id = ext_chan_ind->session_id;
1431 roamInfo.target_channel = ext_chan_ind->new_channel;
1432 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1433 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001434 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1435 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301436
1437 /* Indicate Ext Channel Change event to SAP */
1438 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1439 roam_status, roam_result);
1440 return status;
1441}
1442
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001443#ifdef FEATURE_WLAN_ESE
1444/**
1445 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1446 * @hHal: HAL handle
1447 * @sessionId: session id
1448 * @isEseIniFeatureEnabled: ese ini enabled
1449 *
1450 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1451 * isEseIniFeatureEnabled. This is a synchronous call
1452 *
1453 * Return: QDF_STATUS enumeration
1454 */
1455QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1456 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1457{
1458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301459 QDF_STATUS status;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001460
1461 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1462 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301463 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001464 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1465 __func__,
1466 pMac->roam.configParam.isEseIniFeatureEnabled,
1467 isEseIniFeatureEnabled);
1468 return QDF_STATUS_SUCCESS;
1469 }
1470
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001472 "%s: EseEnabled is changed from %d to %d", __func__,
1473 pMac->roam.configParam.isEseIniFeatureEnabled,
1474 isEseIniFeatureEnabled);
1475 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001476 csr_neighbor_roam_update_fast_roaming_enabled(
1477 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001478
1479 if (true == isEseIniFeatureEnabled)
1480 sme_update_fast_transition_enabled(hHal, true);
1481
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301482 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
1483 status = sme_acquire_global_lock(&pMac->sme);
1484 if (QDF_IS_STATUS_SUCCESS(status)) {
1485 csr_roam_offload_scan(pMac, sessionId,
1486 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1487 REASON_ESE_INI_CFG_CHANGED);
1488 sme_release_global_lock(&pMac->sme);
1489 } else {
1490 sme_err("Failed to acquire SME lock");
1491 return status;
1492 }
1493 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001494 return QDF_STATUS_SUCCESS;
1495}
1496
1497/**
1498 * sme_set_plm_request() - set plm request
1499 * @hHal: HAL handle
1500 * @pPlmReq: Pointer to input plm request
1501 *
1502 * Return: QDF_STATUS enumeration
1503 */
1504QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1505{
1506 QDF_STATUS status;
1507 bool ret = false;
1508 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001509 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001510 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001511 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301512 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1513 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001514
1515 status = sme_acquire_global_lock(&pMac->sme);
1516 if (!QDF_IS_STATUS_SUCCESS(status))
1517 return status;
1518
1519 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001520 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001521 sme_release_global_lock(&pMac->sme);
1522 return QDF_STATUS_E_FAILURE;
1523 }
1524
1525 if (!pSession->sessionActive) {
1526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1527 FL("Invalid Sessionid"));
1528 sme_release_global_lock(&pMac->sme);
1529 return QDF_STATUS_E_FAILURE;
1530 }
1531
1532 if (!pPlmReq->enable)
1533 goto send_plm_start;
1534 /* validating channel numbers */
1535 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1536 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1537 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001538 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1539 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001540 pPlmReq->plmChList[count])) {
1541 /* DFS channel is provided, no PLM bursts can be
1542 * transmitted. Ignoring these channels.
1543 */
1544 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301545 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001546 FL("DFS channel %d ignored for PLM"),
1547 pPlmReq->plmChList[count]);
1548 continue;
1549 }
1550 } else if (!ret) {
1551 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301552 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001553 FL("Unsupported channel %d ignored for PLM"),
1554 pPlmReq->plmChList[count]);
1555 continue;
1556 }
1557 ch_list[valid_count] = pPlmReq->plmChList[count];
1558 valid_count++;
1559 } /* End of for () */
1560
1561 /* Copying back the valid channel list to plm struct */
1562 qdf_mem_set((void *)pPlmReq->plmChList,
1563 pPlmReq->plmNumCh, 0);
1564 if (valid_count)
1565 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1566 valid_count);
1567 /* All are invalid channels, FW need to send the PLM
1568 * report with "incapable" bit set.
1569 */
1570 pPlmReq->plmNumCh = valid_count;
1571
1572send_plm_start:
1573 /* PLM START */
1574 msg.type = WMA_SET_PLM_REQ;
1575 msg.reserved = 0;
1576 msg.bodyptr = pPlmReq;
1577
gaurank kathpalia36b0c582018-08-28 17:45:43 +05301578 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_message(QDF_MODULE_ID_SME,
1579 QDF_MODULE_ID_WMA,
1580 QDF_MODULE_ID_WMA,
1581 &msg))) {
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001582 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1583 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1584 sme_release_global_lock(&pMac->sme);
1585 return QDF_STATUS_E_FAILURE;
1586 }
1587
1588 sme_release_global_lock(&pMac->sme);
1589 return status;
1590}
1591
1592/**
1593 * sme_tsm_ie_ind() - sme tsm ie indication
Jeff Johnson24e65b52018-06-10 08:45:26 -07001594 * @mac: Global mac context
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001595 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 *
1597 * Handle the tsm ie indication from LIM and forward it to HDD.
1598 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001599 * Return: QDF_STATUS enumeration
1600 */
Jeff Johnson24e65b52018-06-10 08:45:26 -07001601static QDF_STATUS sme_tsm_ie_ind(tpAniSirGlobal mac,
1602 tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301604 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001605 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301607
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001608 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1609 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1610 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 /* forward the tsm ie information to HDD */
Jeff Johnson24e65b52018-06-10 08:45:26 -07001612 csr_roam_call_callback(mac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301613 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 return status;
1615}
1616
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001617/**
1618 * sme_set_cckm_ie() - set cckm ie
1619 * @hHal: HAL handle
1620 * @sessionId: session id
1621 * @pCckmIe: Pointer to CCKM Ie
1622 * @cckmIeLen: Length of @pCckmIe
1623 *
1624 * Function to store the CCKM IE passed from supplicant and use
1625 * it while packing reassociation request.
1626 *
1627 * Return: QDF_STATUS enumeration
1628 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301629QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 uint8_t *pCckmIe, uint8_t cckmIeLen)
1631{
1632 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301633 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301634
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301636 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1638 sme_release_global_lock(&pMac->sme);
1639 }
1640 return status;
1641}
1642
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001643/**
1644 * sme_set_ese_beacon_request() - set ese beacon request
1645 * @hHal: HAL handle
1646 * @sessionId: session id
1647 * @pEseBcnReq: Ese beacon report
1648 *
1649 * function to set ESE beacon request parameters
1650 *
1651 * Return: QDF_STATUS enumeration
1652 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301653QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 const tCsrEseBeaconReq *pEseBcnReq)
1655{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001656 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1658 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1659 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1660 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301661 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1663
1664 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001665 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301666 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 }
1668
1669 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301670 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 sizeof(tCsrEseBeaconReq));
1672
1673 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301674 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001676 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301677 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 }
1679
1680 pSmeRrmContext->eseBcnReqInProgress = true;
1681
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001682 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683
1684 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1685 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301686 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 pSession->connectedProfile.bssid.bytes,
1688 sizeof(tSirMacAddr));
1689 pSmeBcnReportReq->channelInfo.channelNum = 255;
1690 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1691 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1692
1693 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1694 pBeaconReq =
1695 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1696 pSmeBcnReportReq->fMeasurementtype[counter] =
1697 pBeaconReq->scanMode;
1698 pSmeBcnReportReq->measurementDuration[counter] =
1699 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1700 pSmeBcnReportReq->channelList.channelNumber[counter] =
1701 pBeaconReq->channel;
1702 }
1703
1704 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1705
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301706 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 pSmeRrmContext->eseBcnReqInProgress = false;
1708
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301709 qdf_mem_free(pSmeBcnReportReq);
1710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 return status;
1712}
1713
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001714/**
1715 * sme_get_tsm_stats() - SME get tsm stats
1716 * @hHal: HAL handle
1717 * @callback: SME sends back the requested stats using the callback
1718 * @staId: The station ID for which the stats is requested for
1719 * @bssId: bssid
1720 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001721 * @tid: Traffic id
1722 *
1723 * API register a callback to get TSM Stats.
1724 *
1725 * Return: QDF_STATUS enumeration
1726 */
1727QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1728 tCsrTsmStatsCallback callback,
1729 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001730 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001731{
1732 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1733 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1734
1735 status = sme_acquire_global_lock(&pMac->sme);
1736 if (QDF_IS_STATUS_SUCCESS(status)) {
1737 status = csr_get_tsm_stats(pMac, callback,
1738 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001739 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001740 sme_release_global_lock(&pMac->sme);
1741 }
1742 return status;
1743}
1744
1745/**
1746 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1747 * @hHal: pointer HAL handle returned by mac_open
1748 * @sessionId: sme session id
1749 * @pChannelList: Output channel list
1750 * @numChannels: Output number of channels
1751 *
1752 * This routine is called to set ese roam scan channel list.
1753 * This is a synchronous call
1754 *
1755 * Return: QDF_STATUS
1756 */
1757QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1758 uint8_t sessionId,
1759 uint8_t *pChannelList,
1760 uint8_t numChannels)
1761{
1762 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1763 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001764 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1765 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001766 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1767 uint8_t newChannelList[128] = { 0 };
1768 uint8_t i = 0, j = 0;
1769
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001770 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1772 FL("Invalid sme session id: %d"), sessionId);
1773 return QDF_STATUS_E_INVAL;
1774 }
1775
1776 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1777 curchnl_list_info =
1778 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1779
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001780 status = sme_acquire_global_lock(&pMac->sme);
1781 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301782 sme_err("Failed to acquire SME lock");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001783 return status;
1784 }
1785 if (NULL != curchnl_list_info->ChannelList) {
1786 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1787 j += snprintf(oldChannelList + j,
1788 sizeof(oldChannelList) - j, "%d",
1789 curchnl_list_info->ChannelList[i]);
1790 }
1791 }
1792 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1793 pChannelList, numChannels,
1794 csr_get_current_band(hHal));
1795 if (QDF_IS_STATUS_SUCCESS(status)) {
1796 if (NULL != curchnl_list_info->ChannelList) {
1797 j = 0;
1798 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1799 j += snprintf(newChannelList + j,
1800 sizeof(newChannelList) - j, "%d",
1801 curchnl_list_info->ChannelList[i]);
1802 }
1803 }
1804 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1805 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1806 newChannelList, oldChannelList,
1807 pNeighborRoamInfo->neighborRoamState);
1808 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301809
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001810 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1811 csr_roam_offload_scan(pMac, sessionId,
1812 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1813 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301814
1815 sme_release_global_lock(&pMac->sme);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001816 return status;
1817}
1818
1819#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820
Jeff Johnson49c02f92016-10-07 10:29:09 -07001821static
Jeff Johnsonbfc58a12018-06-10 08:49:08 -07001822QDF_STATUS sme_ibss_peer_info_response_handler(tpAniSirGlobal pMac,
Jeff Johnson49c02f92016-10-07 10:29:09 -07001823 tpSirIbssGetPeerInfoRspParams
1824 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001825{
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001826 if (NULL == pMac) {
1827 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1828 "%s: pMac is null", __func__);
1829 return QDF_STATUS_E_FAILURE;
1830 }
1831 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1832 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1833 "%s: HDD callback is null", __func__);
1834 return QDF_STATUS_E_FAILURE;
1835 }
1836 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1837 &pIbssPeerInfoParams->
1838 ibssPeerInfoRspParams);
1839 return QDF_STATUS_SUCCESS;
1840}
1841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1844 * @mac: Global MAC pointer
1845 * @msg: Dual mac config response
1846 *
1847 * Processes the dual mac configuration response and invokes the HDD callback
1848 * to process further
1849 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301850static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 uint8_t *msg)
1852{
1853 tListElem *entry = NULL;
1854 tSmeCmd *command = NULL;
1855 bool found;
1856 dual_mac_cb callback = NULL;
1857 struct sir_dual_mac_config_resp *param;
1858
1859 param = (struct sir_dual_mac_config_resp *)msg;
1860 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001861 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 /* Not returning. Need to check if active command list
1863 * needs to be freed
1864 */
1865 }
1866
Krunal Sonia8270f52017-02-23 19:51:25 -08001867 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001869 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301870 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 }
1872
1873 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1874 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001875 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301876 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 }
1878
1879 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001880 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301881 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 }
1883
1884 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1885 if (callback) {
1886 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001887 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001889 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 callback(param->status,
1891 command->u.set_dual_mac_cmd.scan_config,
1892 command->u.set_dual_mac_cmd.fw_mode_config);
1893 }
1894 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001895 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 }
1897
Krunal Soni72dba662017-02-15 20:13:17 -08001898 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 if (found)
1900 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001901 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301903 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904}
1905
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001906/**
1907 * sme_process_antenna_mode_resp() - Process set antenna mode
1908 * response
1909 * @mac: Global MAC pointer
1910 * @msg: antenna mode response
1911 *
1912 * Processes the antenna mode response and invokes the HDD
1913 * callback to process further
1914 */
1915static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1916 uint8_t *msg)
1917{
1918 tListElem *entry;
1919 tSmeCmd *command;
1920 bool found;
Dundi Raviteja6bb9e322018-05-16 17:04:41 +05301921 void *context = NULL;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001922 antenna_mode_cb callback;
1923 struct sir_antenna_mode_resp *param;
1924
1925 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301926 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001927 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001928 /* Not returning. Need to check if active command list
1929 * needs to be freed
1930 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001931
Krunal Sonia8270f52017-02-23 19:51:25 -08001932 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001933 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001934 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001935 return QDF_STATUS_E_FAILURE;
1936 }
1937
1938 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1939 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001940 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001941 return QDF_STATUS_E_FAILURE;
1942 }
1943
1944 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001945 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001946 return QDF_STATUS_E_FAILURE;
1947 }
1948
Dundi Raviteja6bb9e322018-05-16 17:04:41 +05301949 context = command->u.set_antenna_mode_cmd.set_antenna_mode_ctx;
1950 callback = command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001951 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301952 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001953 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301954 else
Dundi Raviteja6bb9e322018-05-16 17:04:41 +05301955 callback(param->status, context);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001956 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001957 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001958 }
1959
Krunal Soni72dba662017-02-15 20:13:17 -08001960 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001961 if (found)
1962 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001963 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001964
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001965 return QDF_STATUS_SUCCESS;
1966}
1967
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07001968QDF_STATUS sme_process_msg(tpAniSirGlobal pMac, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301970 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301971 struct sir_peer_info *peer_stats;
1972 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973
1974 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001975 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 return status;
1977 }
1978 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301979 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001980 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301982 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 return status;
1984 }
1985 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001986 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301988 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 goto release_lock;
1990 }
1991 switch (pMsg->type) {
1992#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1996 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301997 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 break;
1999#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 case WNI_CFG_SET_CNF:
2001 case WNI_CFG_DNLD_CNF:
2002 case WNI_CFG_GET_RSP:
2003 case WNI_CFG_ADD_GRP_ADDR_CNF:
2004 case WNI_CFG_DEL_GRP_ADDR_CNF:
2005 break;
2006 case eWNI_SME_ADDTS_RSP:
2007 case eWNI_SME_DELTS_RSP:
2008 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 /* QoS */
2011 if (pMsg->bodyptr) {
2012#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2013 status = sme_qos_msg_processor(pMac, pMsg->type,
2014 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302015 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016#endif
2017 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002018 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 }
2020 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 case eWNI_SME_NEIGHBOR_REPORT_IND:
2022 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 if (pMsg->bodyptr) {
2024 status = sme_rrm_msg_processor(pMac, pMsg->type,
2025 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302026 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302028 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 }
2030 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 case eWNI_SME_ADD_STA_SELF_RSP:
2032 if (pMsg->bodyptr) {
2033 status = csr_process_add_sta_session_rsp(pMac,
2034 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302035 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002037 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 }
2039 break;
2040 case eWNI_SME_DEL_STA_SELF_RSP:
2041 if (pMsg->bodyptr) {
2042 status = csr_process_del_sta_session_rsp(pMac,
2043 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302044 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002046 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 }
2048 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2050 if (pMsg->bodyptr) {
2051 status = sme_handle_generic_change_country_code(
2052 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002055 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 }
2057 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059#ifdef WLAN_FEATURE_11W
2060 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2061 if (pMsg->bodyptr) {
2062 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302063 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002065 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 }
2067 break;
2068#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002069#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 case eWNI_SME_TSM_IE_IND:
2071 if (pMsg->bodyptr) {
2072 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302073 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002075 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 }
2077 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002078#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2080 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2081 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302082 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002084 case eWNI_SME_IBSS_PEER_INFO_RSP:
2085 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002086 sme_ibss_peer_info_response_handler(pMac,
2087 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002088 qdf_mem_free(pMsg->bodyptr);
2089 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002090 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002091 }
2092 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 case eWNI_SME_READY_TO_SUSPEND_IND:
2094 if (pMsg->bodyptr) {
2095 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302096 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002098 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 }
2100 break;
2101#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2102 case eWNI_SME_READY_TO_EXTWOW_IND:
2103 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002104 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302105 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002107 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 }
2109 break;
2110#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2112 case eWNI_SME_AUTO_SHUTDOWN_IND:
2113 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302114 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 FL("Auto shutdown notification"));
2116 pMac->sme.pAutoShutdownNotificationCb();
2117 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302118 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 break;
2120#endif
2121 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002122 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Abhishek Singh20a8e442018-09-12 15:50:44 +05302124 case eWNI_SME_CSA_RESTART_RSP:
Arif Hussaincd151632017-02-11 16:57:19 -08002125 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302126 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 break;
2128 case eWNI_SME_CHANNEL_CHANGE_RSP:
2129 if (pMsg->bodyptr) {
2130 status = sme_process_channel_change_resp(pMac,
2131 pMsg->type,
2132 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302133 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002135 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 }
2137 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 case eWNI_SME_STATS_EXT_EVENT:
Jeff Johnsonfdecd512018-06-10 09:18:32 -07002139 status = sme_stats_ext_event(pMac, pMsg->bodyptr);
2140 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 break;
Will Huang558f8082017-05-31 16:22:24 +08002142 case eWNI_SME_GET_PEER_INFO_IND:
2143 if (pMac->sme.pget_peer_info_ind_cb)
2144 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2145 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302146 if (pMsg->bodyptr) {
2147 peer_info_rsp = (struct sir_peer_info_resp *)
2148 (pMsg->bodyptr);
2149 peer_stats = (struct sir_peer_info *)
2150 (peer_info_rsp->info);
2151 if (peer_stats) {
2152 pMac->peer_rssi = peer_stats[0].rssi;
2153 pMac->peer_txrate = peer_stats[0].tx_rate;
2154 pMac->peer_rxrate = peer_stats[0].rx_rate;
2155 }
2156 }
Will Huang558f8082017-05-31 16:22:24 +08002157 qdf_mem_free(pMsg->bodyptr);
2158 break;
2159 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2160 if (pMac->sme.pget_peer_info_ext_ind_cb)
2161 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2162 pMac->sme.pget_peer_info_ext_cb_context);
2163 qdf_mem_free(pMsg->bodyptr);
2164 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 case eWNI_SME_CSA_OFFLOAD_EVENT:
2166 if (pMsg->bodyptr) {
2167 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302168 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 }
2170 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002171 case eWNI_SME_TSF_EVENT:
2172 if (pMac->sme.get_tsf_cb) {
2173 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2174 (struct stsf *)pMsg->bodyptr);
2175 }
2176 if (pMsg->bodyptr)
2177 qdf_mem_free(pMsg->bodyptr);
2178 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179#ifdef WLAN_FEATURE_NAN
2180 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302181 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2182 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 if (pMsg->bodyptr) {
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07002184 sme_nan_event(MAC_HANDLE(pMac), pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302185 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 }
2187 break;
2188#endif /* WLAN_FEATURE_NAN */
2189 case eWNI_SME_LINK_STATUS_IND:
2190 {
2191 tAniGetLinkStatus *pLinkStatus =
2192 (tAniGetLinkStatus *) pMsg->bodyptr;
2193 if (pLinkStatus) {
Jeff Johnsonca7a7162018-07-07 12:56:54 -07002194 if (pMac->sme.link_status_callback)
2195 pMac->sme.link_status_callback(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 pLinkStatus->linkStatus,
Jeff Johnsonca7a7162018-07-07 12:56:54 -07002197 pMac->sme.link_status_context);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302198
Jeff Johnsonca7a7162018-07-07 12:56:54 -07002199 pMac->sme.link_status_callback = NULL;
2200 pMac->sme.link_status_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302201 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 }
2203 break;
2204 }
2205 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302206 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2208 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 break;
2210 case eWNI_SME_SNR_IND:
2211 {
2212 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 if (pSnrReq) {
2215 if (pSnrReq->snrCallback) {
2216 ((tCsrSnrCallback)
2217 (pSnrReq->snrCallback))
2218 (pSnrReq->snr, pSnrReq->staId,
2219 pSnrReq->pDevContext);
2220 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302221 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 }
2223 break;
2224 }
2225#ifdef FEATURE_WLAN_EXTSCAN
2226 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
Jeff Johnson17b12392018-07-03 22:21:15 -07002227 if (pMac->sme.ext_scan_ind_cb)
2228 pMac->sme.ext_scan_ind_cb(pMac->hdd_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2230 pMsg->bodyptr);
2231 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002232 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 pMsg->type);
2234
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 break;
2237 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
Jeff Johnson17b12392018-07-03 22:21:15 -07002238 if (pMac->sme.ext_scan_ind_cb)
2239 pMac->sme.ext_scan_ind_cb(pMac->hdd_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 eSIR_EPNO_NETWORK_FOUND_IND,
2241 pMsg->bodyptr);
2242 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002243 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 pMsg->type);
2245
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302246 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 break;
2248#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 case eWNI_SME_SET_HW_MODE_RESP:
2250 if (pMsg->bodyptr) {
2251 status = sme_process_set_hw_mode_resp(pMac,
2252 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002255 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 }
2257 break;
2258 case eWNI_SME_HW_MODE_TRANS_IND:
2259 if (pMsg->bodyptr) {
2260 status = sme_process_hw_mode_trans_ind(pMac,
2261 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302262 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002264 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 }
2266 break;
2267 case eWNI_SME_NSS_UPDATE_RSP:
2268 if (pMsg->bodyptr) {
2269 status = sme_process_nss_update_resp(pMac,
2270 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302271 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002273 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 }
2275 break;
Nirav Shah575282c2018-07-08 22:48:00 +05302276#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302278 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 pMac->sme.ocb_set_config_callback(
2280 pMac->sme.ocb_set_config_context,
2281 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302282 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002283 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 pMac->sme.ocb_set_config_callback = NULL;
2285 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 break;
2288 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302289 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 pMac->sme.ocb_get_tsf_timer_callback(
2291 pMac->sme.ocb_get_tsf_timer_context,
2292 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302293 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002294 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2296 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302297 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 break;
2299 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302300 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 pMac->sme.dcc_get_stats_callback(
2302 pMac->sme.dcc_get_stats_context,
2303 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302304 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002305 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 pMac->sme.dcc_get_stats_callback = NULL;
2307 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302308 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 break;
2310 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302311 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 pMac->sme.dcc_update_ndl_callback(
2313 pMac->sme.dcc_update_ndl_context,
2314 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302315 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002316 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 pMac->sme.dcc_update_ndl_callback = NULL;
2318 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302319 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 break;
2321 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302322 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 pMac->sme.dcc_stats_event_callback(
2324 pMac->sme.dcc_stats_event_context,
2325 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302326 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002327 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302328 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 break;
Nirav Shah575282c2018-07-08 22:48:00 +05302330#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2332 if (pMsg->bodyptr) {
2333 status = sme_process_dual_mac_config_resp(pMac,
2334 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002337 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 }
gaurank kathpaliaebe3fc82018-05-07 09:39:46 +05302339 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2341 if (pMac->sme.set_thermal_level_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07002342 pMac->sme.set_thermal_level_cb(pMac->hdd_handle,
2343 pMsg->bodyval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302345 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2346 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302347 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302348 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002349 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2350 if (pMsg->bodyptr) {
2351 status = sme_process_antenna_mode_resp(pMac,
2352 pMsg->bodyptr);
2353 qdf_mem_free(pMsg->bodyptr);
2354 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002355 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002356 }
2357 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302358 case eWNI_SME_LOST_LINK_INFO_IND:
2359 if (pMac->sme.lost_link_info_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07002360 pMac->sme.lost_link_info_cb(pMac->hdd_handle,
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302361 (struct sir_lost_link_info *)pMsg->bodyptr);
2362 qdf_mem_free(pMsg->bodyptr);
2363 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302364 case eWNI_SME_RSO_CMD_STATUS_IND:
2365 if (pMac->sme.rso_cmd_status_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07002366 pMac->sme.rso_cmd_status_cb(pMac->hdd_handle,
2367 pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002368 qdf_mem_free(pMsg->bodyptr);
2369 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002370 case eWMI_SME_LL_STATS_IND:
2371 if (pMac->sme.link_layer_stats_ext_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07002372 pMac->sme.link_layer_stats_ext_cb(pMac->hdd_handle,
Zhang Qiana6e9c102016-12-22 16:47:24 +08002373 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302374 qdf_mem_free(pMsg->bodyptr);
2375 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302376 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2377 if (pMac->sme.bt_activity_info_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07002378 pMac->sme.bt_activity_info_cb(pMac->hdd_handle,
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302379 pMsg->bodyval);
2380 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 default:
2382
2383 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2384 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2385 /* CSR */
2386 if (pMsg->bodyptr) {
Jeff Johnsone0349a02018-06-10 11:31:06 -07002387 status = csr_msg_processor(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302388 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302389 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002390 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002392 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302394 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 }
2396 } /* switch */
2397release_lock:
2398 sme_release_global_lock(&pMac->sme);
2399 return status;
2400}
2401
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002402QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2403{
2404 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2405
2406 if (mac_ctx == NULL) {
2407 QDF_ASSERT(0);
2408 return QDF_STATUS_E_FAILURE;
2409 }
2410
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -07002411 return sme_process_msg(mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002412}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002413
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414/**
2415 * sme_process_nss_update_resp() - Process nss update response
2416 * @mac: Global MAC pointer
2417 * @msg: nss update response
2418 *
2419 * Processes the nss update response and invokes the HDD
2420 * callback to process further
2421 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302422static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423{
2424 tListElem *entry = NULL;
2425 tSmeCmd *command = NULL;
2426 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002427 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 struct sir_beacon_tx_complete_rsp *param;
2429
2430 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302431 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002432 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 /* Not returning. Need to check if active command list
2434 * needs to be freed
2435 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
Krunal Sonia8270f52017-02-23 19:51:25 -08002437 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002439 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302440 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 }
2442
2443 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2444 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002445 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302446 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 }
2448
2449 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002450 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302451 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452 }
2453
2454 callback = command->u.nss_update_cmd.nss_update_cb;
2455 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302456 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002457 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302458 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 callback(command->u.nss_update_cmd.context,
2460 param->tx_status,
2461 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302462 command->u.nss_update_cmd.next_action,
2463 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002465 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 }
2467
Krunal Soni72dba662017-02-15 20:13:17 -08002468 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 if (found) {
2470 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002471 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002473
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302474 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475}
2476
Jeff Johnson62cd6802018-07-20 12:38:25 -07002477QDF_STATUS sme_stop(mac_handle_t mac_handle)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478{
Jeff Johnson62cd6802018-07-20 12:38:25 -07002479 QDF_STATUS status;
2480 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
2481 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482
Jeff Johnson62cd6802018-07-20 12:38:25 -07002483 status = rrm_stop(mac);
2484 if (QDF_IS_STATUS_ERROR(status)) {
2485 ret_status = status;
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002486 sme_err("rrm_stop failed with status: %d", status);
2487 }
2488
Jeff Johnson62cd6802018-07-20 12:38:25 -07002489 status = csr_stop(mac);
2490 if (QDF_IS_STATUS_ERROR(status)) {
2491 ret_status = status;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002492 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494
Jeff Johnson62cd6802018-07-20 12:38:25 -07002495 mac->sme.state = SME_STATE_STOP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496
Jeff Johnson62cd6802018-07-20 12:38:25 -07002497 return ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498}
2499
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302500/*
2501 * sme_close() - Release all SME modules and their resources.
2502 * The function release each module in SME, PMC, CSR, etc. . Upon
2503 * return, all modules are at closed state.
2504 *
2505 * No SME APIs can be involved after smeClose except smeOpen.
2506 * smeClose must be called before mac_close.
2507 * This is a synchronous call
2508 *
2509 * hHal - The handle returned by mac_open
2510 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2511 *
2512 * Other status means SME is failed to be closed but caller still cannot
2513 * call any other SME functions except smeOpen.
2514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302515QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302517 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2518 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2520
2521 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302522 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523
2524 /* Note: pSession will be invalid from here on, do not access */
2525 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302526 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002527 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 fail_status = status;
2529 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2531 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302532 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002533 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 fail_status = status;
2535 }
2536#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302538 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002539 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 fail_status = status;
2541 }
2542
Jeff Johnson3639a642018-06-09 23:47:44 -07002543 status = rrm_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302544 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002545 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 fail_status = status;
2547 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 free_sme_cmd_list(pMac);
2550
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302552 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302553 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302555 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557
2558 pMac->sme.state = SME_STATE_STOP;
2559
2560 return status;
2561}
2562
2563/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302564 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2565 * scan list
2566 * @hal: hal context.
2567 * @bssid: bssid to be removed
2568 *
2569 * This function remove the given bssid from scan list.
2570 *
2571 * Return: QDF status.
2572 */
2573QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2574 tSirMacAddr bssid)
2575{
2576 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2577 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2578
2579 status = sme_acquire_global_lock(&mac_ctx->sme);
2580 if (QDF_IS_STATUS_SUCCESS(status)) {
2581 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2582 sme_release_global_lock(&mac_ctx->sme);
2583 }
2584
2585 return status;
2586}
2587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302589/*
2590 * sme_scan_get_result
2591 * A wrapper function to request scan results from CSR.
2592 * This is a synchronous call
2593 *
2594 * pFilter - If pFilter is NULL, all cached results are returned
2595 * phResult - an object for the result.
2596 * Return QDF_STATUS
2597 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302598QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 tCsrScanResultFilter *pFilter,
2600 tScanResultHandle *phResult)
2601{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302602 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2604
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302605 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2607 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302609 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnsonadf800d2018-06-10 18:00:00 -07002610 status = csr_scan_get_result(pMac, pFilter, phResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 sme_release_global_lock(&pMac->sme);
2612 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613
2614 return status;
2615}
2616
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302617QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2618 struct qdf_mac_addr *bssid,
2619 tCsrScanResultInfo *res)
2620{
2621 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2622 QDF_STATUS status;
2623
2624 status = sme_acquire_global_lock(&mac_ctx->sme);
2625 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson1b56f6b2018-06-10 18:17:10 -07002626 status = csr_scan_get_result_for_bssid(mac_ctx, bssid, res);
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302627 sme_release_global_lock(&mac_ctx->sme);
2628 }
2629
2630 return status;
2631}
2632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002634 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002635 * AP's channel id from
2636 * CSR by filtering the
2637 * result which matches
2638 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002639 * @profile: SAP profile
2640 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2641 * best ap from scan cache.
2642 *
2643 * This function is written to get AP's channel id from CSR by filtering
2644 * the result which matches our roam profile. This is a synchronous call.
2645 *
2646 * Return: QDF_STATUS.
2647 */
2648QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2649 tScanResultHandle *scan_cache,
2650 uint8_t *ap_chnl_id)
2651{
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002652 return sme_get_ap_channel_from_scan_cache((struct csr_roam_profile *)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002653 profile,
2654 scan_cache,
2655 ap_chnl_id);
2656}
2657
2658/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2660 * channel id from CSR by filtering the
2661 * result which matches our roam profile.
2662 * @profile: SAP adapter
2663 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2664 * best ap from scan cache.
2665 *
2666 * This function is written to get AP's channel id from CSR by filtering
2667 * the result which matches our roam profile. This is a synchronous call.
2668 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302669 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002671QDF_STATUS sme_get_ap_channel_from_scan_cache(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002672 struct csr_roam_profile *profile, tScanResultHandle *scan_cache,
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002673 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302675 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002676 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 tCsrScanResultFilter *scan_filter = NULL;
2678 tScanResultHandle filtered_scan_result = NULL;
2679 tSirBssDescription first_ap_profile;
2680
2681 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302682 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302684 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302686 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302688 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302690 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302691 }
2692 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2693 if (NULL == profile) {
2694 scan_filter->EncryptionType.numEntries = 1;
2695 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302697 } else {
2698 /* Here is the profile we need to connect to */
2699 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 profile,
2701 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302702 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302704 if (QDF_STATUS_SUCCESS == status) {
2705 /* Save the WPS info */
2706 if (NULL != profile) {
2707 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302709 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302712 scan_filter->bWPSAssociation = 0;
2713 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302715 } else {
2716 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2717 FL("Preparing the profile filter failed"));
2718 qdf_mem_free(scan_filter);
2719 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 }
2721 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302722 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002723 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302725 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2727 &first_ap_profile);
2728 *scan_cache = filtered_scan_result;
2729 if (0 != first_ap_profile.channelId) {
2730 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302731 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302732 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 FL("Found best AP & its on chnl[%d]"),
2734 first_ap_profile.channelId);
2735 } else {
2736 /*
2737 * This means scan result is empty
2738 * so set the channel to zero, caller should
2739 * take of zero channel id case.
2740 */
2741 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302742 QDF_TRACE(QDF_MODULE_ID_SME,
2743 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302745 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 }
2747 } else {
Sandeep Puligilla1f1e4002018-08-18 12:15:01 -07002748 sme_err("Failed to get scan get result");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302749 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 }
2751 csr_free_scan_filter(mac_ctx, scan_filter);
2752 sme_release_global_lock(&mac_ctx->sme);
2753 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002756 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302757 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302759 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 return status;
2761}
2762
2763/**
2764 * sme_store_joinreq_param() - This function will pass station's join
2765 * request to store to csr.
2766 * @hal_handle: pointer to hal context.
2767 * @profile: pointer to station's roam profile.
2768 * @scan_cache: pointer to station's scan cache.
2769 * @roam_id: reference to roam_id variable being passed.
2770 * @session_id: station's session id.
2771 *
2772 * This function will pass station's join request further down to csr
2773 * to store it. this stored parameter will be used later.
2774 *
2775 * Return: true or false based on function's overall success.
2776 **/
2777bool sme_store_joinreq_param(tHalHandle hal_handle,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002778 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 tScanResultHandle scan_cache,
2780 uint32_t *roam_id,
2781 uint32_t session_id)
2782{
2783 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302784 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 bool ret_status = true;
2786
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302787 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2789 session_id, 0));
2790 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302791 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002792 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302793 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 sme_release_global_lock(&mac_ctx->sme);
2796 } else {
2797 ret_status = false;
2798 }
2799
2800 return ret_status;
2801}
2802
2803/**
2804 * sme_clear_joinreq_param() - This function will pass station's clear
2805 * the join request to csr.
2806 * @hal_handle: pointer to hal context.
2807 * @session_id: station's session id.
2808 *
2809 * This function will pass station's clear join request further down to csr
2810 * to cleanup.
2811 *
2812 * Return: true or false based on function's overall success.
2813 **/
2814bool sme_clear_joinreq_param(tHalHandle hal_handle,
2815 uint32_t session_id)
2816{
2817 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302818 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 bool ret_status = true;
2820
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302821 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2823 session_id, 0));
2824 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302825 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302827 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 sme_release_global_lock(&mac_ctx->sme);
2830 } else {
2831 ret_status = false;
2832 }
2833
2834 return ret_status;
2835}
2836
2837/**
2838 * sme_issue_stored_joinreq() - This function will issues station's stored
2839 * the join request to csr.
2840 * @hal_handle: pointer to hal context.
2841 * @roam_id: reference to roam_id variable being passed.
2842 * @session_id: station's session id.
2843 *
2844 * This function will issue station's stored join request further down to csr
2845 * to proceed forward.
2846 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302847 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302849QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 uint32_t *roam_id,
2851 uint32_t session_id)
2852{
2853 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302854 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2855 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302857 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2859 session_id, 0));
2860 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302861 if (QDF_STATUS_SUCCESS == status) {
2862 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 roam_id,
2864 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302865 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 }
2867 sme_release_global_lock(&mac_ctx->sme);
2868 } else {
2869 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302870 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 }
2872 return ret_status;
2873}
2874
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302875/*
2876 * sme_scan_flush_result() -
2877 * A wrapper function to request CSR to clear scan results.
2878 * This is a synchronous call
2879 *
2880 * Return QDF_STATUS
2881 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302882QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302884 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2886
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302887 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2889 0, 0));
2890 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302891 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnsona1a36512018-06-10 18:20:55 -07002892 status = csr_scan_flush_result(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 sme_release_global_lock(&pMac->sme);
2894 }
2895
2896 return status;
2897}
2898
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302899/*
2900 * sme_filter_scan_results() -
2901 * A wrapper function to request CSR to clear scan results.
2902 * This is a synchronous call
2903 *
2904 * tHalHandle - HAL context handle
2905 * sessionId - session id
2906 * Return QDF_STATUS
2907 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302908QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2912
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302913 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2915 sessionId, 0));
2916 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302917 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 csr_scan_filter_results(pMac);
2919 sme_release_global_lock(&pMac->sme);
2920 }
2921
2922 return status;
2923}
2924
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302925QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302927 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2929
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302930 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2932 sessionId, 0));
2933 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302934 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson1d3f8672018-06-10 18:24:15 -07002935 status = csr_scan_flush_selective_result(pMac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 sme_release_global_lock(&pMac->sme);
2937 }
2938
2939 return status;
2940}
2941
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302942/*
2943 * sme_scan_result_get_first() -
2944 * A wrapper function to request CSR to returns the first element of
2945 * scan result.
2946 * This is a synchronous call
2947 *
2948 * hScanResult - returned from csr_scan_get_result
2949 * Return tCsrScanResultInfo * - NULL if no result
2950 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2952 tScanResultHandle hScanResult)
2953{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302954 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2956 tCsrScanResultInfo *pRet = NULL;
2957
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302958 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2960 NO_SESSION, 0));
2961 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302962 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 pRet = csr_scan_result_get_first(pMac, hScanResult);
2964 sme_release_global_lock(&pMac->sme);
2965 }
2966
2967 return pRet;
2968}
2969
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302970/*
2971 * sme_scan_result_get_next() -
2972 * A wrapper function to request CSR to returns the next element of
2973 * scan result. It can be called without calling csr_scan_result_get_first first
2974 * This is a synchronous call
2975 *
2976 * hScanResult - returned from csr_scan_get_result
2977 * Return Null if no result or reach the end
2978 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
2980 tScanResultHandle hScanResult)
2981{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2984 tCsrScanResultInfo *pRet = NULL;
2985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302987 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 pRet = csr_scan_result_get_next(pMac, hScanResult);
2989 sme_release_global_lock(&pMac->sme);
2990 }
2991
2992 return pRet;
2993}
2994
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302995/*
2996 * sme_scan_result_purge() -
2997 * A wrapper function to request CSR to remove all items(tCsrScanResult)
2998 * in the list and free memory for each item
2999 * This is a synchronous call
3000 *
3001 * hScanResult - returned from csr_scan_get_result. hScanResult is
3002 * considered gone by
3003 * calling this function and even before this function reutrns.
3004 * Return QDF_STATUS
3005 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003006QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303008 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003009 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303011 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3013 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003014 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303015 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003016 status = csr_scan_result_purge(mac_ctx, hScanResult);
3017 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 }
3019
3020 return status;
3021}
3022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3024{
3025 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 return pMac->roam.configParam.phyMode;
3028}
3029
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303030/*
jiadbdefb252018-01-03 14:27:06 +08003031 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303032 *
3033 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003034 * mode - channel bonding mode
3035 *
3036 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303037 */
jiadbdefb252018-01-03 14:27:06 +08003038QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039{
jiadbdefb252018-01-03 14:27:06 +08003040 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041
jiadbdefb252018-01-03 14:27:06 +08003042 if (!mode) {
3043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3044 "%s: invalid mode", __func__);
3045 return QDF_STATUS_E_FAILURE;
3046 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047
jiadbdefb252018-01-03 14:27:06 +08003048 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3049 if (!smeConfig) {
3050 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3051 "%s: failed to alloc smeConfig", __func__);
3052 return QDF_STATUS_E_NOMEM;
3053 }
3054
Jeff Johnson0a38afe2018-06-09 23:11:27 -07003055 if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) {
jiadbdefb252018-01-03 14:27:06 +08003056 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3057 "%s: sme_get_config_param failed", __func__);
3058 qdf_mem_free(smeConfig);
3059 return QDF_STATUS_E_FAILURE;
3060 }
3061
3062 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3063 qdf_mem_free(smeConfig);
3064
3065 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066}
3067
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303068/*
jiadbdefb252018-01-03 14:27:06 +08003069 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3070 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303071 *
3072 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003073 * mode - channel bonding mode
3074 *
3075 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303076 */
jiadbdefb252018-01-03 14:27:06 +08003077QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078{
jiadbdefb252018-01-03 14:27:06 +08003079 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080
jiadbdefb252018-01-03 14:27:06 +08003081 if (!mode) {
3082 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3083 "%s: invalid mode", __func__);
3084 return QDF_STATUS_E_FAILURE;
3085 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086
jiadbdefb252018-01-03 14:27:06 +08003087 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3088 if (!smeConfig) {
3089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3090 "%s: failed to alloc smeConfig", __func__);
3091 return QDF_STATUS_E_NOMEM;
3092 }
3093
Jeff Johnson0a38afe2018-06-09 23:11:27 -07003094 if (sme_get_config_param(hHal, smeConfig) != QDF_STATUS_SUCCESS) {
jiadbdefb252018-01-03 14:27:06 +08003095 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3096 "%s: sme_get_config_param failed", __func__);
3097 qdf_mem_free(smeConfig);
3098 return QDF_STATUS_E_FAILURE;
3099 }
3100
3101 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3102 qdf_mem_free(smeConfig);
3103
3104 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105}
3106
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303107/*
3108 * sme_roam_connect() -
3109 * A wrapper function to request CSR to inititiate an association
3110 * This is an asynchronous call.
3111 *
3112 * sessionId - the sessionId returned by sme_open_session.
3113 * pProfile - description of the network to which to connect
3114 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3115 * from csr_scan_get_result
3116 * pRoamId - to get back the request ID
3117 * Return QDF_STATUS
3118 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303119QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003120 struct csr_roam_profile *pProfile,
3121 uint32_t *pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303123 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3125
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303126 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303127 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303129 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303132 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3134 status =
3135 csr_roam_connect(pMac, sessionId, pProfile,
3136 pRoamId);
3137 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003138 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303139 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 }
3141 sme_release_global_lock(&pMac->sme);
3142 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003143 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144 }
3145
3146 return status;
3147}
3148
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303149/*
3150 * sme_set_phy_mode() -
3151 * Changes the PhyMode.
3152 *
3153 * hHal - The handle returned by mac_open.
3154 * phyMode new phyMode which is to set
3155 * Return QDF_STATUS SUCCESS.
3156 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303157QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158{
3159 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3160
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161 pMac->roam.configParam.phyMode = phyMode;
3162 pMac->roam.configParam.uCfgDot11Mode =
3163 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303164 pMac->roam.configParam.phyMode,
3165 pMac->roam.configParam.
3166 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303168 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169}
3170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303171/*
3172 * sme_roam_reassoc() -
3173 * A wrapper function to request CSR to inititiate a re-association
3174 *
3175 * pProfile - can be NULL to join the currently connected AP. In that
3176 * case modProfileFields should carry the modified field(s) which could trigger
3177 * reassoc
3178 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3179 * that might need modification dynamically once STA is up & running and this
3180 * could trigger a reassoc
3181 * pRoamId - to get back the request ID
3182 * Return QDF_STATUS
3183 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303184QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003185 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 tCsrRoamModifyProfileFields modProfileFields,
3187 uint32_t *pRoamId, bool fForce)
3188{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303189 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3191
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303192 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303195 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303197 if ((NULL == pProfile) && (fForce == 1))
3198 status = csr_reassoc(pMac, sessionId,
3199 &modProfileFields, pRoamId,
3200 fForce);
3201 else
3202 status = csr_roam_reassoc(pMac, sessionId,
3203 pProfile,
3204 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303206 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 }
3208 sme_release_global_lock(&pMac->sme);
3209 }
3210
3211 return status;
3212}
3213
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303214/*
3215 * sme_roam_connect_to_last_profile() -
3216 * A wrapper function to request CSR to disconnect and reconnect with
3217 * the same profile
3218 * This is an asynchronous call.
3219 *
3220 * Return QDF_STATUS. It returns fail if currently connected
3221 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303222QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303224 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3226
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303227 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3229 sessionId, 0));
3230 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303231 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303232 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3233 status = csr_roam_connect_to_last_profile(pMac,
3234 sessionId);
3235 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303236 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 sme_release_global_lock(&pMac->sme);
3238 }
3239
3240 return status;
3241}
3242
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003243QDF_STATUS sme_roam_disconnect(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 eCsrRoamDisconnectReason reason)
3245{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303246 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003247 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303249 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003250 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 reason));
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003252 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303253 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003254 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3255 status = csr_roam_disconnect(mac_ctx, session_id,
3256 reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303257 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303258 status = QDF_STATUS_E_INVAL;
Varun Reddy Yeturu363809c2018-06-27 14:12:52 -07003259 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 }
3261
3262 return status;
3263}
3264
Abhishek Singhca408032016-09-13 15:26:12 +05303265/* sme_dhcp_done_ind() - send dhcp done ind
3266 * @hal: hal context
3267 * @session_id: session id
3268 *
3269 * Return: void.
3270 */
3271void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3272{
3273 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303274 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303275
3276 if (!mac_ctx)
3277 return;
3278
3279 session = CSR_GET_SESSION(mac_ctx, session_id);
3280 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003281 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303282 return;
3283 }
3284 session->dhcp_done = true;
3285}
3286
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303287/*
3288 * sme_roam_stop_bss() -
3289 * To stop BSS for Soft AP. This is an asynchronous API.
3290 *
3291 * hHal - Global structure
3292 * sessionId - sessionId of SoftAP
3293 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3294 * actual results
3295 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303296QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303298 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3300
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))
3304 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303305 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303306 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303307 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 sme_release_global_lock(&pMac->sme);
3309 }
3310
3311 return status;
3312}
3313
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303314/**
3315 * sme_roam_disconnect_sta() - disassociate a station
3316 * @hHal: Global structure
3317 * @sessionId: SessionId of SoftAP
3318 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3319 *
3320 * To disassociate a station. This is an asynchronous API.
3321 *
3322 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3323 * be called to indicate actual result.
3324 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303325QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003326 struct csr_del_sta_params *p_del_sta_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303328 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3330
3331 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303332 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 return status;
3334 }
3335
3336 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303337 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303338 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303340 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303341 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303342 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 sme_release_global_lock(&pMac->sme);
3344 }
3345
3346 return status;
3347}
3348
3349/**
3350 * sme_roam_deauth_sta() - deauthenticate a station
3351 * @hHal: Global structure
3352 * @sessionId: SessionId of SoftAP
3353 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3354 *
3355 * To disassociate a station. This is an asynchronous API.
3356 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303357 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 * code on error. Roam callback will be called to indicate actual
3359 * result
3360 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303361QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003362 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303364 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3366
3367 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303368 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369 return status;
3370 }
3371
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303372 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303373 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3374 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303376 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303377 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 status =
3379 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3380 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303381 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303382 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 sme_release_global_lock(&pMac->sme);
3384 }
3385
3386 return status;
3387}
3388
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303389/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303390 * sme_roam_get_associated_stas() -
3391 * To probe the list of associated stations from various modules
3392 * of CORE stack.
3393 * This is an asynchronous API.
3394 *
3395 * sessionId - sessionId of SoftAP
3396 * modId - Module from whom list of associtated stations is
3397 * to be probed. If an invalid module is passed then
3398 * by default QDF_MODULE_ID_PE will be probed.
3399 * pUsrContext - Opaque HDD context
3400 * pfnSapEventCallback - Sap event callback in HDD
3401 * pAssocBuf - Caller allocated memory to be filled with associatd
3402 * stations info
3403 * Return QDF_STATUS
3404 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303405QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303406 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 void *pfnSapEventCallback,
3408 uint8_t *pAssocStasBuf)
3409{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303410 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3412
3413 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303414 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 return status;
3416 }
3417
3418 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303419 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303420 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303422 csr_roam_get_associated_stas(pMac, sessionId,
3423 modId,
3424 pUsrContext,
3425 pfnSapEventCallback,
3426 pAssocStasBuf);
3427 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303428 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 sme_release_global_lock(&pMac->sme);
3430 }
3431
3432 return status;
3433}
3434
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303435/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303436 * sme_roam_get_connect_state() -
3437 * A wrapper function to request CSR to return the current connect state
3438 * of Roaming
3439 * This is a synchronous call.
3440 *
3441 * Return QDF_STATUS
3442 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 eCsrConnectState *pState)
3445{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303446 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3448
3449 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303450 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303451 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3452 status = csr_roam_get_connect_state(pMac, sessionId,
3453 pState);
3454 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456 sme_release_global_lock(&pMac->sme);
3457 }
3458
3459 return status;
3460}
3461
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303462/*
3463 * sme_roam_get_connect_profile() -
3464 * A wrapper function to request CSR to return the current connect
3465 * profile. Caller must call csr_roam_free_connect_profile after it is done
3466 * and before reuse for another csr_roam_get_connect_profile call.
3467 * This is a synchronous call.
3468 *
3469 * pProfile - pointer to a caller allocated structure
3470 * tCsrRoamConnectedProfile
3471 * eturn QDF_STATUS. Failure if not connected
3472 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303473QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 tCsrRoamConnectedProfile *pProfile)
3475{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3478
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303479 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3481 sessionId, 0));
3482 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303483 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303484 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3485 status = csr_roam_get_connect_profile(pMac, sessionId,
3486 pProfile);
3487 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303488 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 sme_release_global_lock(&pMac->sme);
3490 }
3491
3492 return status;
3493}
3494
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003495/**
3496 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3497 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3498 *
3499 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3500 *
3501 * Return: none
3502 */
3503void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303505 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3507 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003508 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509}
3510
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303511/*
3512 * sme_roam_set_pmkid_cache() -
3513 * A wrapper function to request CSR to return the PMKID candidate list
3514 * This is a synchronous call.
3515
3516 * pPMKIDCache - caller allocated buffer point to an array of
3517 * tPmkidCacheInfo
3518 * numItems - a variable that has the number of tPmkidCacheInfo
3519 * allocated when retruning, this is either the number needed
3520 * or number of items put into pPMKIDCache
3521 * update_entire_cache - this bool value specifies if the entire pmkid
3522 * cache should be overwritten or should it be
3523 * updated entry by entry.
3524 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3525 * big enough and pNumItems has the number of
3526 * tPmkidCacheInfo.
3527 * \Note: pNumItems is a number of tPmkidCacheInfo,
3528 * not sizeof(tPmkidCacheInfo) * something
3529 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303530QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 tPmkidCacheInfo *pPMKIDCache,
3532 uint32_t numItems, bool update_entire_cache)
3533{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303534 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3536
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303537 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3539 numItems));
3540 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303541 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303542 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3543 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3544 pPMKIDCache,
3545 numItems, update_entire_cache);
3546 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303547 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 sme_release_global_lock(&pMac->sme);
3549 }
3550
3551 return status;
3552}
3553
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303555 tPmkidCacheInfo *pmksa,
3556 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303560
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303561 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303562 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3563 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303565 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303566 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303568 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303569 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303570 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 sme_release_global_lock(&pMac->sme);
3572 }
3573 return status;
3574}
3575
Abhinav Kumar7830d9c2018-06-27 17:57:48 +05303576#ifdef WLAN_FEATURE_ROAM_OFFLOAD
gaurank kathpalia99d06c12018-05-16 16:28:35 +05303577void sme_get_pmk_info(tHalHandle hal, uint8_t session_id,
3578 tPmkidCacheInfo *pmk_cache)
3579{
3580 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3581 QDF_STATUS status = sme_acquire_global_lock(&mac_ctx->sme);
3582
3583 if (QDF_IS_STATUS_SUCCESS(status)) {
3584 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3585 csr_get_pmk_info(mac_ctx, session_id, pmk_cache);
3586 sme_release_global_lock(&mac_ctx->sme);
3587 }
3588}
Abhinav Kumar7830d9c2018-06-27 17:57:48 +05303589#else
3590static inline
3591void sme_get_pmk_info(tHalHandle hal, uint8_t session_id,
3592 tPmkidCacheInfo *pmk_cache)
3593{}
3594#endif
3595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303597/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 * \fn sme_roam_set_psk_pmk
3599 * \brief a wrapper function to request CSR to save PSK/PMK
3600 * This is a synchronous call.
3601 * \param hHal - Global structure
3602 * \param sessionId - SME sessionId
3603 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3604 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3605 * connections. Need to pass this information to
3606 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303607 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 uint8_t *pPSK_PMK, size_t pmk_len)
3611{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303612 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303616 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303617 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3618 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303620 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303621 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 sme_release_global_lock(&pMac->sme);
3623 }
3624 return status;
3625}
3626#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627
Jeff Johnson0a078b52018-06-01 16:15:54 -07003628QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id,
3629 uint32_t *len, uint8_t *buf)
3630{
3631 QDF_STATUS status;
3632 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3633
3634 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003636 if (CSR_IS_SESSION_VALID(mac, session_id))
3637 status = csr_roam_get_wpa_rsn_req_ie(mac, session_id,
3638 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303639 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003641 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 }
3643
3644 return status;
3645}
3646
Jeff Johnson0a078b52018-06-01 16:15:54 -07003647QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id,
3648 uint32_t *len, uint8_t *buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649{
Jeff Johnson0a078b52018-06-01 16:15:54 -07003650 QDF_STATUS status;
3651 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652
Jeff Johnson0a078b52018-06-01 16:15:54 -07003653 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003655 if (CSR_IS_SESSION_VALID(mac, session_id))
3656 status = csr_roam_get_wpa_rsn_rsp_ie(mac, session_id,
3657 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303658 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003660 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
3662
3663 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664}
3665
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303666/*
3667 * sme_roam_get_num_pmkid_cache() -
3668 * A wrapper function to request CSR to return number of PMKID cache
3669 * entries
3670 * This is a synchronous call.
3671 *
3672 * Return uint32_t - the number of PMKID cache entries
3673 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3675{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303676 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3678 uint32_t numPmkidCache = 0;
3679
3680 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303681 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3683 numPmkidCache =
3684 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303685 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303686 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303687 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003688 sme_release_global_lock(&pMac->sme);
3689 }
3690
3691 return numPmkidCache;
3692}
3693
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303694/*
3695 * sme_roam_get_pmkid_cache() -
3696 * A wrapper function to request CSR to return PMKID cache from CSR
3697 * This is a synchronous call.
3698 *
3699 * pNum - caller allocated memory that has the space of the number of
3700 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3701 * needed or actually number in tPmkidCacheInfo.
3702 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3703 * any, upon return
3704 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3705 * big enough
3706 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303707QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303708 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303710 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3712
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303713 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3715 0));
3716 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303717 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303718 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3719 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303721 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303722 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 sme_release_global_lock(&pMac->sme);
3724 }
3725
3726 return status;
3727}
3728
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303729/*
3730 * sme_get_config_param() -
3731 * A wrapper function that HDD calls to get the global settings
3732 * currently maintained by CSR.
3733 * This is a synchronous call.
3734 *
3735 * pParam - caller allocated memory
3736 * Return QDF_STATUS
3737 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303738QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303740 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3742
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303743 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3745 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303746 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303748 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003749 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003750 sme_release_global_lock(&pMac->sme);
3751 return status;
3752 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303753 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003754 &pMac->rrm.rrmSmeContext.rrmConfig,
3755 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303756 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 sme_release_global_lock(&pMac->sme);
3758 }
3759
3760 return status;
3761}
3762
3763/**
3764 * sme_cfg_set_int() - Sets the cfg parameter value.
3765 * @hal: Handle to hal.
3766 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003767 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 *
3769 * This function sets the string value in cfg parameter.
3770 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303771 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303773QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774{
3775 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303776 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003778 if (QDF_STATUS_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780
3781 return status;
3782}
3783
3784/**
3785 * sme_cfg_set_str() - Sets the cfg parameter string.
3786 * @hal: Handle to hal.
3787 * @cfg_id: Configuration parameter ID.
3788 * @str: Pointer to the string buffer.
3789 * @length: Length of the string.
3790 *
3791 * This function sets the string value in cfg parameter.
3792 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303793 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303795QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 uint32_t length)
3797{
3798 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003801 if (QDF_STATUS_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303802 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803
3804 return status;
3805}
3806
3807/**
3808 * sme_cfg_get_int() - Gets the cfg parameter value.
3809 * @hal: Handle to hal.
3810 * @cfg_id: Configuration parameter ID.
3811 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003812 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813 *
3814 * This function gets the value of the cfg parameter.
3815 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303818QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819{
3820 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303821 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003823 if (QDF_STATUS_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303824 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825
3826 return status;
3827}
3828
3829/**
3830 * sme_cfg_get_str() - Gets the cfg parameter string.
3831 * @hal: Handle to hal.
3832 * @cfg_id: Configuration parameter ID.
3833 * @str: Pointer to the string buffer.
3834 * @length: Pointer to length of the string.
3835 *
3836 * This function gets the string value of the cfg parameter.
3837 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303838 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003839 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303840QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 uint32_t *length)
3842{
3843 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303844 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845
Jeff Johnsonc09caa42018-06-07 22:58:55 -07003846 if (QDF_STATUS_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303847 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848
3849 return status;
3850}
3851
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303852/*
3853 * sme_get_modify_profile_fields() -
3854 * HDD or SME - QOS calls this function to get the current values of
3855 * connected profile fields, changing which can cause reassoc.
3856 * This function must be called after CFG is downloaded and STA is in connected
3857 * state. Also, make sure to call this function to get the current profile
3858 * fields before calling the reassoc. So that pModifyProfileFields will have
3859 * all the latest values plus the one(s) has been updated as part of reassoc
3860 * request.
3861 *
3862 * pModifyProfileFields - pointer to the connected profile fields
3863 * changing which can cause reassoc
3864 * Return QDF_STATUS
3865 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303866QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 tCsrRoamModifyProfileFields *
3868 pModifyProfileFields)
3869{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303870 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3872
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303873 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3875 0));
3876 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303877 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303878 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3879 status = csr_get_modify_profile_fields(pMac, sessionId,
3880 pModifyProfileFields);
3881 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303882 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 sme_release_global_lock(&pMac->sme);
3884 }
3885
3886 return status;
3887}
3888
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303889/*
3890 * sme_set_dhcp_till_power_active_flag() -
3891 * Sets/Clears DHCP related flag to disable/enable auto PS
3892 *
3893 * hal - The handle returned by mac_open.
3894 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3896{
3897 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3898 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3899
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303900 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3902 flag));
3903 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3904 ps_global_info->remain_in_power_active_till_dhcp = flag;
3905}
3906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907#ifdef FEATURE_OEM_DATA_SUPPORT
3908/**
3909 * sme_register_oem_data_rsp_callback() - Register a routine of
3910 * type send_oem_data_rsp_msg
3911 * @h_hal: Handle returned by mac_open.
3912 * @callback: Callback to send response
3913 * to oem application.
3914 *
3915 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
3916 * callback function.
3917 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303918 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303920QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003921 sme_send_oem_data_rsp_msg callback)
3922{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303923 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
3925
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07003926 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927
3928 return status;
3929
3930}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303931
3932/**
3933 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
3934 * @h_hal: Handler return by mac_open
3935 * This function De-registers the OEM data response callback to SME
3936 *
3937 * Return: None
3938 */
3939void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
3940{
3941 tpAniSirGlobal pmac;
3942
3943 if (!h_hal) {
3944 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3945 FL("hHal is not valid"));
3946 return;
3947 }
3948 pmac = PMAC_STRUCT(h_hal);
3949
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07003950 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303951}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952
3953/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003954 * sme_oem_update_capability() - update UMAC's oem related capability.
3955 * @hal: Handle returned by mac_open
3956 * @oem_cap: pointer to oem_capability
3957 *
3958 * This function updates OEM capability to UMAC. Currently RTT
3959 * related capabilities are updated. More capabilities can be
3960 * added in future.
3961 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303962 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003963 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303964QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003965 struct sme_oem_capability *cap)
3966{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303967 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003968 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
3969 uint8_t *bytes;
3970
3971 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
3972
3973 if (cap->ftm_rr)
3974 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
3975 if (cap->lci_capability)
3976 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
3977
3978 return status;
3979}
3980
3981/**
3982 * sme_oem_get_capability() - get oem capability
3983 * @hal: Handle returned by mac_open
3984 * @oem_cap: pointer to oem_capability
3985 *
3986 * This function is used to get the OEM capability from UMAC.
3987 * Currently RTT related capabilities are received. More
3988 * capabilities can be added in future.
3989 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303990 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003991 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303992QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003993 struct sme_oem_capability *cap)
3994{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303995 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08003996 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
3997 uint8_t *bytes;
3998
3999 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4000
4001 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4002 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4003
4004 return status;
4005}
Naveen Rawat910726a2017-03-06 11:42:51 -08004006#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004007
4008/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 * sme_roam_set_key() - To set encryption key.
4010 * @hal: hal global context
4011 * @session_id: session id
4012 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4013 * @ptr_roam_id: Upon success return, this is the id caller can use to
4014 * identify the request in roamcallback
4015 *
4016 * This function should be called only when connected. This is an asynchronous
4017 * API.
4018 *
4019 * Return: Status of operation
4020 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304021QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4023{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304024 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4026 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304027 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4029
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304030 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 session_id, 0));
4032 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004033 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304034 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 }
4036 /*Once Setkey is done, we can go in BMPS */
4037 if (set_key->keyLength)
4038 ps_global_info->remain_in_power_active_till_dhcp = false;
4039
4040 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 return status;
4043
4044 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4045 if (ptr_roam_id)
4046 *ptr_roam_id = roam_id;
4047
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004048 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004050 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 session = CSR_GET_SESSION(mac_ctx, session_id);
4052 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004053 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304055 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 }
4057 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4058 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4059 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4060 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4061 set_key->encType)) {
4062 session->pCurRoamProfile->negotiatedUCEncryptionType =
4063 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4064 }
4065 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4066 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4067 set_key->encType)) {
4068 session->pCurRoamProfile->negotiatedUCEncryptionType =
4069 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4070 }
4071 }
4072 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4073 sme_release_global_lock(&mac_ctx->sme);
4074 return status;
4075}
4076
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304077/**
4078 * sme_roam_set_default_key_index - To set default wep key idx
4079 * @hal: pointer to hal handler
4080 * @session_id: session id
4081 * @default_idx: default wep key index
4082 *
4083 * This function prepares a message and post to WMA to set wep default
4084 * key index
4085 *
4086 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4087 */
4088QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4089 uint8_t default_idx)
4090{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004091 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304092 struct wep_update_default_key_idx *update_key;
4093
4094 update_key = qdf_mem_malloc(sizeof(*update_key));
4095 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004096 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304097 return QDF_STATUS_E_NOMEM;
4098 }
4099
4100 update_key->session_id = session_id;
4101 update_key->default_idx = default_idx;
4102
4103 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4104 msg.reserved = 0;
4105 msg.bodyptr = (void *)update_key;
4106
4107 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304108 scheduler_post_message(QDF_MODULE_ID_SME,
4109 QDF_MODULE_ID_WMA,
4110 QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004111 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304112 qdf_mem_free(update_key);
4113 return QDF_STATUS_E_FAILURE;
4114 }
4115
4116 return QDF_STATUS_SUCCESS;
4117}
4118
4119
Jeff Johnson8bd23352017-09-26 11:39:24 -07004120/**
4121 * sme_get_rssi() - API to retrieve current RSSI
4122 * @hHal: HAL handle for device
4123 * @callback: SME sends back the requested stats using the callback
4124 * @staId: The station ID for which the RSSI is requested for
4125 * @bssid: The bssid of the connected session
4126 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4127 * RSSI, do not hold up but return this value.
4128 * @pContext: user context to be passed back along with the callback
4129 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304130 * A wrapper function that client calls to register a callback to get RSSI
4131 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004132 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304133 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304134QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304135 tCsrRssiCallback callback, uint8_t staId,
4136 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004137 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304139 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4141
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304142 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4144 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304145 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 status = csr_get_rssi(pMac, callback,
4147 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004148 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 sme_release_global_lock(&pMac->sme);
4150 }
4151 return status;
4152}
4153
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304154/*
4155 * sme_get_snr() -
4156 * A wrapper function that client calls to register a callback to get SNR
4157 *
4158 * callback - SME sends back the requested stats using the callback
4159 * staId - The station ID for which the stats is requested for
4160 * pContext - user context to be passed back along with the callback
4161 * p_cds_context - cds context
4162 * \return QDF_STATUS
4163 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304164QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304166 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304168 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4170
4171 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304172 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4174 sme_release_global_lock(&pMac->sme);
4175 }
4176 return status;
4177}
4178
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004179#ifndef QCA_SUPPORT_CP_STATS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304180/*
4181 * sme_get_statistics() -
4182 * A wrapper function that client calls to register a callback to get
4183 * different PHY level statistics from CSR.
4184 *
4185 * requesterId - different client requesting for statistics,
4186 * HDD, UMA/GAN etc
4187 * statsMask - The different category/categories of stats requester
4188 * is looking for
4189 * callback - SME sends back the requested stats using the callback
4190 * periodicity - If requester needs periodic update in millisec, 0 means
4191 * it's an one time request
4192 * cache - If requester is happy with cached stats
4193 * staId - The station ID for which the stats is requested for
4194 * pContext - user context to be passed back along with the callback
4195 * sessionId - sme session interface
4196 * Return QDF_STATUS
4197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304198QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 eCsrStatsRequesterType requesterId,
4200 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004201 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304203 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304207 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304208 status = csr_get_statistics(pMac, requesterId, statsMask,
4209 callback, staId, pContext,
4210 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 sme_release_global_lock(&pMac->sme);
4212 }
4213
4214 return status;
4215
4216}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004217#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004219QDF_STATUS sme_get_link_status(mac_handle_t mac_handle,
4220 csr_link_status_callback callback,
4221 void *context, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304223 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004224 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
4225 tAniGetLinkStatus *msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004226 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004228 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304229 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004230 msg = qdf_mem_malloc(sizeof(*msg));
4231 if (!msg) {
4232 sme_err("Malloc failure");
4233 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304234 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 }
4236
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004237 msg->msgType = WMA_LINK_STATUS_GET_REQ;
4238 msg->msgLen = sizeof(*msg);
4239 msg->sessionId = session_id;
4240 mac->sme.link_status_context = context;
4241 mac->sme.link_status_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004243 message.type = WMA_LINK_STATUS_GET_REQ;
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004244 message.bodyptr = msg;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004245 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304247 status = scheduler_post_message(QDF_MODULE_ID_SME,
4248 QDF_MODULE_ID_WMA,
4249 QDF_MODULE_ID_WMA, &message);
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004250 if (QDF_IS_STATUS_ERROR(status)) {
4251 sme_err("post msg failed, %d", status);
4252 qdf_mem_free(msg);
4253 mac->sme.link_status_context = NULL;
4254 mac->sme.link_status_callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 }
4256
Jeff Johnsonca7a7162018-07-07 12:56:54 -07004257 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 }
4259
4260 return status;
4261}
4262
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304263/*
4264 * sme_get_country_code() -
4265 * To return the current country code. If no country code is applied,
4266 * default country code is used to fill the buffer.
4267 * If 11d supported is turned off, an error is return and the last
4268 * applied/default country code is used.
4269 * This is a synchronous API.
4270 *
4271 * pBuf - pointer to a caller allocated buffer for returned country code.
4272 * pbLen For input, this parameter indicates how big is the buffer.
4273 * Upon return, this parameter has the number of bytes for
4274 * country. If pBuf doesn't have enough space, this function
4275 * returns fail status and this parameter contains the number
4276 * that is needed.
4277 *
4278 * Return QDF_STATUS SUCCESS.
4279 *
4280 * FAILURE or RESOURCES The API finished and failed.
4281 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304282QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283{
4284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4285
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304286 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4288
4289 return csr_get_country_code(pMac, pBuf, pbLen);
4290}
4291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292/* some support functions */
4293bool sme_is11d_supported(tHalHandle hHal)
4294{
4295 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4296
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004297 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298}
4299
4300bool sme_is11h_supported(tHalHandle hHal)
4301{
4302 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4303
4304 return csr_is11h_supported(pMac);
4305}
4306
4307bool sme_is_wmm_supported(tHalHandle hHal)
4308{
4309 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4310
4311 return csr_is_wmm_supported(pMac);
4312}
4313
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304314/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304315 * sme_generic_change_country_code() -
4316 * Change Country code from upperlayer during WLAN driver operation.
4317 * This is a synchronous API.
4318 *
4319 * hHal - The handle returned by mac_open.
4320 * pCountry New Country Code String
4321 * reg_domain regulatory domain
4322 * Return QDF_STATUS SUCCESS.
4323 * FAILURE or RESOURCES The API finished and failed.
4324 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304325QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004326 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304328 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004330 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 tAniGenericChangeCountryCodeReq *pMsg;
4332
4333 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304334 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 "%s: pMac is null", __func__);
4336 return status;
4337 }
4338
4339 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304340 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304341 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
4343 if (NULL == pMsg) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304345 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 }
4347
4348 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4349 pMsg->msgLen =
4350 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304351 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004352 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353
4354 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4355 msg.bodyptr = pMsg;
4356 msg.reserved = 0;
4357
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304358 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304359 scheduler_post_message(QDF_MODULE_ID_SME,
4360 QDF_MODULE_ID_SME,
4361 QDF_MODULE_ID_SME, &msg)) {
4362 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304363 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304364 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 sme_release_global_lock(&pMac->sme);
4367 }
4368
4369 return status;
4370}
4371
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304372/*
4373 * sme_dhcp_start_ind() -
4374 * API to signal the FW about the DHCP Start event.
4375 *
4376 * hHal - HAL handle for device.
4377 * device_mode - mode(AP,SAP etc) of the device.
4378 * macAddr - MAC address of the adapter.
4379 * sessionId - session ID.
4380 * Return QDF_STATUS SUCCESS.
4381 * FAILURE or RESOURCES The API finished and failed.
4382 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304383QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 uint8_t device_mode,
4385 uint8_t *macAddr, uint8_t sessionId)
4386{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304387 QDF_STATUS status;
4388 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004390 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304392 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393
4394 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304395 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 pSession = CSR_GET_SESSION(pMac, sessionId);
4397
4398 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004399 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304401 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 }
Arif Hussain3316f402016-11-10 13:08:03 -08004403 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304405 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304407 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 "%s: Not able to allocate memory for dhcp start",
4409 __func__);
4410 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304411 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 }
4413 pMsg->msgType = WMA_DHCP_START_IND;
4414 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4415 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304416 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304417 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304418 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004419 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004421 message.type = WMA_DHCP_START_IND;
4422 message.bodyptr = pMsg;
4423 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304424 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004425 sessionId, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304426 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
4427 QDF_MODULE_ID_WMA,
4428 QDF_MODULE_ID_WMA,
4429 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304430 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304431 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304433 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 }
4436 sme_release_global_lock(&pMac->sme);
4437 }
4438 return status;
4439}
4440
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304441/*
4442 * sme_dhcp_stop_ind() -
4443 * API to signal the FW about the DHCP complete event.
4444 *
4445 * hHal - HAL handle for device.
4446 * device_mode - mode(AP, SAP etc) of the device.
4447 * macAddr - MAC address of the adapter.
4448 * sessionId - session ID.
4449 * Return QDF_STATUS SUCCESS.
4450 * FAILURE or RESOURCES The API finished and failed.
4451 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304452QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 uint8_t device_mode,
4454 uint8_t *macAddr, uint8_t sessionId)
4455{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304456 QDF_STATUS status;
4457 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004459 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304461 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
4463 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304464 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 pSession = CSR_GET_SESSION(pMac, sessionId);
4466
4467 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004468 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304470 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 }
Arif Hussain3316f402016-11-10 13:08:03 -08004472 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304474 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304476 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 "%s: Not able to allocate memory for dhcp stop",
4478 __func__);
4479 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304480 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 }
4482
4483 pMsg->msgType = WMA_DHCP_STOP_IND;
4484 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4485 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304486 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304487 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304488 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004489 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004491 message.type = WMA_DHCP_STOP_IND;
4492 message.bodyptr = pMsg;
4493 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304494 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004495 sessionId, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304496 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
4497 QDF_MODULE_ID_WMA,
4498 QDF_MODULE_ID_WMA,
4499 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304500 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304501 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304504 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 }
4506
4507 sme_release_global_lock(&pMac->sme);
4508 }
4509 return status;
4510}
4511
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304512/*
4513 * sme_TXFailMonitorStopInd() -
4514 * API to signal the FW to start monitoring TX failures
4515 *
4516 * Return QDF_STATUS SUCCESS.
4517 * FAILURE or RESOURCES The API finished and failed.
4518 */
4519QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4520 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004521 void *txFailIndCallback)
4522{
4523 QDF_STATUS status;
4524 QDF_STATUS qdf_status;
4525 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004526 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004527 tAniTXFailMonitorInd *pMsg;
4528
4529 status = sme_acquire_global_lock(&pMac->sme);
4530 if (QDF_STATUS_SUCCESS == status) {
4531 pMsg = (tAniTXFailMonitorInd *)
4532 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4533 if (NULL == pMsg) {
4534 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4535 "%s: Failed to allocate memory", __func__);
4536 sme_release_global_lock(&pMac->sme);
4537 return QDF_STATUS_E_NOMEM;
4538 }
4539
4540 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4541 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4542
4543 /* tx_fail_count = 0 should disable the Monitoring in FW */
4544 pMsg->tx_fail_count = tx_fail_count;
4545 pMsg->txFailIndCallback = txFailIndCallback;
4546
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004547 message.type = WMA_TX_FAIL_MONITOR_IND;
4548 message.bodyptr = pMsg;
4549 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004550
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304551 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
4552 QDF_MODULE_ID_WMA,
4553 QDF_MODULE_ID_WMA,
4554 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004555 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4556 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4557 "%s: Post TX Fail monitor Start MSG fail",
4558 __func__);
4559 qdf_mem_free(pMsg);
4560 status = QDF_STATUS_E_FAILURE;
4561 }
4562 sme_release_global_lock(&pMac->sme);
4563 }
4564 return status;
4565}
4566
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304567/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304568 * sme_neighbor_report_request() -
4569 * API to request neighbor report.
4570 *
4571 * hHal - The handle returned by mac_open.
4572 * pRrmNeighborReq - Pointer to a caller allocated object of type
4573 * tRrmNeighborReq. Caller owns the memory and is
4574 * responsible for freeing it.
4575 * Return QDF_STATUS
4576 * QDF_STATUS_E_FAILURE - failure
4577 * QDF_STATUS_SUCCESS success
4578 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304579QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304581 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304583 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304585
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304586 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4588 0));
4589
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304590 if (pRrmNeighborReq->neighbor_report_offload) {
4591 status = csr_invoke_neighbor_report_request(sessionId,
4592 pRrmNeighborReq,
4593 false);
4594 return status;
4595 }
4596
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304597 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 status =
Jeff Johnsoned3de522018-06-10 18:27:51 -07004599 sme_rrm_neighbor_report_request(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304600 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 sme_release_global_lock(&pMac->sme);
4602 }
4603
4604 return status;
4605}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304607/*
4608 * sme_get_wcnss_wlan_compiled_version() -
4609 * This API returns the version of the WCNSS WLAN API with
4610 * which the HOST driver was built
4611 *
4612 * hHal - The handle returned by mac_open.
4613 * pVersion - Points to the Version structure to be filled
4614 * Return QDF_STATUS
4615 * QDF_STATUS_E_INVAL - failure
4616 * QDF_STATUS_SUCCESS success
4617 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304618QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 tSirVersionType *pVersion)
4620{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304621 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304624 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304626 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304628 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629
4630 sme_release_global_lock(&pMac->sme);
4631 }
4632
4633 return status;
4634}
4635
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304636/*
4637 * sme_get_wcnss_wlan_reported_version() -
4638 * This API returns the version of the WCNSS WLAN API with
4639 * which the WCNSS driver reports it was built
4640 * hHal - The handle returned by mac_open.
4641 * pVersion - Points to the Version structure to be filled
4642 * Return QDF_STATUS
4643 * QDF_STATUS_E_INVAL - failure
4644 * QDF_STATUS_SUCCESS success
4645 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 tSirVersionType *pVersion)
4648{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304649 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4651
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304654 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304656 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657
4658 sme_release_global_lock(&pMac->sme);
4659 }
4660
4661 return status;
4662}
4663
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304664/*
4665 * sme_get_wcnss_software_version() -
4666 * This API returns the version string of the WCNSS driver
4667 *
4668 * hHal - The handle returned by mac_open.
4669 * pVersion - Points to the Version string buffer to be filled
4670 * versionBufferSize - THe size of the Version string buffer
4671 * Return QDF_STATUS
4672 * QDF_STATUS_E_INVAL - failure
4673 * QDF_STATUS_SUCCESS success
4674 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304675QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 uint8_t *pVersion,
4677 uint32_t versionBufferSize)
4678{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304682 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304683 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004685 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 pVersion,
4687 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304688 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 sme_release_global_lock(&pMac->sme);
4691 }
4692
4693 return status;
4694}
4695
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304696/*
4697 * sme_get_wcnss_hardware_version() -
4698 * This API returns the version string of the WCNSS hardware
4699 *
4700 * hHal - The handle returned by mac_open.
4701 * pVersion - Points to the Version string buffer to be filled
4702 * versionBufferSize - THe size of the Version string buffer
4703 * Return QDF_STATUS
4704 * QDF_STATUS_E_INVAL - failure
4705 * QDF_STATUS_SUCCESS success
4706 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304707QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 uint8_t *pVersion,
4709 uint32_t versionBufferSize)
4710{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304711 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4713
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304714 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304716 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304718 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719
4720 sme_release_global_lock(&pMac->sme);
4721 }
4722
4723 return status;
4724}
4725
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004727/**
4728 * sme_oem_data_req() - send oem data request to WMA
4729 * @hal: HAL handle
4730 * @hdd_oem_req: OEM data request from HDD
4731 *
4732 * Return: QDF_STATUS
4733 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004734QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304736 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004737 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004738 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004740 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004741 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4742 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004743 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004744 return QDF_STATUS_E_FAILURE;
4745 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004747 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
4748 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004749 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004750 return QDF_STATUS_E_NOMEM;
4751 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004753 oem_data_req->data_len = hdd_oem_req->data_len;
4754 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
4755 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004756 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004757 return QDF_STATUS_E_NOMEM;
4758 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004760 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
4761 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004762
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004763 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304765 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004766 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304767 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004768 sme_debug("OEM request(length: %d) sent to WMA",
4769 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004770
4771 if (oem_data_req->data_len)
4772 qdf_mem_free(oem_data_req->data);
4773 qdf_mem_free(oem_data_req);
4774
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004775 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 return status;
4777}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778#endif /*FEATURE_OEM_DATA_SUPPORT */
4779
Krunal Soni8d184fa2017-11-20 21:52:05 -08004780QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781{
Arif Hussainee677012017-01-26 17:50:13 -08004782 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004783 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08004784 struct cdp_pdev *pdev;
4785 ol_txrx_peer_handle peer;
4786 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07004787 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304789 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07004790 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08004791 __func__, params->type_of_persona,
4792 params->sme_session_id, params->subtype_of_persona,
4793 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794
Arif Hussainee677012017-01-26 17:50:13 -08004795 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4796
4797 if (NULL == pdev) {
4798 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4799 "%s: Failed to get pdev handler", __func__);
4800 return status;
4801 }
4802
Krunal Soni8d184fa2017-11-20 21:52:05 -08004803 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004804 if (QDF_IS_STATUS_ERROR(status))
4805 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004806
Krunal Soni8d184fa2017-11-20 21:52:05 -08004807 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
4808 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08004809 if (peer) {
4810 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4811 "%s: Peer=%d exist with same MAC",
4812 __func__, peer_id);
4813 status = QDF_STATUS_E_INVAL;
4814 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004815 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08004816 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08004817 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004818
4819 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004820 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821
4822 return status;
4823}
4824
Krunal Soni8d184fa2017-11-20 21:52:05 -08004825QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304827 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004828 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304830 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004831 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304833 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004834 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 sme_release_global_lock(&pMac->sme);
4836 }
4837
4838 return status;
4839}
4840
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304841/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304842 * sme_change_mcc_beacon_interval() -
4843 * To update P2P-GO beaconInterval. This function should be called after
4844 * disassociating all the station is done
4845 * This is an asynchronous API.
4846 *
4847 * @sessionId: Session Identifier
4848 * Return QDF_STATUS SUCCESS
4849 * FAILURE or RESOURCES
4850 * The API finished and failed.
4851 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004852QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304854 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004855 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856
Krunal Soni3fa80e22018-01-09 14:16:02 -08004857 if (!mac_ctx) {
4858 sme_err("mac_ctx is NULL");
4859 return status;
4860 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004861 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304862 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004863 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
4864 sessionId);
4865 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 }
4867 return status;
4868}
4869
4870/**
4871 * sme_set_host_offload(): API to set the host offload feature.
4872 * @hHal: The handle returned by mac_open.
4873 * @sessionId: Session Identifier
4874 * @request: Pointer to the offload request.
4875 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304876 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304878QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879 tpSirHostOffloadReq request)
4880{
4881 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304882 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304884 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
4886 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304887 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888#ifdef WLAN_NS_OFFLOAD
4889 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
4890 status = sme_set_ps_ns_offload(hHal, request,
4891 sessionId);
4892 } else
4893#endif /* WLAN_NS_OFFLOAD */
4894 {
4895 status = sme_set_ps_host_offload(hHal, request,
4896 sessionId);
4897 }
4898 sme_release_global_lock(&pMac->sme);
4899 }
4900
4901 return status;
4902}
4903
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304904/*
4905 * sme_set_keep_alive() -
4906 * API to set the Keep Alive feature.
4907 *
4908 * hHal - The handle returned by mac_open.
4909 * request - Pointer to the Keep Alive request.
4910 * Return QDF_STATUS
4911 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304912QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 tpSirKeepAliveReq request)
4914{
4915 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004916 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304918 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304920 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 FL("WMA_SET_KEEP_ALIVE message"));
4922
4923 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304924 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304926 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304928 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304930 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304931 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304932 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 }
4934
Anurag Chouhanc5548422016-02-24 18:33:27 +05304935 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304936 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304938 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 "buff TP %d input TP %d ", request_buf->timePeriod,
4940 request->timePeriod);
4941 request_buf->sessionId = session_id;
4942
4943 msg.type = WMA_SET_KEEP_ALIVE;
4944 msg.reserved = 0;
4945 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304946 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
4947 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304948 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +05304949 scheduler_post_message(QDF_MODULE_ID_SME,
4950 QDF_MODULE_ID_WMA,
4951 QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304952 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304953 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304954 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304955 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004956 }
4957
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959}
4960
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304961/*
4962 * sme_get_operation_channel() -
4963 * API to get current channel on which STA is parked his function gives
4964 * channel information only of infra station or IBSS station
4965 *
4966 * hHal, pointer to memory location and sessionId
4967 * Returns QDF_STATUS_SUCCESS
4968 * QDF_STATUS_E_FAILURE
4969 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304970QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 uint8_t sessionId)
4972{
4973 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304974 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975
4976 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
4977 pSession = CSR_GET_SESSION(pMac, sessionId);
4978
4979 if ((pSession->connectedProfile.BSSType ==
4980 eCSR_BSS_TYPE_INFRASTRUCTURE)
4981 || (pSession->connectedProfile.BSSType ==
4982 eCSR_BSS_TYPE_IBSS)
4983 || (pSession->connectedProfile.BSSType ==
4984 eCSR_BSS_TYPE_INFRA_AP)
4985 || (pSession->connectedProfile.BSSType ==
4986 eCSR_BSS_TYPE_START_IBSS)) {
4987 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304988 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 }
4990 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304991 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992} /* sme_get_operation_channel ends here */
4993
Abhishek Singh7996eb72015-12-30 17:24:02 +05304994/**
4995 * sme_register_mgmt_frame_ind_callback() - Register a callback for
4996 * management frame indication to PE.
4997 *
4998 * @hal: hal pointer
4999 * @callback: callback pointer to be registered
5000 *
5001 * This function is used to register a callback for management
5002 * frame indication to PE.
5003 *
5004 * Return: Success if msg is posted to PE else Failure.
5005 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305006QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305007 sir_mgmt_frame_ind_callback callback)
5008{
5009 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5010 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305011 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305012
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305014 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305015 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305016 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005017 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305018 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305019 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305020 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305021 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5022 msg->length = sizeof(*msg);
5023
5024 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005025 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305026 sme_release_global_lock(&mac_ctx->sme);
5027 return status;
5028 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305029 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305030}
5031
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305032/*
5033 * sme_RegisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005034 * To register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305035 *
5036 * frameType - type of the frame that needs to be passed to HDD.
5037 * matchData - data which needs to be matched before passing frame
5038 * to HDD.
5039 * matchDataLen - Length of matched data.
5040 * Return QDF_STATUS
5041 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305042QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043 uint16_t frameType, uint8_t *matchData,
5044 uint16_t matchLen)
5045{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305046 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305050 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005051 tSirRegisterMgmtFrame *pMsg;
5052 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305053 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5054 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055
5056 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005057 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305059 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 }
5061
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305062 if (!CSR_IS_SESSION_ANY(sessionId) &&
5063 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005065 "%s Invalid Sessionid", __func__);
5066 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305067 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068 }
5069
5070 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305072 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305074 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5077 pMsg->length = len;
5078 pMsg->sessionId = sessionId;
5079 pMsg->registerFrame = true;
5080 pMsg->frameType = frameType;
5081 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305082 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005083 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 }
5085 sme_release_global_lock(&pMac->sme);
5086 }
5087 return status;
5088}
5089
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305090/*
5091 * sme_DeregisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005092 * To De-register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305093 *
5094 * frameType - type of the frame that needs to be passed to HDD.
5095 * matchData - data which needs to be matched before passing frame
5096 * to HDD.
5097 * matchDataLen - Length of matched data.
5098 * Return QDF_STATUS
5099 */
5100QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101 uint16_t frameType, uint8_t *matchData,
5102 uint16_t matchLen)
5103{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305104 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005105 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5106
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305107 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5109 0));
5110 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305111 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 tSirRegisterMgmtFrame *pMsg;
5113 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305114 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5115 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116
5117 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005118 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305120 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 }
5122
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305123 if (!CSR_IS_SESSION_ANY(sessionId) &&
5124 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126 "%s Invalid Sessionid", __func__);
5127 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305128 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 }
5130
5131 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5132
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305133 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305135 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5138 pMsg->length = len;
5139 pMsg->registerFrame = false;
5140 pMsg->frameType = frameType;
5141 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305142 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005143 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 }
5145 sme_release_global_lock(&pMac->sme);
5146 }
5147 return status;
5148}
5149
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305150/**
5151 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5152 * @hal: The handle returned by mac_open
5153 * @session_id: session id
5154 * @buf: pointer to frame
5155 * @len: frame length
5156 *
5157 * Return: QDF_STATUS
5158 */
5159static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5160 const uint8_t *buf, uint32_t len)
5161{
5162 QDF_STATUS status = QDF_STATUS_SUCCESS;
5163 struct sir_mgmt_msg *msg;
5164 uint16_t msg_len;
5165 struct scheduler_msg sch_msg = {0};
5166
5167 sme_debug("prepares auth frame");
5168
5169 msg_len = sizeof(*msg) + len;
5170 msg = qdf_mem_malloc(msg_len);
5171 if (msg == NULL) {
5172 status = QDF_STATUS_E_NOMEM;
5173 } else {
5174 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5175 msg->msg_len = msg_len;
5176 msg->session_id = session_id;
5177 msg->data = (uint8_t *)msg + sizeof(*msg);
5178 qdf_mem_copy(msg->data, buf, len);
5179
5180 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5181 sch_msg.bodyptr = msg;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305182 status = scheduler_post_message(QDF_MODULE_ID_SME,
5183 QDF_MODULE_ID_PE,
5184 QDF_MODULE_ID_PE, &sch_msg);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305185 }
5186 return status;
5187}
5188
5189QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5190 const uint8_t *buf, uint32_t len)
5191{
5192 QDF_STATUS status = QDF_STATUS_SUCCESS;
5193 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5194
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305195 status = sme_acquire_global_lock(&mac->sme);
5196 if (QDF_IS_STATUS_SUCCESS(status)) {
5197 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5198 sme_release_global_lock(&mac->sme);
5199 }
5200
5201 return status;
5202}
5203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005204#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005205/**
5206 * sme_configure_ext_wow() - configure Extr WoW
5207 * @hHal - The handle returned by mac_open.
5208 * @wlanExtParams - Depicts the wlan Ext params.
5209 * @callback - ext_wow callback to be registered.
5210 * @callback_context - ext_wow callback context
5211 *
5212 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305213 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005214 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305215QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 tpSirExtWoWParams wlanExtParams,
5217 csr_readyToExtWoWCallback callback,
5218 void *callback_context)
5219{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305220 QDF_STATUS status = QDF_STATUS_SUCCESS;
5221 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005223 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305224 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005225
5226 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305227 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305229 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5231
5232 pMac->readyToExtWoWCallback = callback;
5233 pMac->readyToExtWoWContext = callback_context;
5234
5235 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305236 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005237
5238 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005240 message.bodyptr = MsgPtr;
5241 message.type = WMA_WLAN_EXT_WOW;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305242 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
5243 QDF_MODULE_ID_WMA,
5244 QDF_MODULE_ID_WMA,
5245 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305246 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 pMac->readyToExtWoWCallback = NULL;
5248 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305249 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305250 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 }
5252 sme_release_global_lock(&pMac->sme);
5253 } else {
5254 pMac->readyToExtWoWCallback = NULL;
5255 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305256 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 }
5258
5259 return status;
5260}
5261
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305262/*
5263 * sme_configure_app_type1_params() -
5264 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5265 *
5266 * hHal - The handle returned by mac_open.
5267 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5268 * Return QDF_STATUS
5269 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305270QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 tpSirAppType1Params wlanAppType1Params)
5272{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305273 QDF_STATUS status = QDF_STATUS_SUCCESS;
5274 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005276 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305277 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278
5279 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305280 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305282 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5284 0));
5285
5286 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305287 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305289 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005290 message.bodyptr = MsgPtr;
5291 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305292 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
5293 QDF_MODULE_ID_WMA,
5294 QDF_MODULE_ID_WMA,
5295 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305296 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305297 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305298 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 }
5300 sme_release_global_lock(&pMac->sme);
5301 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305302 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 }
5304
5305 return status;
5306}
5307
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305308/*
5309 * sme_configure_app_type2_params() -
5310 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5311 *
5312 * hHal - The handle returned by mac_open.
5313 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5314 * Return QDF_STATUS
5315 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305316QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305317 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319 QDF_STATUS status = QDF_STATUS_SUCCESS;
5320 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005322 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305323 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305326 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305328 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5330 0));
5331
5332 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305333 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305335 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005336 message.bodyptr = MsgPtr;
5337 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305338 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
5339 QDF_MODULE_ID_WMA,
5340 QDF_MODULE_ID_WMA,
5341 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305342 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305343 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305344 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 }
5346 sme_release_global_lock(&pMac->sme);
5347 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305348 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 }
5350
5351 return status;
5352}
5353#endif
5354
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305355/*
5356 * sme_get_infra_session_id
5357 * To get the session ID for infra session, if connected
5358 * This is a synchronous API.
5359 *
5360 * hHal - The handle returned by mac_open.
5361 * sessionid, -1 if infra session is not connected
5362 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363int8_t sme_get_infra_session_id(tHalHandle hHal)
5364{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305365 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 int8_t sessionid = -1;
5367 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5368
5369 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305370 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371
5372 sessionid = csr_get_infra_session_id(pMac);
5373
5374 sme_release_global_lock(&pMac->sme);
5375 }
5376
5377 return sessionid;
5378}
5379
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305380/*
5381 * sme_get_infra_operation_channel() -
5382 * To get the operating channel for infra session, if connected
5383 * This is a synchronous API.
5384 *
5385 * hHal - The handle returned by mac_open.
5386 * sessionId - the sessionId returned by sme_open_session.
5387 * Return operating channel, 0 if infra session is not connected
5388 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5390{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305391 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5393 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305396 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397
5398 channel = csr_get_infra_operation_channel(pMac, sessionId);
5399
5400 sme_release_global_lock(&pMac->sme);
5401 }
5402
5403 return channel;
5404}
5405
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305406/* This routine will return poerating channel on which other BSS is operating
5407 * to be used for concurrency mode. If other BSS is not up or not connected it
5408 * will return 0
5409 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5411{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305412 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5414 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305417 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418
5419 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305420 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5421 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 sme_release_global_lock(&pMac->sme);
5423 }
5424
5425 return channel;
5426}
5427
5428#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5429uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5430 eCsrPhyMode sapPhyMode,
5431 uint8_t cc_switch_mode)
5432{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305433 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5435 uint16_t channel = 0;
5436
5437 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305438 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305440 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5441 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 cc_switch_mode);
5443 sme_release_global_lock(&pMac->sme);
5444 }
5445
5446 return channel;
5447}
5448#endif
5449
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305450/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005451 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005452 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005453 * @cb_fn: Callback function pointer
5454 * @db_ctx: Callback data
5455 *
5456 * Return: QDF_STATUS
5457 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005458QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005459 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5460{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005461 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005462 QDF_STATUS status;
5463
Manikandan Mohan976e7562016-03-15 16:33:31 -07005464 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005465 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005466 mac->sme.get_tsf_cb = cb_fn;
5467 mac->sme.get_tsf_cxt = cb_ctx;
5468 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005469 }
5470 return status;
5471}
5472
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305473/**
5474 * sme_reset_tsfcb() - Reset callback for TSF capture
5475 * @h_hal: Handler return by mac_open
5476 *
5477 * This function reset the tsf capture callback to SME
5478 *
5479 * Return: QDF_STATUS
5480 */
5481QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5482{
5483 tpAniSirGlobal mac;
5484 QDF_STATUS status;
5485
5486 if (!h_hal) {
5487 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5488 FL("h_hal is not valid"));
5489 return QDF_STATUS_E_INVAL;
5490 }
5491 mac = PMAC_STRUCT(h_hal);
5492
5493 status = sme_acquire_global_lock(&mac->sme);
5494 if (QDF_IS_STATUS_SUCCESS(status)) {
5495 mac->sme.get_tsf_cb = NULL;
5496 mac->sme.get_tsf_cxt = NULL;
5497 sme_release_global_lock(&mac->sme);
5498 }
5499 return status;
5500}
5501
yuanl2746f072018-09-21 19:19:16 +08005502#if defined(WLAN_FEATURE_TSF) && !defined(WLAN_FEATURE_TSF_PLUS_NOIRQ)
Manikandan Mohan976e7562016-03-15 16:33:31 -07005503/*
yuanl2746f072018-09-21 19:19:16 +08005504 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tsf
Manikandan Mohan976e7562016-03-15 16:33:31 -07005505 * @h_hal: Handler return by mac_open
5506 * @pinvalue: gpio pin id
5507 *
5508 * Return: QDF_STATUS
5509 */
5510QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5511{
5512 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005513 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005514 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5515
5516 status = sme_acquire_global_lock(&mac->sme);
5517 if (QDF_IS_STATUS_SUCCESS(status)) {
5518 tsf_msg.type = WMA_TSF_GPIO_PIN;
5519 tsf_msg.reserved = 0;
5520 tsf_msg.bodyval = pinvalue;
5521
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305522 status = scheduler_post_message(QDF_MODULE_ID_SME,
5523 QDF_MODULE_ID_WMA,
5524 QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005525 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005526 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005527 status = QDF_STATUS_E_FAILURE;
5528 }
5529 sme_release_global_lock(&mac->sme);
5530 }
5531 return status;
5532}
5533#endif
5534
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005535QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005536 uint32_t *len)
5537{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305538 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005539 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005541 if (NULL == mac_ctx) {
5542 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5543 FL("Invalid MAC context"));
5544 return QDF_STATUS_E_FAILURE;
5545 }
5546
5547 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305548 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005549 status = csr_get_cfg_valid_channels(mac_ctx,
5550 aValidChannels, len);
5551 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 }
5553
5554 return status;
5555}
5556
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005557static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5558{
5559 switch (src) {
5560 case SOURCE_CORE:
5561 return "WORLD MODE";
5562
5563 case SOURCE_DRIVER:
5564 return "BDF file";
5565
5566 case SOURCE_USERSPACE:
5567 return "user-space";
5568
5569 case SOURCE_11D:
5570 return "802.11D IEs in beacons";
5571
5572 default:
5573 return "unknown";
5574 }
5575}
5576
Amar Singhal6edf9732016-11-20 21:43:40 -08005577void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5578{
5579 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5580
5581 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005582
5583 sme_debug("Country source is %s",
5584 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005585}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586
5587/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005588 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589 * @mac_ctx: mac global context
5590 * @msg: request msg packet
5591 *
5592 * If Supplicant country code is priority than 11d is disabled.
5593 * If 11D is enabled, we update the country code after every scan.
5594 * Hence when Supplicant country code is priority, we don't need 11D info.
5595 * Country code from Supplicant is set as current country code.
5596 *
5597 * Return: status of operation
5598 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305599static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005600sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5601 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305603 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005604 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005605 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005607 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
Amar Singhal6edf9732016-11-20 21:43:40 -08005609 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5610 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5611 if (user_ctry_priority)
5612 mac_ctx->roam.configParam.Is11dSupportEnabled =
5613 false;
5614 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305615 if (mac_ctx->roam.configParam.
5616 Is11dSupportEnabled &&
5617 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005619 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005620
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305621 status =
5622 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005623 mac_ctx,
5624 mac_ctx->scan.countryCode11d,
5625 &reg_domain_id,
5626 SOURCE_11D);
5627 return QDF_STATUS_E_FAILURE;
5628 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005629 }
5630 }
5631 } else {
5632 /* if kernel gets invalid country code; it
5633 * resets the country code to world
5634 */
5635 if (('0' != msg->countryCode[0]) ||
5636 ('0' != msg->countryCode[1]))
5637 qdf_mem_copy(mac_ctx->scan.countryCode11d,
5638 msg->countryCode,
5639 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005641
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005642 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
5643 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005645
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 /* get the channels based on new cc */
5647 status = csr_get_channel_and_power_list(mac_ctx);
5648
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305649 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005650 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 return status;
5652 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 /* reset info based on new cc, and we are done */
5655 csr_apply_channel_power_info_wrapper(mac_ctx);
5656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005658
5659 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 * Country IE
5661 */
5662 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005663
Amar Singhal6edf9732016-11-20 21:43:40 -08005664 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
5665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005667
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305668 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005669}
5670
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005671QDF_STATUS sme_update_channel_list(tHalHandle hal)
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305672{
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005673 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5674 QDF_STATUS status;
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305675
5676 status = sme_acquire_global_lock(&mac_ctx->sme);
5677 if (QDF_IS_STATUS_SUCCESS(status)) {
5678 /* Update umac channel (enable/disable) from cds channels */
5679 status = csr_get_channel_and_power_list(mac_ctx);
5680 if (status != QDF_STATUS_SUCCESS) {
5681 sme_err("fail to get Channels");
5682 sme_release_global_lock(&mac_ctx->sme);
5683 return status;
5684 }
5685
5686 csr_apply_channel_power_info_wrapper(mac_ctx);
5687 csr_scan_filter_results(mac_ctx);
5688 sme_disconnect_connected_sessions(mac_ctx);
5689 sme_release_global_lock(&mac_ctx->sme);
5690 }
5691
5692 return status;
5693}
5694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695static bool
5696sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
5697{
5698 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305699 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 ch_lst_info = &mac_ctx->scan.base_channels;
5702 for (i = 0; i < ch_lst_info->numChannels; i++) {
5703 if (ch_lst_info->channelList[i] == curr_ch)
5704 return true;
5705 }
5706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 return false;
5708}
5709/**
5710 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
5711 * if channel is not supported
5712 * @mac_ctx: mac global context
5713 *
5714 * If new country code does not support the channel on which STA/P2P client
5715 * is connetced, it sends the disconnect to the AP/P2P GO
5716 *
5717 * Return: void
5718 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305719static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720{
5721 uint8_t session_id, found = false;
5722 uint8_t curr_ch;
5723
5724 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
5725 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
5726 continue;
5727 found = false;
5728 /* Session is connected.Check the channel */
5729 curr_ch = csr_get_infra_operation_channel(mac_ctx,
5730 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005731 sme_debug("Current Operating channel : %d, session :%d",
5732 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005733 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
5734 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005735 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 csr_roam_disconnect(mac_ctx, session_id,
5737 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5738 }
5739 }
5740}
5741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305743QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005744 tpSirRcvFltMcAddrList pMulticastAddrs)
5745{
5746 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005747 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305749 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
5752 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005754 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005756 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07005757 pSession = CSR_GET_SESSION(pMac, sessionId);
5758 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
5759 (!csr_is_conn_state_infra(pMac, sessionId) &&
5760 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05305761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08005762 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305764 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 }
5766
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305767 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305769 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305770 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005771 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305772 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 }
5774
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005775 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
5776 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305777 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005778 "%s: Request ignored, session %d is not connected or started",
5779 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305780 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305781 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 }
5783
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305784 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 sizeof(tSirRcvFltMcAddrList));
5786
Anurag Chouhanc5548422016-02-24 18:33:27 +05305787 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
5788 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005789 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790
5791 msg.type = WMA_8023_MULTICAST_LIST_REQ;
5792 msg.reserved = 0;
5793 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305794 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5795 sessionId, msg.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305796 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
5797 QDF_MODULE_ID_WMA,
5798 QDF_MODULE_ID_WMA,
5799 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305800 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305801 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305803 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305804 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005805 }
5806
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305807 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809#endif /* WLAN_FEATURE_PACKET_FILTERING */
5810
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305811/*
5812 * sme_is_channel_valid() -
5813 * To check if the channel is valid for currently established domain
5814 * This is a synchronous API.
5815 *
5816 * hHal - The handle returned by mac_open.
5817 * channel - channel to verify
5818 * Return true/false, true if channel is valid
5819 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
5821{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305822 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 bool valid = false;
5824 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5825
5826 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305827 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828
5829 valid = csr_roam_is_channel_valid(pMac, channel);
5830
5831 sme_release_global_lock(&pMac->sme);
5832 }
5833
5834 return valid;
5835}
5836
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305837/*
5838 * sme_set_freq_band() -
5839 * Used to set frequency band.
5840 *
5841 * hHal
5842 * sessionId - Session Identifier
5843 * band value to be configured
5844 * Return QDF_STATUS
5845 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005846QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
5847 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305849 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5851
5852 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305853 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 status = csr_set_band(hHal, sessionId, eBand);
5855 sme_release_global_lock(&pMac->sme);
5856 }
5857 return status;
5858}
5859
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305860/*
5861 * sme_get_freq_band() -
5862 * Used to get the current band settings.
5863 *
5864 * hHal
5865 * pBand pointer to hold band value
5866 * Return QDF_STATUS
5867 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005868QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005869{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305870 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005871 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5872
5873 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305874 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875 *pBand = csr_get_current_band(hHal);
5876 sme_release_global_lock(&pMac->sme);
5877 }
5878 return status;
5879}
5880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305881/*
5882 * sme_set_max_tx_power_per_band() -
5883 * Set the Maximum Transmit Power specific to band dynamically.
5884 * Note: this setting will not persist over reboots.
5885 *
5886 * band
5887 * power to set in dB
5888 * Return QDF_STATUS
5889 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005890QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005892 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
5894
5895 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305896 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
5900 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305901 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902 }
5903
5904 pMaxTxPowerPerBandParams->power = dB;
5905 pMaxTxPowerPerBandParams->bandInfo = band;
5906
5907 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
5908 msg.reserved = 0;
5909 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305910 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5911 NO_SESSION, msg.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305912 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
5913 QDF_MODULE_ID_WMA,
5914 QDF_MODULE_ID_WMA,
5915 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
5918 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305919 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305920 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 }
5922
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305923 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005924}
5925
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305926/*
5927 * sme_set_max_tx_power() -
5928 * Set the Maximum Transmit Power dynamically. Note: this setting will
5929 * not persist over reboots.
5930 *
5931 * hHal
5932 * pBssid BSSID to set the power cap for
5933 * pBssid pSelfMacAddress self MAC Address
5934 * pBssid power to set in dB
5935 * Return QDF_STATUS
5936 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05305937QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
5938 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005940 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 tpMaxTxPowerParams pMaxTxParams = NULL;
5942
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305943 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005944 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305945 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005948 "%s: Not able to allocate memory for pMaxTxParams",
5949 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305950 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 }
5952
Anurag Chouhanc5548422016-02-24 18:33:27 +05305953 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
5954 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955 pMaxTxParams->power = dB;
5956
5957 msg.type = WMA_SET_MAX_TX_POWER_REQ;
5958 msg.reserved = 0;
5959 msg.bodyptr = pMaxTxParams;
5960
gaurank kathpalia36b0c582018-08-28 17:45:43 +05305961 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
5962 QDF_MODULE_ID_WMA,
5963 QDF_MODULE_ID_WMA,
5964 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305965 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
5967 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305968 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305969 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970 }
5971
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305972 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973}
5974
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305975/*
5976 * sme_set_custom_mac_addr() -
5977 * Set the customer Mac Address.
5978 *
5979 * customMacAddr customer MAC Address
5980 * Return QDF_STATUS
5981 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305982QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005984 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 tSirMacAddr *pBaseMacAddr;
5986
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305987 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305989 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305991 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992 }
5993
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305994 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995
5996 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
5997 msg.reserved = 0;
5998 msg.bodyptr = pBaseMacAddr;
5999
gaurank kathpalia36b0c582018-08-28 17:45:43 +05306000 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
6001 QDF_MODULE_ID_WMA,
6002 QDF_MODULE_ID_WMA,
6003 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306004 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306005 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306006 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306007 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 }
6009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306010 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011}
6012
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306013/*
6014 * sme_set_tx_power() -
6015 * Set Transmit Power dynamically.
6016 *
6017 * hHal
6018 * sessionId Target Session ID
6019 * BSSID
6020 * dev_mode dev_mode such as station, P2PGO, SAP
6021 * dBm power to set
6022 * Return QDF_STATUS
6023 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306024QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306025 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006026 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006028 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 tpMaxTxPowerParams pTxParams = NULL;
6030 int8_t power = (int8_t) dBm;
6031
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306032 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6034
6035 /* make sure there is no overflow */
6036 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306037 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306039 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 }
6041
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306042 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306044 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 "%s: Not able to allocate memory for pTxParams",
6046 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306047 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 }
6049
Anurag Chouhanc5548422016-02-24 18:33:27 +05306050 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 pTxParams->power = power; /* unit is dBm */
6052 pTxParams->dev_mode = dev_mode;
6053 msg.type = WMA_SET_TX_POWER_REQ;
6054 msg.reserved = 0;
6055 msg.bodyptr = pTxParams;
6056
gaurank kathpalia36b0c582018-08-28 17:45:43 +05306057 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
6058 QDF_MODULE_ID_WMA,
6059 QDF_MODULE_ID_WMA,
6060 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306061 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006062 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6063 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306064 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306065 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006066 }
6067
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306068 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069}
6070
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306071QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306072 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006073{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306074 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306075 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 uint16_t len;
6077
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306078 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306079 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306080 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306081 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6082 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306084 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006085 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306086 sme_release_global_lock(&mac_ctx->sme);
6087 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 }
6089
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306090 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6091 mac_ctx->ignore_assoc_disallowed = param_val;
6092
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306093 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306094 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306096 len = sizeof(*msg);
6097 msg = qdf_mem_malloc(len);
6098 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306099 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006100 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306101 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6102 msg->length = len;
6103 msg->session_id = session_id;
6104 msg->param_type = param_type;
6105 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006106 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306108 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109 }
6110 return status;
6111}
6112
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306113/*
6114 * sme_set_tm_level() -
6115 * Set Thermal Mitigation Level to RIVA
6116 *
6117 * hHal - The handle returned by mac_open.
6118 * newTMLevel - new Thermal Mitigation Level
6119 * tmMode - Thermal Mitigation handle mode, default 0
6120 * Return QDF_STATUS
6121 */
6122QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6123 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306125 QDF_STATUS status = QDF_STATUS_SUCCESS;
6126 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006128 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 tAniSetTmLevelReq *setTmLevelReq = NULL;
6130
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306131 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006132 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6133 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306134 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006135 setTmLevelReq =
6136 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306137 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 if (NULL == setTmLevelReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306140 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 }
6142
6143 setTmLevelReq->tmMode = tmMode;
6144 setTmLevelReq->newTmLevel = newTMLevel;
6145
6146 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006147 message.bodyptr = setTmLevelReq;
6148 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306149 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006150 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05306151 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
6152 QDF_MODULE_ID_WMA,
6153 QDF_MODULE_ID_WMA,
6154 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306155 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306156 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306158 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306159 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160 }
6161 sme_release_global_lock(&pMac->sme);
6162 }
6163 return status;
6164}
6165
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306166/*
6167 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6168 * Host and FW.
6169 *
6170 * hHal - HAL handle for device
6171 * Return NONE
6172 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173void sme_feature_caps_exchange(tHalHandle hHal)
6174{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306175 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306176 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6177 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178}
6179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306180/*
6181 * sme_disable_feature_capablity() - SME interface to disable Active mode
6182 * offload capablity in Host.
6183 *
6184 * hHal - HAL handle for device
6185 * Return NONE
6186 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187void sme_disable_feature_capablity(uint8_t feature_index)
6188{
6189}
6190
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306191/*
6192 * sme_reset_power_values_for5_g
6193 * Reset the power values for 5G band with default power values.
6194 *
6195 * hHal - HAL handle for device
6196 * Return NONE
6197 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198void sme_reset_power_values_for5_g(tHalHandle hHal)
6199{
6200 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306201
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306202 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6204 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306205 /* Store the channel+power info in the global place: Cfg */
6206 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006207}
6208
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306209/*
6210 * sme_update_roam_prefer5_g_hz() -
6211 * Enable/disable Roam prefer 5G runtime option
6212 * This function is called through dynamic setConfig callback function
6213 * to configure the Roam prefer 5G runtime option
6214 *
6215 * hHal - HAL handle for device
6216 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6217 * Return Success or failure
6218 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306220QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6221 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222{
6223 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306224 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006225
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306226 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6228 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306229 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306230 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006231 "%s: gRoamPrefer5GHz is changed from %d to %d",
6232 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6233 nRoamPrefer5GHz);
6234 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6235 sme_release_global_lock(&pMac->sme);
6236 }
6237
6238 return status;
6239}
6240
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306241/*
6242 * sme_set_roam_intra_band() -
6243 * enable/disable Intra band roaming
6244 * This function is called through dynamic setConfig callback function
6245 * to configure the intra band roaming
6246 * hHal - HAL handle for device
6247 * nRoamIntraBand Enable/Disable Intra band roaming
6248 * Return Success or failure
6249 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306250QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251{
6252 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306253 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006254
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306255 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006256 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6257 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306258 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306259 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 "%s: gRoamIntraBand is changed from %d to %d",
6261 __func__, pMac->roam.configParam.nRoamIntraBand,
6262 nRoamIntraBand);
6263 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6264 sme_release_global_lock(&pMac->sme);
6265 }
6266
6267 return status;
6268}
6269
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306270/*
6271 * sme_update_roam_scan_n_probes() -
6272 * Function to update roam scan N probes
6273 * This function is called through dynamic setConfig callback function
6274 * to update roam scan N probes
6275 * hHal - HAL handle for device
6276 * sessionId - Session Identifier
6277 * nProbes number of probe requests to be sent out
6278 * Return Success or failure
6279 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306280QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006281 const uint8_t nProbes)
6282{
6283 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306284 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306286 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6288 NO_SESSION, 0));
6289 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306290 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 "%s: gRoamScanNProbes is changed from %d to %d",
6293 __func__, pMac->roam.configParam.nProbes, nProbes);
6294 pMac->roam.configParam.nProbes = nProbes;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306295
6296 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6297 csr_roam_offload_scan(pMac, sessionId,
6298 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6299 REASON_NPROBES_CHANGED);
6300 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006301 sme_release_global_lock(&pMac->sme);
6302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303 return status;
6304}
6305
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306306/*
6307 * sme_update_roam_scan_home_away_time() -
6308 * Function to update roam scan Home away time
6309 * This function is called through dynamic setConfig callback function
6310 * to update roam scan home away time
6311 *
6312 * hHal - HAL handle for device
6313 * sessionId - Session Identifier
6314 * nRoamScanAwayTime Scan home away time
6315 * bSendOffloadCmd If true then send offload command to firmware
6316 * If false then command is not sent to firmware
6317 * Return Success or failure
6318 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306319QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306321 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006322 const bool bSendOffloadCmd)
6323{
6324 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306325 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006326
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306327 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006328 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6329 NO_SESSION, 0));
6330 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306331 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306332 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6334 __func__,
6335 pMac->roam.configParam.nRoamScanHomeAwayTime,
6336 nRoamScanHomeAwayTime);
6337 pMac->roam.configParam.nRoamScanHomeAwayTime =
6338 nRoamScanHomeAwayTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306339
6340 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6341 bSendOffloadCmd) {
6342 csr_roam_offload_scan(pMac, sessionId,
6343 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6344 REASON_HOME_AWAY_TIME_CHANGED);
6345 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 sme_release_global_lock(&pMac->sme);
6347 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006348 return status;
6349}
6350
Abhishek Singh518323d2015-10-19 17:42:01 +05306351/**
6352 * sme_ext_change_channel()- function to post send ECSA
6353 * action frame to csr.
6354 * @hHal: Hal context
6355 * @channel: new channel to switch
6356 * @session_id: senssion it should be sent on.
6357 *
6358 * This function is called to post ECSA frame to csr.
6359 *
6360 * Return: success if msg is sent else return failure
6361 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306362QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306363 uint8_t session_id)
6364{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306365 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306366 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6367 uint8_t channel_state;
6368
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006369 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306370 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006371 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306372
6373 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006374 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306375 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306376 }
6377
6378 status = sme_acquire_global_lock(&mac_ctx->sme);
6379
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306380 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306381 /* update the channel list to the firmware */
6382 status = csr_send_ext_change_channel(mac_ctx,
6383 channel, session_id);
6384 sme_release_global_lock(&mac_ctx->sme);
6385 }
6386
6387 return status;
6388}
6389
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306390/*
6391 * sme_get_roam_intra_band() -
6392 * get Intra band roaming
6393 *
6394 * hHal - HAL handle for device
6395 * Return Success or failure
6396 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006397bool sme_get_roam_intra_band(tHalHandle hHal)
6398{
6399 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306400
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306401 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006402 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6403 return pMac->roam.configParam.nRoamIntraBand;
6404}
6405
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306406/*
6407 * sme_get_roam_scan_n_probes() -
6408 * get N Probes
6409 *
6410 * hHal - HAL handle for device
6411 * Return Success or failure
6412 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006413uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6414{
6415 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 return pMac->roam.configParam.nProbes;
6418}
6419
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306420/*
6421 * sme_get_roam_scan_home_away_time() -
6422 * get Roam scan home away time
6423 *
6424 * hHal - HAL handle for device
6425 * Return Success or failure
6426 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006427uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6428{
6429 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306430
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006431 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6432}
6433
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306434/*
6435 * sme_update_roam_rssi_diff() -
6436 * Update RoamRssiDiff
6437 * This function is called through dynamic setConfig callback function
6438 * to configure RoamRssiDiff
6439 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6440 *
6441 * hHal - HAL handle for device
6442 * sessionId - Session Identifier
6443 * RoamRssiDiff - minimum rssi difference between potential
6444 * candidate and current AP.
6445 * Return Success or failure
6446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306448QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006449 uint8_t RoamRssiDiff)
6450{
6451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306452 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006453
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006454 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6455 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6456 FL("Invalid sme session id: %d"), sessionId);
6457 return QDF_STATUS_E_INVAL;
6458 }
6459
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306461 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006463 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6464 RoamRssiDiff,
6465 pMac->roam.configParam.RoamRssiDiff,
6466 mac_trace_get_neighbour_roam_state(pMac->roam.
6467 neighborRoamInfo
6468 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306469 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006470 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306471
6472 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
6473 csr_roam_offload_scan(pMac, sessionId,
6474 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6475 REASON_RSSI_DIFF_CHANGED);
6476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 sme_release_global_lock(&pMac->sme);
6478 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006479 return status;
6480}
6481
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306482#ifdef WLAN_FEATURE_FILS_SK
6483QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006484 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306485{
6486 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6487 QDF_STATUS status = QDF_STATUS_SUCCESS;
6488 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6489 &mac->roam.neighborRoamInfo[session_id];
6490
6491 if (session_id >= CSR_ROAM_SESSION_MAX) {
6492 sme_err("Invalid sme session id: %d", session_id);
6493 return QDF_STATUS_E_INVAL;
6494 }
6495
6496 if (!src_profile) {
6497 sme_err("src roam profile NULL");
6498 return QDF_STATUS_E_INVAL;
6499 }
6500
6501 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6502 (neighbor_roam_info->neighborRoamState !=
6503 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6504 sme_info("Fast roam is disabled or not connected(%d)",
6505 neighbor_roam_info->neighborRoamState);
6506 return QDF_STATUS_E_PERM;
6507 }
6508
6509 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306510 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306511 status = sme_acquire_global_lock(&mac->sme);
6512 if (QDF_IS_STATUS_SUCCESS(status)) {
6513 sme_debug("Updating fils config to fw");
6514 csr_roam_offload_scan(mac, session_id,
6515 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6516 REASON_FILS_PARAMS_CHANGED);
6517 sme_release_global_lock(&mac->sme);
6518 } else {
6519 sme_err("Failed to acquire SME lock");
6520 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306521 } else {
6522 sme_info("LFR3 not enabled");
6523 return QDF_STATUS_E_INVAL;
6524 }
6525
6526 return status;
6527}
6528
6529void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006530 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306531{
6532 int i;
6533 struct scheduler_msg msg;
6534 QDF_STATUS status;
6535 struct hlp_params *params;
6536 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6537 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6538 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6539 &mac->roam.neighborRoamInfo[session_id];
6540
6541 if (!session) {
6542 sme_err("session NULL");
6543 return;
6544 }
6545
6546 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6547 (neighbor_roam_info->neighborRoamState !=
6548 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6549 sme_debug("Fast roam is disabled or not connected(%d)",
6550 neighbor_roam_info->neighborRoamState);
6551 return;
6552 }
6553
6554 params = qdf_mem_malloc(sizeof(*params));
6555 if (!params) {
6556 sme_err("Mem alloc for HLP IE fails");
6557 return;
6558 }
6559 if ((profile->hlp_ie_len +
6560 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6561 sme_err("HLP IE len exceeds %d",
6562 profile->hlp_ie_len);
6563 qdf_mem_free(params);
6564 return;
6565 }
6566
6567 params->vdev_id = session_id;
6568 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6569
6570 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6571 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6572
6573 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6574 profile->hlp_ie, profile->hlp_ie_len);
6575
6576 msg.type = SIR_HAL_HLP_IE_INFO;
6577 msg.reserved = 0;
6578 msg.bodyptr = params;
6579 status = sme_acquire_global_lock(&mac->sme);
6580 if (status != QDF_STATUS_SUCCESS) {
6581 sme_err("sme lock acquire fails");
6582 qdf_mem_free(params);
6583 return;
6584 }
6585
6586 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +05306587 (scheduler_post_message(QDF_MODULE_ID_SME,
6588 QDF_MODULE_ID_WMA,
6589 QDF_MODULE_ID_WMA, &msg))) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306590 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6591 sme_release_global_lock(&mac->sme);
6592 qdf_mem_free(params);
6593 return;
6594 }
6595
6596 sme_release_global_lock(&mac->sme);
6597}
6598
Jeff Johnson172237b2017-11-07 15:32:59 -08006599void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306600{
6601 struct fils_join_rsp_params *roam_fils_params;
6602
6603 if (!roam_info) {
6604 sme_err("FILS Roam Info NULL");
6605 return;
6606 }
6607
6608 roam_fils_params = roam_info->fils_join_rsp;
6609 if (!roam_fils_params) {
6610 sme_err("FILS Roam Param NULL");
6611 return;
6612 }
6613
6614 if (roam_fils_params->fils_pmk)
6615 qdf_mem_free(roam_fils_params->fils_pmk);
6616
6617 qdf_mem_free(roam_fils_params);
6618
6619 roam_info->fils_join_rsp = NULL;
6620}
6621
6622#else
6623inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006624 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306625{}
6626#endif
6627
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306628/*
6629 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6630 * support at runtime
6631 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6632 * isFastTransitionEnabled.
6633 * This is a synchronous call
6634 *
6635 * hHal - The handle returned by mac_open.
6636 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
6637 * successfully.
6638 * Other status means SME is failed to update isFastTransitionEnabled.
6639 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306640QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006641 bool isFastTransitionEnabled)
6642{
6643 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306644 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006645
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306646 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006647 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
6648 0));
6649 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306650 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306651 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 "%s: FastTransitionEnabled is changed from %d to %d",
6653 __func__,
6654 pMac->roam.configParam.isFastTransitionEnabled,
6655 isFastTransitionEnabled);
6656 pMac->roam.configParam.isFastTransitionEnabled =
6657 isFastTransitionEnabled;
6658 sme_release_global_lock(&pMac->sme);
6659 }
6660
6661 return status;
6662}
6663
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306664/*
6665 * sme_update_wes_mode() -
6666 * Update WES Mode
6667 * This function is called through dynamic setConfig callback function
6668 * to configure isWESModeEnabled
6669 *
6670 * hHal - HAL handle for device
6671 * isWESModeEnabled - WES mode
6672 * sessionId - Session Identifier
6673 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
6674 * Other status means SME is failed to update isWESModeEnabled.
6675 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306677QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006678 uint8_t sessionId)
6679{
6680 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306681 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006682
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006683 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6684 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6685 FL("Invalid sme session id: %d"), sessionId);
6686 return QDF_STATUS_E_INVAL;
6687 }
6688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306690 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306691 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006692 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
6693 isWESModeEnabled,
6694 pMac->roam.configParam.isWESModeEnabled,
6695 mac_trace_get_neighbour_roam_state(pMac->roam.
6696 neighborRoamInfo
6697 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306698 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006699 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
6700 sme_release_global_lock(&pMac->sme);
6701 }
6702
6703 return status;
6704}
6705
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306706/*
6707 * sme_set_roam_scan_control() -
6708 * Set roam scan control
6709 * This function is called to set roam scan control
6710 * if roam scan control is set to 0, roaming scan cache is cleared
6711 * any value other than 0 is treated as invalid value
6712 * hHal - HAL handle for device
6713 * sessionId - Session Identifier
6714 * Return QDF_STATUS_SUCCESS - SME update config successfully.
6715 * Other status means SME failure to update
6716 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306717QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718 bool roamScanControl)
6719{
6720 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306721 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006722
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306723 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006725
6726 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6728 FL("Invalid sme session id: %d"), sessionId);
6729 return QDF_STATUS_E_INVAL;
6730 }
6731
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006732 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306733 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006735 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
6736 roamScanControl,
6737 pMac->roam.configParam.nRoamScanControl,
6738 mac_trace_get_neighbour_roam_state(pMac->roam.
6739 neighborRoamInfo
6740 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306741 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006742 pMac->roam.configParam.nRoamScanControl = roamScanControl;
6743 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306744 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006745 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306746 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
6747 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006748 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6749 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306750 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6751 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006752 }
6753 }
6754 sme_release_global_lock(&pMac->sme);
6755 }
6756 return status;
6757}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306759/*
6760 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
6761 * support at runtime
6762 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6763 * isFastRoamIniFeatureEnabled.
6764 * This is a synchronous call
6765 *
6766 * hHal - The handle returned by mac_open.
6767 * sessionId - Session Identifier
6768 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
6769 * successfully.
6770 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6771 */
6772QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
6773 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
6774{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006775 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6776
6777 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
6778 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306779 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006780 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
6781 __func__,
6782 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6783 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306784 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006785 }
6786
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006788 "%s: FastRoamEnabled is changed from %d to %d", __func__,
6789 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6790 isFastRoamIniFeatureEnabled);
6791 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
6792 isFastRoamIniFeatureEnabled;
6793 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306794 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006795
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306796 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006797}
6798
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306799/**
6800 * sme_config_fast_roaming() - enable/disable LFR support at runtime
6801 * @hal - The handle returned by macOpen.
6802 * @session_id - Session Identifier
6803 * @is_fast_roam_enabled - flag to enable/disable roaming
6804 *
6805 * When Supplicant issues enabled/disable fast roaming on the basis
6806 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
6807 *
6808 * Return: QDF_STATUS
6809 */
6810
6811QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
6812 const bool is_fast_roam_enabled)
6813{
6814 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306815 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306816 QDF_STATUS status;
6817
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006818 /*
6819 * supplicant_disabled_roaming flag is set to true in
6820 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
6821 * request with BSSID. This flag is reset when supplicant sends
6822 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006823 *
6824 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006825 * if roaming is disabled using driver command or INI and
6826 * supplicant_disabled_roaming flag remains set. So make sure to set
6827 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
6828 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006829 */
6830 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006831 session->pCurRoamProfile->supplicant_disabled_roaming =
6832 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08006833
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306834 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006835 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306836 if (!is_fast_roam_enabled)
6837 return QDF_STATUS_SUCCESS;
6838 return QDF_STATUS_E_FAILURE;
6839 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05306840
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306841 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
6842 session_id, is_fast_roam_enabled);
6843 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006844 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306845 return QDF_STATUS_E_FAILURE;
6846 }
6847
6848 return QDF_STATUS_SUCCESS;
6849}
6850
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306851/*
6852 * sme_update_is_mawc_ini_feature_enabled() -
6853 * Enable/disable LFR MAWC support at runtime
6854 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6855 * isMAWCIniFeatureEnabled.
6856 * This is a synchronous call
6857 *
6858 * hHal - The handle returned by mac_open.
6859 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
6860 * Other status means SME is failed to update MAWCEnabled.
6861 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306862QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 const bool MAWCEnabled)
6864{
6865 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306866 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006867
6868 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306869 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07006872 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
6873 MAWCEnabled);
6874 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
6875 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006876 sme_release_global_lock(&pMac->sme);
6877 }
6878
6879 return status;
6880
6881}
6882
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006883/**
6884 * sme_stop_roaming() - Stop roaming for a given sessionId
6885 * This is a synchronous call
6886 *
6887 * @hHal - The handle returned by mac_open
6888 * @sessionId - Session Identifier
6889 *
6890 * Return QDF_STATUS_SUCCESS on success
6891 * Other status on failure
6892 */
6893QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006894{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006895 struct scheduler_msg wma_msg = {0};
Jeff Johnsonc09caa42018-06-07 22:58:55 -07006896 QDF_STATUS status;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006897 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006898 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6899 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006900 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006902 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006903 sme_err("incorrect session/vdev ID");
6904 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006905 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006906
6907 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306908
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306909 /*
6910 * set the driver_disabled_roaming flag to true even if roaming
6911 * is not enabled on this session so that roam start requests for
6912 * this session can be blocked until driver enables roaming
6913 */
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05306914 if (reason == ecsr_driver_disabled && session->pCurRoamProfile &&
6915 session->pCurRoamProfile->csrPersona == QDF_STA_MODE) {
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306916 session->pCurRoamProfile->driver_disabled_roaming = true;
6917 sme_debug("driver_disabled_roaming set for session %d",
6918 session_id);
6919 }
6920
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306921 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
6922 if (!roam_info->b_roam_scan_offload_started) {
6923 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006924 return QDF_STATUS_SUCCESS;
6925 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006926 req = qdf_mem_malloc(sizeof(*req));
6927 if (!req) {
6928 sme_err("failed to allocated memory");
6929 return QDF_STATUS_E_NOMEM;
6930 }
6931
6932 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306933 if ((reason == eCsrForcedDisassoc) || reason == ecsr_driver_disabled)
Abhishek Singh533c9da2017-05-04 10:23:34 +05306934 req->reason = REASON_ROAM_STOP_ALL;
6935 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08006936 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006937 req->sessionId = session_id;
6938 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006939 req->middle_of_roaming = 1;
6940 else
6941 csr_roam_reset_roam_params(mac_ctx);
6942
6943 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
6944 wma_msg.bodyptr = req;
6945
6946 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnsonc09caa42018-06-07 22:58:55 -07006947 if (QDF_STATUS_SUCCESS != status) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006948 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006949 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006950 qdf_mem_free(req);
6951 return QDF_STATUS_E_FAULT;
6952 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006953 roam_info->b_roam_scan_offload_started = false;
6954 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006955
6956 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957}
6958
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306959/*
6960 * sme_start_roaming() - Start roaming for a given sessionId
6961 * This is a synchronous call
6962 *
6963 * hHal - The handle returned by mac_open
6964 * sessionId - Session Identifier
6965 * Return QDF_STATUS_SUCCESS on success
6966 * Other status on failure
6967 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306968QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006969{
6970 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306971 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972
6973 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306974 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006975 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
6976 reason);
6977 sme_release_global_lock(&pMac->sme);
6978 }
6979
6980 return status;
6981}
6982
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306983/*
6984 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
6985 * Concurrent session exists
6986 * This is a synchronuous call
6987 *
6988 * hHal - The handle returned by mac_open.
6989 * Return QDF_STATUS_SUCCESS
6990 * Other status means SME is failed
6991 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306992QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306994 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006995{
6996
6997 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306998 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006999
7000 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307001 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007002 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7003 bFastRoamInConIniFeatureEnabled;
7004 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7005 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7006 0;
7007 }
7008 sme_release_global_lock(&pMac->sme);
7009 }
7010
7011 return status;
7012}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307014/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307015 * sme_set_roam_opportunistic_scan_threshold_diff() -
7016 * Update Opportunistic Scan threshold diff
7017 * This function is called through dynamic setConfig callback function
7018 * to configure nOpportunisticThresholdDiff
7019 *
7020 * hHal - HAL handle for device
7021 * sessionId - Session Identifier
7022 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7023 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7024 * successfully.
7025 * else SME is failed to update nOpportunisticThresholdDiff.
7026 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307027QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007028 uint8_t sessionId,
7029 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307030 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007031{
7032 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307033 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007034
7035 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307036 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007037 status = csr_neighbor_roam_update_config(pMac, sessionId,
7038 nOpportunisticThresholdDiff,
7039 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307040 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007041 pMac->roam.configParam.neighborRoamConfig.
7042 nOpportunisticThresholdDiff =
7043 nOpportunisticThresholdDiff;
7044 }
7045 sme_release_global_lock(&pMac->sme);
7046 }
7047 return status;
7048}
7049
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307050/*
7051 * sme_get_roam_opportunistic_scan_threshold_diff()
7052 * gets Opportunistic Scan threshold diff
7053 * This is a synchronous call
7054 *
7055 * hHal - The handle returned by mac_open
7056 * Return uint8_t - nOpportunisticThresholdDiff
7057 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007058uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7059{
7060 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007062 return pMac->roam.configParam.neighborRoamConfig.
7063 nOpportunisticThresholdDiff;
7064}
7065
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307066/*
7067 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7068 * This function is called through dynamic setConfig callback function
7069 * to configure nRoamRescanRssiDiff
7070 *
7071 * hHal - HAL handle for device
7072 * sessionId - Session Identifier
7073 * nRoamRescanRssiDiff - roam rescan rssi diff
7074 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7075 * successfully.
7076 * else SME is failed to update nRoamRescanRssiDiff.
7077 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307078QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 uint8_t sessionId,
7080 const uint8_t nRoamRescanRssiDiff)
7081{
7082 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307083 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007084
7085 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307086 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007087 status = csr_neighbor_roam_update_config(pMac, sessionId,
7088 nRoamRescanRssiDiff,
7089 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307090 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007091 pMac->roam.configParam.neighborRoamConfig.
7092 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7093 }
7094 sme_release_global_lock(&pMac->sme);
7095 }
7096 return status;
7097}
7098
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307099/*
7100 * sme_get_roam_rescan_rssi_diff()
7101 * gets roam rescan rssi diff
7102 * This is a synchronous call
7103 *
7104 * hHal - The handle returned by mac_open
7105 * Return int8_t - nRoamRescanRssiDiff
7106 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007107uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7108{
7109 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007111 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7112}
7113
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307114/*
7115 * sme_set_roam_bmiss_first_bcnt() -
7116 * Update Roam count for first beacon miss
7117 * This function is called through dynamic setConfig callback function
7118 * to configure nRoamBmissFirstBcnt
7119 * hHal - HAL handle for device
7120 * sessionId - Session Identifier
7121 * nRoamBmissFirstBcnt - Roam first bmiss count
7122 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7123 * successfully.
7124 * else SME is failed to update nRoamBmissFirstBcnt
7125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307126QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007127 uint8_t sessionId,
7128 const uint8_t nRoamBmissFirstBcnt)
7129{
7130 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307131 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007132
7133 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307134 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007135 status = csr_neighbor_roam_update_config(pMac, sessionId,
7136 nRoamBmissFirstBcnt,
7137 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307138 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 pMac->roam.configParam.neighborRoamConfig.
7140 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7141 }
7142 sme_release_global_lock(&pMac->sme);
7143 }
7144 return status;
7145}
7146
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307147/*
7148 * sme_get_roam_bmiss_first_bcnt() -
7149 * get neighbor roam beacon miss first count
7150 *
7151 * hHal - The handle returned by mac_open.
7152 * Return uint8_t - neighbor roam beacon miss first count
7153 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007154uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7155{
7156 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307157
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007158 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7159}
7160
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307161/*
7162 * sme_set_roam_bmiss_final_bcnt() -
7163 * Update Roam count for final beacon miss
7164 * This function is called through dynamic setConfig callback function
7165 * to configure nRoamBmissFinalBcnt
7166 * hHal - HAL handle for device
7167 * sessionId - Session Identifier
7168 * nRoamBmissFinalBcnt - Roam final bmiss count
7169 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7170 * successfully.
7171 * else SME is failed to update nRoamBmissFinalBcnt
7172 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307173QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007174 uint8_t sessionId,
7175 const uint8_t nRoamBmissFinalBcnt)
7176{
7177 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307178 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007179
7180 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307181 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007182 status = csr_neighbor_roam_update_config(pMac, sessionId,
7183 nRoamBmissFinalBcnt,
7184 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307185 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007186 pMac->roam.configParam.neighborRoamConfig.
7187 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7188 }
7189 sme_release_global_lock(&pMac->sme);
7190 }
7191 return status;
7192}
7193
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307194/*
7195 * sme_get_roam_bmiss_final_bcnt() -
7196 * gets Roam count for final beacon miss
7197 * This is a synchronous call
7198 *
7199 * hHal - The handle returned by mac_open
7200 * Return uint8_t - nRoamBmissFinalBcnt
7201 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007202uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7203{
7204 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007206 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7207}
7208
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307209/*
7210 * sme_set_roam_beacon_rssi_weight() -
7211 * Update Roam beacon rssi weight
7212 * This function is called through dynamic setConfig callback function
7213 * to configure nRoamBeaconRssiWeight
7214 *
7215 * hHal - HAL handle for device
7216 * sessionId - Session Identifier
7217 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7218 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7219 * successfully.
7220 * else SME is failed to update nRoamBeaconRssiWeight
7221 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307222QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007223 uint8_t sessionId,
7224 const uint8_t nRoamBeaconRssiWeight)
7225{
7226 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307227 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007228
7229 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307230 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007231 status = csr_neighbor_roam_update_config(pMac, sessionId,
7232 nRoamBeaconRssiWeight,
7233 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307234 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007235 pMac->roam.configParam.neighborRoamConfig.
7236 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7237 }
7238 sme_release_global_lock(&pMac->sme);
7239 }
7240 return status;
7241}
7242
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307243/*
7244 * sme_get_roam_beacon_rssi_weight() -
7245 * gets Roam beacon rssi weight
7246 * This is a synchronous call
7247 *
7248 * hHal - The handle returned by mac_open
7249 * Return uint8_t - nRoamBeaconRssiWeight
7250 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7252{
7253 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307254
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007255 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7256}
7257
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307258/*
7259 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7260 * rssi threshold
7261 * This is a synchronous call
7262 *
7263 * hHal - The handle returned by mac_open.
7264 * sessionId - Session Identifier
7265 * Return QDF_STATUS_SUCCESS - SME update config successful.
7266 * Other status means SME is failed to update
7267 */
7268QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7269 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7270{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007271 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307272 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007273
7274 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307275 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007276 status = csr_neighbor_roam_update_config(pMac,
7277 sessionId, neighborLookupRssiThreshold,
7278 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307279 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007280 pMac->roam.configParam.neighborRoamConfig.
7281 nNeighborLookupRssiThreshold =
7282 neighborLookupRssiThreshold;
7283 }
7284 sme_release_global_lock(&pMac->sme);
7285 }
7286 return status;
7287}
7288
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307289/*
7290 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7291 * This is a synchronous call
7292 *
7293 * hal - The handle returned by macOpen.
7294 * session_id - Session Identifier
7295 * delay_before_vdev_stop - value to be set
7296 * Return QDF_STATUS_SUCCESS - SME update config successful.
7297 * Other status means SME is failed to update
7298 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307299QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007300 uint8_t session_id,
7301 uint8_t delay_before_vdev_stop)
7302{
7303 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307304 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007305
7306 if (session_id >= CSR_ROAM_SESSION_MAX) {
7307 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7308 FL("Invalid sme session id: %d"), session_id);
7309 return QDF_STATUS_E_INVAL;
7310 }
7311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007312 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307313 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307314 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7315 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 pMac->roam.configParam.neighborRoamConfig.
7317 delay_before_vdev_stop,
7318 delay_before_vdev_stop);
7319 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7320 delay_before_vdev_stop = delay_before_vdev_stop;
7321 pMac->roam.configParam.neighborRoamConfig.
7322 delay_before_vdev_stop = delay_before_vdev_stop;
7323 sme_release_global_lock(&pMac->sme);
7324 }
7325 return status;
7326}
7327
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307328/*
7329 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7330 * rssi threshold
7331 * This is a synchronous call
7332 *
7333 * hHal - The handle returned by mac_open.
7334 * Return QDF_STATUS_SUCCESS - SME update config successful.
7335 * Other status means SME is failed to update
7336 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007337uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7338{
7339 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007341 return pMac->roam.configParam.neighborRoamConfig.
7342 nNeighborLookupRssiThreshold;
7343}
7344
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307345/*
7346 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7347 * refresh period
7348 * This is a synchronous call
7349 *
7350 * hHal - The handle returned by mac_open.
7351 * sessionId - Session Identifier
7352 * Return QDF_STATUS_SUCCESS - SME update config successful.
7353 * Other status means SME is failed to update
7354 */
7355QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7356 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7357{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007358 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307359 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307360 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7362
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007363 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7364 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7365 FL("Invalid sme session id: %d"), sessionId);
7366 return QDF_STATUS_E_INVAL;
7367 }
7368
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007369 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307370 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007371 pNeighborRoamConfig =
7372 &pMac->roam.configParam.neighborRoamConfig;
7373 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307374 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007375 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7376 neighborScanResultsRefreshPeriod,
7377 pMac->roam.configParam.neighborRoamConfig.
7378 nNeighborResultsRefreshPeriod,
7379 mac_trace_get_neighbour_roam_state(pMac->roam.
7380 neighborRoamInfo
7381 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307382 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007383 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7384 neighborScanResultsRefreshPeriod;
7385 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7386 neighborScanResultsRefreshPeriod;
7387
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307388 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7389 csr_roam_offload_scan(pMac, sessionId,
7390 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7391 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
7392 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007393 sme_release_global_lock(&pMac->sme);
7394 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307395
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007396 return status;
7397}
7398
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307399/*
7400 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7401 * offload feaure
7402 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7403 * gRoamScanOffloadEnabled.
7404 * This is a synchronous call
7405 *
7406 * hHal - The handle returned by mac_open.
7407 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7408 * Other status means SME is failed to update.
7409 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307410QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007411 bool nRoamScanOffloadEnabled)
7412{
7413 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307414 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007415
7416 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307417 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307418 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307419 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007420 pMac->roam.configParam.isRoamOffloadScanEnabled,
7421 nRoamScanOffloadEnabled);
7422 pMac->roam.configParam.isRoamOffloadScanEnabled =
7423 nRoamScanOffloadEnabled;
7424 sme_release_global_lock(&pMac->sme);
7425 }
7426
7427 return status;
7428}
7429
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307430/*
7431 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7432 * refresh period
7433 * This is a synchronous call
7434 *
7435 * \param hHal - The handle returned by mac_open.
7436 * \return uint16_t - Neighbor scan results refresh period value
7437 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7439{
7440 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307441
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 return pMac->roam.configParam.neighborRoamConfig.
7443 nNeighborResultsRefreshPeriod;
7444}
7445
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307446/*
7447 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7448 * This is a synchronuous call
7449 *
7450 * hHal - The handle returned by mac_open.
7451 * Return QDF_STATUS_SUCCESS - SME update config successful.
7452 * Other status means SME is failed to update
7453 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7455{
7456 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458 return pMac->roam.configParam.neighborRoamConfig.
7459 nEmptyScanRefreshPeriod;
7460}
7461
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307462/*
7463 * sme_update_empty_scan_refresh_period
7464 * Update nEmptyScanRefreshPeriod
7465 * This function is called through dynamic setConfig callback function
7466 * to configure nEmptyScanRefreshPeriod
7467 * Usage: adb shell iwpriv wlan0 setConfig
7468 * nEmptyScanRefreshPeriod=[0 .. 60]
7469 *
7470 * hHal - HAL handle for device
7471 * sessionId - Session Identifier
7472 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7473 * Return Success or failure
7474 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007475
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307476QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7477 sessionId, uint16_t
7478 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007479{
7480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307481 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307482 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007483 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7484
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007485 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7486 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7487 FL("Invalid sme session id: %d"), sessionId);
7488 return QDF_STATUS_E_INVAL;
7489 }
7490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007491 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307492 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007493 pNeighborRoamConfig =
7494 &pMac->roam.configParam.neighborRoamConfig;
7495 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307496 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007497 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7498 nEmptyScanRefreshPeriod,
7499 pMac->roam.configParam.neighborRoamConfig.
7500 nEmptyScanRefreshPeriod,
7501 mac_trace_get_neighbour_roam_state(pMac->roam.
7502 neighborRoamInfo
7503 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307504 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007505 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7506 nEmptyScanRefreshPeriod;
7507 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7508 nEmptyScanRefreshPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307509
7510 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7511 csr_roam_offload_scan(pMac, sessionId,
7512 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7513 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7514 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007515 sme_release_global_lock(&pMac->sme);
7516 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007518 return status;
7519}
7520
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307521/*
7522 * sme_set_neighbor_scan_min_chan_time() -
7523 * Update nNeighborScanMinChanTime
7524 * This function is called through dynamic setConfig callback function
7525 * to configure gNeighborScanChannelMinTime
7526 * Usage: adb shell iwpriv wlan0 setConfig
7527 * gNeighborScanChannelMinTime=[0 .. 60]
7528 *
7529 * hHal - HAL handle for device
7530 * nNeighborScanMinChanTime - Channel minimum dwell time
7531 * sessionId - Session Identifier
7532 * Return Success or failure
7533 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307534QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535 const uint16_t
7536 nNeighborScanMinChanTime,
7537 uint8_t sessionId)
7538{
7539 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307540 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007541
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007542 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7544 FL("Invalid sme session id: %d"), sessionId);
7545 return QDF_STATUS_E_INVAL;
7546 }
7547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007548 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307549 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307550 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7552 nNeighborScanMinChanTime,
7553 pMac->roam.configParam.neighborRoamConfig.
7554 nNeighborScanMinChanTime,
7555 mac_trace_get_neighbour_roam_state(pMac->roam.
7556 neighborRoamInfo
7557 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307558 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007559
7560 pMac->roam.configParam.neighborRoamConfig.
7561 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7562 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7563 minChannelScanTime = nNeighborScanMinChanTime;
7564 sme_release_global_lock(&pMac->sme);
7565 }
7566
7567 return status;
7568}
7569
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307570/*
7571 * sme_set_neighbor_scan_max_chan_time() -
7572 * Update nNeighborScanMaxChanTime
7573 * This function is called through dynamic setConfig callback function
7574 * to configure gNeighborScanChannelMaxTime
7575 * Usage: adb shell iwpriv wlan0 setConfig
7576 * gNeighborScanChannelMaxTime=[0 .. 60]
7577 *
7578 * hHal - HAL handle for device
7579 * sessionId - Session Identifier
7580 * nNeighborScanMinChanTime - Channel maximum dwell time
7581 * Return Success or failure
7582 */
7583QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7584 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007585 const uint16_t
7586 nNeighborScanMaxChanTime)
7587{
7588 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307589 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307590 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7592
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007593 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7594 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7595 FL("Invalid sme session id: %d"), sessionId);
7596 return QDF_STATUS_E_INVAL;
7597 }
7598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307600 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007601 pNeighborRoamConfig =
7602 &pMac->roam.configParam.neighborRoamConfig;
7603 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307604 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007605 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
7606 nNeighborScanMaxChanTime,
7607 pMac->roam.configParam.neighborRoamConfig.
7608 nNeighborScanMaxChanTime,
7609 mac_trace_get_neighbour_roam_state(pMac->roam.
7610 neighborRoamInfo
7611 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307612 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007613 pNeighborRoamConfig->nNeighborScanMaxChanTime =
7614 nNeighborScanMaxChanTime;
7615 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
7616 nNeighborScanMaxChanTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307617 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7618 csr_roam_offload_scan(pMac, sessionId,
7619 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7620 REASON_SCAN_CH_TIME_CHANGED);
7621 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622 sme_release_global_lock(&pMac->sme);
7623 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007625
7626 return status;
7627}
7628
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307629/*
7630 * sme_get_neighbor_scan_min_chan_time() -
7631 * get neighbor scan min channel time
7632 *
7633 * hHal - The handle returned by mac_open.
7634 * sessionId - Session Identifier
7635 * Return uint16_t - channel min time value
7636 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007637uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
7638{
7639 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007640
7641 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7643 FL("Invalid sme session id: %d"), sessionId);
7644 return 0;
7645 }
7646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007647 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7648 minChannelScanTime;
7649}
7650
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307651/*
7652 * sme_get_neighbor_roam_state() -
7653 * get neighbor roam state
7654 *
7655 * hHal - The handle returned by mac_open.
7656 * sessionId - Session Identifier
7657 * Return uint32_t - neighbor roam state
7658 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007659uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
7660{
7661 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007662
7663 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7664 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7665 FL("Invalid sme session id: %d"), sessionId);
7666 return 0;
7667 }
7668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007669 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
7670}
7671
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307672/*
7673 * sme_get_current_roam_state() -
7674 * get current roam state
7675 *
7676 * hHal - The handle returned by mac_open.
7677 * sessionId - Session Identifier
7678 * Return uint32_t - current roam state
7679 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
7681{
7682 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 return pMac->roam.curState[sessionId];
7685}
7686
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307687/*
7688 * sme_get_current_roam_sub_state() -
7689 * \brief get neighbor roam sub state
7690 *
7691 * hHal - The handle returned by mac_open.
7692 * sessionId - Session Identifier
7693 * Return uint32_t - current roam sub state
7694 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007695uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
7696{
7697 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007699 return pMac->roam.curSubState[sessionId];
7700}
7701
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307702/*
7703 * sme_get_lim_sme_state() -
7704 * get Lim Sme state
7705 *
7706 * hHal - The handle returned by mac_open.
7707 * Return uint32_t - Lim Sme state
7708 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007709uint32_t sme_get_lim_sme_state(tHalHandle hHal)
7710{
7711 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007713 return pMac->lim.gLimSmeState;
7714}
7715
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307716/*
7717 * sme_get_lim_mlm_state() -
7718 * get Lim Mlm state
7719 *
7720 * hHal - The handle returned by mac_open.
7721 * Return uint32_t - Lim Mlm state
7722 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007723uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
7724{
7725 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007727 return pMac->lim.gLimMlmState;
7728}
7729
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307730/*
7731 * sme_is_lim_session_valid() -
7732 * is Lim session valid
7733 *
7734 * hHal - The handle returned by mac_open.
7735 * sessionId - Session Identifier
7736 * Return bool - true or false
7737 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007738bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
7739{
7740 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05307741
7742 if (sessionId > pMac->lim.maxBssId)
7743 return false;
7744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007745 return pMac->lim.gpSession[sessionId].valid;
7746}
7747
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307748/*
7749 * sme_get_lim_sme_session_state() -
7750 * get Lim Sme session state
7751 *
7752 * hHal - The handle returned by mac_open.
7753 * sessionId - Session Identifier
7754 * Return uint32_t - Lim Sme session state
7755 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007756uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
7757{
7758 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307759
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007760 return pMac->lim.gpSession[sessionId].limSmeState;
7761}
7762
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307763/*
7764 * sme_get_lim_mlm_session_state() -
7765 * \brief get Lim Mlm session state
7766 *
7767 * hHal - The handle returned by mac_open.
7768 * sessionId - Session Identifier
7769 * Return uint32_t - Lim Mlm session state
7770 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007771uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
7772{
7773 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007775 return pMac->lim.gpSession[sessionId].limMlmState;
7776}
7777
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307778/*
7779 * sme_get_neighbor_scan_max_chan_time() -
7780 * get neighbor scan max channel time
7781 *
7782 * hHal - The handle returned by mac_open.
7783 * sessionId - Session Identifier
7784 * Return uint16_t - channel max time value
7785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007786uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
7787{
7788 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007789
7790 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7791 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7792 FL("Invalid sme session id: %d"), sessionId);
7793 return 0;
7794 }
7795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007796 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7797 maxChannelScanTime;
7798}
7799
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307800/*
7801 * sme_set_neighbor_scan_period() -
7802 * Update nNeighborScanPeriod
7803 * This function is called through dynamic setConfig callback function
7804 * to configure nNeighborScanPeriod
7805 * Usage: adb shell iwpriv wlan0 setConfig
7806 * nNeighborScanPeriod=[0 .. 1000]
7807 *
7808 * hHal - HAL handle for device
7809 * sessionId - Session Identifier
7810 * nNeighborScanPeriod - neighbor scan period
7811 * Return Success or failure
7812 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307813QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 const uint16_t nNeighborScanPeriod)
7815{
7816 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307817 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307818 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7820
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007821 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7822 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7823 FL("Invalid sme session id: %d"), sessionId);
7824 return QDF_STATUS_E_INVAL;
7825 }
7826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007827 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307828 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007829 pNeighborRoamConfig =
7830 &pMac->roam.configParam.neighborRoamConfig;
7831 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307832 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307833 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 nNeighborScanPeriod,
7835 pMac->roam.configParam.neighborRoamConfig.
7836 nNeighborScanTimerPeriod,
7837 mac_trace_get_neighbour_roam_state(pMac->roam.
7838 neighborRoamInfo
7839 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307840 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 pNeighborRoamConfig->nNeighborScanTimerPeriod =
7842 nNeighborScanPeriod;
7843 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
7844 nNeighborScanPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307845
7846 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7847 csr_roam_offload_scan(pMac, sessionId,
7848 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7849 REASON_SCAN_HOME_TIME_CHANGED);
7850 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007851 sme_release_global_lock(&pMac->sme);
7852 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007853
7854 return status;
7855}
7856
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307857/*
7858 * sme_get_neighbor_scan_period() -
7859 * get neighbor scan period
7860 *
7861 * hHal - The handle returned by mac_open.
7862 * sessionId - Session Identifier
7863 * Return uint16_t - neighbor scan period
7864 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007865uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
7866{
7867 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007868
7869 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7871 FL("Invalid sme session id: %d"), sessionId);
7872 return 0;
7873 }
7874
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007875 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7876 neighborScanPeriod;
7877}
7878
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307879/**
7880 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
7881 * This function is called through dynamic setConfig callback function
7882 * to configure neighbor_scan_min_period
7883 *
7884 * @hal - HAL handle for device
7885 * @session_id - Session Identifier
7886 * @neighbor_scan_min_period - neighbor scan min period
7887 *
7888 * Return - QDF_STATUS
7889 */
7890QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
7891 uint8_t session_id,
7892 const uint16_t
7893 neighbor_scan_min_period)
7894{
7895 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
7896 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307897 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307898 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007899
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307900 if (session_id >= CSR_ROAM_SESSION_MAX) {
7901 sme_err("Invalid sme session id: %d", session_id);
7902 return QDF_STATUS_E_INVAL;
7903 }
7904
7905 status = sme_acquire_global_lock(&pmac->sme);
7906 if (QDF_IS_STATUS_SUCCESS(status)) {
7907 p_neighbor_roam_config =
7908 &pmac->roam.configParam.neighborRoamConfig;
7909 p_neighbor_roam_info = &pmac->
7910 roam.neighborRoamInfo[session_id];
7911 sme_debug("LFR:set neighbor scan min period, old:%d, "
7912 "new: %d, state: %s",
7913 pmac->roam.configParam.neighborRoamConfig.
7914 neighbor_scan_min_timer_period,
7915 neighbor_scan_min_period,
7916 mac_trace_get_neighbour_roam_state(pmac->roam.
7917 neighborRoamInfo[session_id].
7918 neighborRoamState));
7919 p_neighbor_roam_config->neighbor_scan_min_timer_period =
7920 neighbor_scan_min_period;
7921 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
7922 neighbor_scan_min_period;
7923 sme_release_global_lock(&pmac->sme);
7924 }
7925
7926 return status;
7927}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007928
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307929/*
7930 * sme_get_roam_rssi_diff() - get Roam rssi diff
7931 * This is a synchronous call
7932 *
7933 * hHal - The handle returned by mac_open.
7934 * Return uint16_t - Rssi diff value
7935 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007936uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
7937{
7938 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007940 return pMac->roam.configParam.RoamRssiDiff;
7941}
7942
7943/**
7944 * sme_change_roam_scan_channel_list() - to change scan channel list
7945 * @hHal: pointer HAL handle returned by mac_open
7946 * @sessionId: sme session id
7947 * @pChannelList: Output channel list
7948 * @numChannels: Output number of channels
7949 *
7950 * This routine is called to Change roam scan channel list.
7951 * This is a synchronous call
7952 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307953 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307955QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 uint8_t *pChannelList,
7957 uint8_t numChannels)
7958{
7959 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307960 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007961 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007962 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
7963 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
7964 uint8_t i = 0, j = 0;
7965 tCsrChannelInfo *chan_info;
7966
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007967 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7968 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7969 FL("Invalid sme session id: %d"), sessionId);
7970 return QDF_STATUS_E_INVAL;
7971 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007973 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007974 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307975 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307976 sme_err("Failed to acquire SME lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007977 return status;
7978 }
7979 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
7980
7981 if (NULL != chan_info->ChannelList) {
7982 for (i = 0; i < chan_info->numOfChannels; i++) {
7983 if (j < sizeof(oldChannelList))
7984 j += snprintf(oldChannelList + j,
7985 sizeof(oldChannelList) -
7986 j, "%d",
7987 chan_info->ChannelList[i]);
7988 else
7989 break;
7990 }
7991 }
7992 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
7993 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
7994 numChannels);
7995 sme_set_roam_scan_control(hHal, sessionId, 1);
7996 if (NULL != chan_info->ChannelList) {
7997 j = 0;
7998 for (i = 0; i < chan_info->numOfChannels; i++) {
7999 if (j < sizeof(newChannelList))
8000 j += snprintf(newChannelList + j,
8001 sizeof(newChannelList) -
8002 j, " %d",
8003 chan_info->ChannelList[i]);
8004 else
8005 break;
8006 }
8007 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308008 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308009 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008010 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308011 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012
8013 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8014 csr_roam_offload_scan(pMac, sessionId,
8015 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8016 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308017
8018 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008019 return status;
8020}
8021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022/**
8023 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8024 * @hHal: HAL pointer
8025 * @pChannelList: Output channel list
8026 * @pNumChannels: Output number of channels
8027 * @sessionId: Session Identifier
8028 *
8029 * To get roam scan channel list This is a synchronous call
8030 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308031 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008032 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308033QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008034 uint8_t *pChannelList, uint8_t *pNumChannels,
8035 uint8_t sessionId)
8036{
8037 int i = 0;
8038 uint8_t *pOutPtr = pChannelList;
8039 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008040 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308041 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008042
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008043 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8044 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8045 FL("Invalid sme session id: %d"), sessionId);
8046 return QDF_STATUS_E_INVAL;
8047 }
8048
8049 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008050 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308051 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008052 return status;
8053 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308054 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 FL("Roam Scan channel list is NOT yet initialized"));
8056 *pNumChannels = 0;
8057 sme_release_global_lock(&pMac->sme);
8058 return status;
8059 }
8060
8061 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308062 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008063 pOutPtr[i] =
8064 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008066 pOutPtr[i] = '\0';
8067 sme_release_global_lock(&pMac->sme);
8068 return status;
8069}
8070
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308071/*
8072 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8073 * This is a synchronuous call
8074 *
8075 * hHal - The handle returned by mac_open.
8076 * Return true (1) - if the ESE feature is enabled
8077 * false (0) - if feature is disabled (compile or runtime)
8078 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008079bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8080{
8081#ifdef FEATURE_WLAN_ESE
8082 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008084 return csr_roam_is_ese_ini_feature_enabled(pMac);
8085#else
8086 return false;
8087#endif
8088}
8089
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308090/*
8091 * sme_get_wes_mode() - get WES Mode
8092 * This is a synchronous call
8093 *
8094 * hHal - The handle returned by mac_open
8095 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8096 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008097bool sme_get_wes_mode(tHalHandle hHal)
8098{
8099 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008101 return pMac->roam.configParam.isWESModeEnabled;
8102}
8103
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308104/*
8105 * sme_get_roam_scan_control() - get scan control
8106 * This is a synchronous call
8107 *
8108 * hHal - The handle returned by mac_open.
8109 * Return bool - Enabled(1)/Disabled(0)
8110 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111bool sme_get_roam_scan_control(tHalHandle hHal)
8112{
8113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308114
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 return pMac->roam.configParam.nRoamScanControl;
8116}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008117
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308118/*
8119 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8120 * This is a synchronuous call
8121 * hHal - The handle returned by mac_open.
8122 * Return true (1) - if the feature is enabled
8123 * false (0) - if feature is disabled (compile or runtime)
8124 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008125bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8126{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008127 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008129 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008130}
8131
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308132/*
8133 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8134 * This is a synchronuous call
8135 *
8136 * hHal - The handle returned by mac_open.
8137 * Return true (1) - if the feature is enabled
8138 * false (0) - if feature is disabled (compile or runtime)
8139 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8141{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008142 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008145}
8146
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008147/**
8148 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8149 * @feature: enum value of requested feature.
8150 *
8151 * Retrun: 1 if supported; 0 otherwise
8152 */
8153bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008154{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008155 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008156}
8157
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308158QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008159 void *plsContext,
8160 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8161 void *pContext))
8162{
8163
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308164 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008165 tpAniSirGlobal pMac;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308166 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167
Jeff Johnsona5317a62017-01-26 08:51:25 -08008168 if (!hHal || !pCallbackfn || !lsReq) {
8169 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8170 FL("Invalid parameter"));
8171 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008172 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008173
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308174 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8175 if (!wma_handle) {
8176 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8177 "wma handle is NULL");
8178 return QDF_STATUS_E_FAILURE;
8179 }
8180
Jeff Johnsona5317a62017-01-26 08:51:25 -08008181 pMac = PMAC_STRUCT(hHal);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008182 status = sme_acquire_global_lock(&pMac->sme);
8183 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008184 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008185 return QDF_STATUS_E_FAILURE;
8186 }
8187
8188 pMac->sme.pLinkSpeedCbContext = plsContext;
8189 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
gaurank kathpaliaca8f4612018-06-13 14:21:53 +05308190 status = wma_get_link_speed(wma_handle, lsReq);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008191 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192 return status;
8193}
8194
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308195QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8196 struct sir_peer_info_req req)
8197{
8198 QDF_STATUS qdf_status;
8199 struct scheduler_msg message = {0};
8200
8201 qdf_status = sme_acquire_global_lock(&mac->sme);
8202 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8203 sme_debug("Failed to get Lock");
8204 return qdf_status;
8205 }
8206 /* serialize the req through MC thread */
8207 message.bodyptr = qdf_mem_malloc(sizeof(req));
8208 if (NULL == message.bodyptr) {
8209 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8210 "%s: Memory allocation failed.", __func__);
8211 sme_release_global_lock(&mac->sme);
8212 return QDF_STATUS_E_NOMEM;
8213 }
8214 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8215 message.type = WMA_GET_PEER_INFO;
8216 message.reserved = 0;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308217 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8218 QDF_MODULE_ID_WMA,
8219 QDF_MODULE_ID_WMA, &message);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308220 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8221 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8222 "%s: Post get peer info msg fail", __func__);
8223 qdf_mem_free(message.bodyptr);
8224 qdf_status = QDF_STATUS_E_FAILURE;
8225 }
8226 sme_release_global_lock(&mac->sme);
8227 return qdf_status;
8228}
8229
Will Huang558f8082017-05-31 16:22:24 +08008230QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8231 void *context,
8232 void (*callbackfn)(struct sir_peer_info_resp *param,
8233 void *pcontext))
8234{
8235
8236 QDF_STATUS status;
8237 QDF_STATUS qdf_status;
8238 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008239 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008240
8241 status = sme_acquire_global_lock(&mac->sme);
8242 if (QDF_STATUS_SUCCESS == status) {
8243 if (NULL == callbackfn) {
8244 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8245 "%s: Indication Call back is NULL",
8246 __func__);
8247 sme_release_global_lock(&mac->sme);
8248 return QDF_STATUS_E_FAILURE;
8249 }
8250
8251 mac->sme.pget_peer_info_ind_cb = callbackfn;
8252 mac->sme.pget_peer_info_cb_context = context;
8253
8254 /* serialize the req through MC thread */
8255 message.bodyptr = qdf_mem_malloc(sizeof(req));
8256 if (NULL == message.bodyptr) {
8257 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8258 "%s: Memory allocation failed.", __func__);
8259 sme_release_global_lock(&mac->sme);
8260 return QDF_STATUS_E_NOMEM;
8261 }
8262 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8263 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308264 message.reserved = 0;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308265 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8266 QDF_MODULE_ID_WMA,
8267 QDF_MODULE_ID_WMA,
8268 &message);
Will Huang558f8082017-05-31 16:22:24 +08008269 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8270 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8271 "%s: Post get peer info msg fail", __func__);
8272 qdf_mem_free(message.bodyptr);
8273 status = QDF_STATUS_E_FAILURE;
8274 }
8275 sme_release_global_lock(&mac->sme);
8276 }
8277 return status;
8278}
8279
8280QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8281 struct sir_peer_info_ext_req *req,
8282 void *context,
8283 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8284 void *pcontext))
8285{
8286 QDF_STATUS status;
8287 QDF_STATUS qdf_status;
8288 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008289 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008290
8291 status = sme_acquire_global_lock(&mac->sme);
8292 if (QDF_STATUS_SUCCESS == status) {
8293 if (NULL == callbackfn) {
8294 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8295 "%s: Indication Call back is NULL",
8296 __func__);
8297 sme_release_global_lock(&mac->sme);
8298 return QDF_STATUS_E_FAILURE;
8299 }
8300
8301 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8302 mac->sme.pget_peer_info_ext_cb_context = context;
8303
8304 /* serialize the req through MC thread */
8305 message.bodyptr =
8306 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8307 if (NULL == message.bodyptr) {
8308 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8309 "%s: Memory allocation failed.", __func__);
8310 sme_release_global_lock(&mac->sme);
8311 return QDF_STATUS_E_NOMEM;
8312 }
8313 qdf_mem_copy(message.bodyptr,
8314 req,
8315 sizeof(struct sir_peer_info_ext_req));
8316 message.type = WMA_GET_PEER_INFO_EXT;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308317 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8318 QDF_MODULE_ID_WMA,
8319 QDF_MODULE_ID_WMA,
8320 &message);
Will Huang558f8082017-05-31 16:22:24 +08008321 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8322 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8323 "%s: Post get rssi msg fail", __func__);
8324 qdf_mem_free(message.bodyptr);
8325 status = QDF_STATUS_E_FAILURE;
8326 }
8327 sme_release_global_lock(&mac->sme);
8328 }
8329 return status;
8330}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008331
8332/*
8333 * SME API to enable/disable WLAN driver initiated SSR
8334 */
8335void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8336{
8337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308338 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339
8340 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308341 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008342 sme_debug("SSR level is changed %d", enableSSR);
Jeff Johnson698eacd2018-05-12 17:00:03 -07008343 /* not serializing this message, as this is only going
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008344 * to set a variable in WMA/WDI
8345 */
8346 WMA_SetEnableSSR(enableSSR);
8347 sme_release_global_lock(&pMac->sme);
8348 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008349}
8350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008351/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8352ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8353{
8354 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8355}
8356
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308357/*
8358 * sme_set_curr_device_mode() - Sets the current operating device mode.
8359 *
8360 * hHal - The handle returned by mac_open.
8361 * currDeviceMode - Current operating device mode.
8362 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008363void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008364 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008365{
8366 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008368 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008369}
8370
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308371/*
8372 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8373 * This is a synchronous call
8374 *
8375 * hHal - The handle returned by mac_open
8376 * sessionId - Session Identifier
8377 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8378 * BSSID, channel etc.)
8379 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8380 * Other status means SME is failed to send the request.
8381 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008382
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308383QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008384 uint8_t sessionId,
8385 tCsrHandoffRequest *pHandoffInfo)
8386{
8387 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308388 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008389
8390 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308391 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308392 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008393 "%s: invoked", __func__);
8394 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8395 sme_release_global_lock(&pMac->sme);
8396 }
8397
8398 return status;
8399}
8400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008401/*
8402 * SME API to check if there is any infra station or
8403 * P2P client is connected
8404 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308405QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008406{
8407 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308408
8409 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308410 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308411
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308412 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008413}
8414
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008415/**
8416 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8417 * @hal: global hal handle
8418 * @addPeriodicTxPtrnParams: request message
8419 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308420 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008421 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308422QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008423sme_add_periodic_tx_ptrn(tHalHandle hal,
8424 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8425{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308426 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008427 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8428 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008429 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008431 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008432
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308433 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008434 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008435 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308436 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008437 }
8438
8439 *req_msg = *addPeriodicTxPtrnParams;
8440
8441 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308442 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008443 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008444 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308445 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008446 return status;
8447 }
8448
8449 /* Serialize the req through MC thread */
8450 msg.bodyptr = req_msg;
8451 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308452 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8453 NO_SESSION, msg.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308454 status = scheduler_post_message(QDF_MODULE_ID_SME,
8455 QDF_MODULE_ID_WMA,
8456 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308457 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008458 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008459 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308460 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008461 }
8462 sme_release_global_lock(&mac->sme);
8463 return status;
8464}
8465
8466/**
8467 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8468 * @hal: global hal handle
8469 * @delPeriodicTxPtrnParams: request message
8470 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308471 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008472 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308473QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008474sme_del_periodic_tx_ptrn(tHalHandle hal,
8475 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8476{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308477 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008478 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8479 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008480 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008481
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008482 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008483
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308484 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008485 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008486 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308487 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488 }
8489
8490 *req_msg = *delPeriodicTxPtrnParams;
8491
8492 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308493 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008494 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008495 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308496 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008497 return status;
8498 }
8499
8500 /* Serialize the req through MC thread */
8501 msg.bodyptr = req_msg;
8502 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308503 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8504 NO_SESSION, msg.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308505 status = scheduler_post_message(QDF_MODULE_ID_SME,
8506 QDF_MODULE_ID_WMA,
8507 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308508 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008509 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308511 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512 }
8513 sme_release_global_lock(&mac->sme);
8514 return status;
8515}
8516
Rachit Kankaneee1735c2018-08-02 13:19:34 +05308517#ifdef FEATURE_WLAN_RMC
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308518/*
8519 * sme_enable_rmc() - enables RMC
8520 * @hHal : Pointer to global HAL handle
8521 * @sessionId : Session ID
8522 *
8523 * Return: QDF_STATUS
8524 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008525QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8526{
8527 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8528 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008529 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008530 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8531
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008532 SME_ENTER();
8533
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008534 status = sme_acquire_global_lock(&pMac->sme);
8535 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008536 message.bodyptr = NULL;
8537 message.type = WMA_RMC_ENABLE_IND;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308538 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8539 QDF_MODULE_ID_WMA,
8540 QDF_MODULE_ID_WMA,
8541 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008542 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8544 "%s: failed to post message to WMA",
8545 __func__);
8546 status = QDF_STATUS_E_FAILURE;
8547 }
8548 sme_release_global_lock(&pMac->sme);
8549 }
8550 return status;
8551}
8552
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308553/*
8554 * sme_disable_rmc() - disables RMC
8555 * @hHal : Pointer to global HAL handle
8556 * @sessionId : Session ID
8557 *
8558 * Return: QDF_STATUS
8559 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008560QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
8561{
8562 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8563 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008564 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008565 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8566
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008567 SME_ENTER();
8568
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008569 status = sme_acquire_global_lock(&pMac->sme);
8570 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008571 message.bodyptr = NULL;
8572 message.type = WMA_RMC_DISABLE_IND;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308573 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8574 QDF_MODULE_ID_WMA,
8575 QDF_MODULE_ID_WMA,
8576 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008577 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8578 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8579 "%s: failed to post message to WMA",
8580 __func__);
8581 status = QDF_STATUS_E_FAILURE;
8582 }
8583 sme_release_global_lock(&pMac->sme);
8584 }
8585 return status;
8586}
8587
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308588/*
8589 * sme_send_rmc_action_period() - sends RMC action period param to target
8590 * @hHal : Pointer to global HAL handle
8591 * @sessionId : Session ID
8592 *
8593 * Return: QDF_STATUS
8594 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008595QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
8596{
8597 QDF_STATUS status = QDF_STATUS_SUCCESS;
8598 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8599 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008600 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008601
8602 status = sme_acquire_global_lock(&pMac->sme);
8603 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008604 message.bodyptr = NULL;
8605 message.type = WMA_RMC_ACTION_PERIOD_IND;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308606 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8607 QDF_MODULE_ID_WMA,
8608 QDF_MODULE_ID_WMA,
8609 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008610 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8611 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8612 "%s: failed to post message to WMA",
8613 __func__);
8614 status = QDF_STATUS_E_FAILURE;
8615 }
8616 sme_release_global_lock(&pMac->sme);
8617 }
8618
8619 return status;
8620}
Rachit Kankaneee1735c2018-08-02 13:19:34 +05308621#endif /* FEATURE_WLAN_RMC */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008622
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308623/*
8624 * sme_request_ibss_peer_info() - request ibss peer info
8625 * @hHal : Pointer to global HAL handle
8626 * @pUserData : Pointer to user data
8627 * @peerInfoCbk : Peer info callback
8628 * @allPeerInfoReqd : All peer info required or not
8629 * @staIdx : sta index
8630 *
8631 * Return: QDF_STATUS
8632 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008633QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
8634 pIbssPeerInfoCb peerInfoCbk,
8635 bool allPeerInfoReqd, uint8_t staIdx)
8636{
8637 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8638 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
8639 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008640 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008641 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
8642
8643 status = sme_acquire_global_lock(&pMac->sme);
8644 if (QDF_STATUS_SUCCESS == status) {
8645 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
8646 pMac->sme.peerInfoParams.pUserData = pUserData;
8647
8648 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308649 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008650 if (NULL == pIbssInfoReqParams) {
8651 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8652 "%s: Not able to allocate memory for dhcp start",
8653 __func__);
8654 sme_release_global_lock(&pMac->sme);
8655 return QDF_STATUS_E_NOMEM;
8656 }
8657 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
8658 pIbssInfoReqParams->staIdx = staIdx;
8659
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008660 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
8661 message.bodyptr = pIbssInfoReqParams;
8662 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008663
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308664 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8665 QDF_MODULE_ID_WMA,
8666 QDF_MODULE_ID_WMA,
8667 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008668 if (QDF_STATUS_SUCCESS != qdf_status) {
8669 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8670 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
8671 __func__);
8672 qdf_mem_free(pIbssInfoReqParams);
8673 qdf_status = QDF_STATUS_E_FAILURE;
8674 }
8675 sme_release_global_lock(&pMac->sme);
8676 }
8677
8678 return qdf_status;
8679}
8680
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308681/*
8682 * sme_send_cesium_enable_ind() -
8683 * Used to send proprietary cesium enable indication to fw
8684 *
8685 * hHal
8686 * sessionId
8687 * Return QDF_STATUS
8688 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008689QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
8690{
8691 QDF_STATUS status = QDF_STATUS_SUCCESS;
8692 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8693 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008694 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008695
8696 status = sme_acquire_global_lock(&pMac->sme);
8697 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008698 message.bodyptr = NULL;
8699 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308700 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
8701 QDF_MODULE_ID_WMA,
8702 QDF_MODULE_ID_WMA,
8703 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008704 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8705 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8706 "%s: failed to post message to WMA",
8707 __func__);
8708 status = QDF_STATUS_E_FAILURE;
8709 }
8710 sme_release_global_lock(&pMac->sme);
8711 }
8712
8713 return status;
8714}
8715
Paul Zhang99fe8842017-12-08 14:43:46 +08008716QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
8717 uint16_t latency_level)
8718{
8719 QDF_STATUS status;
8720 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
8721 struct wlm_latency_level_param params;
8722 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
8723
Bala Venkatesh7cf5b662018-05-10 15:18:53 +05308724 if (!wma)
8725 return QDF_STATUS_E_FAILURE;
8726
Paul Zhang99fe8842017-12-08 14:43:46 +08008727 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
8728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8729 "%s: WLM latency level setting is disabled",
8730 __func__);
8731 return QDF_STATUS_E_FAILURE;
8732 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08008733 if (!wma) {
8734 sme_err("wma is NULL");
8735 return QDF_STATUS_E_FAILURE;
8736 }
Paul Zhang99fe8842017-12-08 14:43:46 +08008737
8738 params.wlm_latency_level = latency_level;
8739 params.wlm_latency_flags =
8740 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
8741 params.vdev_id = session_id;
8742
8743 status = wma_set_wlm_latency_level(wma, &params);
8744 if (!QDF_IS_STATUS_SUCCESS(status))
8745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8746 "%s: failed to set latency level",
8747 __func__);
8748
8749 return status;
8750}
8751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008752void sme_get_command_q_status(tHalHandle hHal)
8753{
8754 tSmeCmd *pTempCmd = NULL;
8755 tListElem *pEntry;
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +05308756 tpAniSirGlobal pMac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008757
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +05308758 if (NULL != hHal) {
8759 pMac = PMAC_STRUCT(hHal);
8760 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +05308762 "%s: Invalid hHal pointer", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008763 return;
8764 }
Krunal Sonia8270f52017-02-23 19:51:25 -08008765 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308766 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008767 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308768
Kabilan Kannan33fcd682018-03-08 14:29:46 -08008769 sme_err("WLAN_BUG_RCA: Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008770 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
8771 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308772 if (eSmeCsrCommandMask & pTempCmd->command)
8773 /* CSR command is stuck. See what the reason code is
8774 * for that command
8775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008777 } /* if(pTempCmd) */
8778
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008779 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08008780 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008782}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008783
Agrawal Ashishb141b092016-09-02 19:59:26 +05308784#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008785/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008786 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
8787 * @src: the source configuration
8788 *
8789 * Return: pointer to the copied OCB configuration
8790 */
8791static struct sir_ocb_config *sme_copy_sir_ocb_config(
8792 struct sir_ocb_config *src)
8793{
8794 struct sir_ocb_config *dst;
8795 uint32_t length;
8796 void *cursor;
8797
8798 length = sizeof(*src) +
8799 src->channel_count * sizeof(*src->channels) +
8800 src->schedule_size * sizeof(*src->schedule) +
8801 src->dcc_ndl_chan_list_len +
8802 src->dcc_ndl_active_state_list_len;
8803
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308804 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008805 if (!dst)
8806 return NULL;
8807
8808 *dst = *src;
8809
8810 cursor = dst;
8811 cursor += sizeof(*dst);
8812 dst->channels = cursor;
8813 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308814 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008815 src->channel_count * sizeof(*src->channels));
8816 dst->schedule = cursor;
8817 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308818 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008819 src->schedule_size * sizeof(*src->schedule));
8820 dst->dcc_ndl_chan_list = cursor;
8821 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308822 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 src->dcc_ndl_chan_list_len);
8824 dst->dcc_ndl_active_state_list = cursor;
8825 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308826 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008827 src->dcc_ndl_active_state_list,
8828 src->dcc_ndl_active_state_list_len);
8829 return dst;
8830}
8831
8832/**
8833 * sme_ocb_set_config() - Set the OCB configuration
8834 * @hHal: reference to the HAL
8835 * @context: the context of the call
8836 * @callback: the callback to hdd
8837 * @config: the OCB configuration
8838 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308839 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308841QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 ocb_callback callback,
8843 struct sir_ocb_config *config)
8844{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308845 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008846 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008847 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 struct sir_ocb_config *msg_body;
8849
8850 /* Lock the SME structure */
8851 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308852 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853 return status;
8854
8855 /*
8856 * Check if there is a pending request and return an error if one
8857 * exists
8858 */
8859 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308860 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861 goto end;
8862 }
8863
8864 msg_body = sme_copy_sir_ocb_config(config);
8865
8866 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 goto end;
8869 }
8870
8871 msg.type = WMA_OCB_SET_CONFIG_CMD;
8872 msg.bodyptr = msg_body;
8873
8874 /* Set the request callback and context */
8875 pMac->sme.ocb_set_config_callback = callback;
8876 pMac->sme.ocb_set_config_context = context;
8877
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308878 status = scheduler_post_message(QDF_MODULE_ID_SME,
8879 QDF_MODULE_ID_WMA,
8880 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308881 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308882 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008883 FL("Error posting message to WDA: %d"), status);
8884 pMac->sme.ocb_set_config_callback = callback;
8885 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308886 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008887 goto end;
8888 }
8889
8890end:
8891 sme_release_global_lock(&pMac->sme);
8892
8893 return status;
8894}
8895
8896/**
8897 * sme_ocb_set_utc_time() - Set the OCB UTC time
8898 * @hHal: reference to the HAL
8899 * @utc: the UTC time struct
8900 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308901 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008902 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308903QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008904{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308905 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008907 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008908 struct sir_ocb_utc *sme_utc;
8909
8910 /* Lock the SME structure */
8911 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308912 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008913 return status;
8914
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308915 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008916 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308917 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008918 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308919 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008920 goto end;
8921 }
8922 *sme_utc = *utc;
8923
8924 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
8925 msg.reserved = 0;
8926 msg.bodyptr = sme_utc;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308927 status = scheduler_post_message(QDF_MODULE_ID_SME,
8928 QDF_MODULE_ID_WMA,
8929 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308930 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308931 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008932 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308933 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008934 goto end;
8935 }
8936
8937end:
8938 sme_release_global_lock(&pMac->sme);
8939
8940 return status;
8941}
8942
8943/**
8944 * sme_ocb_start_timing_advert() - Start sending timing advert frames
8945 * @hHal: reference to the HAL
8946 * @timing_advert: the timing advertisement struct
8947 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308948 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308950QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008951 struct sir_ocb_timing_advert *timing_advert)
8952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308953 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008955 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008956 void *buf;
8957 struct sir_ocb_timing_advert *sme_timing_advert;
8958
8959 /* Lock the SME structure */
8960 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308961 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008962 return status;
8963
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308964 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008965 timing_advert->template_length);
8966 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308967 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008968 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308969 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008970 goto end;
8971 }
8972
8973 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
8974 *sme_timing_advert = *timing_advert;
8975 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308976 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008977 timing_advert->template_value, timing_advert->template_length);
8978
8979 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
8980 msg.reserved = 0;
8981 msg.bodyptr = buf;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05308982 status = scheduler_post_message(QDF_MODULE_ID_SME,
8983 QDF_MODULE_ID_WMA,
8984 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308985 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308986 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008987 FL("Not able to post msg to WDA"));
8988 goto end;
8989 }
8990
8991end:
8992 sme_release_global_lock(&pMac->sme);
8993
8994 return status;
8995}
8996
8997/**
8998 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
8999 * @hHal: reference to the HAL
9000 * @timing_advert: the timing advertisement struct
9001 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309002 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009003 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309004QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009005 struct sir_ocb_timing_advert *timing_advert)
9006{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309007 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009009 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009010 struct sir_ocb_timing_advert *sme_timing_advert;
9011
9012 /* Lock the SME structure */
9013 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309014 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009015 return status;
9016
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309017 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009018 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309019 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309021 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009022 goto end;
9023 }
9024 *sme_timing_advert = *timing_advert;
9025
9026 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9027 msg.reserved = 0;
9028 msg.bodyptr = sme_timing_advert;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309029 status = scheduler_post_message(QDF_MODULE_ID_SME,
9030 QDF_MODULE_ID_WMA,
9031 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309032 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309033 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009034 FL("Not able to post msg to WDA"));
9035 goto end;
9036 }
9037
9038end:
9039 sme_release_global_lock(&pMac->sme);
9040
9041 return status;
9042}
9043
9044/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009045 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9046 * @hal_handle: reference to the HAL
9047 * @self_addr: the self MAC address
9048 * @buf: the buffer that will contain the frame
9049 * @timestamp_offset: return for the offset of the timestamp field
9050 * @time_value_offset: return for the time_value field in the TA IE
9051 *
9052 * Return: the length of the buffer.
9053 */
9054int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9055 tSirMacAddr self_addr, uint8_t **buf,
9056 uint32_t *timestamp_offset,
9057 uint32_t *time_value_offset)
9058{
9059 int template_length;
9060 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9061
9062 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9063 timestamp_offset,
9064 time_value_offset);
9065 return template_length;
9066}
9067/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009068 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9069 * @hHal: reference to the HAL
9070 * @context: the context of the call
9071 * @callback: the callback to hdd
9072 * @request: the TSF timer request
9073 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309074 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309076QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009077 ocb_callback callback,
9078 struct sir_ocb_get_tsf_timer *request)
9079{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309080 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009081 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009082 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009083 struct sir_ocb_get_tsf_timer *msg_body;
9084
9085 /* Lock the SME structure */
9086 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309087 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009088 return status;
9089
9090 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309091 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009092 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309093 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009094 goto end;
9095 }
9096 *msg_body = *request;
9097
9098 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9099 msg.bodyptr = msg_body;
9100
9101 /* Set the request callback and the context */
9102 pMac->sme.ocb_get_tsf_timer_callback = callback;
9103 pMac->sme.ocb_get_tsf_timer_context = context;
9104
9105 /* Post the message to WDA */
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309106 status = scheduler_post_message(QDF_MODULE_ID_SME,
9107 QDF_MODULE_ID_WMA,
9108 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309109 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009111 FL("Error posting message to WDA: %d"), status);
9112 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9113 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309114 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009115 goto end;
9116 }
9117
9118end:
9119 sme_release_global_lock(&pMac->sme);
9120
9121 return status;
9122}
9123
9124/**
9125 * sme_dcc_get_stats() - Get the DCC stats
9126 * @hHal: reference to the HAL
9127 * @context: the context of the call
9128 * @callback: the callback to hdd
9129 * @request: the get DCC stats request
9130 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309131 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009132 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309133QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009134 ocb_callback callback,
9135 struct sir_dcc_get_stats *request)
9136{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309137 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009138 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009139 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009140 struct sir_dcc_get_stats *msg_body;
9141
9142 /* Lock the SME structure */
9143 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309144 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145 return status;
9146
9147 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309148 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 request->request_array_len);
9150 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309151 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009152 goto end;
9153 }
9154 *msg_body = *request;
9155 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309156 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009157 request->request_array_len);
9158
9159 msg.type = WMA_DCC_GET_STATS_CMD;
9160 msg.bodyptr = msg_body;
9161
9162 /* Set the request callback and context */
9163 pMac->sme.dcc_get_stats_callback = callback;
9164 pMac->sme.dcc_get_stats_context = context;
9165
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309166 status = scheduler_post_message(QDF_MODULE_ID_SME,
9167 QDF_MODULE_ID_WMA,
9168 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309169 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309170 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009171 FL("Error posting message to WDA: %d"), status);
9172 pMac->sme.dcc_get_stats_callback = callback;
9173 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309174 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009175 goto end;
9176 }
9177
9178end:
9179 sme_release_global_lock(&pMac->sme);
9180
9181 return status;
9182}
9183
9184/**
9185 * sme_dcc_clear_stats() - Clear the DCC stats
9186 * @hHal: reference to the HAL
9187 * @vdev_id: vdev id for OCB interface
9188 * @dcc_stats_bitmap: the entries in the stats to clear
9189 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309190 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009191 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309192QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009193 uint32_t dcc_stats_bitmap)
9194{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309195 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009196 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009197 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009198 struct sir_dcc_clear_stats *request;
9199
9200 /* Lock the SME structure */
9201 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309202 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009203 return status;
9204
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309205 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009206 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009208 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309209 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009210 goto end;
9211 }
9212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 request->vdev_id = vdev_id;
9214 request->dcc_stats_bitmap = dcc_stats_bitmap;
9215
9216 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9217 msg.bodyptr = request;
9218
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309219 status = scheduler_post_message(QDF_MODULE_ID_SME,
9220 QDF_MODULE_ID_WMA,
9221 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309222 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309223 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009224 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309225 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009226 goto end;
9227 }
9228
9229end:
9230 sme_release_global_lock(&pMac->sme);
9231
9232 return status;
9233}
9234
9235/**
9236 * sme_dcc_update_ndl() - Update the DCC settings
9237 * @hHal: reference to the HAL
9238 * @context: the context of the call
9239 * @callback: the callback to hdd
9240 * @request: the update DCC request
9241 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309242 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009243 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309244QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009245 ocb_callback callback,
9246 struct sir_dcc_update_ndl *request)
9247{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309248 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009249 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009250 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009251 struct sir_dcc_update_ndl *msg_body;
9252
9253 /* Lock the SME structure */
9254 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309255 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009256 return status;
9257
9258 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309259 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009260 request->dcc_ndl_chan_list_len +
9261 request->dcc_ndl_active_state_list_len);
9262 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309263 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309265 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 goto end;
9267 }
9268
9269 *msg_body = *request;
9270
9271 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9272 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9273 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309274 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309276 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009277 request->dcc_ndl_active_state_list,
9278 request->dcc_ndl_active_state_list_len);
9279
9280 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9281 msg.bodyptr = msg_body;
9282
9283 /* Set the request callback and the context */
9284 pMac->sme.dcc_update_ndl_callback = callback;
9285 pMac->sme.dcc_update_ndl_context = context;
9286
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309287 status = scheduler_post_message(QDF_MODULE_ID_SME,
9288 QDF_MODULE_ID_WMA,
9289 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309290 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009292 FL("Error posting message to WDA: %d"), status);
9293 pMac->sme.dcc_update_ndl_callback = NULL;
9294 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309295 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009296 goto end;
9297 }
9298
9299end:
9300 sme_release_global_lock(&pMac->sme);
9301
9302 return status;
9303}
9304
9305/**
9306 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9307 * event
9308 * @hHal: reference to the HAL
9309 * @context: the context of the call
9310 * @callback: the callback to hdd
9311 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309312 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009313 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309314QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009315 ocb_callback callback)
9316{
9317 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309318 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009319
9320 status = sme_acquire_global_lock(&pMac->sme);
9321 pMac->sme.dcc_stats_event_callback = callback;
9322 pMac->sme.dcc_stats_event_context = context;
9323 sme_release_global_lock(&pMac->sme);
9324
9325 return 0;
9326}
9327
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309328/**
9329 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9330 * event
9331 * @h_hal: Hal Handle
9332 *
9333 * This function de-registers the DCC perioc stats callback
9334 *
9335 * Return: QDF_STATUS Enumeration
9336 */
9337QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9338{
9339 tpAniSirGlobal mac;
9340 QDF_STATUS status;
9341
9342 if (!h_hal) {
9343 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9344 FL("h_hal is not valid"));
9345 return QDF_STATUS_E_INVAL;
9346 }
9347 mac = PMAC_STRUCT(h_hal);
9348
9349 status = sme_acquire_global_lock(&mac->sme);
9350 if (!QDF_IS_STATUS_SUCCESS(status)) {
9351 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9352 FL("Failed to acquire global lock"));
9353 return status;
9354 }
9355 mac->sme.dcc_stats_event_callback = NULL;
9356 mac->sme.dcc_stats_event_context = NULL;
9357 sme_release_global_lock(&mac->sme);
9358
9359 return status;
9360}
Kiran Kumar Lokere1a43bcf2018-05-15 15:51:58 -07009361#else
9362void sme_set_etsi13_srd_ch_in_master_mode(tHalHandle hal,
9363 bool etsi13_srd_chan_support)
9364{
9365 tpAniSirGlobal mac;
9366
9367 mac = PMAC_STRUCT(hal);
9368 mac->sap.enable_etsi13_srd_chan_support = etsi13_srd_chan_support;
9369 sme_debug("srd_ch_support %d", mac->sap.enable_etsi13_srd_chan_support);
9370}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309371#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009373void sme_get_recovery_stats(tHalHandle hHal)
9374{
9375 uint8_t i;
9376
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309377 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378 "Self Recovery Stats");
9379 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9380 if (eSmeNoCommand !=
9381 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309382 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383 "timestamp %llu: command 0x%0X: reason %d: session %d",
9384 g_self_recovery_stats.activeCmdStats[i].
9385 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309386 g_self_recovery_stats.activeCmdStats[i].command,
9387 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009388 g_self_recovery_stats.activeCmdStats[i].
9389 sessionId);
9390 }
9391 }
9392}
9393
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309394QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009396 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009397 tpSirModemPowerStateInd request_buf;
9398 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9399
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309400 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309401 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309403 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009404 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309405 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9407 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309408 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009409 }
9410
9411 request_buf->param = value;
9412
9413 msg.type = WMA_MODEM_POWER_STATE_IND;
9414 msg.reserved = 0;
9415 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309416 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309417 (scheduler_post_message(QDF_MODULE_ID_SME,
9418 QDF_MODULE_ID_WMA,
9419 QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309420 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309421 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9422 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309423 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309424 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009425 }
9426
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309427 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009428}
9429
9430#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309431QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309432 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009433 uint8_t sessionId,
9434 uint8_t channel_type)
9435{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009436 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009437 tUpdateVHTOpMode *pHtOpMode = NULL;
9438 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9439
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309440 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309441 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309443 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009444 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009446 "%s: Not able to allocate memory for setting OP mode",
9447 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309448 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009449 }
9450
9451 switch (channel_type) {
9452 case eHT_CHAN_HT20:
9453 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9454 break;
9455
9456 case eHT_CHAN_HT40MINUS:
9457 case eHT_CHAN_HT40PLUS:
9458 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9459 break;
9460
9461 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309464 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009465 }
9466
9467 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309468 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009469 sizeof(tSirMacAddr));
9470 pHtOpMode->smesessionId = sessionId;
9471
9472 msg.type = WMA_UPDATE_OP_MODE;
9473 msg.reserved = 0;
9474 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309475 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309476 (scheduler_post_message(QDF_MODULE_ID_SME,
9477 QDF_MODULE_ID_WMA,
9478 QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309479 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309480 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9481 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309482 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309483 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009484 }
9485
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309486 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson698eacd2018-05-12 17:00:03 -07009487 "%s: Notified FW about OP mode: %d for staId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009488 __func__, pHtOpMode->opMode, staId);
9489
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309490 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491}
9492
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309493/*
9494 * sme_set_ht2040_mode() -
9495 * To update HT Operation beacon IE.
9496 *
9497 * Return QDF_STATUS SUCCESS
9498 * FAILURE or RESOURCES
9499 * The API finished and failed.
9500 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309501QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009502 uint8_t channel_type, bool obssEnabled)
9503{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309504 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009505 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9506 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309507 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309509 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9510 sme_err("Session not valid for session id %d", sessionId);
9511 return QDF_STATUS_E_INVAL;
9512 }
9513 session = CSR_GET_SESSION(pMac, sessionId);
9514 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9515 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009516
9517 switch (channel_type) {
9518 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309519 if (!session->bssParams.cbMode)
9520 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9522 break;
9523 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309524 if (session->bssParams.cbMode)
9525 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009526 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9527 break;
9528 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309529 if (session->bssParams.cbMode)
9530 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009531 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9532 break;
9533 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309534 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309535 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309537 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309539 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 status = csr_set_ht2040_mode(pMac, sessionId,
9541 cbMode, obssEnabled);
9542 sme_release_global_lock(&pMac->sme);
9543 }
9544 return status;
9545}
9546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009547#endif
9548
9549/*
9550 * SME API to enable/disable idle mode powersave
9551 * This should be called only if powersave offload
9552 * is enabled
9553 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309554QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309556 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009557
9558 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309559 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009560 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309561 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309563 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564 " Idle Ps Set Value %d", value);
9565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309566 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009568 " Failed to Set Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309569 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009570 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309571
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309572 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009573}
9574
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309575int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9576 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009577{
9578 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309579 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009580
9581 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309582 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583 "%s: pSession is NULL", __func__);
9584 return -EIO;
9585 }
9586 switch (ht_capab) {
9587 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9588 return pSession->htConfig.ht_rx_ldpc;
9589 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9590 return pSession->htConfig.ht_tx_stbc;
9591 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9592 return pSession->htConfig.ht_rx_stbc;
9593 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009594 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009595 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009596 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309598 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009599 "invalid ht capability");
9600 return -EIO;
9601 }
9602}
9603
9604int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9605 int value)
9606{
9607 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309608 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609
9610 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309611 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 "%s: pSession is NULL", __func__);
9613 return -EIO;
9614 }
9615
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309616 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009618 "Failed to set ht capability in target");
9619 return -EIO;
9620 }
9621
9622 switch (htCapab) {
9623 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9624 pSession->htConfig.ht_rx_ldpc = value;
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -07009625 pMac->roam.configParam.rx_ldpc_enable = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009626 break;
9627 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9628 pSession->htConfig.ht_tx_stbc = value;
9629 break;
9630 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9631 pSession->htConfig.ht_rx_stbc = value;
9632 break;
9633 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009634 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009635 pSession->htConfig.ht_sgi20 = value;
9636 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009637 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009638 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009639 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009640 break;
9641 }
9642
Naveen Rawat8029a402017-06-01 10:54:19 -07009643 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009644 return 0;
9645}
9646
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08009647int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
9648{
9649 struct sme_addba_accept *addba_accept;
9650 struct scheduler_msg msg = {0};
9651 QDF_STATUS status;
9652
9653 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
9654 if (!addba_accept) {
9655 sme_err("mem alloc failed for addba_accept");
9656 return -EIO;
9657 }
9658 addba_accept->session_id = session_id;
9659 addba_accept->addba_accept = value;
9660 qdf_mem_zero(&msg, sizeof(msg));
9661 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
9662 msg.reserved = 0;
9663 msg.bodyptr = addba_accept;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309664 status = scheduler_post_message(QDF_MODULE_ID_SME,
9665 QDF_MODULE_ID_PE,
9666 QDF_MODULE_ID_PE, &msg);
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08009667 if (status != QDF_STATUS_SUCCESS) {
9668 sme_err("Not able to post addba reject");
9669 qdf_mem_free(addba_accept);
9670 return -EIO;
9671 }
9672 return 0;
9673}
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08009674
9675int sme_set_ba_buff_size(tHalHandle hal, uint8_t session_id,
9676 uint16_t buff_size)
9677{
9678 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9679 if (!buff_size) {
9680 sme_err("invalid buff size %d", buff_size);
9681 return -EINVAL;
9682 }
9683 mac_ctx->usr_cfg_ba_buff_size = buff_size;
9684 sme_debug("addba buff size is set to %d",
9685 mac_ctx->usr_cfg_ba_buff_size);
9686
9687 return 0;
9688}
9689
9690#define DEFAULT_BA_BUFF_SIZE 64
9691int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid,
9692 uint16_t buff_size)
9693{
9694 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9695 uint16_t ba_buff = 0;
9696 QDF_STATUS status;
9697 struct scheduler_msg msg = {0};
9698 struct send_add_ba_req *send_ba_req;
9699 struct csr_roam_session *csr_session = NULL;
9700
9701 if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9702 sme_err("STA not infra/connected state session_id: %d",
9703 session_id);
9704 return -EINVAL;
9705 }
9706 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
9707 if (!csr_session) {
9708 sme_err("CSR session is NULL");
9709 return -EINVAL;
9710 }
9711 send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req));
9712 if (!send_ba_req) {
9713 sme_err("mem alloc failed");
9714 return -EIO;
9715 }
9716 qdf_mem_copy(send_ba_req->mac_addr,
9717 csr_session->connectedProfile.bssid.bytes,
9718 QDF_MAC_ADDR_SIZE);
9719 ba_buff = buff_size;
9720 if (!buff_size) {
9721 if (mac_ctx->usr_cfg_ba_buff_size)
9722 ba_buff = mac_ctx->usr_cfg_ba_buff_size;
9723 else
9724 ba_buff = DEFAULT_BA_BUFF_SIZE;
9725 }
9726 send_ba_req->param.vdev_id = session_id;
9727 send_ba_req->param.tidno = tid;
9728 send_ba_req->param.buffersize = ba_buff;
9729 msg.type = WMA_SEND_ADDBA_REQ;
9730 msg.bodyptr = send_ba_req;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309731 status = scheduler_post_message(QDF_MODULE_ID_SME,
9732 QDF_MODULE_ID_WMA,
9733 QDF_MODULE_ID_WMA, &msg);
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08009734 if (QDF_STATUS_SUCCESS != status) {
9735 sme_err("Failed to post WMA_SEND_ADDBA_REQ");
9736 qdf_mem_free(send_ba_req);
9737 return -EIO;
9738 }
9739 sme_debug("ADDBA_REQ sent to FW: tid %d buff_size %d", tid, ba_buff);
9740
9741 return 0;
9742}
9743
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009744int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id,
9745 uint8_t val, uint8_t ac)
9746{
9747 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9748 uint8_t i, set_val;
Arif Hussaineb8ba362018-03-07 19:15:13 -08009749 struct scheduler_msg msg = {0};
9750 QDF_STATUS status;
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009751
9752 if (ac > MAX_NUM_AC) {
9753 sme_err("invalid ac val %d", ac);
9754 return -EINVAL;
9755 }
9756 if (val)
9757 set_val = 1;
9758 else
9759 set_val = 0;
9760 if (ac == MAX_NUM_AC) {
9761 for (i = 0; i < ac; i++)
9762 mac_ctx->no_ack_policy_cfg[i] = set_val;
9763 } else {
9764 mac_ctx->no_ack_policy_cfg[ac] = set_val;
9765 }
9766 sme_debug("no ack is set to %d for ac %d", set_val, ac);
Arif Hussaineb8ba362018-03-07 19:15:13 -08009767 qdf_mem_zero(&msg, sizeof(msg));
9768 msg.type = eWNI_SME_UPDATE_EDCA_PROFILE;
9769 msg.reserved = 0;
9770 msg.bodyval = session_id;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309771 status = scheduler_post_message(QDF_MODULE_ID_SME,
9772 QDF_MODULE_ID_PE,
9773 QDF_MODULE_ID_PE, &msg);
Arif Hussaineb8ba362018-03-07 19:15:13 -08009774 if (status != QDF_STATUS_SUCCESS) {
9775 sme_err("Not able to post update edca profile");
9776 return -EIO;
9777 }
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009778
9779 return 0;
9780}
9781
Kiran Kumar Lokerea006a302018-03-07 20:58:13 -08009782int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id,
9783 uint8_t cfg_val)
9784{
9785 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9786 uint32_t set_val;
9787 uint32_t bit_mask = 0;
9788 int status;
9789
9790 if (cfg_val > QCA_WLAN_HE_LTF_4X) {
9791 sme_err("invalid HE LTF cfg %d", cfg_val);
9792 return -EINVAL;
9793 }
9794
9795 /*set the corresponding HE LTF cfg BIT*/
9796 if (cfg_val == QCA_WLAN_HE_LTF_AUTO)
9797 bit_mask = HE_LTF_ALL;
9798 else
9799 bit_mask = (1 << (cfg_val - 1));
9800
9801 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9802
9803 SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask);
9804
9805 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9806 status = wma_cli_set_command(session_id,
9807 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9808 set_val, VDEV_CMD);
9809 if (status) {
9810 sme_err("failed to set he_ltf_sgi");
9811 return status;
9812 }
9813
9814 sme_debug("HE SGI_LTF is set to 0x%08X",
9815 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9816
9817 return 0;
9818}
9819
9820int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id,
9821 uint8_t cfg_val)
9822{
9823 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9824 uint32_t set_val;
9825 uint32_t sgi_bit_mask = 0;
9826 int status;
9827
9828 if ((cfg_val > AUTO_RATE_GI_3200NS) ||
9829 (cfg_val < AUTO_RATE_GI_400NS)) {
9830 sme_err("invalid auto rate GI cfg %d", cfg_val);
9831 return -EINVAL;
9832 }
9833
9834 sgi_bit_mask = (1 << cfg_val);
9835
9836 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9837 SET_AUTO_RATE_SGI_VAL(set_val, sgi_bit_mask);
9838
9839 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9840 status = wma_cli_set_command(session_id,
9841 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9842 set_val, VDEV_CMD);
9843 if (status) {
9844 sme_err("failed to set he_ltf_sgi");
9845 return status;
9846 }
9847
9848 sme_debug("auto rate HE SGI_LTF is set to 0x%08X",
9849 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9850
9851 return 0;
9852}
9853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309855/*
9856 * sme_send_rate_update_ind() -
9857 * API to Update rate
9858 *
9859 * hHal - The handle returned by mac_open
9860 * rateUpdateParams - Pointer to rate update params
9861 * Return QDF_STATUS
9862 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309863QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009864 tSirRateUpdateInd *rateUpdateParams)
9865{
9866 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309867 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009868 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309869 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870
9871 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009873 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 }
9876 *rate_upd = *rateUpdateParams;
9877
9878 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
9879 rate_upd->mcastDataRate24GHzTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009880 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 else if (rate_upd->reliableMcastDataRate ==
9882 HT20_SHORT_GI_MCS7_RATE)
9883 rate_upd->reliableMcastDataRateTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009884 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009885
9886 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309887 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888 msg.type = WMA_RATE_UPDATE_IND;
9889 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309890 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9891 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309892 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309893 (scheduler_post_message(QDF_MODULE_ID_SME,
9894 QDF_MODULE_ID_WMA,
9895 QDF_MODULE_ID_WMA,
9896 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309897 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Rachit Kankaneee1735c2018-08-02 13:19:34 +05309898 "%s: Not able to post WMA_RATE_UPDATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009899 __func__);
9900
9901 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309902 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309903 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009904 }
9905
9906 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309907 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908 }
9909
9910 return status;
9911}
9912
9913/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309914 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
9915 * @hal: Pointer to the mac context
9916 * @session_id: sme session id
9917 * @vendor_ie: vendor ie
9918 * @access_policy: vendor ie access policy
9919 *
9920 * This function updates the vendor ie and access policy to lim.
9921 *
9922 * Return: success or failure.
9923 */
9924QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
9925 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
9926{
9927 struct sme_update_access_policy_vendor_ie *msg;
9928 uint16_t msg_len;
9929 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309930
9931 msg_len = sizeof(*msg);
9932
9933 msg = qdf_mem_malloc(msg_len);
9934 if (!msg) {
Srinivas Girigowda09625b02018-09-10 15:28:09 -07009935 return QDF_STATUS_E_NOMEM;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309936 }
9937
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309938 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
9939 msg->length = (uint16_t)msg_len;
9940
9941 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
9942
9943 msg->sme_session_id = session_id;
9944 msg->access_policy = access_policy;
9945
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009946 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
9947 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309948
Rajeev Kumard138ac52017-01-30 18:38:37 -08009949 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309950
9951 return status;
9952}
9953
9954/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309955 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
9956 * @hal: Handle returned by mac_open
9957 * @session_id: Session ID on which short frame retry limit needs to be
9958 * updated to FW
9959 * @short_limit_count_th: Retry count TH to retry short frame.
9960 *
9961 * This function is used to configure count to retry short frame.
9962 *
9963 * Return: QDF_STATUS
9964 */
9965QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
9966 struct sme_short_retry_limit *short_retry_limit_th)
9967{
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309968 QDF_STATUS status = QDF_STATUS_SUCCESS;
9969 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009970 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309971
9972 srl = qdf_mem_malloc(sizeof(*srl));
9973 if (NULL == srl) {
9974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9975 "%s: fail to alloc short retry limit", __func__);
9976 return QDF_STATUS_E_FAILURE;
9977 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009978 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309979 short_retry_limit_th->session_id,
9980 short_retry_limit_th->short_retry_limit);
9981
9982 srl->session_id = short_retry_limit_th->session_id;
9983 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
9984
9985 qdf_mem_zero(&msg, sizeof(msg));
9986 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
9987 msg.reserved = 0;
9988 msg.bodyptr = srl;
gaurank kathpalia36b0c582018-08-28 17:45:43 +05309989 status = scheduler_post_message(QDF_MODULE_ID_SME,
9990 QDF_MODULE_ID_WMA,
9991 QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309992 if (status != QDF_STATUS_SUCCESS) {
9993 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9994 FL("Not able to post short retry limit count to WDA"));
9995 qdf_mem_free(srl);
9996 return QDF_STATUS_E_FAILURE;
9997 }
9998
9999 return status;
10000}
10001
10002/**
10003 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10004 * @hal: Handle returned by mac_open
10005 * @session_id: Session ID on which long frames retry TH needs to be updated
10006 * to FW
10007 * @long_limit_count_th: Retry count to retry long frame.
10008 *
10009 * This function is used to configure TH to retry long frame.
10010 *
10011 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010012 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010013QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10014 struct sme_long_retry_limit *long_retry_limit_th)
10015{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010016 QDF_STATUS status = QDF_STATUS_SUCCESS;
10017 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010018 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010019
10020 lrl = qdf_mem_malloc(sizeof(*lrl));
10021 if (NULL == lrl) {
10022 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10023 "%s: fail to alloc long retry limit", __func__);
10024 return QDF_STATUS_E_FAILURE;
10025 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010026 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010027 long_retry_limit_th->session_id,
10028 long_retry_limit_th->long_retry_limit);
10029
10030 lrl->session_id = long_retry_limit_th->session_id;
10031 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10032
10033 qdf_mem_zero(&msg, sizeof(msg));
10034 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10035 msg.reserved = 0;
10036 msg.bodyptr = lrl;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010037 status = scheduler_post_message(QDF_MODULE_ID_SME,
10038 QDF_MODULE_ID_WMA,
10039 QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010040
10041 if (status != QDF_STATUS_SUCCESS) {
10042 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10043 FL("Not able to post long retry limit count to WDA"));
10044 qdf_mem_free(lrl);
10045 return QDF_STATUS_E_FAILURE;
10046 }
10047
10048 return status;
10049}
10050
10051/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010052 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10053 * @hal: Handle returned by mac_open
10054 * @session_id: Session ID on which sta_inactivity_timeout needs
10055 * to be updated to FW
10056 * @sta_inactivity_timeout: sta inactivity timeout.
10057 *
10058 * If a station does not send anything in sta_inactivity_timeout seconds, an
10059 * empty data frame is sent to it in order to verify whether it is
10060 * still in range. If this frame is not ACKed, the station will be
10061 * disassociated and then deauthenticated.
10062 *
10063 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010064 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010065QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10066 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10067{
10068 struct sme_sta_inactivity_timeout *inactivity_time;
10069 void *wma_handle;
10070
10071 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10072 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10073 if (NULL == inactivity_time) {
10074 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10075 "%s: fail to alloc inactivity_time", __func__);
10076 return QDF_STATUS_E_FAILURE;
10077 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010078 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010079 FL("sta_inactivity_timeout: %d"),
10080 sta_inactivity_timer->sta_inactivity_timeout);
10081 inactivity_time->session_id = sta_inactivity_timer->session_id;
10082 inactivity_time->sta_inactivity_timeout =
10083 sta_inactivity_timer->sta_inactivity_timeout;
10084
10085 wma_update_sta_inactivity_timeout(wma_handle,
10086 inactivity_time);
10087 return QDF_STATUS_SUCCESS;
10088}
10089
10090/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010091 * sme_get_reg_info() - To get registration info
10092 * @hHal: HAL context
10093 * @chanId: channel id
10094 * @regInfo1: first reg info to fill
10095 * @regInfo2: second reg info to fill
10096 *
10097 * This routine will give you reg info
10098 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010099 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010100 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010101QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102 uint32_t *regInfo1, uint32_t *regInfo2)
10103{
10104 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010105 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010106 uint8_t i;
10107 bool found = false;
10108
10109 status = sme_acquire_global_lock(&pMac->sme);
10110 *regInfo1 = 0;
10111 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010112 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010113 return status;
10114
10115 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010116 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010117 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010118 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119
10120 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010121 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010122 found = true;
10123 break;
10124 }
10125 }
10126 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010127 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010128
10129 sme_release_global_lock(&pMac->sme);
10130 return status;
10131}
10132
10133#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010134/*
10135 * sme_auto_shutdown_cb() -
10136 * Used to plug in callback function for receiving auto shutdown evt
10137 *
10138 * hHal
10139 * pCallbackfn : callback function pointer should be plugged in
10140 * Return QDF_STATUS
10141 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010142QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010143 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010144 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010145 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10146
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010147 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010148 "%s: Plug in Auto shutdown event callback", __func__);
10149
10150 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010151 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010152 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010153 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010154 sme_release_global_lock(&pMac->sme);
10155 }
10156
10157 return status;
10158}
10159
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010160/*
10161 * sme_set_auto_shutdown_timer() -
10162 * API to set auto shutdown timer value in FW.
10163 *
10164 * hHal - The handle returned by mac_open
10165 * timer_val - The auto shutdown timer value to be set
10166 * Return Configuration message posting status, SUCCESS or Fail
10167 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010168QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010169{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010170 QDF_STATUS status = QDF_STATUS_SUCCESS;
10171 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010172 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10173 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010174 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010175
10176 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010177 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010178 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010179 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010180 if (auto_sh_cmd == NULL) {
Dustin Browna2868622018-03-20 11:38:14 -070010181 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010182 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010183 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010184 }
10185
10186 auto_sh_cmd->timer_val = timer_val;
10187
10188 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010189 message.bodyptr = auto_sh_cmd;
10190 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010191 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
10192 QDF_MODULE_ID_WMA,
10193 QDF_MODULE_ID_WMA,
10194 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010195 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010197 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010198 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010199 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010203 "%s: Posted Auto shutdown MSG", __func__);
10204 sme_release_global_lock(&pMac->sme);
10205 }
10206
10207 return status;
10208}
10209#endif
10210
Nirav Shaheb017be2018-02-15 11:20:58 +053010211#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010212/*
10213 * sme_ch_avoid_update_req() -
10214 * API to request channel avoidance update from FW.
10215 *
10216 * hHal - The handle returned by mac_open
Jeff Johnsonc5927de2018-05-11 09:12:53 -070010217 * update_type - The update_type parameter of this request call
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010218 * Return Configuration message posting status, SUCCESS or Fail
10219 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010220QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010221{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010222 QDF_STATUS status = QDF_STATUS_SUCCESS;
10223 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010224 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10225 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010226 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010227
10228 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010229 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010230 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010231 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 if (NULL == cauReq) {
Dustin Browna2868622018-03-20 11:38:14 -070010233 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010234 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010235 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010236 }
10237
10238 cauReq->reserved_param = 0;
10239
10240 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010241 message.bodyptr = cauReq;
10242 message.type = WMA_CH_AVOID_UPDATE_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010243 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
10244 QDF_MODULE_ID_WMA,
10245 QDF_MODULE_ID_WMA,
10246 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010247 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010248 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 "%s: Post Ch Avoid Update MSG fail",
10250 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010251 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010252 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010253 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010254 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010255 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010256 "%s: Posted Ch Avoid Update MSG", __func__);
10257 sme_release_global_lock(&pMac->sme);
10258 }
10259
10260 return status;
10261}
Nirav Shaheb017be2018-02-15 11:20:58 +053010262#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263
10264/**
10265 * sme_set_miracast() - Function to set miracast value to UMAC
10266 * @hal: Handle returned by macOpen
10267 * @filter_type: 0-Disabled, 1-Source, 2-sink
10268 *
10269 * This function passes down the value of miracast set by
10270 * framework to UMAC
10271 *
10272 * Return: Configuration message posting status, SUCCESS or Fail
10273 *
10274 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010275QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010276{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010277 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010278 uint32_t *val;
10279 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10280
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010281 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010283 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010284 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010285 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010286 }
10287
10288 *val = filter_type;
10289
10290 msg.type = SIR_HAL_SET_MIRACAST;
10291 msg.reserved = 0;
10292 msg.bodyptr = val;
10293
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010294 if (!QDF_IS_STATUS_SUCCESS(
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010295 scheduler_post_message(QDF_MODULE_ID_SME,
10296 QDF_MODULE_ID_WMA,
10297 QDF_MODULE_ID_WMA,
10298 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010299 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10301 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010302 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010303 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010304 }
10305
10306 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010307 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308}
10309
10310/**
10311 * sme_set_mas() - Function to set MAS value to UMAC
10312 * @val: 1-Enable, 0-Disable
10313 *
10314 * This function passes down the value of MAS to the UMAC. A
10315 * value of 1 will enable MAS and a value of 0 will disable MAS
10316 *
10317 * Return: Configuration message posting status, SUCCESS or Fail
10318 *
10319 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010320QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010321{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010322 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010323 uint32_t *ptr_val;
10324
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010325 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010326 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010327 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010328 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010329 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010330 }
10331
10332 *ptr_val = val;
10333
10334 msg.type = SIR_HAL_SET_MAS;
10335 msg.reserved = 0;
10336 msg.bodyptr = ptr_val;
10337
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010338 if (!QDF_IS_STATUS_SUCCESS(
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010339 scheduler_post_message(QDF_MODULE_ID_SME,
10340 QDF_MODULE_ID_WMA,
10341 QDF_MODULE_ID_WMA,
10342 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010343 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10345 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010346 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010347 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010348 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010349 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010350}
10351
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010352/**
10353 * sme_roam_channel_change_req() - Channel change to new target channel
10354 * @hHal: handle returned by mac_open
10355 * @bssid: mac address of BSS
10356 * @ch_params: target channel information
10357 * @profile: CSR profile
10358 *
10359 * API to Indicate Channel change to new target channel
10360 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010361 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010362 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010363QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010364 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010365 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010366 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010367{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010368 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010370
10371 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010372 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010373
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010374 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010375 profile);
10376 sme_release_global_lock(&pMac->sme);
10377 }
10378 return status;
10379}
10380
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010381/*
10382 * sme_process_channel_change_resp() -
10383 * API to Indicate Channel change response message to SAP.
10384 *
10385 * Return QDF_STATUS
10386 */
10387static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388 uint16_t msg_type, void *pMsgBuf)
10389{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010390 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010391 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010392 eCsrRoamResult roamResult;
10393 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10394 uint32_t SessionId = pChnlParams->peSessionId;
10395
10396 proam_info.channelChangeRespEvent =
10397 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010398 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010399 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010400 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010401 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010402 return status;
10403 }
10404 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10405 proam_info.channelChangeRespEvent->sessionId = SessionId;
10406 proam_info.channelChangeRespEvent->newChannelNumber =
10407 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010408
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010409 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010410 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010411 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10412 SessionId);
10413 proam_info.channelChangeRespEvent->channelChangeStatus =
10414 1;
10415 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10416 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010417 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010418 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10419 SessionId);
10420 proam_info.channelChangeRespEvent->channelChangeStatus =
10421 0;
10422 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10423 }
10424
10425 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10426 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10427
10428 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010429 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010430 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 status);
10432 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010433 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010434
10435 return status;
10436}
10437
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010438/*
10439 * sme_roam_start_beacon_req() -
10440 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10441 *
10442 * hHal - The handle returned by mac_open
10443 * sessionId - session ID
10444 * dfsCacWaitStatus - CAC WAIT status flag
10445 * Return QDF_STATUS
10446 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010447QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010448 uint8_t dfsCacWaitStatus)
10449{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010450 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010451 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 status = sme_acquire_global_lock(&pMac->sme);
10454
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010455 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010456 status = csr_roam_start_beacon_req(pMac, bssid,
10457 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010458 sme_release_global_lock(&pMac->sme);
10459 }
10460 return status;
10461}
10462
Abhishek Singh20a8e442018-09-12 15:50:44 +053010463#ifdef CONFIG_VDEV_SM
10464QDF_STATUS sme_csa_restart(tpAniSirGlobal mac_ctx, uint8_t session_id)
10465{
10466 QDF_STATUS status = QDF_STATUS_E_FAILURE;
10467
10468 status = sme_acquire_global_lock(&mac_ctx->sme);
10469 if (QDF_IS_STATUS_SUCCESS(status)) {
10470 status = csr_csa_restart(mac_ctx, session_id);
10471 sme_release_global_lock(&mac_ctx->sme);
10472 }
10473
10474 return status;
10475}
10476#endif
10477
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010478/**
10479 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10480 * @hHal: handle returned by mac_open
10481 * @bssid: SAP bssid
10482 * @targetChannel: target channel information
10483 * @csaIeReqd: CSA IE Request
10484 * @ch_params: channel information
10485 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010486 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010487 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010488QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010489 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010490 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010491{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010492 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010496 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010497 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10498 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010499 sme_release_global_lock(&pMac->sme);
10500 }
10501 return status;
10502}
10503
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010504/*
10505 * sme_init_thermal_info() -
10506 * SME API to initialize the thermal mitigation parameters
10507 *
10508 * hHal
10509 * thermalParam : thermal mitigation parameters
10510 * Return QDF_STATUS
10511 */
10512QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10513 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010514{
10515 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010516 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010517 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10518
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010519 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010521 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010522 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010523 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010524 }
10525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010526 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10527 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010528
10529 pWmaParam->throttle_duty_cycle_tbl[0] =
10530 thermalParam.sme_throttle_duty_cycle_tbl[0];
10531 pWmaParam->throttle_duty_cycle_tbl[1] =
10532 thermalParam.sme_throttle_duty_cycle_tbl[1];
10533 pWmaParam->throttle_duty_cycle_tbl[2] =
10534 thermalParam.sme_throttle_duty_cycle_tbl[2];
10535 pWmaParam->throttle_duty_cycle_tbl[3] =
10536 thermalParam.sme_throttle_duty_cycle_tbl[3];
10537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010538 pWmaParam->thermalLevels[0].minTempThreshold =
10539 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10540 pWmaParam->thermalLevels[0].maxTempThreshold =
10541 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10542 pWmaParam->thermalLevels[1].minTempThreshold =
10543 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10544 pWmaParam->thermalLevels[1].maxTempThreshold =
10545 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10546 pWmaParam->thermalLevels[2].minTempThreshold =
10547 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10548 pWmaParam->thermalLevels[2].maxTempThreshold =
10549 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10550 pWmaParam->thermalLevels[3].minTempThreshold =
10551 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10552 pWmaParam->thermalLevels[3].maxTempThreshold =
10553 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10554
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010555 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010556 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10557 msg.bodyptr = pWmaParam;
10558
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010559 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010560 (scheduler_post_message(QDF_MODULE_ID_SME,
10561 QDF_MODULE_ID_WMA,
10562 QDF_MODULE_ID_WMA,
10563 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010564 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010565 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10566 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010567 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010568 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010569 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010570 }
10571 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010572 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010573 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010574 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010575 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010576}
10577
10578/**
10579 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10580 * @hal: Handle returned by macOpen
10581 * @callback: sme_set_thermal_level_callback
10582 *
10583 * Plug in set thermal level callback
10584 *
10585 * Return: none
10586 */
10587void sme_add_set_thermal_level_callback(tHalHandle hal,
10588 sme_set_thermal_level_callback callback)
10589{
10590 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10591
10592 pMac->sme.set_thermal_level_cb = callback;
10593}
10594
10595/**
10596 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10597 * @hal: Handler to HAL
10598 * @level: Thermal mitigation level
10599 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010600 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010602QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010603{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010604 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010605 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010606 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010608 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010609 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010610 msg.type = WMA_SET_THERMAL_LEVEL;
10611 msg.bodyval = level;
10612
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010613 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
10614 QDF_MODULE_ID_WMA,
10615 QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010616 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010617 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010618 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10619 __func__);
10620 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010621 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010622 }
10623 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010624 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010625 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010626 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010627}
10628
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010629/*
10630 * sme_txpower_limit() -
10631 * SME API to set txpower limits
10632 *
10633 * hHal
10634 * psmetx : power limits for 2g/5g
10635 * Return QDF_STATUS
10636 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010637QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010638{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010639 QDF_STATUS status = QDF_STATUS_SUCCESS;
10640 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010641 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010642 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010643 tSirTxPowerLimit *tx_power_limit;
10644
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010645 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010646 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010647 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010648 "%s: Memory allocation for TxPowerLimit failed!",
10649 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010650 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010651 }
10652
10653 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010654
10655 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010656 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010657 message.type = WMA_TX_POWER_LIMIT;
10658 message.reserved = 0;
10659 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010660
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010661 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
10662 QDF_MODULE_ID_WMA,
10663 QDF_MODULE_ID_WMA,
10664 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010665 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010666 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010667 "%s: not able to post WMA_TX_POWER_LIMIT",
10668 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010669 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010670 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010671 }
10672 sme_release_global_lock(&pMac->sme);
10673 }
10674 return status;
10675}
10676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010677QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010678{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010680 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010681
Dundi Ravitejaf99ce092018-09-27 17:51:59 +053010682 pMac->mlme_cfg->gen.debug_packet_log = set_value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010683 return status;
10684}
10685
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010686/*
10687 * sme_ap_disable_intra_bss_fwd() -
10688 * SME will send message to WMA to set Intra BSS in txrx
10689 *
10690 * hHal - The handle returned by mac_open
10691 * sessionId - session id ( vdev id)
10692 * disablefwd - bool value that indicate disable intrabss fwd disable
10693 * Return QDF_STATUS
10694 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010695QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696 bool disablefwd)
10697{
10698 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010699 int status = QDF_STATUS_SUCCESS;
10700 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010701 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010702 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10703
10704 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010705 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010706 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010707 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010708 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 }
10710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 pSapDisableIntraFwd->sessionId = sessionId;
10712 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10713
10714 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010715 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010716 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010717 message.bodyptr = pSapDisableIntraFwd;
10718 message.type = WMA_SET_SAP_INTRABSS_DIS;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010719 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
10720 QDF_MODULE_ID_WMA,
10721 QDF_MODULE_ID_WMA,
10722 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010723 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10724 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010725 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010726 }
10727 sme_release_global_lock(&pMac->sme);
10728 }
10729 return status;
10730}
10731
10732#ifdef WLAN_FEATURE_STATS_EXT
10733
Jeff Johnson45843652018-07-04 12:47:34 -070010734void sme_stats_ext_register_callback(mac_handle_t mac_handle,
10735 stats_ext_cb callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010736{
Jeff Johnson45843652018-07-04 12:47:34 -070010737 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010738
Jeff Johnson45843652018-07-04 12:47:34 -070010739 if (!mac) {
10740 sme_err("Invalid mac context");
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010741 return;
10742 }
10743
Jeff Johnson45843652018-07-04 12:47:34 -070010744 mac->sme.stats_ext_cb = callback;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010745}
10746
Jeff Johnson45843652018-07-04 12:47:34 -070010747void sme_stats_ext_deregister_callback(mac_handle_t mac_handle)
10748{
10749 sme_stats_ext_register_callback(mac_handle, NULL);
10750}
10751
10752void sme_stats_ext2_register_callback(mac_handle_t mac_handle,
10753 stats_ext2_cb callback)
10754{
10755 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
10756
10757 if (!mac) {
10758 sme_err("Invalid mac context");
10759 return;
10760 }
10761
10762 mac->sme.stats_ext2_cb = callback;
10763}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010764
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010765/*
10766 * sme_stats_ext_request() -
10767 * Function called when HDD receives STATS EXT vendor command from userspace
10768 *
10769 * sessionID - vdevID for the stats ext request
10770 * input - Stats Ext Request structure ptr
10771 * Return QDF_STATUS
10772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010773QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010774{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010775 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010776 tpStatsExtRequest data;
10777 size_t data_len;
10778
10779 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010780 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010781
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010782 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010783 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010785 data->vdev_id = session_id;
10786 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010787 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010788 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010789 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010790
10791 msg.type = WMA_STATS_EXT_REQUEST;
10792 msg.reserved = 0;
10793 msg.bodyptr = data;
10794
gaurank kathpalia36b0c582018-08-28 17:45:43 +053010795 if (QDF_STATUS_SUCCESS != scheduler_post_message(QDF_MODULE_ID_SME,
10796 QDF_MODULE_ID_WMA,
10797 QDF_MODULE_ID_WMA,
10798 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010799 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10801 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010802 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010803 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010804 }
10805
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010806 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807}
10808
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010809/**
10810 * sme_stats_ext_event() - eWNI_SME_STATS_EXT_EVENT processor
10811 * @mac: Global MAC context
10812 * @msg: "stats ext" message
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010813
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010814 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10815 * response from WMA
10816 *
10817 * Return: QDF_STATUS
10818 */
10819static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
Jeff Johnson45843652018-07-04 12:47:34 -070010820 struct stats_ext_event *msg)
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010821{
10822 if (!msg) {
10823 sme_err("Null msg");
10824 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010825 }
10826
Jeff Johnson45843652018-07-04 12:47:34 -070010827 if (mac->sme.stats_ext_cb)
10828 mac->sme.stats_ext_cb(mac->hdd_handle, msg);
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010829
10830 return QDF_STATUS_SUCCESS;
10831}
10832
10833#else
10834
10835static QDF_STATUS sme_stats_ext_event(tpAniSirGlobal mac,
Jeff Johnson45843652018-07-04 12:47:34 -070010836 struct stats_ext_event *msg)
Jeff Johnsonfdecd512018-06-10 09:18:32 -070010837{
10838 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010839}
10840
10841#endif
10842
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010843/*
10844 * sme_update_dfs_scan_mode() -
10845 * Update DFS roam scan mode
10846 * This function is called through dynamic setConfig callback function
10847 * to configure allowDFSChannelRoam.
10848 * hHal - HAL handle for device
10849 * sessionId - Session Identifier
10850 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10851 * 1 (passive), 2 (active)
10852 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
10853 * successfully.
10854 * Other status means SME failed to update DFS roaming scan config.
10855 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010856QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010857 uint8_t allowDFSChannelRoam)
10858{
10859 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010860 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010861
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080010862 if (sessionId >= CSR_ROAM_SESSION_MAX) {
10863 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10864 FL("Invalid sme session id: %d"), sessionId);
10865 return QDF_STATUS_E_INVAL;
10866 }
10867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010868 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010869 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010871 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872 allowDFSChannelRoam,
10873 pMac->roam.configParam.allowDFSChannelRoam,
10874 mac_trace_get_neighbour_roam_state(pMac->roam.
10875 neighborRoamInfo
10876 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010877 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878 pMac->roam.configParam.allowDFSChannelRoam =
10879 allowDFSChannelRoam;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010880 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
10881 csr_roam_offload_scan(pMac, sessionId,
10882 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10883 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
10884 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010885 sme_release_global_lock(&pMac->sme);
10886 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010888
10889 return status;
10890}
10891
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010892/*
10893 * sme_get_dfs_scan_mode() - get DFS roam scan mode
10894 * This is a synchronous call
10895 *
10896 * hHal - The handle returned by mac_open.
10897 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
10898 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010899uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
10900{
10901 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010903 return pMac->roam.configParam.allowDFSChannelRoam;
10904}
10905
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010906/*
10907 * sme_modify_add_ie() -
10908 * This function sends msg to updates the additional IE buffers in PE
10909 *
10910 * hHal - global structure
10911 * pModifyIE - pointer to tModifyIE structure
10912 * updateType - type of buffer
10913 * Return Success or failure
10914 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010915QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
10917{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010918 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010919 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010921 status = sme_acquire_global_lock(&pMac->sme);
10922
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010923 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010924 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
10925 sme_release_global_lock(&pMac->sme);
10926 }
10927 return status;
10928}
10929
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010930/*
10931 * sme_update_add_ie() -
10932 * This function sends msg to updates the additional IE buffers in PE
10933 *
10934 * hHal - global structure
10935 * pUpdateIE - pointer to structure tUpdateIE
10936 * updateType - type of buffer
10937 * Return Success or failure
10938 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010939QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
10941{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010942 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010943 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010945 status = sme_acquire_global_lock(&pMac->sme);
10946
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010947 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010948 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
10949 sme_release_global_lock(&pMac->sme);
10950 }
10951 return status;
10952}
10953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010954/**
10955 * sme_update_dsc_pto_up_mapping()
10956 * @hHal: HAL context
10957 * @dscpmapping: pointer to DSCP mapping structure
10958 * @sessionId: SME session id
10959 *
10960 * This routine is called to update dscp mapping
10961 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010962 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010963 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010964QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053010965 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010966 uint8_t sessionId)
10967{
10968 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010969 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010970 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010971 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010972 tpPESession pSession = NULL;
10973
10974 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010975 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010976 return status;
10977 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
10978 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010979 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010980 FL("Session lookup fails for CSR session"));
10981 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010982 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 }
10984 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010985 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010986 FL("Invalid session Id %u"), sessionId);
10987 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010988 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010989 }
10990
10991 pSession = pe_find_session_by_bssid(pMac,
10992 pCsrSession->connectedProfile.bssid.bytes,
10993 &peSessionId);
10994
10995 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010997 FL(" Session lookup fails for BSSID"));
10998 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010999 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011000 }
11001
11002 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011003 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011004 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011005 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011006 }
11007 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11008 for (j = pSession->QosMapSet.dscp_range[i][0];
11009 j <= pSession->QosMapSet.dscp_range[i][1];
11010 j++) {
11011 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11012 && (pSession->QosMapSet.dscp_range[i][1] ==
11013 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011014 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011015 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011016 FL("User Priority %d isn't used"), i);
11017 break;
11018 } else {
11019 dscpmapping[j] = i;
11020 }
11021 }
11022 }
11023 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11024 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11025 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11026 pSession->QosMapSet.dscp_exceptions[i][1];
11027
11028 sme_release_global_lock(&pMac->sme);
11029 return status;
11030}
11031
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011032/*
11033 * sme_abort_roam_scan() -
11034 * API to abort current roam scan cycle by roam scan offload module.
11035 *
11036 * hHal - The handle returned by mac_open.
11037 * sessionId - Session Identifier
11038 * Return QDF_STATUS
11039 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011040
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011041QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011042{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011043 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011044 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11045
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011046 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11047 /* acquire the lock for the sme object */
11048 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011049 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011050 csr_roam_offload_scan(pMac, sessionId,
11051 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11052 REASON_ROAM_ABORT_ROAM_SCAN);
11053 /* release the lock for the sme object */
11054 sme_release_global_lock(&pMac->sme);
11055 }
11056 }
11057
11058 return status;
11059}
11060
11061#ifdef FEATURE_WLAN_EXTSCAN
11062/**
11063 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11064 * @hHal: HAL context
11065 * @wifiBand: RF band information
11066 * @aValidChannels: output array to store channel info
11067 * @pNumChannels: output number of channels
11068 *
11069 * SME API to fetch all valid channels filtered by band
11070 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011071 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011072 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011073QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011074 uint8_t wifiBand,
11075 uint32_t *aValidChannels,
11076 uint8_t *pNumChannels)
11077{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011078 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011079 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011080 uint8_t numChannels = 0;
11081 uint8_t i = 0;
11082 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011083 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011084
11085 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011086 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011087 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011088 }
11089
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011090 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011091 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011092 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011093 }
11094
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011095 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011096 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011097 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011098 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011099 return status;
11100 }
11101
11102 switch (wifiBand) {
11103 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011104 sme_debug("Unspec Band, return all %d valid channels",
11105 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011106 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011107 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011108 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011109 break;
11110
11111 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011112 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011114 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011115 aValidChannels[numChannels++] =
11116 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011117 }
11118 break;
11119
11120 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011121 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011122 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011123 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011124 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011125 aValidChannels[numChannels++] =
11126 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011127 }
11128 break;
11129
11130 case WIFI_BAND_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011131 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011132 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011133 if ((WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
11134 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011135 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011136 aValidChannels[numChannels++] =
11137 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011138 }
11139 break;
11140
11141 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011142 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011143 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011144 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011145 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011146 aValidChannels[numChannels++] =
11147 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011148 }
11149 break;
11150
11151 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011152 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011153 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011154 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155 aValidChannels[numChannels++] =
11156 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 }
11158 break;
11159
11160 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011161 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011162 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011163 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011164 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011165 aValidChannels[numChannels++] =
11166 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011167 }
11168 break;
11169
11170 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011171 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011172 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011173 }
11174 *pNumChannels = numChannels;
11175
11176 return status;
11177}
11178
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011179QDF_STATUS
11180sme_ext_scan_get_capabilities(mac_handle_t mac_handle,
11181 struct extscan_capabilities_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011182{
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011183 QDF_STATUS status;
11184 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011185 struct scheduler_msg message = {0};
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011186 struct extscan_capabilities_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011187
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011188 /* per contract must make a copy of the params when messaging */
11189 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11190 if (!bodyptr)
11191 return QDF_STATUS_E_NOMEM;
11192 *bodyptr = *params;
11193
11194 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011195 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011196 /* Serialize the req through MC thread */
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011197 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011198 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011199 qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
11200 NO_SESSION, message.type);
11201 status = scheduler_post_message(QDF_MODULE_ID_SME,
11202 QDF_MODULE_ID_WMA,
11203 QDF_MODULE_ID_WMA,
11204 &message);
11205 sme_release_global_lock(&mac->sme);
11206 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011207
Jeff Johnsonfed9a732018-07-18 12:18:03 -070011208 if (QDF_IS_STATUS_ERROR(status)) {
11209 sme_err("failure: %d", status);
11210 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011211 }
11212 return status;
11213}
11214
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011215/*
11216 * sme_ext_scan_start() -
11217 * SME API to issue extscan start
11218 *
11219 * hHal
11220 * pStartCmd: extscan start structure
11221 * Return QDF_STATUS
11222 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011223QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011224 tSirWifiScanCmdReqParams *pStartCmd)
11225{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011226 QDF_STATUS status = QDF_STATUS_SUCCESS;
11227 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011228 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011229 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011230
11231 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011232 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011233 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011234 message.bodyptr = pStartCmd;
11235 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011236 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011237 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011238 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
11239 QDF_MODULE_ID_WMA,
11240 QDF_MODULE_ID_WMA,
11241 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011242 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11243 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011244
11245 sme_release_global_lock(&pMac->sme);
11246 }
11247 return status;
11248}
11249
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011250/*
11251 * sme_ext_scan_stop() -
11252 * SME API to issue extscan stop
11253 *
11254 * hHal
11255 * pStopReq: extscan stop structure
11256 * Return QDF_STATUS
11257 */
11258QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11259 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011260{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011261 QDF_STATUS status = QDF_STATUS_SUCCESS;
11262 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011263 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011264 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011265
11266 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011267 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011269 message.bodyptr = pStopReq;
11270 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011271 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011272 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011273 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
11274 QDF_MODULE_ID_WMA,
11275 QDF_MODULE_ID_WMA,
11276 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011277 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11278 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011279 sme_release_global_lock(&pMac->sme);
11280 }
11281 return status;
11282}
11283
Jeff Johnson1148cb02018-07-13 23:14:32 -070011284QDF_STATUS
11285sme_set_bss_hotlist(mac_handle_t mac_handle,
11286 struct extscan_bssid_hotlist_set_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011287{
Jeff Johnson1148cb02018-07-13 23:14:32 -070011288 QDF_STATUS status;
11289 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011290 struct scheduler_msg message = {0};
Jeff Johnson1148cb02018-07-13 23:14:32 -070011291 struct extscan_bssid_hotlist_set_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011292
Jeff Johnson1148cb02018-07-13 23:14:32 -070011293 /* per contract must make a copy of the params when messaging */
11294 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11295 if (!bodyptr) {
11296 sme_err("buffer allocation failure");
11297 return QDF_STATUS_E_NOMEM;
11298 }
11299 *bodyptr = *params;
11300
11301 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011302 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303 /* Serialize the req through MC thread */
Jeff Johnson1148cb02018-07-13 23:14:32 -070011304 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011305 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Jeff Johnson1148cb02018-07-13 23:14:32 -070011306 qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
11307 NO_SESSION, message.type);
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011308 status = scheduler_post_message(QDF_MODULE_ID_SME,
11309 QDF_MODULE_ID_WMA,
11310 QDF_MODULE_ID_WMA, &message);
Jeff Johnson1148cb02018-07-13 23:14:32 -070011311 sme_release_global_lock(&mac->sme);
11312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011313
Jeff Johnson1148cb02018-07-13 23:14:32 -070011314 if (QDF_IS_STATUS_ERROR(status)) {
11315 sme_err("failure: %d", status);
11316 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317 }
11318 return status;
11319}
11320
Jeff Johnson9743eb72018-07-14 10:30:04 -070011321QDF_STATUS
11322sme_reset_bss_hotlist(mac_handle_t mac_handle,
11323 struct extscan_bssid_hotlist_reset_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011324{
Jeff Johnson9743eb72018-07-14 10:30:04 -070011325 QDF_STATUS status;
11326 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011327 struct scheduler_msg message = {0};
Jeff Johnson9743eb72018-07-14 10:30:04 -070011328 struct extscan_bssid_hotlist_reset_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011329
Jeff Johnson9743eb72018-07-14 10:30:04 -070011330 /* per contract must make a copy of the params when messaging */
11331 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11332 if (!bodyptr) {
11333 sme_err("buffer allocation failure");
11334 return QDF_STATUS_E_NOMEM;
11335 }
11336 *bodyptr = *params;
11337
11338 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011339 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011340 /* Serialize the req through MC thread */
Jeff Johnson9743eb72018-07-14 10:30:04 -070011341 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011342 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011343 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011344 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011345 status = scheduler_post_message(QDF_MODULE_ID_SME,
11346 QDF_MODULE_ID_WMA,
11347 QDF_MODULE_ID_WMA, &message);
Jeff Johnson9743eb72018-07-14 10:30:04 -070011348 sme_release_global_lock(&mac->sme);
11349 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011350
Jeff Johnson9743eb72018-07-14 10:30:04 -070011351 if (QDF_IS_STATUS_ERROR(status)) {
11352 sme_err("failure: %d", status);
11353 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011354 }
11355 return status;
11356}
11357
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011358QDF_STATUS
11359sme_set_significant_change(mac_handle_t mac_handle,
11360 struct extscan_set_sig_changereq_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011361{
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011362 QDF_STATUS status;
11363 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011364 struct scheduler_msg message = {0};
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011365 struct extscan_set_sig_changereq_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011366
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011367 /* per contract must make a copy of the params when messaging */
11368 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11369 if (!bodyptr) {
11370 sme_err("buffer allocation failure");
11371 return QDF_STATUS_E_NOMEM;
11372 }
11373 *bodyptr = *params;
11374
11375 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011376 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 /* Serialize the req through MC thread */
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011378 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011379 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011380 status = scheduler_post_message(QDF_MODULE_ID_SME,
11381 QDF_MODULE_ID_WMA,
11382 QDF_MODULE_ID_WMA,
11383 &message);
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011384 sme_release_global_lock(&mac->sme);
11385 }
Jeff Johnsonb43ed032018-07-16 06:59:21 -070011386 if (QDF_IS_STATUS_ERROR(status)) {
11387 sme_err("failure: %d", status);
11388 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389 }
11390 return status;
11391}
11392
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011393QDF_STATUS
11394sme_reset_significant_change(mac_handle_t mac_handle,
11395 struct extscan_capabilities_reset_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011396{
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011397 QDF_STATUS status;
11398 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011399 struct scheduler_msg message = {0};
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011400 struct extscan_capabilities_reset_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011402 /* per contract must make a copy of the params when messaging */
11403 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11404 if (!bodyptr) {
11405 sme_err("buffer allocation failure");
11406 return QDF_STATUS_E_NOMEM;
11407 }
11408 *bodyptr = *params;
11409
11410 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011411 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011412 /* Serialize the req through MC thread */
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011413 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011414 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011415 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011416 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011417 status = scheduler_post_message(QDF_MODULE_ID_SME,
11418 QDF_MODULE_ID_WMA,
11419 QDF_MODULE_ID_WMA,
11420 &message);
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011421 sme_release_global_lock(&mac->sme);
11422 }
Jeff Johnson0c8dbc32018-07-16 22:10:48 -070011423 if (QDF_IS_STATUS_ERROR(status)) {
11424 sme_err("failure: %d", status);
11425 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011426 }
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011428 return status;
11429}
11430
Jeff Johnson2ba60092018-07-17 08:19:37 -070011431QDF_STATUS
11432sme_get_cached_results(mac_handle_t mac_handle,
11433 struct extscan_cached_result_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011434{
Jeff Johnson2ba60092018-07-17 08:19:37 -070011435 QDF_STATUS status;
11436 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011437 struct scheduler_msg message = {0};
Jeff Johnson2ba60092018-07-17 08:19:37 -070011438 struct extscan_cached_result_params *bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439
Jeff Johnson2ba60092018-07-17 08:19:37 -070011440 /* per contract must make a copy of the params when messaging */
11441 bodyptr = qdf_mem_malloc(sizeof(*bodyptr));
11442 if (!bodyptr)
11443 return QDF_STATUS_E_NOMEM;
11444 *bodyptr = *params;
11445
11446 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011447 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011448 /* Serialize the req through MC thread */
Jeff Johnson2ba60092018-07-17 08:19:37 -070011449 message.bodyptr = bodyptr;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011450 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Jeff Johnson2ba60092018-07-17 08:19:37 -070011451 qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
11452 NO_SESSION, message.type);
11453 status = scheduler_post_message(QDF_MODULE_ID_SME,
11454 QDF_MODULE_ID_WMA,
11455 QDF_MODULE_ID_WMA,
11456 &message);
11457 sme_release_global_lock(&mac->sme);
11458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011459
Jeff Johnson2ba60092018-07-17 08:19:37 -070011460 if (QDF_IS_STATUS_ERROR(status)) {
11461 sme_err("failure: %d", status);
11462 qdf_mem_free(bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463 }
11464 return status;
11465}
11466
11467/**
11468 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011469 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011470 * @input: request message
11471 *
11472 * This function constructs the cds message and fill in message type,
11473 * bodyptr with %input and posts it to WDA queue.
11474 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011475 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011476 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011477QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011478 struct wifi_epno_params *input)
11479{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011480 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011482 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483 struct wifi_epno_params *req_msg;
11484 int len, i;
11485
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011486 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011487 len = sizeof(*req_msg) +
11488 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011489
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011490 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011491 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011492 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011493 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011494 }
11495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011496 req_msg->num_networks = input->num_networks;
11497 req_msg->request_id = input->request_id;
11498 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011499
11500 /* Fill only when num_networks are non zero */
11501 if (req_msg->num_networks) {
11502 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11503 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11504 req_msg->initial_score_max = input->initial_score_max;
11505 req_msg->same_network_bonus = input->same_network_bonus;
11506 req_msg->secure_bonus = input->secure_bonus;
11507 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11508 req_msg->current_connection_bonus =
11509 input->current_connection_bonus;
11510
11511 for (i = 0; i < req_msg->num_networks; i++) {
11512 req_msg->networks[i].flags = input->networks[i].flags;
11513 req_msg->networks[i].auth_bit_field =
11514 input->networks[i].auth_bit_field;
11515 req_msg->networks[i].ssid.length =
11516 input->networks[i].ssid.length;
11517 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11518 input->networks[i].ssid.ssId,
11519 req_msg->networks[i].ssid.length);
11520 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011521 }
11522
11523 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011524 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011525 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011526 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011527 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011528 return status;
11529 }
11530
11531 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011532 message.bodyptr = req_msg;
11533 message.type = WMA_SET_EPNO_LIST_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011534 status = scheduler_post_message(QDF_MODULE_ID_SME,
11535 QDF_MODULE_ID_WMA,
11536 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011537 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011538 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011539 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011540 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011541 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011542 }
11543 sme_release_global_lock(&mac->sme);
11544 return status;
11545}
11546
11547/**
11548 * sme_set_passpoint_list() - set passpoint network list
11549 * @hal: global hal handle
11550 * @input: request message
11551 *
11552 * This function constructs the cds message and fill in message type,
11553 * bodyptr with @input and posts it to WDA queue.
11554 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011555 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011556 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011557QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011558 struct wifi_passpoint_req *input)
11559{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011560 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011561 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011562 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 struct wifi_passpoint_req *req_msg;
11564 int len, i;
11565
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011566 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011567 len = sizeof(*req_msg) +
11568 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011569 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011570 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011571 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011572 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 }
11574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575 req_msg->num_networks = input->num_networks;
11576 req_msg->request_id = input->request_id;
11577 req_msg->session_id = input->session_id;
11578 for (i = 0; i < req_msg->num_networks; i++) {
11579 req_msg->networks[i].id =
11580 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011581 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 input->networks[i].realm,
11583 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011584 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011585 input->networks[i].plmn,
11586 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011587 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011588 input->networks[i].roaming_consortium_ids,
11589 sizeof(req_msg->networks[i].roaming_consortium_ids));
11590 }
11591
11592 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011593 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011594 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011595 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011596 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011597 return status;
11598 }
11599
11600 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011601 message.bodyptr = req_msg;
11602 message.type = WMA_SET_PASSPOINT_LIST_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011603 status = scheduler_post_message(QDF_MODULE_ID_SME,
11604 QDF_MODULE_ID_WMA,
11605 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011606 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011607 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011608 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011609 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011610 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011611 }
11612 sme_release_global_lock(&mac->sme);
11613 return status;
11614}
11615
11616/**
11617 * sme_reset_passpoint_list() - reset passpoint network list
11618 * @hHal: global hal handle
11619 * @input: request message
11620 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011621 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011622 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011623QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011624 struct wifi_passpoint_req *input)
11625{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011626 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011627 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011628 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011629 struct wifi_passpoint_req *req_msg;
11630
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011631 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011632 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011633 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011634 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011635 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011636 }
11637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011638 req_msg->request_id = input->request_id;
11639 req_msg->session_id = input->session_id;
11640
11641 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011642 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011643 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011644 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011645 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011646 return status;
11647 }
11648
11649 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011650 message.bodyptr = req_msg;
11651 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011652 status = scheduler_post_message(QDF_MODULE_ID_SME,
11653 QDF_MODULE_ID_WMA,
11654 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011655 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011656 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011657 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011658 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011659 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 }
11661 sme_release_global_lock(&mac->sme);
11662 return status;
11663}
11664
Jeff Johnson17b12392018-07-03 22:21:15 -070011665QDF_STATUS sme_ext_scan_register_callback(mac_handle_t mac_handle,
11666 ext_scan_ind_cb ext_scan_ind_cb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011667{
Jeff Johnson17b12392018-07-03 22:21:15 -070011668 QDF_STATUS status;
11669 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670
Jeff Johnson17b12392018-07-03 22:21:15 -070011671 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011672 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson17b12392018-07-03 22:21:15 -070011673 mac->sme.ext_scan_ind_cb = ext_scan_ind_cb;
11674 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011675 }
11676 return status;
11677}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011678#endif /* FEATURE_WLAN_EXTSCAN */
11679
Wen Gong7952fbd2018-04-18 11:27:23 +080011680/**
11681 * sme_send_wisa_params(): Pass WISA mode to WMA
11682 * @hal: HAL context
11683 * @wisa_params: pointer to WISA params struct
11684 * @sessionId: SME session id
11685 *
11686 * Pass WISA params to WMA
11687 *
11688 * Return: QDF_STATUS
11689 */
11690QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11691 struct sir_wisa_params *wisa_params)
11692{
11693 QDF_STATUS status = QDF_STATUS_SUCCESS;
11694 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11695 struct scheduler_msg message = {0};
11696 struct sir_wisa_params *cds_msg_wisa_params;
11697
11698 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11699 if (!cds_msg_wisa_params)
11700 return QDF_STATUS_E_NOMEM;
11701
11702 *cds_msg_wisa_params = *wisa_params;
11703 status = sme_acquire_global_lock(&mac->sme);
11704 if (QDF_IS_STATUS_SUCCESS(status)) {
11705 message.bodyptr = cds_msg_wisa_params;
11706 message.type = WMA_SET_WISA_PARAMS;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011707 status = scheduler_post_message(QDF_MODULE_ID_SME,
11708 QDF_MODULE_ID_WMA,
11709 QDF_MODULE_ID_WMA, &message);
Wen Gong7952fbd2018-04-18 11:27:23 +080011710 sme_release_global_lock(&mac->sme);
11711 }
11712 return status;
11713}
11714
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011715#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11716
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011717/*
11718 * sme_ll_stats_clear_req() -
11719 * SME API to clear Link Layer Statistics
11720 *
11721 * hHal
11722 * pclearStatsReq: Link Layer clear stats request params structure
11723 * Return QDF_STATUS
11724 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011725QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 tSirLLStatsClearReq *pclearStatsReq)
11727{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011728 QDF_STATUS status = QDF_STATUS_SUCCESS;
11729 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011730 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011731 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011732 tSirLLStatsClearReq *clear_stats_req;
11733
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011734 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011736 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011737 "statsClearReqMask = 0x%X",
11738 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011741 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11743 "%s: invalid staId %d",
11744 __func__, pclearStatsReq->staId);
11745 return QDF_STATUS_E_INVAL;
11746 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011747
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011748 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011749
11750 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011751 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011752 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11753 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011754 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 }
11756
11757 *clear_stats_req = *pclearStatsReq;
11758
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011759 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011760 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011761 message.bodyptr = clear_stats_req;
11762 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011763 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011764 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011765 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
11766 QDF_MODULE_ID_WMA,
11767 QDF_MODULE_ID_WMA,
11768 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011769 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011770 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011771 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11772 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011773 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011774 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011775 }
11776 sme_release_global_lock(&pMac->sme);
11777 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011778 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11779 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011780 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011781 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011782 }
11783
11784 return status;
11785}
11786
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011787/*
11788 * sme_ll_stats_set_req() -
11789 * SME API to set the Link Layer Statistics
11790 *
11791 * hHal
11792 * psetStatsReq: Link Layer set stats request params structure
11793 * Return QDF_STATUS
11794 */
11795QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11796 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011798 QDF_STATUS status = QDF_STATUS_SUCCESS;
11799 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011801 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 tSirLLStatsSetReq *set_stats_req;
11803
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011804 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011805 "%s: MPDU Size = %u", __func__,
11806 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011808 " Aggressive Stats Collections = %u",
11809 psetStatsReq->aggressiveStatisticsGathering);
11810
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011811 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812
11813 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011814 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011815 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11816 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011817 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011818 }
11819
11820 *set_stats_req = *psetStatsReq;
11821
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011822 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011823 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011824 message.bodyptr = set_stats_req;
11825 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011826 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011827 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011828 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
11829 QDF_MODULE_ID_WMA,
11830 QDF_MODULE_ID_WMA,
11831 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011832 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011833 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011834 "%s: not able to post WMA_LL_STATS_SET_REQ",
11835 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011836 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011837 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011838 }
11839 sme_release_global_lock(&pMac->sme);
11840 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011841 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11842 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011843 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011844 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011845 }
11846
11847 return status;
11848}
11849
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011850QDF_STATUS sme_ll_stats_get_req(mac_handle_t mac_handle,
11851 tSirLLStatsGetReq *get_stats_req,
11852 void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853{
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011854 QDF_STATUS status = QDF_STATUS_E_FAILURE;
11855 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011856 struct scheduler_msg message = {0};
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011857 tSirLLStatsGetReq *ll_stats_get_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011859 ll_stats_get_req = qdf_mem_malloc(sizeof(*ll_stats_get_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011860
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011861 if (!ll_stats_get_req) {
11862 sme_err("Unable to allocate memory for WMA_LL_STATS_GET_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011863 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011864 }
11865
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011866 *ll_stats_get_req = *get_stats_req;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011867
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011868 mac->sme.ll_stats_context = context;
11869 if (sme_acquire_global_lock(&mac->sme) == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870 /* Serialize the req through MC thread */
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011871 message.bodyptr = ll_stats_get_req;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011872 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011873 qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
11874 NO_SESSION, message.type);
gaurank kathpalia36b0c582018-08-28 17:45:43 +053011875 status = scheduler_post_message(QDF_MODULE_ID_SME,
11876 QDF_MODULE_ID_WMA,
11877 QDF_MODULE_ID_WMA, &message);
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011878 if (!QDF_IS_STATUS_SUCCESS(status)) {
11879 sme_err("Not able to post WMA_LL_STATS_GET_REQ");
11880 qdf_mem_free(ll_stats_get_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 }
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011882 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 } else {
Dundi Ravitejae232cf12018-05-16 18:34:34 +053011884 sme_err("sme_acquire_global_lock error");
11885 qdf_mem_free(ll_stats_get_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011886 }
11887
11888 return status;
11889}
11890
Jeff Johnson959f3692018-07-03 17:30:40 -070011891QDF_STATUS sme_set_link_layer_stats_ind_cb(mac_handle_t mac_handle,
11892 link_layer_stats_cb callback)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011893{
Jeff Johnson959f3692018-07-03 17:30:40 -070011894 QDF_STATUS status;
11895 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011896
Jeff Johnson959f3692018-07-03 17:30:40 -070011897 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011898 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson959f3692018-07-03 17:30:40 -070011899 mac->sme.link_layer_stats_cb = callback;
11900 sme_release_global_lock(&mac->sme);
11901 } else {
11902 sme_err("sme_acquire_global_lock error");
11903 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011904
11905 return status;
11906}
11907
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011908/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080011909 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
11910 * @hal: Mac global handle
11911 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
11912 * status notification from FW
11913 *
11914 * Return: eHalStatus
11915 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011916QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
Jeff Johnson2d292122018-06-02 21:02:02 -070011917 (hdd_handle_t callback_ctx, tSirLLStatsResults
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011918 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080011919{
11920 QDF_STATUS status;
11921 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11922
11923 status = sme_acquire_global_lock(&mac->sme);
11924 if (status == QDF_STATUS_SUCCESS) {
11925 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
11926 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011927 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080011928 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11929 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080011930 return status;
11931}
11932
11933/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011934 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
11935 * indication
11936 * @h_hal: Hal Handle
11937 *
11938 * This function reset's the link layer stats indication
11939 *
11940 * Return: QDF_STATUS Enumeration
11941 */
11942
11943QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
11944{
11945 QDF_STATUS status;
11946 tpAniSirGlobal pmac;
11947
11948 if (!h_hal) {
11949 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11950 FL("hHal is not valid"));
11951 return QDF_STATUS_E_INVAL;
11952 }
11953 pmac = PMAC_STRUCT(h_hal);
11954
11955 status = sme_acquire_global_lock(&pmac->sme);
11956 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson959f3692018-07-03 17:30:40 -070011957 pmac->sme.link_layer_stats_cb = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011958 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011959 } else
11960 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11961 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011962
11963 return status;
11964}
11965
Zhang Qian73c348a2017-03-13 16:15:55 +080011966/**
11967 * sme_ll_stats_set_thresh - set threshold for mac counters
11968 * @hal, hal layer handle
11969 * @threshold, threshold for mac counters
11970 *
11971 * Return: QDF_STATUS Enumeration
11972 */
11973QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
11974 struct sir_ll_ext_stats_threshold *threshold)
11975{
11976 QDF_STATUS status;
11977 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080011978 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080011979 struct sir_ll_ext_stats_threshold *thresh;
11980
11981 if (!threshold) {
11982 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11983 FL("threshold is not valid"));
11984 return QDF_STATUS_E_INVAL;
11985 }
11986
11987 if (!hal) {
11988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11989 FL("hal is not valid"));
11990 return QDF_STATUS_E_INVAL;
11991 }
11992 mac = PMAC_STRUCT(hal);
11993
11994 thresh = qdf_mem_malloc(sizeof(*thresh));
11995 if (!thresh) {
11996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11997 "%s: Fail to alloc mem", __func__);
11998 return QDF_STATUS_E_NOMEM;
11999 }
12000 *thresh = *threshold;
12001
12002 status = sme_acquire_global_lock(&mac->sme);
12003 if (QDF_IS_STATUS_SUCCESS(status)) {
12004 /* Serialize the req through MC thread */
12005 message.bodyptr = thresh;
12006 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12007 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12008 NO_SESSION, message.type));
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012009 status = scheduler_post_message(QDF_MODULE_ID_SME,
12010 QDF_MODULE_ID_WMA,
12011 QDF_MODULE_ID_WMA, &message);
Zhang Qian73c348a2017-03-13 16:15:55 +080012012 if (!QDF_IS_STATUS_SUCCESS(status)) {
12013 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12014 "%s: not able to post WDA_LL_STATS_GET_REQ",
12015 __func__);
12016 qdf_mem_free(thresh);
12017 }
12018 sme_release_global_lock(&mac->sme);
12019 } else {
12020 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12021 FL("sme_acquire_global_lock error"));
12022 qdf_mem_free(thresh);
12023 }
12024 return status;
12025}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012027#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12028
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012029#ifdef WLAN_POWER_DEBUGFS
12030/**
12031 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12032 * @callback_fn: Pointer to the callback function for Power stats event
12033 * @power_stats_context: Pointer to context
12034 *
12035 * Return: QDF_STATUS
12036 */
12037QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12038 (struct power_stats_response *response,
12039 void *context), void *power_stats_context)
12040{
12041 QDF_STATUS status = QDF_STATUS_SUCCESS;
12042 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012043 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012044
12045 status = sme_acquire_global_lock(&mac_ctx->sme);
12046 if (QDF_IS_STATUS_SUCCESS(status)) {
12047 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012048 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012049 sme_release_global_lock(&mac_ctx->sme);
12050 return QDF_STATUS_E_FAILURE;
12051 }
12052
12053 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12054 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12055 msg.bodyptr = NULL;
12056 msg.type = WMA_POWER_DEBUG_STATS_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012057 status = scheduler_post_message(QDF_MODULE_ID_SME,
12058 QDF_MODULE_ID_WMA,
12059 QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012060 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012061 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012062 sme_release_global_lock(&mac_ctx->sme);
12063 }
12064 return status;
12065}
12066#endif
12067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012068#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012069/**
12070 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12071 * This is a synchronous call
12072 * @hal_ctx: The handle returned by mac_open.
12073 * @session_id: Session Identifier
12074 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012075 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012076 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12077 * Other status means SME is failed to update.
12078 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012079
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012080QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012081 uint8_t session_id,
12082 bool key_mgmt_offload_enabled,
12083 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012084{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012085 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012086 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012087
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012088 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012089 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012090 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012092 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12093 __func__, key_mgmt_offload_enabled);
12094 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12095 session_id,
12096 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012097 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012098 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012099 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012100 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012101 }
12102
12103 return status;
12104}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012105#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012106
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012107/*
12108 * sme_get_temperature() -
12109 * SME API to get the pdev temperature
12110 *
12111 * hHal
12112 * temperature context
12113 * pCallbackfn: callback fn with response (temperature)
12114 * Return QDF_STATUS
12115 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012116QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012117 void *tempContext,
12118 void (*pCallbackfn)(int temperature,
12119 void *pContext))
12120{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012121 QDF_STATUS status = QDF_STATUS_SUCCESS;
12122 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012123 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012124 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012125
12126 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012127 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012128 if ((NULL == pCallbackfn) &&
12129 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012131 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012132 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012133 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012134 } else if (NULL != pCallbackfn) {
12135 pMac->sme.pTemperatureCbContext = tempContext;
12136 pMac->sme.pGetTemperatureCb = pCallbackfn;
12137 }
12138 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012139 message.bodyptr = NULL;
12140 message.type = WMA_GET_TEMPERATURE_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012141 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
12142 QDF_MODULE_ID_WMA,
12143 QDF_MODULE_ID_WMA,
12144 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012145 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012146 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012147 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012148 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012149 }
12150 sme_release_global_lock(&pMac->sme);
12151 }
12152 return status;
12153}
12154
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012155/*
12156 * sme_set_scanning_mac_oui() -
12157 * SME API to set scanning mac oui
12158 *
12159 * hHal
12160 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12161 * Return QDF_STATUS
12162 */
12163QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12164 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012166 QDF_STATUS status = QDF_STATUS_SUCCESS;
12167 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012168 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012169 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012170
12171 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012172 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012173 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012174 message.bodyptr = pScanMacOui;
12175 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012176 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
12177 QDF_MODULE_ID_WMA,
12178 QDF_MODULE_ID_WMA,
12179 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012180 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012181 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012182 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012183 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012184 }
12185 sme_release_global_lock(&pMac->sme);
12186 }
12187 return status;
12188}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012189
12190#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012191/*
12192 * sme_set_dhcp_srv_offload() -
12193 * SME API to set DHCP server offload info
12194 *
12195 * hHal
12196 * pDhcpSrvInfo : DHCP server offload info struct
12197 * Return QDF_STATUS
12198 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012199QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012200 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12201{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012202 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012203 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012204 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012205 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12206
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012207 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012208
12209 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012210 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012211 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12212 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012213 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012214 }
12215
12216 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12217
12218 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012219 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012220 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012221 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12222 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012223
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012224 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012225 (scheduler_post_message(QDF_MODULE_ID_SME,
12226 QDF_MODULE_ID_WMA,
12227 QDF_MODULE_ID_WMA,
12228 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012229 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012230 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012231 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012232 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012233 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012234 }
12235 sme_release_global_lock(&pMac->sme);
12236 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012237 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012238 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012239 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012240 }
12241
12242 return status;
12243}
12244#endif /* DHCP_SERVER_OFFLOAD */
12245
Krunal Soniaadaa272017-10-04 16:42:55 -070012246QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12247 uint32_t arg_count, uint32_t *arg)
12248{
12249 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12250 arg_count, arg);
12251}
12252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012253#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012254/*
12255 * sme_set_led_flashing() -
12256 * API to set the Led flashing parameters.
12257 *
12258 * hHal - The handle returned by mac_open.
12259 * x0, x1 - led flashing parameters
12260 * Return QDF_STATUS
12261 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012262QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012263 uint32_t x0, uint32_t x1)
12264{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012265 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012266 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012267 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012268 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012269
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012270 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012271 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012272 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012273 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012274 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012275 }
12276
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012277 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012278 ledflashing->pattern_id = type;
12279 ledflashing->led_x0 = x0;
12280 ledflashing->led_x1 = x1;
12281
12282 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012283 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012284 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012285 message.bodyptr = ledflashing;
12286 message.type = WMA_LED_FLASHING_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012287 status = scheduler_post_message(QDF_MODULE_ID_SME,
12288 QDF_MODULE_ID_WMA,
12289 QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012290 sme_release_global_lock(&pMac->sme);
12291 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012292 if (!QDF_IS_STATUS_SUCCESS(status))
12293 qdf_mem_free(ledflashing);
12294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295 return status;
12296}
12297#endif
12298
12299/**
12300 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12301 * @h_hal: corestack handler
12302 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012303 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012304 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012305QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012306{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012307 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012308 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12309
12310 status = sme_acquire_global_lock(&mac->sme);
12311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012312 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012313
12314 mac->scan.fEnableDFSChnlScan = dfs_flag;
12315
12316 /* update the channel list to the firmware */
12317 status = csr_update_channel_list(mac);
12318
12319 sme_release_global_lock(&mac->sme);
12320 }
12321
12322 return status;
12323}
12324
Min Liu5eaf7242018-03-13 17:32:15 +080012325/**
12326 * sme_enable_dfS_chan_scan() - set DFS channel scan enable/disable
12327 * @h_hal: corestack handler
12328 * @dfs_flag: flag indicating dfs channel enable/disable
12329 * Return: QDF_STATUS
12330 */
12331QDF_STATUS sme_enable_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
12332{
12333 QDF_STATUS status = QDF_STATUS_SUCCESS;
12334 tpAniSirGlobal mac;
12335
12336 if (!h_hal) {
12337 sme_err("hal is NULL");
12338 return QDF_STATUS_E_INVAL;
12339 }
12340
12341 mac = PMAC_STRUCT(h_hal);
Min Liu5eaf7242018-03-13 17:32:15 +080012342
12343 mac->scan.fEnableDFSChnlScan = dfs_flag;
12344
12345 return status;
12346}
12347
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012348#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12349/**
12350 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12351 * concurreny rules set to avoid channel interference.
12352 * @hal - Hal context
12353 * @sap_ch - channel to switch
12354 * @sap_phy_mode - phy mode of SAP
12355 * @cc_switch_mode - concurreny switch mode
12356 * @session_id - sme session id.
12357 *
12358 * Return: true if there is no channel interference else return false
12359 */
12360bool sme_validate_sap_channel_switch(tHalHandle hal,
12361 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12362 uint8_t session_id)
12363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012364 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012365 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012366 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012367 uint16_t intf_channel = 0;
12368
12369 if (!session)
12370 return false;
12371
12372 session->ch_switch_in_progress = true;
12373 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012374 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012375 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12376 sap_phy_mode,
12377 cc_switch_mode);
12378 sme_release_global_lock(&mac->sme);
12379 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012380 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012381 FL("sme_acquire_global_lock error!"));
12382 session->ch_switch_in_progress = false;
12383 return false;
12384 }
12385
12386 session->ch_switch_in_progress = false;
12387 return (intf_channel == 0) ? true : false;
12388}
12389#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012390
12391/**
12392 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12393 * @hal: hal
12394 * @session_id: session ID
12395 * @stats_avg_factor: average stats factor
12396 *
12397 * This function configures the stats avg factor in firmware
12398 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012399 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012400 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012401QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012402 uint16_t stats_avg_factor)
12403{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012404 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012405 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012406 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12407 struct sir_stats_avg_factor *stats_factor;
12408
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012409 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012410
12411 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012412 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012413 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12414 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012415 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012416 }
12417
12418 status = sme_acquire_global_lock(&mac->sme);
12419
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012420 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012421
12422 stats_factor->vdev_id = session_id;
12423 stats_factor->stats_avg_factor = stats_avg_factor;
12424
12425 /* serialize the req through MC thread */
12426 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12427 msg.bodyptr = stats_factor;
12428
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012429 if (!QDF_IS_STATUS_SUCCESS(
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012430 scheduler_post_message(QDF_MODULE_ID_SME,
12431 QDF_MODULE_ID_WMA,
12432 QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012433 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012434 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12435 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012436 qdf_mem_free(stats_factor);
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(&mac->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!",
12443 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012444 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012445 }
12446
12447 return status;
12448}
12449
12450/**
12451 * sme_configure_guard_time() - function to configure guard time
12452 * @hal: hal
12453 * @session_id: session id
12454 * @guard_time: guard time
12455 *
12456 * This function configures the guard time in firmware
12457 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012458 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012460QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012461 uint32_t guard_time)
12462{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012463 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012464 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012465 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12466 struct sir_guard_time_request *g_time;
12467
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012468 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012469
12470 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012471 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012472 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12473 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012474 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012475 }
12476
12477 status = sme_acquire_global_lock(&mac->sme);
12478
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012479 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012480
12481 g_time->vdev_id = session_id;
12482 g_time->guard_time = guard_time;
12483
12484 /* serialize the req through MC thread */
12485 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12486 msg.bodyptr = g_time;
12487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012488 if (!QDF_IS_STATUS_SUCCESS(
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012489 scheduler_post_message(QDF_MODULE_ID_SME,
12490 QDF_MODULE_ID_WMA,
12491 QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012492 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012493 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12494 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012495 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012496 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012497 }
12498 sme_release_global_lock(&mac->sme);
12499 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012500 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501 "%s: sme_acquire_global_lock error!",
12502 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012503 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012504 }
12505
12506 return status;
12507}
12508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012509/*
12510 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12511 * to either start/stop logging
12512 * @hal: HAL context
12513 * @start_log: Structure containing the wifi start logger params
12514 *
12515 * This function sends the start/stop logging command to WMA
12516 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012517 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012518 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012519QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012520 struct sir_wifi_start_log start_log)
12521{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012522 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012523 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012524 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012525 struct sir_wifi_start_log *req_msg;
12526 uint32_t len;
12527
12528 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012529 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012530 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012531 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012532 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012533 }
12534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012535 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012536 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012537 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012538 req_msg->ini_triggered = start_log.ini_triggered;
12539 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012540 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012541 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012542
12543 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012544 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012545 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012546 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012547 return status;
12548 }
12549
12550 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012551 message.bodyptr = req_msg;
12552 message.type = SIR_HAL_START_STOP_LOGGING;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012553 status = scheduler_post_message(QDF_MODULE_ID_SME,
12554 QDF_MODULE_ID_WMA,
12555 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012556 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012557 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012558 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012559 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012560 }
12561 sme_release_global_lock(&mac->sme);
12562
12563 return status;
12564}
12565
12566/**
12567 * sme_neighbor_middle_of_roaming() - Function to know if
12568 * STA is in the middle of roaming states
12569 * @hal: Handle returned by macOpen
12570 * @sessionId: sessionId of the STA session
12571 *
12572 * This function is a wrapper to call
12573 * csr_neighbor_middle_of_roaming to know STA is in the
12574 * middle of roaming states
12575 *
12576 * Return: True or False
12577 *
12578 */
12579bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12580{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012581 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12582 bool val = false;
12583
12584 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12585 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12586 else
Rajeev Kumar9176ca42018-05-03 09:20:40 -070012587 sme_debug("Invalid Session: %d", sessionId);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012588
Sandeep Puligillaca631612016-11-08 11:53:52 -080012589 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012590}
12591
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +053012592bool sme_is_any_session_in_middle_of_roaming(mac_handle_t hal)
12593{
12594 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12595 uint8_t session_id;
12596
12597 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
12598 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
12599 csr_neighbor_middle_of_roaming(mac_ctx, session_id))
12600 return true;
12601 }
12602
12603 return false;
12604}
12605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012606/*
12607 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12608 * @mac: MAC handle
12609 *
12610 * This function is used to send the command that will
12611 * be used to flush the logs in the firmware
12612 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012613 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012614 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012615QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012616{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012617 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012618 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012620 /* Serialize the req through MC thread */
12621 message.bodyptr = NULL;
12622 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012623 status = scheduler_post_message(QDF_MODULE_ID_SME,
12624 QDF_MODULE_ID_WMA,
12625 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012626 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012627 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012628 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012629 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012630 return status;
12631}
12632
Jeff Johnsona1e92612017-09-24 15:33:44 -070012633QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012634 sme_ac_enum_type ac, uint8_t tid,
12635 uint8_t pri, uint32_t srvc_int,
12636 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012637 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012638 uint8_t psb, uint32_t sessionId,
12639 uint32_t delay_interval)
12640{
12641 void *wma_handle;
12642 t_wma_trigger_uapsd_params uapsd_params;
12643 enum uapsd_ac access_category;
12644
12645 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012646 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012647 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012648 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012649 }
12650
Anurag Chouhan6d760662016-02-20 16:05:43 +053012651 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012652 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012653 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012654 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012655 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012656 }
12657
12658 switch (ac) {
12659 case SME_AC_BK:
12660 access_category = UAPSD_BK;
12661 break;
12662 case SME_AC_BE:
12663 access_category = UAPSD_BE;
12664 break;
12665 case SME_AC_VI:
12666 access_category = UAPSD_VI;
12667 break;
12668 case SME_AC_VO:
12669 access_category = UAPSD_VO;
12670 break;
12671 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012672 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 }
12674
12675 uapsd_params.wmm_ac = access_category;
12676 uapsd_params.user_priority = pri;
12677 uapsd_params.service_interval = srvc_int;
12678 uapsd_params.delay_interval = delay_interval;
12679 uapsd_params.suspend_interval = sus_int;
12680
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012681 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012682 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012683 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012684 "Failed to Trigger Uapsd params for sessionId %d",
12685 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012686 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012687 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012688 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012689}
12690
Jeff Johnsona1e92612017-09-24 15:33:44 -070012691QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012692 sme_ac_enum_type ac,
12693 uint32_t sessionId)
12694{
12695 void *wma_handle;
12696 enum uapsd_ac access_category;
12697
12698 switch (ac) {
12699 case SME_AC_BK:
12700 access_category = UAPSD_BK;
12701 break;
12702 case SME_AC_BE:
12703 access_category = UAPSD_BE;
12704 break;
12705 case SME_AC_VI:
12706 access_category = UAPSD_VI;
12707 break;
12708 case SME_AC_VO:
12709 access_category = UAPSD_VO;
12710 break;
12711 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012712 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012713 }
12714
Anurag Chouhan6d760662016-02-20 16:05:43 +053012715 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012716 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012718 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012719 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012720 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012721 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012722 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012723 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012724 "Failed to disable uapsd for ac %d for sessionId %d",
12725 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012726 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012727 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012728 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012729}
12730
12731/**
12732 * sme_update_nss() - SME API to change the number for spatial streams
12733 * (1 or 2)
12734 * @hal: Handle returned by mac open
12735 * @nss: Number of spatial streams
12736 *
12737 * This function is used to update the number of spatial streams supported.
12738 *
12739 * Return: Success upon successfully changing nss else failure
12740 *
12741 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012742QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012743{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012744 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012745 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053012746 uint32_t i;
12747 struct mlme_ht_capabilities_info *ht_cap_info;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012748 struct csr_roam_session *csr_session;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +053012749 struct mlme_vht_capabilities_info vht_cap_info;
12750
12751 vht_cap_info = mac_ctx->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012752
12753 status = sme_acquire_global_lock(&mac_ctx->sme);
12754
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012755 if (QDF_STATUS_SUCCESS == status) {
Abhinav Kumarb074f2f2018-09-15 15:32:11 +053012756 vht_cap_info.enable2x2 = (nss == 1) ? 0 : 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012757
12758 /* get the HT capability info*/
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053012759 ht_cap_info = &mac_ctx->mlme_cfg->ht_caps.ht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012760
12761 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
12762 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
12763 csr_session = &mac_ctx->roam.roamSession[i];
12764 csr_session->htConfig.ht_tx_stbc =
Vignesh Viswanathan78182502018-08-06 15:13:30 +053012765 ht_cap_info->tx_stbc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012766 }
12767 }
12768
12769 sme_release_global_lock(&mac_ctx->sme);
12770 }
12771 return status;
12772}
12773
12774/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070012775 * sme_update_user_configured_nss() - sets the nss based on user request
12776 * @hal: Pointer to HAL
12777 * @nss: number of streams
12778 *
12779 * Return: None
12780 */
12781void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
12782{
12783 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12784
12785 mac_ctx->user_configured_nss = nss;
12786}
12787
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012788int sme_update_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12789 uint8_t cfg_val)
12790{
Abhinav Kumarb074f2f2018-09-15 15:32:11 +053012791 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012792
Abhinav Kumarb074f2f2018-09-15 15:32:11 +053012793 mac_ctx->mlme_cfg->vht_caps.vht_cap_info.su_bformee = cfg_val;
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012794
12795 return sme_update_he_tx_bfee_supp(hal, session_id, cfg_val);
12796}
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070012797
12798int sme_update_tx_bfee_nsts(mac_handle_t hal, uint8_t session_id,
12799 uint8_t usr_cfg_val, uint8_t nsts_val)
12800{
12801 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070012802 uint8_t nsts_set_val;
12803
12804 mac_ctx->usr_cfg_tx_bfee_nsts = usr_cfg_val;
12805 if (usr_cfg_val)
12806 nsts_set_val = usr_cfg_val;
12807 else
12808 nsts_set_val = nsts_val;
Dustin Brown48f27fe2018-10-09 12:47:57 -070012809
12810 mac_ctx->mlme_cfg->vht_caps.vht_cap_info.tx_bfee_ant_supp =
12811 nsts_set_val;
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070012812
Kiran Kumar Lokere86e85592018-07-18 15:34:24 -070012813 if (usr_cfg_val)
12814 sme_set_he_tx_bf_cbf_rates(session_id);
12815
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070012816 return sme_update_he_tx_bfee_nsts(hal, session_id, nsts_set_val);
12817}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012818#ifdef WLAN_FEATURE_11AX
Jinwei Chenffaa4672018-08-30 16:55:09 +080012819void sme_update_tgt_he_cap(mac_handle_t mac_handle,
12820 struct wma_tgt_cfg *cfg,
12821 tDot11fIEhe_cap *he_cap_ini)
Jinwei Chen998a1a02018-06-20 17:20:34 +080012822{
Jinwei Chenef742dc2018-06-27 12:57:50 +080012823 tpAniSirGlobal mac_ctx = PMAC_STRUCT(mac_handle);
Jinwei Chen998a1a02018-06-20 17:20:34 +080012824
12825 qdf_mem_copy(&mac_ctx->he_cap_2g,
Jinwei Chenef742dc2018-06-27 12:57:50 +080012826 &cfg->he_cap_2g,
12827 sizeof(tDot11fIEhe_cap));
Jinwei Chen998a1a02018-06-20 17:20:34 +080012828
12829 qdf_mem_copy(&mac_ctx->he_cap_5g,
Jinwei Chenef742dc2018-06-27 12:57:50 +080012830 &cfg->he_cap_5g,
12831 sizeof(tDot11fIEhe_cap));
Jinwei Chenffaa4672018-08-30 16:55:09 +080012832
12833 /* modify HE Caps field according to INI setting */
12834 mac_ctx->he_cap_2g.bfee_sts_lt_80 =
12835 QDF_MIN(cfg->he_cap_2g.bfee_sts_lt_80,
12836 he_cap_ini->bfee_sts_lt_80);
12837
12838 mac_ctx->he_cap_5g.bfee_sts_lt_80 =
12839 QDF_MIN(cfg->he_cap_5g.bfee_sts_lt_80,
12840 he_cap_ini->bfee_sts_lt_80);
Jinwei Chen998a1a02018-06-20 17:20:34 +080012841}
12842
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012843void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
12844 uint8_t nss)
12845{
12846 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12847 struct csr_roam_session *csr_session;
12848 uint32_t tx_mcs_map = 0;
12849 uint32_t rx_mcs_map = 0;
Kiran Kumar Lokere8dba1892018-07-24 17:09:52 -070012850 uint32_t mcs_map = 0;
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012851
12852 if (!nss || (nss > 2)) {
12853 sme_err("invalid Nss value %d", nss);
12854 }
12855 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012856 sme_cfg_get_int(hal, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
12857 sme_cfg_get_int(hal, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
Kiran Kumar Lokere8dba1892018-07-24 17:09:52 -070012858 mcs_map = rx_mcs_map & 0x3;
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012859 if (nss == 1) {
12860 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
12861 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
12862 } else {
Kiran Kumar Lokere8dba1892018-07-24 17:09:52 -070012863 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, mcs_map, 2);
12864 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, mcs_map, 2);
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012865 }
12866 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
12867 rx_mcs_map, tx_mcs_map);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012868 sme_cfg_set_int(hal, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
12869 sme_cfg_set_int(hal, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012870 csr_update_session_he_cap(mac_ctx, csr_session);
12871
12872}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012873
12874int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
12875{
12876 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12877 struct csr_roam_session *csr_session;
12878 uint16_t mcs_val = 0;
12879 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
12880 uint32_t wni_cfg_tx_param = 0;
12881 uint32_t wni_cfg_rx_param = 0;
12882
12883 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12884 if (!csr_session) {
12885 sme_err("No session for id %d", session_id);
12886 return -EINVAL;
12887 }
12888 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
12889 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
12890 he_mcs);
12891 return -EINVAL;
12892 }
12893 mcs_val = he_mcs & 0x3;
12894 switch (he_mcs) {
12895 case HE_80_MCS0_7:
12896 case HE_80_MCS0_9:
12897 case HE_80_MCS0_11:
Abhinav Kumarb074f2f2018-09-15 15:32:11 +053012898 if (mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2) {
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012899 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12900 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
12901 } else {
12902 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12903 }
12904 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
12905 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
12906 break;
12907
12908 case HE_160_MCS0_7:
12909 case HE_160_MCS0_9:
12910 case HE_160_MCS0_11:
12911 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12912 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
12913 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
12914 break;
12915
12916 case HE_80p80_MCS0_7:
12917 case HE_80p80_MCS0_9:
12918 case HE_80p80_MCS0_11:
12919 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12920 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
12921 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
12922 break;
12923
12924 default:
12925 sme_err("Invalid HE MCS 0x%0x", he_mcs);
12926 return -EINVAL;
12927 }
12928 sme_info("new HE MCS 0x%0x", mcs_map);
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012929 sme_cfg_set_int(hal, wni_cfg_tx_param, mcs_map);
12930 sme_cfg_set_int(hal, wni_cfg_rx_param, mcs_map);
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012931 csr_update_session_he_cap(mac_ctx, csr_session);
12932
12933 return 0;
12934}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012935
12936static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
12937 uint16_t he_cap, int value)
12938{
12939 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12940 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012941
12942 session = CSR_GET_SESSION(mac_ctx, session_id);
12943 if (!session) {
12944 sme_err("No session for id %d", session_id);
12945 return -EINVAL;
12946 }
Jeff Johnsonc18469b2018-06-11 06:48:59 -070012947 sme_cfg_set_int(hal, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080012948 csr_update_session_he_cap(mac_ctx, session);
12949
12950 return 0;
12951}
12952
Kiran Kumar Lokeref54b8552018-07-10 00:53:38 -070012953void sme_set_usr_cfg_mu_edca(mac_handle_t hal, bool val)
12954{
12955 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12956
12957 mac_ctx->usr_cfg_mu_edca_params = val;
12958}
12959
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -070012960int sme_update_mu_edca_params(mac_handle_t hal, uint8_t session_id)
12961{
12962 struct scheduler_msg msg = {0};
12963 QDF_STATUS status;
12964
12965 qdf_mem_zero(&msg, sizeof(msg));
12966 msg.type = WNI_SME_UPDATE_MU_EDCA_PARAMS;
12967 msg.reserved = 0;
12968 msg.bodyval = session_id;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053012969 status = scheduler_post_message(QDF_MODULE_ID_SME,
12970 QDF_MODULE_ID_PE,
12971 QDF_MODULE_ID_PE, &msg);
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -070012972 if (status != QDF_STATUS_SUCCESS) {
12973 sme_err("Not able to post update edca profile");
12974 return -EIO;
12975 }
12976
12977 return 0;
12978}
12979void sme_set_he_mu_edca_def_cfg(mac_handle_t hal)
12980{
12981 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12982 uint8_t i;
12983
Kiran Kumar Lokere8dba1892018-07-24 17:09:52 -070012984 sme_debug("Set MU EDCA params to default");
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -070012985 for (i = 0; i < MAX_NUM_AC; i++) {
12986 mac_ctx->usr_mu_edca_params[i].aci.aifsn = MU_EDCA_DEF_AIFSN;
12987 mac_ctx->usr_mu_edca_params[i].aci.aci = i;
12988 mac_ctx->usr_mu_edca_params[i].cw.max = MU_EDCA_DEF_CW_MAX;
12989 mac_ctx->usr_mu_edca_params[i].cw.min = MU_EDCA_DEF_CW_MIN;
12990 mac_ctx->usr_mu_edca_params[i].mu_edca_timer =
12991 MU_EDCA_DEF_TIMER;
12992 }
12993}
12994
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012995int sme_update_he_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12996 uint8_t cfg_val)
12997{
12998 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_SU_BEAMFORMEE,
12999 cfg_val);
13000}
13001
Kiran Kumar Lokeref54b8552018-07-10 00:53:38 -070013002int sme_update_he_trigger_frm_mac_pad(mac_handle_t hal, uint8_t session_id,
13003 uint8_t cfg_val)
13004{
13005 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_TRIG_PAD,
13006 cfg_val);
13007}
13008
Kiran Kumar Lokeref1a96f42018-08-29 18:53:47 -070013009int sme_update_he_om_ctrl_supp(mac_handle_t hal, uint8_t session_id,
13010 uint8_t cfg_val)
13011{
13012 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_OMI,
13013 cfg_val);
13014}
13015
Kiran Kumar Lokeref3044852018-06-27 14:14:24 -070013016int sme_update_he_tx_bfee_nsts(mac_handle_t hal, uint8_t session_id,
13017 uint8_t cfg_val)
13018{
13019 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_BFEE_STS_LT80,
13020 cfg_val);
13021}
13022
Kiran Kumar Lokere86e85592018-07-18 15:34:24 -070013023void sme_set_he_tx_bf_cbf_rates(uint8_t session_id)
13024{
13025 uint32_t tx_bf_cbf_rates_5g[] = {91, 1, 0, 3, 2, 4, 0};
13026 uint32_t tx_bf_cbf_rates_2g[] = {91, 1, 1, 3, 1, 3, 0};
13027 QDF_STATUS status;
13028
13029 status = wma_form_unit_test_cmd_and_send(session_id, 0x48, 7,
13030 tx_bf_cbf_rates_5g);
13031 if (QDF_STATUS_SUCCESS != status)
13032 sme_err("send_unit_test_cmd returned %d", status);
13033
13034 status = wma_form_unit_test_cmd_and_send(session_id, 0x48, 7,
13035 tx_bf_cbf_rates_2g);
13036 if (QDF_STATUS_SUCCESS != status)
13037 sme_err("send_unit_test_cmd returned %d", status);
13038}
13039
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013040int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13041{
13042 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013043 uint32_t he_cap_val = 0;
13044
13045 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013046
13047 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013048 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013049 if (ret)
13050 return ret;
13051
13052 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013053 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013054}
13055
13056int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13057{
13058 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013059 uint32_t he_cap_val = 0;
13060
13061 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013062
13063 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013064 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013065 if (ret)
13066 return ret;
13067
13068 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013069 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
13070}
13071
13072int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
13073 uint16_t he_frag)
13074{
13075 return sme_update_he_cap(hal, session_id,
13076 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013077}
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -070013078
13079int sme_update_he_ldpc_supp(tHalHandle hal, uint8_t session_id,
13080 uint16_t he_ldpc)
13081{
13082 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_LDPC, he_ldpc);
13083}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013084#endif
13085
Archana Ramachandran5041b252016-04-25 14:29:25 -070013086/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013087 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13088 * @hal: global hal handle
13089 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013090 * @context: callback context
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013091 *
13092 * This function stores nud debug stats callback function.
13093 *
13094 * Return: QDF_STATUS enumeration.
13095 */
13096QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013097 void (*cb)(void *, struct rsp_stats *, void *),
13098 void *context)
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013099{
13100 QDF_STATUS status = QDF_STATUS_SUCCESS;
13101 tpAniSirGlobal mac;
13102
13103 if (!hal) {
13104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13105 FL("hal is not valid"));
13106 return QDF_STATUS_E_INVAL;
13107 }
13108 mac = PMAC_STRUCT(hal);
13109
13110 status = sme_acquire_global_lock(&mac->sme);
13111 if (!QDF_IS_STATUS_SUCCESS(status)) {
13112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13113 FL("sme_acquire_global_lock failed!(status=%d)"),
13114 status);
13115 return status;
13116 }
13117
13118 mac->sme.get_arp_stats_cb = cb;
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013119 mac->sme.get_arp_stats_context = context;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013120 sme_release_global_lock(&mac->sme);
13121 return status;
13122}
13123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013124/**
13125 * sme_is_any_session_in_connected_state() - SME wrapper API to
13126 * check if any session is in connected state or not.
13127 *
13128 * @hal: Handle returned by mac open
13129 *
13130 * This function is used to check if any valid sme session is in
13131 * connected state or not.
13132 *
13133 * Return: true if any session is connected, else false.
13134 *
13135 */
13136bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13137{
13138 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013139 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013140 bool ret = false;
13141
13142 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013143 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013144 ret = csr_is_any_session_in_connect_state(mac_ctx);
13145 sme_release_global_lock(&mac_ctx->sme);
13146 }
13147 return ret;
13148}
13149
Jeff Johnsonb7fa2562018-07-02 08:36:17 -070013150QDF_STATUS sme_set_chip_pwr_save_fail_cb(mac_handle_t mac_handle,
13151 pwr_save_fail_cb cb)
13152{
13153 QDF_STATUS status;
13154 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013155
13156 status = sme_acquire_global_lock(&mac->sme);
13157 if (status != QDF_STATUS_SUCCESS) {
13158 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13159 return status;
13160 }
13161 mac->sme.chip_power_save_fail_cb = cb;
13162 sme_release_global_lock(&mac->sme);
13163 return status;
13164}
13165
Qiwei Caie689a262018-07-26 15:50:22 +080013166#ifdef FEATURE_RSSI_MONITOR
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013167/**
13168 * sme_set_rssi_monitoring() - set rssi monitoring
13169 * @hal: global hal handle
13170 * @input: request message
13171 *
13172 * This function constructs the vos message and fill in message type,
13173 * bodyptr with @input and posts it to WDA queue.
13174 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013175 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013176 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013177QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013178 struct rssi_monitor_req *input)
13179{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013180 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013181 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013182 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013183 struct rssi_monitor_req *req_msg;
13184
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013185 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013186 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013188 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013189 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013190 }
13191
13192 *req_msg = *input;
13193
13194 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013195 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013196 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013197 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013198 return status;
13199 }
13200
13201 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013202 message.bodyptr = req_msg;
13203 message.type = WMA_SET_RSSI_MONITOR_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053013204 status = scheduler_post_message(QDF_MODULE_ID_SME,
13205 QDF_MODULE_ID_WMA,
13206 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013207 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013208 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013209 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013210 }
13211 sme_release_global_lock(&mac->sme);
13212
13213 return status;
13214}
13215
Qiwei Caie689a262018-07-26 15:50:22 +080013216QDF_STATUS sme_set_rssi_threshold_breached_cb(mac_handle_t mac_handle,
13217 rssi_threshold_breached_cb cb)
13218{
13219 QDF_STATUS status;
13220 tpAniSirGlobal mac;
13221
13222 mac = MAC_CONTEXT(mac_handle);
13223 if (!mac) {
13224 sme_err("Invalid mac context");
13225 return QDF_STATUS_E_INVAL;
13226 }
13227
13228 status = sme_acquire_global_lock(&mac->sme);
13229 if (!QDF_IS_STATUS_SUCCESS(status)) {
13230 sme_err("sme_acquire_global_lock failed!(status=%d)",
13231 status);
13232 return status;
13233 }
13234
13235 mac->sme.rssi_threshold_breached_cb = cb;
13236 sme_release_global_lock(&mac->sme);
13237 return status;
13238}
13239#endif /* FEATURE_RSSI_MONITOR */
13240
13241QDF_STATUS sme_reset_rssi_threshold_breached_cb(mac_handle_t mac_handle)
13242{
13243 return sme_set_rssi_threshold_breached_cb(mac_handle, NULL);
13244}
13245
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013246static enum band_info sme_get_connected_roaming_vdev_band(void)
13247{
13248 enum band_info band = BAND_ALL;
13249 tpAniSirGlobal mac = sme_get_mac_context();
13250 struct csr_roam_session *session;
13251 uint8_t session_id, channel;
13252
13253 if (!mac) {
13254 sme_debug("MAC Context is NULL");
13255 return band;
13256 }
13257 session_id = csr_get_roam_enabled_sta_sessionid(mac);
13258 if (session_id != CSR_SESSION_ID_INVALID) {
13259 session = CSR_GET_SESSION(mac, session_id);
13260 channel = session->connectedProfile.operationChannel;
13261 band = csr_get_rf_band(channel);
13262 return band;
13263 }
13264
13265 return band;
13266}
13267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013268/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013269 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013270 * @hal: Handle returned by macOpen
13271 * @msg: PCL channel list and length structure
13272 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013273 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013274 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013275 */
Krunal Soni8a090df2018-05-03 15:02:54 -070013276QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013278 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013279 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013280 struct scheduler_msg message = {0};
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013281 struct set_pcl_req *req_msg;
13282 uint32_t i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013283
Krunal Soni3fa80e22018-01-09 14:16:02 -080013284 if (!mac) {
13285 sme_err("mac is NULL");
13286 return QDF_STATUS_E_FAILURE;
13287 }
Krunal Soni8a090df2018-05-03 15:02:54 -070013288
13289 if (!msg) {
13290 sme_err("msg is NULL");
13291 return QDF_STATUS_E_FAILURE;
13292 }
13293
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013294 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013295 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013296 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013297 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013298 }
13299
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013300 req_msg->band = BAND_ALL;
13301 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(mac)) {
13302 req_msg->band = sme_get_connected_roaming_vdev_band();
13303 sme_debug("Connected STA band %d", req_msg->band);
13304 }
Krunal Soni8a090df2018-05-03 15:02:54 -070013305 for (i = 0; i < msg->pcl_len; i++) {
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013306 req_msg->chan_weights.pcl_list[i] = msg->pcl_list[i];
13307 req_msg->chan_weights.weight_list[i] = msg->weight_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013309
Varun Reddy Yeturu951de5d2018-09-10 21:36:22 -070013310 req_msg->chan_weights.pcl_len = msg->pcl_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013311
13312 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013313 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013314 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013315 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013316 return status;
13317 }
13318
13319 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013320 message.bodyptr = req_msg;
13321 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053013322 status = scheduler_post_message(QDF_MODULE_ID_SME,
13323 QDF_MODULE_ID_WMA,
13324 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013325 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013326 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013327 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013328 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013329 }
13330 sme_release_global_lock(&mac->sme);
13331
13332 return status;
13333}
13334
13335/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013336 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013337 * @hal: Handle returned by macOpen
13338 * @msg: HW mode structure containing hw mode and callback details
13339 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013340 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013341 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013342 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013343QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013344{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013345 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013346 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013347 tSmeCmd *cmd = NULL;
13348
Krunal Soni3fa80e22018-01-09 14:16:02 -080013349 if (!mac) {
13350 sme_err("mac is NULL");
13351 return QDF_STATUS_E_FAILURE;
13352 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013353 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013354 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013355 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013356 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013357 }
13358
Krunal Soni78618d92017-02-14 21:46:31 -080013359 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013360 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013361 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013362 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013363 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013364 }
13365
13366 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013367 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013368 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13369 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013370 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13371 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013372 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013373 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013374
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013375 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013376 cmd->u.set_hw_mode_cmd.session_id,
13377 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 csr_queue_sme_command(mac, cmd, false);
13379
13380 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013381 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013382}
13383
13384/**
13385 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13386 * @hal: Handle returned by macOpen
13387 * @callback: HDD callback to be registered
13388 *
13389 * Registers the HDD callback with SME. This callback will be invoked when
13390 * HW mode transition event is received from the FW
13391 *
13392 * Return: None
13393 */
13394void sme_register_hw_mode_trans_cb(tHalHandle hal,
13395 hw_mode_transition_cb callback)
13396{
13397 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13398
13399 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013400}
13401
13402/**
13403 * sme_nss_update_request() - Send beacon templete update to FW with new
13404 * nss value
13405 * @hal: Handle returned by macOpen
13406 * @vdev_id: the session id
13407 * @new_nss: the new nss value
13408 * @cback: hdd callback
13409 * @next_action: next action to happen at policy mgr after beacon update
13410 *
13411 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013412 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013413 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013414QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13415 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13416 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13417 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013418{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013419 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013420 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013421 tSmeCmd *cmd = NULL;
13422
Krunal Soni3fa80e22018-01-09 14:16:02 -080013423 if (!mac) {
13424 sme_err("mac is null");
13425 return status;
13426 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013427 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013428 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013429 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013430 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013431 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013432 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013433 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013434 }
13435 cmd->command = e_sme_command_nss_update;
13436 /* Sessionized modules may require this info */
13437 cmd->sessionId = vdev_id;
13438 cmd->u.nss_update_cmd.new_nss = new_nss;
13439 cmd->u.nss_update_cmd.session_id = vdev_id;
13440 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013441 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013442 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013443 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013444
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013445 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013446 csr_queue_sme_command(mac, cmd, false);
13447 sme_release_global_lock(&mac->sme);
13448 }
13449 return status;
13450}
13451
13452/**
13453 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13454 * @hal: Handle returned by macOpen
13455 * @msg: Structure containing the dual mac config parameters
13456 *
13457 * Queues configuration information to CSR to configure
13458 * WLAN firmware for the dual MAC features
13459 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013460 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013461 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013462QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013463{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013464 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013465 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013466 tSmeCmd *cmd;
13467
Krunal Soni3fa80e22018-01-09 14:16:02 -080013468 if (!mac) {
13469 sme_err("mac is null");
13470 return QDF_STATUS_E_FAILURE;
13471 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013472 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013473 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013474 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013475 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013476 }
13477
Krunal Soni78618d92017-02-14 21:46:31 -080013478 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013479 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013480 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013481 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013482 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013483 }
13484
13485 cmd->command = e_sme_command_set_dual_mac_config;
13486 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13487 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13488 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13489
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013490 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013491 cmd->u.set_dual_mac_cmd.scan_config,
13492 cmd->u.set_dual_mac_cmd.fw_mode_config);
13493 csr_queue_sme_command(mac, cmd, false);
13494
13495 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013496 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013497}
13498
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013499#ifdef FEATURE_LFR_SUBNET_DETECTION
13500/**
13501 * sme_gateway_param_update() - to update gateway parameters with WMA
13502 * @Hal: hal handle
13503 * @gw_params: request parameters from HDD
13504 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013505 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013506 *
13507 * This routine will update gateway parameters to WMA
13508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013509QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013510 struct gateway_param_update_req *gw_params)
13511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013512 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013513 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013514 struct gateway_param_update_req *request_buf;
13515
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013516 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013517 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013518 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013519 "Not able to allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013520 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013521 }
13522
13523 *request_buf = *gw_params;
13524
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013525 message.type = WMA_GW_PARAM_UPDATE_REQ;
13526 message.reserved = 0;
13527 message.bodyptr = request_buf;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053013528 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
13529 QDF_MODULE_ID_WMA,
13530 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013531 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013532 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013533 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013534 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013535 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013536 }
13537
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013538 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013539}
13540#endif /* FEATURE_LFR_SUBNET_DETECTION */
13541
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013542/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013543 * sme_soc_set_antenna_mode() - set antenna mode
13544 * @hal: Handle returned by macOpen
13545 * @msg: Structure containing the antenna mode parameters
13546 *
13547 * Send the command to CSR to send
13548 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13549 *
13550 * Return: QDF_STATUS
13551 */
13552QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13553 struct sir_antenna_mode_param *msg)
13554{
13555 QDF_STATUS status = QDF_STATUS_SUCCESS;
13556 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13557 tSmeCmd *cmd;
13558
13559 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013560 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013561 return QDF_STATUS_E_FAILURE;
13562 }
13563
13564 status = sme_acquire_global_lock(&mac->sme);
13565 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013566 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013567 return QDF_STATUS_E_RESOURCES;
13568 }
13569
Krunal Soni78618d92017-02-14 21:46:31 -080013570 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013571 if (!cmd) {
13572 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013573 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013574 return QDF_STATUS_E_NULL_VALUE;
13575 }
13576
13577 cmd->command = e_sme_command_set_antenna_mode;
13578 cmd->u.set_antenna_mode_cmd = *msg;
13579
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013580 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013581 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13582 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13583
13584 csr_queue_sme_command(mac, cmd, false);
13585 sme_release_global_lock(&mac->sme);
13586
13587 return QDF_STATUS_SUCCESS;
13588}
13589
13590/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013591 * sme_set_peer_authorized() - call peer authorized callback
13592 * @peer_addr: peer mac address
13593 * @auth_cb: auth callback
13594 * @vdev_id: vdev id
13595 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013596 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013597 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013598QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013599 sme_peer_authorized_fp auth_cb,
13600 uint32_t vdev_id)
13601{
13602 void *wma_handle;
13603
Anurag Chouhan6d760662016-02-20 16:05:43 +053013604 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013605 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013606 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013607 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013608 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013609 }
13610
13611 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13612 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13613 1, vdev_id);
13614}
13615
13616/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013617 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013618 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013619 * @fcc_constraint: flag to enable/disable the constraint
13620 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013621 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013622 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013623 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013624QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13625 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013626{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013627 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013628 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13629
13630 status = sme_acquire_global_lock(&mac_ptr->sme);
13631
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013632 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013633
13634 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13635 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013636 if (scan_pending)
13637 mac_ptr->scan.defer_update_channel_list = true;
13638 else
13639 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013640 }
13641
13642 sme_release_global_lock(&mac_ptr->sme);
13643 }
13644
13645 return status;
13646}
13647/**
13648 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13649 * @hal: Global MAC pointer
13650 *
13651 * Return: NULL.
13652 */
13653void sme_setdef_dot11mode(tHalHandle hal)
13654{
13655 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 csr_set_default_dot11_mode(mac_ctx);
13658}
13659
13660/**
13661 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13662 * params
13663 * @hal_handle - The handle returned by macOpen.
13664 * @session_id - Session Identifier
13665 * @notify_id - Identifies 1 of the 4 parameters to be modified
13666 * @val New value of the parameter
13667 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013668 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669 * Other status means SME failed to update
13670 */
13671
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013672QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013673 uint8_t session_id,
13674 uint32_t notify_id,
13675 int32_t val)
13676{
13677 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013678 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013679 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013680 tpCsrNeighborRoamControlInfo nr_info = NULL;
13681 uint32_t reason = 0;
13682
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013683 if (session_id >= CSR_ROAM_SESSION_MAX) {
13684 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13685 FL("Invalid sme session id: %d"), session_id);
13686 return QDF_STATUS_E_INVAL;
13687 }
13688
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013689 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013690 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013691 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13692 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13693 switch (notify_id) {
13694 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013695 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013696 "%s: gRoamScanHirssiMaxCount %d => %d",
13697 __func__, nr_config->nhi_rssi_scan_max_count,
13698 val);
13699 nr_config->nhi_rssi_scan_max_count = val;
13700 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13701 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13702 break;
13703
13704 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013705 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013706 FL("gRoamScanHiRssiDelta %d => %d"),
13707 nr_config->nhi_rssi_scan_rssi_delta,
13708 val);
13709 nr_config->nhi_rssi_scan_rssi_delta = val;
13710 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13711 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13712 break;
13713
13714 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013715 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013716 FL("gRoamScanHiRssiDelay %d => %d"),
13717 nr_config->nhi_rssi_scan_delay,
13718 val);
13719 nr_config->nhi_rssi_scan_delay = val;
13720 nr_info->cfgParams.hi_rssi_scan_delay = val;
13721 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13722 break;
13723
13724 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013725 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013726 FL("gRoamScanHiRssiUpperBound %d => %d"),
13727 nr_config->nhi_rssi_scan_rssi_ub,
13728 val);
13729 nr_config->nhi_rssi_scan_rssi_ub = val;
13730 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13731 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13732 break;
13733
13734 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013735 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013736 FL("invalid parameter notify_id %d"),
13737 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013738 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013739 break;
13740 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053013741
13742 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
13743 status == QDF_STATUS_SUCCESS) {
13744 csr_roam_offload_scan(mac_ctx, session_id,
13745 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13746 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013747 sme_release_global_lock(&mac_ctx->sme);
13748 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013749
13750 return status;
13751}
13752
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013753/**
13754 * sme_update_tgt_services() - update the target services config.
13755 * @hal: HAL pointer.
13756 * @cfg: wma_tgt_services parameters.
13757 *
13758 * update the target services config.
13759 *
13760 * Return: None.
13761 */
13762void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13763{
13764 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13765
Liangwei Dong0da14262018-07-03 03:30:23 -040013766 mac_ctx->obss_scan_offload = cfg->obss_scan_offload;
13767 sme_debug("obss_scan_offload: %d", mac_ctx->obss_scan_offload);
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013768 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013769 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013770 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013771 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013772 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013773 mac_ctx->is_fils_roaming_supported =
13774 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013775 mac_ctx->is_11k_offload_supported =
13776 cfg->is_11k_offload_supported;
13777 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13778 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13779 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013780}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013781
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013782/**
13783 * sme_is_session_id_valid() - Check if the session id is valid
13784 * @hal: Pointer to HAL
13785 * @session_id: Session id
13786 *
13787 * Checks if the session id is valid or not
13788 *
13789 * Return: True is the session id is valid, false otherwise
13790 */
13791bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13792{
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +053013793 tpAniSirGlobal mac;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013794
Pragaspathi Thilagarajb11dbe42018-07-23 16:42:17 +053013795 if (NULL != hal) {
13796 mac = PMAC_STRUCT(hal);
13797 } else {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13799 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013800 return false;
13801 }
13802
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013803 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013804 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013805
13806 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013807}
13808
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013809#ifdef FEATURE_WLAN_TDLS
13810
13811/**
13812 * sme_get_opclass() - determine operating class
13813 * @hal: Pointer to HAL
13814 * @channel: channel id
13815 * @bw_offset: bandwidth offset
13816 * @opclass: pointer to operating class
13817 *
13818 * Function will determine operating class from regdm_get_opclass_from_channel
13819 *
13820 * Return: none
13821 */
13822void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13823 uint8_t *opclass)
13824{
13825 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13826
13827 /* redgm opclass table contains opclass for 40MHz low primary,
13828 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13829 * first we will check if bit for 40MHz is set and if so find
13830 * matching opclass either with low primary or high primary
13831 * (a channel would never be in both) and then search for opclass
13832 * matching 20MHz, else for any BW.
13833 */
13834 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013835 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013836 mac_ctx->scan.countryCodeCurrent,
13837 channel, BW40_LOW_PRIMARY);
13838 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013839 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013840 mac_ctx->scan.countryCodeCurrent,
13841 channel, BW40_HIGH_PRIMARY);
13842 }
13843 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013844 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013845 mac_ctx->scan.countryCodeCurrent,
13846 channel, BW20);
13847 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013848 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013849 mac_ctx->scan.countryCodeCurrent,
13850 channel, BWALL);
13851 }
13852}
13853#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013854
Sandeep Puligillae0875662016-02-12 16:09:21 -080013855/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013856 * sme_set_fw_test() - set fw test
13857 * @fw_test: fw test param
13858 *
13859 * Return: Return QDF_STATUS, otherwise appropriate failure code
13860 */
13861QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13862{
13863 void *wma_handle;
13864
13865 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13866 if (!wma_handle) {
13867 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13868 "wma handle is NULL");
13869 return QDF_STATUS_E_FAILURE;
13870 }
13871 wma_process_fw_test_cmd(wma_handle, fw_test);
13872 return QDF_STATUS_SUCCESS;
13873}
13874
13875/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013876 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13877 * @hal: mac handel
13878 * @vdev_id: vdev identifier
13879 *
13880 * Return: Return QDF_STATUS, otherwise appropriate failure code
13881 */
13882QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13883{
13884 void *wma_handle;
13885
13886 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13887 if (!wma_handle) {
13888 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13889 "wma handle is NULL");
13890 return QDF_STATUS_E_FAILURE;
13891 }
13892 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13893 return QDF_STATUS_SUCCESS;
13894}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013895
13896/**
13897 * sme_update_mimo_power_save() - Update MIMO power save
13898 * configuration
13899 * @hal: The handle returned by macOpen
13900 * @is_ht_smps_enabled: enable/disable ht smps
13901 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013902 * @send_smps_action: flag to send smps force mode command
13903 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013904 *
13905 * Return: QDF_STATUS if SME update mimo power save
Jeff Johnson698eacd2018-05-12 17:00:03 -070013906 * configuration success else failure status
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013907 */
13908QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13909 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013910 uint8_t ht_smps_mode,
13911 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013912{
13913 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013914
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013915 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013916 is_ht_smps_enabled, ht_smps_mode,
13917 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013918 mac_ctx->roam.configParam.enableHtSmps =
13919 is_ht_smps_enabled;
13920 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013921 mac_ctx->roam.configParam.send_smps_action =
13922 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013923
13924 return QDF_STATUS_SUCCESS;
13925}
13926
13927/**
13928 * sme_is_sta_smps_allowed() - check if the supported nss for
13929 * the session is greater than 1x1 to enable sta SMPS
13930 * @hal: The handle returned by macOpen
13931 * @session_id: session id
13932 *
13933 * Return: bool returns true if supported nss is greater than
13934 * 1x1 else false
13935 */
13936bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13937{
13938 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013939 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013940
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013941 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13942 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013943 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013944 return false;
13945 }
13946
13947 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013948 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013949 return false;
13950 }
13951
13952 return (csr_session->supported_nss_1x1 == true) ? false : true;
13953}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013954
13955/**
13956 * sme_add_beacon_filter() - set the beacon filter configuration
13957 * @hal: The handle returned by macOpen
13958 * @session_id: session id
13959 * @ie_map: bitwise array of IEs
13960 *
13961 * Return: Return QDF_STATUS, otherwise appropriate failure code
13962 */
13963QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13964 uint32_t session_id,
13965 uint32_t *ie_map)
13966{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013967 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013968 QDF_STATUS qdf_status;
13969 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13970 struct beacon_filter_param *filter_param;
13971
13972 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013973 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013974 return QDF_STATUS_E_FAILURE;
13975 }
13976
13977 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13978 if (NULL == filter_param) {
13979 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13980 "%s: fail to alloc filter_param", __func__);
13981 return QDF_STATUS_E_FAILURE;
13982 }
13983
13984 filter_param->vdev_id = session_id;
13985
13986 qdf_mem_copy(filter_param->ie_map, ie_map,
13987 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
13988
13989 message.type = WMA_ADD_BCN_FILTER_CMDID;
13990 message.bodyptr = filter_param;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053013991 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
13992 QDF_MODULE_ID_WMA,
13993 QDF_MODULE_ID_WMA,
13994 &message);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013995 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
13996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13997 "%s: Not able to post msg to WDA!",
13998 __func__);
13999
14000 qdf_mem_free(filter_param);
14001 }
14002 return qdf_status;
14003}
14004
14005/**
14006 * sme_remove_beacon_filter() - set the beacon filter configuration
14007 * @hal: The handle returned by macOpen
14008 * @session_id: session id
14009 *
14010 * Return: Return QDF_STATUS, otherwise appropriate failure code
14011 */
14012QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14013{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014014 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014015 QDF_STATUS qdf_status;
14016 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14017 struct beacon_filter_param *filter_param;
14018
14019 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014020 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014021 return QDF_STATUS_E_FAILURE;
14022 }
14023
14024 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14025 if (NULL == filter_param) {
14026 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14027 "%s: fail to alloc filter_param", __func__);
14028 return QDF_STATUS_E_FAILURE;
14029 }
14030
14031 filter_param->vdev_id = session_id;
14032
14033 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14034 message.bodyptr = filter_param;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014035 qdf_status = scheduler_post_message(QDF_MODULE_ID_SME,
14036 QDF_MODULE_ID_WMA,
14037 QDF_MODULE_ID_WMA,
14038 &message);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014039 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14040 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14041 "%s: Not able to post msg to WDA!",
14042 __func__);
14043
14044 qdf_mem_free(filter_param);
14045 }
14046 return qdf_status;
14047}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014048
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014049/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014050 * sme_send_disassoc_req_frame - send disassoc req
14051 * @hal: handler to hal
14052 * @session_id: session id
14053 * @peer_mac: peer mac address
14054 * @reason: reason for disassociation
14055 * wait_for_ack: wait for acknowledgment
14056 *
14057 * function to send disassoc request to lim
14058 *
14059 * return: none
14060 */
14061void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14062 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14063{
14064 struct sme_send_disassoc_frm_req *msg;
14065 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14066 A_UINT8 *buf;
14067 A_UINT16 tmp;
14068
14069 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14070
14071 if (NULL == msg)
14072 qdf_status = QDF_STATUS_E_FAILURE;
14073 else
14074 qdf_status = QDF_STATUS_SUCCESS;
14075
14076 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14077 return;
14078
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014079 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14080
14081 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14082
14083 buf = &msg->session_id;
14084
14085 /* session id */
14086 *buf = (A_UINT8) session_id;
14087 buf += sizeof(A_UINT8);
14088
14089 /* transaction id */
14090 *buf = 0;
14091 *(buf + 1) = 0;
14092 buf += sizeof(A_UINT16);
14093
14094 /* Set the peer MAC address before sending the message to LIM */
14095 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14096
14097 buf += QDF_MAC_ADDR_SIZE;
14098
14099 /* reasoncode */
14100 tmp = (uint16_t) reason;
14101 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14102 buf += sizeof(uint16_t);
14103
14104 *buf = wait_for_ack;
14105 buf += sizeof(uint8_t);
14106
Rajeev Kumard138ac52017-01-30 18:38:37 -080014107 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014108
14109 if (qdf_status != QDF_STATUS_SUCCESS)
14110 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14111 FL("cds_send_mb_message Failed"));
14112}
14113
Nachiket Kukade177b5b02018-05-22 20:52:17 +053014114#ifdef FEATURE_WLAN_APF
14115QDF_STATUS sme_get_apf_capabilities(tHalHandle hal,
14116 apf_get_offload_cb callback,
14117 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014118{
14119 QDF_STATUS status = QDF_STATUS_SUCCESS;
14120 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014121 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014122
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014123 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014124
14125 status = sme_acquire_global_lock(&mac_ctx->sme);
14126 if (QDF_STATUS_SUCCESS == status) {
14127 /* Serialize the req through MC thread */
Nachiket Kukadee547a482018-05-22 16:43:30 +053014128 mac_ctx->sme.apf_get_offload_cb = callback;
14129 mac_ctx->sme.apf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014130 cds_msg.bodyptr = NULL;
Nachiket Kukadee547a482018-05-22 16:43:30 +053014131 cds_msg.type = WDA_APF_GET_CAPABILITIES_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014132 status = scheduler_post_message(QDF_MODULE_ID_SME,
14133 QDF_MODULE_ID_WMA,
14134 QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014135 if (!QDF_IS_STATUS_SUCCESS(status)) {
14136 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053014137 FL("Post apf get offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014138 status = QDF_STATUS_E_FAILURE;
14139 }
14140 sme_release_global_lock(&mac_ctx->sme);
14141 } else {
14142 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14143 FL("sme_acquire_global_lock error"));
14144 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014145 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014146 return status;
14147}
14148
Nachiket Kukadee547a482018-05-22 16:43:30 +053014149QDF_STATUS sme_set_apf_instructions(tHalHandle hal,
14150 struct sir_apf_set_offload *req)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014151{
14152 QDF_STATUS status = QDF_STATUS_SUCCESS;
14153 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014154 struct scheduler_msg cds_msg = {0};
Nachiket Kukadee547a482018-05-22 16:43:30 +053014155 struct sir_apf_set_offload *set_offload;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014156
Arun Khandavallica198b52016-04-26 20:53:35 +053014157 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14158 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014159
14160 if (NULL == set_offload) {
14161 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14162 FL("Failed to alloc set_offload"));
14163 return QDF_STATUS_E_NOMEM;
14164 }
14165
14166 set_offload->session_id = req->session_id;
14167 set_offload->filter_id = req->filter_id;
14168 set_offload->current_offset = req->current_offset;
14169 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014170 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014171 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014172 set_offload->program = ((uint8_t *)set_offload) +
14173 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014174 qdf_mem_copy(set_offload->program, req->program,
14175 set_offload->current_length);
14176 }
14177 status = sme_acquire_global_lock(&mac_ctx->sme);
14178 if (QDF_STATUS_SUCCESS == status) {
14179 /* Serialize the req through MC thread */
14180 cds_msg.bodyptr = set_offload;
Nachiket Kukadee547a482018-05-22 16:43:30 +053014181 cds_msg.type = WDA_APF_SET_INSTRUCTIONS_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014182 status = scheduler_post_message(QDF_MODULE_ID_SME,
14183 QDF_MODULE_ID_WMA,
14184 QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014185
14186 if (!QDF_IS_STATUS_SUCCESS(status)) {
14187 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053014188 FL("Post APF set offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014189 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014190 qdf_mem_free(set_offload);
14191 }
14192 sme_release_global_lock(&mac_ctx->sme);
14193 } else {
14194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14195 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014196 qdf_mem_free(set_offload);
14197 }
14198 return status;
14199}
14200
Nachiket Kukade177b5b02018-05-22 20:52:17 +053014201QDF_STATUS sme_set_apf_enable_disable(tHalHandle hal, uint8_t vdev_id,
14202 bool apf_enable)
14203{
14204 void *wma_handle;
14205
14206 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14207 if (!wma_handle) {
14208 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14209 "wma handle is NULL");
14210 return QDF_STATUS_E_FAILURE;
14211 }
14212
14213 return wma_send_apf_enable_cmd(wma_handle, vdev_id, apf_enable);
14214}
14215
14216QDF_STATUS
14217sme_apf_write_work_memory(tHalHandle hal,
14218 struct wmi_apf_write_memory_params *write_params)
14219{
14220 void *wma_handle;
14221
14222 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14223 if (!wma_handle) {
14224 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14225 "wma handle is NULL");
14226 return QDF_STATUS_E_FAILURE;
14227 }
14228
14229 return wma_send_apf_write_work_memory_cmd(wma_handle, write_params);
14230}
14231
14232QDF_STATUS
14233sme_apf_read_work_memory(tHalHandle hal,
14234 struct wmi_apf_read_memory_params *read_params,
14235 apf_read_mem_cb callback)
14236{
14237 QDF_STATUS status = QDF_STATUS_SUCCESS;
14238 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14239 void *wma_handle;
14240
14241 status = sme_acquire_global_lock(&mac->sme);
14242 if (QDF_IS_STATUS_SUCCESS(status)) {
14243 mac->sme.apf_read_mem_cb = callback;
14244 sme_release_global_lock(&mac->sme);
14245 } else {
14246 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14247 FL("sme_acquire_global_lock failed"));
14248 }
14249
14250 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14251 if (!wma_handle) {
14252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14253 "wma handle is NULL");
14254 return QDF_STATUS_E_FAILURE;
14255 }
14256
14257 return wma_send_apf_read_work_memory_cmd(wma_handle, read_params);
14258}
14259#endif /* FEATURE_WLAN_APF */
14260
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014261/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014262 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14263 * @hal: hal pointer
14264 *
14265 * Return: wni dot11 mode.
14266 */
14267uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14268{
14269 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14270
14271 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14272 mac_ctx->roam.configParam.uCfgDot11Mode);
14273}
14274
14275/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014276 * sme_create_mon_session() - post message to create PE session for monitormode
14277 * operation
14278 * @hal_handle: Handle to the HAL
14279 * @bssid: pointer to bssid
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +053014280 * @vdev_id: sme session id
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014281 *
14282 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14283 */
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +053014284QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id,
14285 uint8_t vdev_id)
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014286{
14287 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14288 struct sir_create_session *msg;
14289
14290 msg = qdf_mem_malloc(sizeof(*msg));
14291 if (NULL != msg) {
14292 msg->type = eWNI_SME_MON_INIT_SESSION;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +053014293 msg->vdev_id = vdev_id;
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014294 msg->msg_len = sizeof(*msg);
14295 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014296 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014297 }
14298 return status;
14299}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014300
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014301void sme_set_chan_info_callback(tHalHandle hal_handle,
14302 void (*callback)(struct scan_chan_info *chan_info))
14303{
14304 tpAniSirGlobal mac;
14305
14306 if (hal_handle == NULL) {
14307 QDF_ASSERT(0);
14308 return;
14309 }
14310 mac = PMAC_STRUCT(hal_handle);
14311 mac->chan_info_cb = callback;
14312}
14313
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014314/**
14315 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14316 * @hal: The handle returned by macOpen
14317 * @params: adaptive_dwelltime_params config
14318 *
14319 * Return: QDF_STATUS if adaptive dwell time update
Jeff Johnson698eacd2018-05-12 17:00:03 -070014320 * configuration success else failure status
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014321 */
14322QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14323 struct adaptive_dwelltime_params *params)
14324{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014325 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014326 QDF_STATUS status;
14327 struct adaptive_dwelltime_params *dwelltime_params;
14328
14329 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14330 if (NULL == dwelltime_params) {
14331 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14332 "%s: fail to alloc dwelltime_params", __func__);
14333 return QDF_STATUS_E_NOMEM;
14334 }
14335
14336 dwelltime_params->is_enabled = params->is_enabled;
14337 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14338 dwelltime_params->lpf_weight = params->lpf_weight;
14339 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14340 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14341
14342 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14343 message.bodyptr = dwelltime_params;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014344 status = scheduler_post_message(QDF_MODULE_ID_SME,
14345 QDF_MODULE_ID_WMA,
14346 QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014347 if (!QDF_IS_STATUS_SUCCESS(status)) {
14348 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14349 "%s: Not able to post msg to WMA!", __func__);
14350
14351 qdf_mem_free(dwelltime_params);
14352 }
14353 return status;
14354}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014355
14356/**
14357 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14358 * @hal: Pointer to HAL
14359 * @vdev_id: vdev_id for which IE is targeted
14360 *
14361 * Return: None
14362 */
14363void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14364{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014365 struct sir_set_vdev_ies_per_band *p_msg;
14366 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14367
14368 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14369 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014370 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014371 return;
14372 }
14373
14374 p_msg->vdev_id = vdev_id;
14375 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14376 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014377 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014378 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014379 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014380 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014381 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014382}
14383
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014384/**
14385 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14386 * @hal: Pointer to HAL
14387 * @enable2x2: 1x1 or 2x2 mode.
14388 *
14389 * Sends the set pdev IE req with Nss value.
14390 *
14391 * Return: None
14392 */
14393void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14394{
14395 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14396 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14397 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14398
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014399 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14400 eCSR_CFG_DOT11_MODE_AUTO) ||
14401 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14402 eCSR_CFG_DOT11_MODE_11N) ||
14403 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14404 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14405 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14406 eCSR_CFG_DOT11_MODE_11AC) ||
14407 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14408 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14409 return;
14410
14411 status = sme_acquire_global_lock(&mac_ctx->sme);
14412 if (QDF_STATUS_SUCCESS == status) {
14413 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14414 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014415 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014416 sme_release_global_lock(&mac_ctx->sme);
14417 return;
14418 }
14419
14420 ht_vht_cfg->pdev_id = 0;
14421 if (enable2x2)
14422 ht_vht_cfg->nss = 2;
14423 else
14424 ht_vht_cfg->nss = 1;
14425 ht_vht_cfg->dot11mode =
14426 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14427 mac_ctx->roam.configParam.uCfgDot11Mode);
14428
14429 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14430 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014431 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14432 ht_vht_cfg->nss,
14433 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014434 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014435 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014436 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014437
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014438 sme_release_global_lock(&mac_ctx->sme);
14439 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014440}
14441
14442/**
14443 * sme_update_vdev_type_nss() - sets the nss per vdev type
14444 * @hal: Pointer to HAL
14445 * @max_supp_nss: max_supported Nss
14446 * @band: 5G or 2.4G band
14447 *
14448 * Sets the per band Nss for each vdev type based on INI and configured
14449 * chain mask value.
14450 *
14451 * Return: None
14452 */
14453void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014454 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014455{
14456 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14457 struct vdev_type_nss *vdev_nss;
14458
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014459 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014460 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14461 else
14462 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14463
14464 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14465 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14466 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14467 CFG_P2P_GO_NSS(vdev_type_nss));
14468 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14469 CFG_P2P_CLI_NSS(vdev_type_nss));
14470 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14471 CFG_P2P_DEV_NSS(vdev_type_nss));
14472 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14473 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14474 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14475
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014476 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 -070014477 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14478 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14479 vdev_nss->tdls, vdev_nss->ocb);
14480}
Peng Xu8fdaa492016-06-22 10:20:47 -070014481
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014482#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14483#define MAX_BSS_COLOR_VAL 63
14484#define MIN_BSS_COLOR_VAL 1
14485
14486QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14487 uint8_t bss_color)
14488
14489{
14490 struct sir_set_he_bss_color *bss_color_msg;
14491 uint8_t len;
14492
14493 if (!hal) {
14494 sme_err("Invalid hal pointer");
14495 return QDF_STATUS_E_FAULT;
14496 }
14497
14498 sme_debug("Set HE bss_color %d", bss_color);
14499
14500 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14501 sme_debug("Invalid HE bss_color %d", bss_color);
14502 return QDF_STATUS_E_INVAL;
14503 }
14504 len = sizeof(*bss_color_msg);
14505 bss_color_msg = qdf_mem_malloc(len);
14506 if (!bss_color_msg) {
14507 sme_err("mem alloc failed");
14508 return QDF_STATUS_E_NOMEM;
14509 }
14510 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14511 bss_color_msg->length = len;
14512 bss_color_msg->session_id = session_id;
14513 bss_color_msg->bss_color = bss_color;
14514 return umac_send_mb_message_to_mac(bss_color_msg);
14515}
14516#endif
14517
Peng Xu8fdaa492016-06-22 10:20:47 -070014518/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014519 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14520 * @hal: Pointer to HAL
14521 * @hw_dbs_capable: HW DBS capability
14522 *
14523 * Sets HW DBS capability based on INI and fw capability.
14524 *
14525 * Return: None
14526 */
14527void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14528{
14529 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014530
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014531 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14532}
14533
Rachit Kankane026e77a2018-07-31 16:21:09 +053014534#ifdef FEATURE_P2P_LISTEN_OFFLOAD
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014535/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014536 * sme_register_p2p_lo_event() - Register for the p2p lo event
14537 * @hHal: reference to the HAL
14538 * @context: the context of the call
14539 * @callback: the callback to hdd
14540 *
14541 * This function registers the callback function for P2P listen
14542 * offload stop event.
14543 *
14544 * Return: none
14545 */
14546void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
Jeff Johnsonf7e36d62018-07-04 21:14:02 -070014547 p2p_lo_callback callback)
Peng Xu8fdaa492016-06-22 10:20:47 -070014548{
14549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14550 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14551
14552 status = sme_acquire_global_lock(&pMac->sme);
14553 pMac->sme.p2p_lo_event_callback = callback;
14554 pMac->sme.p2p_lo_event_context = context;
14555 sme_release_global_lock(&pMac->sme);
14556}
Rachit Kankane026e77a2018-07-31 16:21:09 +053014557#endif
Manjeet Singhf82ed072016-07-08 11:40:00 +053014558
14559/**
14560 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14561 * @hal: The handle returned by macOpen
14562 * @session_id: session id
14563 * @dbg_args: args for mac pwr debug command
14564 * Return: Return QDF_STATUS, otherwise appropriate failure code
14565 */
14566QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14567 struct sir_mac_pwr_dbg_cmd*
14568 dbg_args)
14569{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014570 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014571 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14572 struct sir_mac_pwr_dbg_cmd *req;
14573 int i;
14574
14575 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014576 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014577 return QDF_STATUS_E_FAILURE;
14578 }
14579
14580 req = qdf_mem_malloc(sizeof(*req));
14581 if (NULL == req) {
14582 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14583 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14584 return QDF_STATUS_E_FAILURE;
14585 }
14586 req->module_id = dbg_args->module_id;
14587 req->pdev_id = dbg_args->pdev_id;
14588 req->num_args = dbg_args->num_args;
14589 for (i = 0; i < req->num_args; i++)
14590 req->args[i] = dbg_args->args[i];
14591
14592 message.type = SIR_HAL_POWER_DBG_CMD;
14593 message.bodyptr = req;
14594
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014595 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_message(QDF_MODULE_ID_SME,
14596 QDF_MODULE_ID_WMA,
14597 QDF_MODULE_ID_WMA,
14598 &message))) {
Manjeet Singhf82ed072016-07-08 11:40:00 +053014599 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14600 "%s: Not able to post msg to WDA!",
14601 __func__);
14602 qdf_mem_free(req);
14603 }
14604 return QDF_STATUS_SUCCESS;
14605}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014606/**
14607 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014608 * @dev_mode: connection type.
14609 * @nss2g: Pointer to the 2G Nss parameter.
14610 * @nss5g: Pointer to the 5G Nss parameter.
14611 *
14612 * Fills the 2G and 5G Nss values based on connection type.
14613 *
14614 * Return: None
14615 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014616void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14617 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014618{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014619 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14620
14621 if (NULL == mac_ctx) {
14622 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14623 FL("Invalid MAC context"));
14624 return;
14625 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014626 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14627}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014628
14629/**
14630 * sme_update_sta_roam_policy() - update sta roam policy for
14631 * unsafe and DFS channels.
14632 * @hal_handle: hal handle for getting global mac struct
14633 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14634 * skipped or not
14635 * @skip_unsafe_channels: Param to tell if driver needs to
14636 * skip unsafe channels or not.
14637 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014638 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014639 *
14640 * sme_update_sta_roam_policy update sta rome policies to csr
14641 * this function will call csrUpdateChannelList as well
14642 * to include/exclude DFS channels and unsafe channels.
14643 *
14644 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14645 */
14646QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14647 enum sta_roam_policy_dfs_mode dfs_mode,
14648 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014649 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014650{
14651 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14652 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014653 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014654
14655 if (!mac_ctx) {
14656 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14657 "%s: mac_ctx is null", __func__);
14658 return QDF_STATUS_E_FAILURE;
14659 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014660
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014661 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14662 if (!sme_config) {
14663 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14664 FL("failed to allocate memory for sme_config"));
14665 return QDF_STATUS_E_FAILURE;
14666 }
14667 qdf_mem_zero(sme_config, sizeof(*sme_config));
14668 sme_get_config_param(hal_handle, sme_config);
14669
14670 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014671 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014672 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014673 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014674 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014675 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014676
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014677 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014678
14679 status = csr_update_channel_list(mac_ctx);
14680 if (QDF_STATUS_SUCCESS != status) {
14681 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14682 FL("failed to update the supported channel list"));
14683 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014684
14685 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled) {
14686 status = sme_acquire_global_lock(&mac_ctx->sme);
14687 if (QDF_IS_STATUS_SUCCESS(status)) {
14688 csr_roam_offload_scan(mac_ctx, session_id,
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014689 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14690 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014691 sme_release_global_lock(&mac_ctx->sme);
14692 } else {
14693 sme_err("Failed to acquire SME lock");
14694 }
14695 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014696 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014697 return status;
14698}
14699
14700/**
14701 * sme_enable_disable_chanavoidind_event - configure ca event ind
14702 * @hal: handler to hal
14703 * @set_value: enable/disable
14704 *
14705 * function to enable/disable chan avoidance indication
14706 *
14707 * Return: QDF_STATUS
14708 */
14709QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14710 uint8_t set_value)
14711{
14712 QDF_STATUS status;
14713 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014714 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014715
Vignesh Viswanathana1f3a1a2018-10-04 13:10:46 +053014716 if (!mac_ctx->mlme_cfg->gen.optimize_ca_event) {
14717 sme_err("optimize_ca_event not enabled in ini");
14718 return QDF_STATUS_E_NOSUPPORT;
14719 }
14720
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014721 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014722 status = sme_acquire_global_lock(&mac_ctx->sme);
14723 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014724 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014725 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14726 msg.bodyval = set_value;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014727 status = scheduler_post_message(QDF_MODULE_ID_SME,
14728 QDF_MODULE_ID_WMA,
14729 QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014730 sme_release_global_lock(&mac_ctx->sme);
14731 return status;
14732 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014733 return status;
14734}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014735
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014736/*
14737 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14738 * @hal: reference to the HAL
14739 * @session_id: current session ID
14740 * @ie_data: Pointer to Scan IE data
14741 * @ie_len: Length of @ie_data
14742 *
14743 * Return: QDF_STATUS
14744 */
14745QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14746 uint8_t *ie_data, uint16_t ie_len)
14747{
14748 QDF_STATUS status;
14749 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14750 struct hdd_default_scan_ie *set_ie_params;
14751
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014752 if (!ie_data)
14753 return QDF_STATUS_E_INVAL;
14754
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014755 status = sme_acquire_global_lock(&mac_ctx->sme);
14756 if (QDF_IS_STATUS_SUCCESS(status)) {
14757 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14758 if (!set_ie_params)
14759 status = QDF_STATUS_E_NOMEM;
14760 else {
14761 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14762 set_ie_params->length = sizeof(*set_ie_params);
14763 set_ie_params->session_id = session_id;
14764 set_ie_params->ie_len = ie_len;
14765 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014766 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014767 }
14768 sme_release_global_lock(&mac_ctx->sme);
14769 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014770 return status;
14771}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014772
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014773QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14774 wma_sar_cb callback, void *context)
14775{
14776 void *wma_handle;
14777
14778 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14779 if (!wma_handle) {
14780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14781 "wma handle is NULL");
14782 return QDF_STATUS_E_FAILURE;
14783 }
14784
14785 return wma_get_sar_limit(wma_handle, callback, context);
14786}
14787
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014788QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14789 struct sar_limit_cmd_params *sar_limit_cmd)
14790{
14791 void *wma_handle;
14792
14793 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14794 if (!wma_handle) {
14795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14796 "wma handle is NULL");
14797 return QDF_STATUS_E_FAILURE;
14798 }
14799
14800 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14801}
14802
Dundi Raviteja3b637092018-09-12 13:42:50 +053014803QDF_STATUS sme_send_coex_config_cmd(struct coex_config_params *coex_cfg_params)
14804{
14805 void *wma_handle;
14806
14807 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14808 if (!wma_handle) {
14809 sme_err("wma handle is NULL");
14810 return QDF_STATUS_E_FAILURE;
14811 }
14812 return wma_send_coex_config_cmd(wma_handle, coex_cfg_params);
14813}
14814
Jeff Johnson6136fb92017-03-30 15:21:49 -070014815#ifdef WLAN_FEATURE_FIPS
14816QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14817 wma_fips_cb callback, void *context)
14818{
14819 void *wma_handle;
14820
14821 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14822 if (!wma_handle) {
14823 sme_err("wma handle is NULL");
14824 return QDF_STATUS_E_FAILURE;
14825 }
14826
14827 return wma_fips_request(wma_handle, param, callback, context);
14828}
14829#endif
14830
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014831QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14832{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014833 void *wma_handle;
14834
14835 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14836 if (!wma_handle) {
14837 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14838 "wma_handle is NULL");
14839 return QDF_STATUS_E_FAILURE;
14840 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014841 if (QDF_STATUS_SUCCESS !=
14842 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14843 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14844 "%s: Failed to set cts2self for p2p GO to firmware",
14845 __func__);
14846 return QDF_STATUS_E_FAILURE;
14847 }
14848 return QDF_STATUS_SUCCESS;
14849}
Yingying Tang95409972016-10-20 15:16:15 +080014850
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014851/**
14852 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14853 * @hal: Handle returned by mac_open
14854 * @session_id: Session ID on which tx fail count needs to be updated to FW
14855 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14856 *
14857 * This function is used to set tx fail count threshold to firmware.
14858 * firmware will issue disocnnect with peer device once this threshold is
14859 * reached.
14860 *
14861 * Return: Return QDF_STATUS, otherwise appropriate failure code
14862 */
14863QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14864 uint8_t session_id, uint32_t tx_fail_count)
14865{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014866 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14867 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014868 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014869
14870 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14871 if (NULL == tx_fail_cnt) {
14872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14873 "%s: fail to alloc filter_param", __func__);
14874 return QDF_STATUS_E_FAILURE;
14875 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014876 sme_debug("session_id: %d tx_fail_count: %d",
14877 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014878 tx_fail_cnt->session_id = session_id;
14879 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14880
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014881 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014882 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14883 msg.reserved = 0;
14884 msg.bodyptr = tx_fail_cnt;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014885 status = scheduler_post_message(QDF_MODULE_ID_SME,
14886 QDF_MODULE_ID_WMA,
14887 QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014888
14889 if (!QDF_IS_STATUS_SUCCESS(status)) {
14890 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014891 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014892 qdf_mem_free(tx_fail_cnt);
14893 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014894 return status;
14895}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014896
Jeff Johnsondc198ec2018-07-04 17:39:53 -070014897QDF_STATUS sme_set_lost_link_info_cb(mac_handle_t mac_handle,
14898 lost_link_info_cb cb)
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014899{
Jeff Johnsondc198ec2018-07-04 17:39:53 -070014900 QDF_STATUS status;
14901 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014902
14903 status = sme_acquire_global_lock(&mac->sme);
14904 if (QDF_IS_STATUS_SUCCESS(status)) {
14905 mac->sme.lost_link_info_cb = cb;
14906 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014907 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014908 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014909 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014910
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014911 return status;
14912}
Yingying Tang95409972016-10-20 15:16:15 +080014913
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014914#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014915bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014916{
14917 return roam_info->isESEAssoc;
14918}
Manjeet Singh2f785062017-03-08 18:14:18 +053014919#endif
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014920
14921bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14922{
14923 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014924
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014925 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14926}
Yingying Tang95409972016-10-20 15:16:15 +080014927
14928#ifdef WLAN_FEATURE_WOW_PULSE
14929/**
14930 * sme_set_wow_pulse() - set wow pulse info
14931 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14932 *
14933 * Return: QDF_STATUS
14934 */
14935QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14936{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014937 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014938 QDF_STATUS status;
14939 struct wow_pulse_mode *wow_pulse_set_cmd;
14940
14941 if (!wow_pulse_set_info) {
14942 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14943 "%s: invalid wow_pulse_set_info pointer", __func__);
14944 return QDF_STATUS_E_FAILURE;
14945 }
14946
14947 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14948 if (NULL == wow_pulse_set_cmd) {
14949 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14950 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14951 return QDF_STATUS_E_NOMEM;
14952 }
14953
14954 *wow_pulse_set_cmd = *wow_pulse_set_info;
14955
14956 message.type = WMA_SET_WOW_PULSE_CMD;
14957 message.bodyptr = wow_pulse_set_cmd;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053014958 status = scheduler_post_message(QDF_MODULE_ID_SME,
14959 QDF_MODULE_ID_WMA,
14960 QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014961 &message);
14962 if (!QDF_IS_STATUS_SUCCESS(status)) {
14963 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14964 "%s: Not able to post msg to WDA!",
14965 __func__);
14966 qdf_mem_free(wow_pulse_set_cmd);
14967 status = QDF_STATUS_E_FAILURE;
14968 }
14969
14970 return status;
14971}
14972#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014973
14974/**
14975 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14976 * different fields and IEs from bss descriptor.
14977 * @frame_buf: frame buffer to populate
14978 * @bss_descp: bss descriptor
14979 * @bssid: bssid of the beacon frame to populate
14980 * @ie_len: length of IE fields
14981 *
14982 * Return: None
14983 */
14984static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14985 tSirBssDescription *bss_descp,
14986 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014987 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014988{
14989 tDot11fBeacon1 *bcn_fixed;
14990 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14991
14992 /* populate mac header first to indicate beacon */
14993 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14994 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14995 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14996 qdf_mem_copy((uint8_t *) mac_hdr->da,
14997 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14998 sizeof(struct qdf_mac_addr));
14999 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
15000 sizeof(struct qdf_mac_addr));
15001 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
15002 sizeof(struct qdf_mac_addr));
15003
15004 /* now populate fixed params */
15005 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
15006 /* populate timestamp */
15007 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
15008 sizeof(bss_descp->timeStamp));
15009 /* populate beacon interval */
15010 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
15011 /* populate capability */
15012 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
15013 sizeof(bss_descp->capabilityInfo));
15014
15015 /* copy IEs now */
15016 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
15017 + SIR_MAC_B_PR_SSID_OFFSET,
15018 &bss_descp->ieFields, ie_len);
15019}
15020
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015021QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015022 struct csr_roam_profile *profile,
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053015023 const uint8_t *bssid,
15024 int8_t *rssi, int8_t *snr)
15025{
15026 tSirBssDescription *bss_descp;
15027 tCsrScanResultFilter *scan_filter;
15028 struct scan_result_list *bss_list;
15029 tScanResultHandle result_handle = NULL;
15030 QDF_STATUS status = QDF_STATUS_SUCCESS;
15031 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15032
15033 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15034 if (NULL == scan_filter) {
15035 sme_err("memory allocation failed");
15036 status = QDF_STATUS_E_NOMEM;
15037 goto free_scan_flter;
15038 }
15039
15040 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15041 profile, scan_filter);
15042 if (QDF_STATUS_SUCCESS != status) {
15043 sme_err("prepare_filter failed");
15044 goto free_scan_flter;
15045 }
15046
15047 /* update filter to get scan result with just target BSSID */
15048 if (NULL == scan_filter->BSSIDs.bssid) {
15049 scan_filter->BSSIDs.bssid =
15050 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15051 if (scan_filter->BSSIDs.bssid == NULL) {
15052 sme_err("malloc failed");
15053 status = QDF_STATUS_E_NOMEM;
15054 goto free_scan_flter;
15055 }
15056 }
15057
15058 scan_filter->BSSIDs.numOfBSSIDs = 1;
15059 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15060 bssid, sizeof(struct qdf_mac_addr));
15061
15062 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15063 if (QDF_STATUS_SUCCESS != status) {
15064 sme_err("parse_scan_result failed");
15065 goto free_scan_flter;
15066 }
15067
15068 bss_list = (struct scan_result_list *)result_handle;
15069 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15070 if (!bss_descp) {
15071 sme_err("unable to fetch bss descriptor");
15072 status = QDF_STATUS_E_FAULT;
15073 goto free_scan_flter;
15074 }
15075
15076 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15077 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15078
15079 if (rssi)
15080 *rssi = bss_descp->rssi;
15081 if (snr)
15082 *snr = bss_descp->sinr;
15083
15084free_scan_flter:
15085 /* free scan filter and exit */
15086 if (scan_filter) {
15087 csr_free_scan_filter(mac_ctx, scan_filter);
15088 qdf_mem_free(scan_filter);
15089 }
15090
15091 if (result_handle)
15092 csr_scan_result_purge(mac_ctx, result_handle);
15093
15094 return status;
15095}
15096
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015097QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile,
15098 const tSirMacAddr bssid,
15099 uint8_t **frame_buf, uint32_t *frame_len,
15100 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015101{
15102 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015103 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015104 tCsrScanResultFilter *scan_filter;
15105 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15106 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015107 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015108 uint32_t ie_len;
15109
15110 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15111 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015112 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015113 status = QDF_STATUS_E_NOMEM;
15114 goto free_scan_flter;
15115 }
15116 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15117 profile, scan_filter);
15118 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015119 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015120 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015121 goto free_scan_flter;
15122 }
15123
15124 /* update filter to get scan result with just target BSSID */
15125 if (NULL == scan_filter->BSSIDs.bssid) {
15126 scan_filter->BSSIDs.bssid =
15127 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15128 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015129 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015130 status = QDF_STATUS_E_NOMEM;
15131 goto free_scan_flter;
15132 }
15133 }
15134 scan_filter->BSSIDs.numOfBSSIDs = 1;
15135 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15136 bssid, sizeof(struct qdf_mac_addr));
15137
15138 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15139 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015140 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015141 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015142 goto free_scan_flter;
15143 }
15144
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015145 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015146 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015147 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015148 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015149 status = QDF_STATUS_E_FAULT;
15150 goto free_scan_flter;
15151 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015152
Naveen Rawat81f058c2017-06-02 16:02:39 -070015153 /**
15154 * Length of BSS descriptor is without length of
15155 * length itself and length of pointer that holds ieFields.
15156 *
15157 * tSirBssDescription
15158 * +--------+---------------------------------+---------------+
15159 * | length | other fields | pointer to IEs|
15160 * +--------+---------------------------------+---------------+
15161 * ^
15162 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015163 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015164 ie_len = bss_descp->length + sizeof(bss_descp->length)
15165 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015166 sme_debug("found bss_descriptor ie_len: %d channel %d",
15167 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015168
15169 /* include mac header and fixed params along with IEs in frame */
15170 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15171 *frame_buf = qdf_mem_malloc(*frame_len);
15172 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015173 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015174 status = QDF_STATUS_E_NOMEM;
15175 goto free_scan_flter;
15176 }
15177
15178 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15179
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015180 if (!*channel)
15181 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015182free_scan_flter:
15183 /* free scan filter and exit */
15184 if (scan_filter) {
15185 csr_free_scan_filter(mac_ctx, scan_filter);
15186 qdf_mem_free(scan_filter);
15187 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015188 if (result_handle)
15189 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015190
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015191 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015192}
15193
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015194#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015195QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile,
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015196 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015197 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015198{
15199 QDF_STATUS status;
15200 struct wma_roam_invoke_cmd *fastreassoc;
15201 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015202 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Abhinav Kumareab25932018-07-13 11:48:43 +053015203 struct csr_roam_session *session;
15204 struct csr_roam_profile *roam_profile;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015205
Abhinav Kumareab25932018-07-13 11:48:43 +053015206 session = CSR_GET_SESSION(mac_ctx, vdev_id);
15207 if (!session || !session->pCurRoamProfile) {
15208 sme_err("session %d not found", vdev_id);
15209 return QDF_STATUS_E_FAILURE;
15210 }
15211
15212 roam_profile = session->pCurRoamProfile;
15213 if (roam_profile->supplicant_disabled_roaming ||
15214 roam_profile->driver_disabled_roaming) {
15215 sme_debug("roaming status in Supplicant %d and in driver %d",
15216 roam_profile->supplicant_disabled_roaming,
15217 roam_profile->driver_disabled_roaming);
15218 return QDF_STATUS_E_FAILURE;
15219 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015220 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15221 if (NULL == fastreassoc) {
15222 sme_err("qdf_mem_malloc failed for fastreassoc");
15223 return QDF_STATUS_E_NOMEM;
15224 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015225 /* if both are same then set the flag */
15226 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15227 fastreassoc->is_same_bssid = true;
15228 sme_debug("bssid same, bssid[%pM]", bssid);
15229 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015230 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015231 fastreassoc->bssid[0] = bssid[0];
15232 fastreassoc->bssid[1] = bssid[1];
15233 fastreassoc->bssid[2] = bssid[2];
15234 fastreassoc->bssid[3] = bssid[3];
15235 fastreassoc->bssid[4] = bssid[4];
15236 fastreassoc->bssid[5] = bssid[5];
15237
15238 status = sme_get_beacon_frm(hal, profile, bssid,
15239 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015240 &fastreassoc->frame_len,
15241 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015242
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015243 if (!channel) {
15244 sme_err("channel retrieval from BSS desc fails!");
15245 qdf_mem_free(fastreassoc);
15246 return QDF_STATUS_E_FAULT;
15247 }
15248
15249 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015250 if (QDF_STATUS_SUCCESS != status) {
15251 sme_warn("sme_get_beacon_frm failed");
15252 fastreassoc->frame_buf = NULL;
15253 fastreassoc->frame_len = 0;
15254 }
15255
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015256 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15257 connectedProfile.AuthType)) {
15258 sme_debug("Beacon is not required for ESE");
15259 if (fastreassoc->frame_len) {
15260 qdf_mem_free(fastreassoc->frame_buf);
15261 fastreassoc->frame_buf = NULL;
15262 fastreassoc->frame_len = 0;
15263 }
15264 }
15265
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015266 msg.type = SIR_HAL_ROAM_INVOKE;
15267 msg.reserved = 0;
15268 msg.bodyptr = fastreassoc;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015269 status = scheduler_post_message(QDF_MODULE_ID_SME,
15270 QDF_MODULE_ID_WMA,
15271 QDF_MODULE_ID_WMA, &msg);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015272 if (QDF_STATUS_SUCCESS != status) {
15273 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15274 qdf_mem_free(fastreassoc);
15275 }
15276
15277 return status;
15278}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015279#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015280
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015281QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15282 tPmkidCacheInfo *pmk_cache_info,
15283 bool is_add)
15284{
15285 struct wmi_unified_pmk_cache *pmk_cache;
15286 struct scheduler_msg msg;
15287
15288 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15289 if (!pmk_cache) {
15290 sme_err("Memory allocation failure");
15291 return QDF_STATUS_E_NOMEM;
15292 }
15293
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015294 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15295
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015296 pmk_cache->session_id = session_id;
15297
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015298 if (!pmk_cache_info)
15299 goto send_flush_cmd;
15300
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015301 if (!pmk_cache_info->ssid_len) {
15302 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15303 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15304 &pmk_cache->bssid);
15305 } else {
15306 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15307 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15308 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15309 pmk_cache_info->ssid,
15310 pmk_cache->ssid.length);
15311 }
15312 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15313 pmk_cache_info->cache_id[1]);
15314
15315 if (is_add)
15316 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15317 else
15318 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15319
15320 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15321 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15322 CSR_RSN_PMKID_SIZE);
15323
15324 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15325 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15326 pmk_cache->pmk_len);
15327
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015328send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015329 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15330 msg.reserved = 0;
15331 msg.bodyptr = pmk_cache;
15332 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015333 scheduler_post_message(QDF_MODULE_ID_SME,
15334 QDF_MODULE_ID_WMA,
15335 QDF_MODULE_ID_WMA, &msg)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015336 sme_err("Not able to post message to WDA");
15337 qdf_mem_free(pmk_cache);
15338 return QDF_STATUS_E_FAILURE;
15339 }
15340
15341 return QDF_STATUS_SUCCESS;
15342}
15343
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015344/* ARP DEBUG STATS */
15345
15346/**
15347 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15348 * @hal: handle to hal
15349 * @set_stats_param: pointer to set stats param
15350 *
15351 * Return: Return QDF_STATUS.
15352 */
15353QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15354 struct set_arp_stats_params
15355 *set_stats_param)
15356{
15357 struct set_arp_stats_params *arp_set_param;
15358 struct scheduler_msg msg;
15359
15360 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15361 if (arp_set_param == NULL) {
15362 sme_err("Memory allocation failure");
15363 return QDF_STATUS_E_NOMEM;
15364 }
15365
15366 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15367
15368 msg.type = WMA_SET_ARP_STATS_REQ;
15369 msg.reserved = 0;
15370 msg.bodyptr = arp_set_param;
15371
15372 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015373 scheduler_post_message(QDF_MODULE_ID_SME,
15374 QDF_MODULE_ID_WMA,
15375 QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015376 sme_err("Not able to post message to WDA");
15377 qdf_mem_free(arp_set_param);
15378 return QDF_STATUS_E_FAILURE;
15379 }
15380
15381 return QDF_STATUS_SUCCESS;
15382}
15383
15384/**
15385 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15386 * @hal: handle to hal
15387 * @get_stats_param: pointer to set stats param
15388 *
15389 * Return: Return QDF_STATUS.
15390 */
15391QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15392 struct get_arp_stats_params
15393 *get_stats_param)
15394{
15395 struct get_arp_stats_params *arp_get_param;
15396 struct scheduler_msg msg;
15397
15398 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15399 if (arp_get_param == NULL) {
15400 sme_err("Memory allocation failure");
15401 return QDF_STATUS_E_NOMEM;
15402 }
15403
15404 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15405
15406 msg.type = WMA_GET_ARP_STATS_REQ;
15407 msg.reserved = 0;
15408 msg.bodyptr = arp_get_param;
15409
15410 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015411 scheduler_post_message(QDF_MODULE_ID_SME,
15412 QDF_MODULE_ID_WMA,
15413 QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015414 sme_err("Not able to post message to WDA");
15415 qdf_mem_free(arp_get_param);
15416 return QDF_STATUS_E_FAILURE;
15417 }
15418
15419 return QDF_STATUS_SUCCESS;
15420}
15421
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015422QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15423 uint32_t param_value, uint32_t vdev_id)
15424{
15425 void *wma_handle;
15426
15427 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15428 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015429 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015430 return QDF_STATUS_E_FAILURE;
15431 }
15432
15433 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15434 param_value, vdev_id);
15435}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015436
15437QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015438 bool (*set_connection_info_cb)(bool),
15439 bool (*get_connection_info_cb)(uint8_t *session_id,
15440 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015441{
15442 QDF_STATUS status = QDF_STATUS_SUCCESS;
15443 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15444
15445 status = sme_acquire_global_lock(&pMac->sme);
15446 if (QDF_IS_STATUS_SUCCESS(status)) {
15447 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015448 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015449 sme_release_global_lock(&pMac->sme);
15450 }
15451 return status;
15452}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015453
Jeff Johnson43975142018-07-04 15:33:47 -070015454QDF_STATUS sme_rso_cmd_status_cb(mac_handle_t mac_handle,
15455 rso_cmd_status_cb cb)
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015456{
15457 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson43975142018-07-04 15:33:47 -070015458 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015459
15460 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015461 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015462 return status;
15463}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015464
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015465QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15466 struct wmi_dbs_scan_sel_params *params)
15467{
15468 struct scheduler_msg message = {0};
15469 QDF_STATUS status;
15470 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15471 uint32_t i;
15472
15473 if (0 == params->num_clients) {
15474 sme_err("Num of clients is 0");
15475 return QDF_STATUS_E_FAILURE;
15476 }
15477
15478 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15479 if (!dbs_scan_params) {
15480 sme_err("fail to alloc dbs_scan_params");
15481 return QDF_STATUS_E_NOMEM;
15482 }
15483
15484 dbs_scan_params->num_clients = params->num_clients;
15485 dbs_scan_params->pdev_id = params->pdev_id;
15486 for (i = 0; i < params->num_clients; i++) {
15487 dbs_scan_params->module_id[i] = params->module_id[i];
15488 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15489 dbs_scan_params->num_non_dbs_scans[i] =
15490 params->num_non_dbs_scans[i];
15491 }
15492 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15493 message.bodyptr = dbs_scan_params;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015494 status = scheduler_post_message(QDF_MODULE_ID_SME,
15495 QDF_MODULE_ID_WMA,
15496 QDF_MODULE_ID_WMA, &message);
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015497 if (!QDF_IS_STATUS_SUCCESS(status)) {
15498 sme_err("Not able to post msg to WMA!");
15499 qdf_mem_free(dbs_scan_params);
15500 }
15501
15502 return status;
15503}
15504
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015505QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15506{
15507 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15508 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015509 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015510 struct sme_rcpi_req *rcpi_req;
15511
15512 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15513 if (rcpi_req == NULL) {
15514 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15515 "%s: Not able to allocate memory for rcpi req",
15516 __func__);
15517 return QDF_STATUS_E_NOMEM;
15518 }
15519 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15520
15521 status = sme_acquire_global_lock(&pMac->sme);
15522 if (QDF_IS_STATUS_SUCCESS(status)) {
15523 msg.bodyptr = rcpi_req;
15524 msg.type = WMA_GET_RCPI_REQ;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015525 status = scheduler_post_message(QDF_MODULE_ID_SME,
15526 QDF_MODULE_ID_WMA,
15527 QDF_MODULE_ID_WMA, &msg);
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015528 sme_release_global_lock(&pMac->sme);
15529 if (!QDF_IS_STATUS_SUCCESS(status)) {
15530 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15531 FL("post get rcpi req failed"));
15532 status = QDF_STATUS_E_FAILURE;
15533 qdf_mem_free(rcpi_req);
15534 }
15535 } else {
15536 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15537 FL("sme_acquire_global_lock failed"));
15538 qdf_mem_free(rcpi_req);
15539 }
15540
15541 return status;
15542}
15543
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015544void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15545{
15546 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15547 void *wma_handle;
15548 QDF_STATUS status;
15549
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015550 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015551 if (QDF_STATUS_SUCCESS != status) {
15552 mac_ctx->pdev = NULL;
15553 return;
15554 }
15555 mac_ctx->pdev = pdev;
15556 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15557 if (!wma_handle) {
15558 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015559 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015560 return;
15561 }
15562 wma_store_pdev(wma_handle, pdev);
15563}
15564
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015565QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
Jeff Johnsonf6182e42018-07-03 14:46:17 -070015566 congestion_cb congestion_cb)
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015567{
15568 QDF_STATUS status;
15569 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15570
15571 status = sme_acquire_global_lock(&mac->sme);
15572 if (QDF_IS_STATUS_SUCCESS(status)) {
15573 mac->sme.congestion_cb = congestion_cb;
15574 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015575 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015576 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015577 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015578 }
15579
15580 return status;
15581}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015582
Jeff Johnsonda2afa42018-07-04 10:25:42 -070015583QDF_STATUS sme_register_tx_queue_cb(mac_handle_t mac_handle,
15584 tx_queue_cb tx_queue_cb)
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015585{
15586 QDF_STATUS status;
Jeff Johnsonda2afa42018-07-04 10:25:42 -070015587 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015588
15589 status = sme_acquire_global_lock(&mac->sme);
15590 if (QDF_IS_STATUS_SUCCESS(status)) {
15591 mac->sme.tx_queue_cb = tx_queue_cb;
15592 sme_release_global_lock(&mac->sme);
15593 sme_debug("Tx queue callback set");
15594 } else {
15595 sme_err("Aquiring lock failed %d", status);
15596 }
15597
15598 return status;
15599}
15600
Jeff Johnsonda2afa42018-07-04 10:25:42 -070015601QDF_STATUS sme_deregister_tx_queue_cb(mac_handle_t mac_handle)
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015602{
Jeff Johnsonda2afa42018-07-04 10:25:42 -070015603 return sme_register_tx_queue_cb(mac_handle, NULL);
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015604}
15605
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -070015606#ifdef WLAN_SUPPORT_TWT
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015607QDF_STATUS sme_register_twt_enable_complete_cb(mac_handle_t mac_handle,
15608 twt_enable_cb twt_enable_cb)
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015609{
15610 QDF_STATUS status;
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015611 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015612
15613 status = sme_acquire_global_lock(&mac->sme);
15614 if (QDF_IS_STATUS_SUCCESS(status)) {
15615 mac->sme.twt_enable_cb = twt_enable_cb;
15616 sme_release_global_lock(&mac->sme);
15617 sme_debug("TWT: enable callback set");
15618 } else {
15619 sme_err("Aquiring lock failed %d", status);
15620 }
15621
15622 return status;
15623}
15624
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015625QDF_STATUS sme_register_twt_disable_complete_cb(mac_handle_t mac_handle,
15626 twt_disable_cb twt_disable_cb)
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015627{
15628 QDF_STATUS status;
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015629 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015630
15631 status = sme_acquire_global_lock(&mac->sme);
15632 if (QDF_IS_STATUS_SUCCESS(status)) {
15633 mac->sme.twt_disable_cb = twt_disable_cb;
15634 sme_release_global_lock(&mac->sme);
15635 sme_debug("TWT: disable callback set");
15636 } else {
15637 sme_err("Aquiring lock failed %d", status);
15638 }
15639
15640 return status;
15641}
15642
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015643QDF_STATUS sme_deregister_twt_enable_complete_cb(mac_handle_t mac_handle)
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015644{
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015645 return sme_register_twt_enable_complete_cb(mac_handle, NULL);
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015646}
15647
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015648QDF_STATUS sme_deregister_twt_disable_complete_cb(mac_handle_t mac_handle)
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015649{
Jeff Johnson3a08ff92018-07-03 19:40:44 -070015650 return sme_register_twt_disable_complete_cb(mac_handle, NULL);
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015651}
15652#endif
15653
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015654QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15655 uint32_t param_val)
15656{
15657 return wma_configure_smps_params(vdev_id, param_id, param_val);
15658}
15659
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015660QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15661 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15662{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015663 wma_cli_set_cmd_t *iwcmd;
15664 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015665
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015666 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15667 if (!iwcmd) {
15668 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015669 return QDF_STATUS_E_NOMEM;
15670 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015671
15672 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15673 iwcmd->param_sec_value = 0;
15674 iwcmd->param_vdev_id = vdev_id;
15675 iwcmd->param_id = param_id;
15676 iwcmd->param_vp_dev = req_cat;
15677 iwcmd->param_value = param_val;
15678 wma_ipa_uc_stat_request(iwcmd);
15679 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015680
15681 return status;
15682}
lifeng66831662017-05-19 16:01:35 +080015683
15684QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15685 struct sir_set_rx_reorder_timeout_val *req)
15686{
15687 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015688 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015689
Zhang Qian1e7649e2018-06-04 13:07:18 +080015690 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15691 status = wma_set_rx_reorder_timeout_val(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015692
15693 return status;
15694}
15695
15696QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15697 struct sir_peer_set_rx_blocksize *req)
15698{
15699 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015700 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015701
Zhang Qian1e7649e2018-06-04 13:07:18 +080015702 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15703 status = wma_set_rx_blocksize(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015704
15705 return status;
15706}
Naveen Rawat247a8682017-06-05 15:00:31 -070015707
15708int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15709{
15710 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15711}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015712
Vignesh Viswanathana851d752018-10-03 19:44:38 +053015713int sme_set_enable_mem_deep_sleep(mac_handle_t mac_handle, int vdev_id)
15714{
15715 tpAniSirGlobal mac_ctx = MAC_CONTEXT(mac_handle);
15716
15717 return wma_cli_set_command(vdev_id, WMI_PDEV_PARAM_HYST_EN,
15718 mac_ctx->mlme_cfg->gen.memory_deep_sleep,
15719 PDEV_CMD);
15720}
15721
15722int sme_set_cck_tx_fir_override(mac_handle_t mac_handle, int vdev_id)
15723{
15724 tpAniSirGlobal mac_ctx = MAC_CONTEXT(mac_handle);
15725
15726 return wma_cli_set_command(vdev_id,
15727 WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE,
15728 mac_ctx->mlme_cfg->gen.cck_tx_fir_override,
15729 PDEV_CMD);
15730}
15731
Jeff Johnsond0b6c7e2018-07-04 14:53:06 -070015732QDF_STATUS sme_set_bt_activity_info_cb(mac_handle_t mac_handle,
15733 bt_activity_info_cb cb)
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015734{
15735 QDF_STATUS status;
Jeff Johnsond0b6c7e2018-07-04 14:53:06 -070015736 tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015737
15738 status = sme_acquire_global_lock(&mac->sme);
15739 if (QDF_IS_STATUS_SUCCESS(status)) {
15740 mac->sme.bt_activity_info_cb = cb;
15741 sme_release_global_lock(&mac->sme);
15742 sme_debug("bt activity info callback set");
15743 } else {
15744 sme_debug("sme_acquire_global_lock failed %d", status);
15745 }
15746
15747 return status;
15748}
lifengd217d192017-05-09 19:44:16 +080015749
15750QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15751 struct get_chain_rssi_req_params *input,
15752 get_chain_rssi_callback callback,
15753 void *context)
15754{
15755 QDF_STATUS status = QDF_STATUS_SUCCESS;
15756 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Zhang Qian1e7649e2018-06-04 13:07:18 +080015757 tp_wma_handle wma_handle;
lifengd217d192017-05-09 19:44:16 +080015758
15759 SME_ENTER();
15760
15761 if (NULL == input) {
15762 sme_err("Invalid req params");
15763 return QDF_STATUS_E_INVAL;
15764 }
15765
15766 mac_ctx->sme.get_chain_rssi_cb = callback;
15767 mac_ctx->sme.get_chain_rssi_context = context;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015768 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15769 wma_get_chain_rssi(wma_handle, input);
lifengd217d192017-05-09 19:44:16 +080015770
15771 SME_EXIT();
15772 return status;
15773}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015774
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -070015775QDF_STATUS sme_process_msg_callback(tpAniSirGlobal mac,
15776 struct scheduler_msg *msg)
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015777{
15778 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15779
15780 if (msg == NULL) {
15781 sme_err("Empty message for SME Msg callback");
15782 return status;
15783 }
Jeff Johnson5f9ce2d2018-06-09 21:20:45 -070015784 status = sme_process_msg(mac, msg);
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015785 return status;
15786}
15787
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015788void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15789{
15790 struct csr_roam_session *session;
15791 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15792
15793 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15794 sme_err("%s Invalid session id: %d", __func__, session_id);
15795 return;
15796 }
15797
15798 session = CSR_GET_SESSION(mac_ctx, session_id);
15799 if (!session) {
15800 sme_err("%s Failed to get session for id: %d",
15801 __func__, session_id);
15802 return;
15803 }
15804
Nirav Shahe6194ac2018-07-13 11:04:41 +053015805 sme_nofl_info("Total No. of Disconnections: %d",
15806 session->disconnect_stats.disconnection_cnt);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015807
Nirav Shahe6194ac2018-07-13 11:04:41 +053015808 sme_nofl_info("No. of Diconnects Triggered by Application: %d",
15809 session->disconnect_stats.disconnection_by_app);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015810
Nirav Shahe6194ac2018-07-13 11:04:41 +053015811 sme_nofl_info("No. of Disassoc Sent by Peer: %d",
15812 session->disconnect_stats.disassoc_by_peer);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015813
Nirav Shahe6194ac2018-07-13 11:04:41 +053015814 sme_nofl_info("No. of Deauth Sent by Peer: %d",
15815 session->disconnect_stats.deauth_by_peer);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015816
Nirav Shahe6194ac2018-07-13 11:04:41 +053015817 sme_nofl_info("No. of Disconnections due to Beacon Miss: %d",
15818 session->disconnect_stats.bmiss);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015819
Nirav Shahe6194ac2018-07-13 11:04:41 +053015820 sme_nofl_info("No. of Disconnections due to Peer Kickout: %d",
15821 session->disconnect_stats.peer_kickout);
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015822}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015823
Rachit Kankanef6834c42018-08-02 18:47:50 +053015824#ifdef FEATURE_WLAN_DYNAMIC_CVM
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015825 /**
15826 * sme_set_vc_mode_config() - Set voltage corner config to FW
15827 * @bitmap: Bitmap that referes to voltage corner config with
15828 * different phymode and bw configuration
15829 *
15830 * Return: QDF_STATUS
15831 */
15832QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15833{
15834 void *wma_handle;
15835
15836 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15837 if (!wma_handle) {
15838 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15839 "wma_handle is NULL");
15840 return QDF_STATUS_E_FAILURE;
15841 }
15842 if (QDF_STATUS_SUCCESS !=
15843 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15845 "%s: Failed to set Voltage Control config to FW",
15846 __func__);
15847 return QDF_STATUS_E_FAILURE;
15848 }
15849 return QDF_STATUS_SUCCESS;
15850}
Rachit Kankanef6834c42018-08-02 18:47:50 +053015851#endif
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015852
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015853/**
15854 * sme_set_bmiss_bcnt() - set bmiss config parameters
15855 * @vdev_id: virtual device for the command
15856 * @first_cnt: bmiss first value
15857 * @final_cnt: bmiss final value
15858 *
15859 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15860 */
15861QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15862 uint32_t final_cnt)
15863{
15864 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15865}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015866
15867QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15868 bool is_tos_active, uint32_t max_off_chan_time,
15869 uint32_t rest_time, bool skip_dfs_chan)
15870{
15871 struct sir_limit_off_chan *cmd;
15872 struct scheduler_msg msg = {0};
15873
15874 cmd = qdf_mem_malloc(sizeof(*cmd));
15875 if (!cmd) {
15876 sme_err("qdf_mem_malloc failed for limit off channel");
15877 return QDF_STATUS_E_NOMEM;
15878 }
15879
15880 cmd->vdev_id = vdev_id;
15881 cmd->is_tos_active = is_tos_active;
15882 cmd->max_off_chan_time = max_off_chan_time;
15883 cmd->rest_time = rest_time;
15884 cmd->skip_dfs_chans = skip_dfs_chan;
15885
15886 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15887 msg.reserved = 0;
15888 msg.bodyptr = cmd;
15889
gaurank kathpalia36b0c582018-08-28 17:45:43 +053015890 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_message(QDF_MODULE_ID_SME,
15891 QDF_MODULE_ID_WMA,
15892 QDF_MODULE_ID_WMA,
15893 &msg))) {
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015894 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15895 qdf_mem_free(cmd);
15896 return QDF_STATUS_E_FAILURE;
15897 }
15898
15899 return QDF_STATUS_SUCCESS;
15900}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015901
Qiwei Caie689a262018-07-26 15:50:22 +080015902uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15903 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15904 bool append_ie)
15905{
15906 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15907
15908 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
15909}
15910
15911#ifdef FEATURE_BSS_TRANSITION
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015912/**
15913 * sme_get_status_for_candidate() - Get bss transition status for candidate
15914 * @hal: Handle for HAL
15915 * @conn_bss_desc: connected bss descriptor
15916 * @bss_desc: candidate bss descriptor
15917 * @info: candiadate bss information
15918 * @trans_reason: transition reason code
15919 * @is_bt_in_progress: bt activity indicator
15920 *
15921 * Return : true if candidate is rejected and reject reason is filled
15922 * @info->status. Otherwise returns false.
15923 */
Jeff Johnson22256fe2018-06-04 20:25:53 -070015924static bool sme_get_status_for_candidate(tHalHandle hal,
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015925 tSirBssDescription *conn_bss_desc,
15926 tSirBssDescription *bss_desc,
15927 struct bss_candidate_info *info,
15928 uint8_t trans_reason,
15929 bool is_bt_in_progress)
15930{
15931 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Pragaspathi Thilagarajcd6aef02018-09-11 20:30:23 +053015932 struct wlan_mlme_mbo *mbo_cfg;
15933 int8_t current_rssi_mcc_thres;
15934
15935 if (!(mac_ctx->mlme_cfg)) {
15936 pe_err("mlme cfg is NULL");
15937 return false;
15938 }
15939 mbo_cfg = &mac_ctx->mlme_cfg->mbo_cfg;
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015940
15941 /*
15942 * Low RSSI based rejection
15943 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15944 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15945 * candidate with MBO reason code 4.
15946 */
Pragaspathi Thilagarajcd6aef02018-09-11 20:30:23 +053015947 if ((bss_desc->rssi < mbo_cfg->mbo_candidate_rssi_thres) &&
15948 (conn_bss_desc->rssi > mbo_cfg->mbo_current_rssi_thres)) {
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015949 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15950 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15951 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15952 return true;
15953 }
15954
15955 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15956 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15957 /*
15958 * MCC rejection
15959 * If moving to candidate's channel will result in MCC scenario
15960 * and the rssi of connected bss is greater than
15961 * mbo_current_rssi_mss_thres, then reject the candidate with
15962 * MBO reason code 3.
15963 */
Pragaspathi Thilagarajcd6aef02018-09-11 20:30:23 +053015964 current_rssi_mcc_thres = mbo_cfg->mbo_current_rssi_mcc_thres;
15965 if ((conn_bss_desc->rssi > current_rssi_mcc_thres) &&
Jeff Johnson9d118852018-06-10 16:54:59 -070015966 csr_is_mcc_channel(mac_ctx, bss_desc->channelId)) {
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015967 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15968 MAC_ADDR_ARRAY(bss_desc->bssId));
15969 info->status =
15970 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15971 return true;
15972 }
15973
15974 /*
15975 * BT coex rejection
15976 * If AP is trying to move the client from 5G to 2.4G and moving
15977 * to 2.4G will result in BT coex and candidate channel rssi is
15978 * less than mbo_candidate_rssi_btc_thres, then reject the
15979 * candidate with MBO reason code 2.
15980 */
15981 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15982 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15983 is_bt_in_progress &&
Pragaspathi Thilagarajcd6aef02018-09-11 20:30:23 +053015984 (bss_desc->rssi < mbo_cfg->mbo_candidate_rssi_btc_thres)) {
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015985 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15986 MAC_ADDR_ARRAY(bss_desc->bssId));
15987 info->status =
15988 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15989 return true;
15990 }
15991
15992 /*
15993 * LTE coex rejection
15994 * If moving to candidate's channel can cause LTE coex, then
15995 * reject the candidate with MBO reason code 5.
15996 */
15997 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15998 conn_bss_desc->channelId) &&
15999 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
16000 bss_desc->channelId))) {
16001 sme_err("High interference expected if transitioned to BSS "
16002 MAC_ADDRESS_STR" hence reject",
16003 MAC_ADDR_ARRAY(bss_desc->bssId));
16004 info->status =
16005 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
16006 return true;
16007 }
16008 }
16009
16010 return false;
16011}
16012
16013/**
16014 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
16015 * @adapter : Pointer to adapter
16016 * @transition_reason : Transition reason
16017 * @info : bss candidate information
16018 * @n_candidates : number of candidates
16019 *
16020 * Return : 0 on success otherwise errno
16021 */
16022int sme_get_bss_transition_status(tHalHandle hal,
16023 uint8_t transition_reason,
16024 struct qdf_mac_addr *bssid,
16025 struct bss_candidate_info *info,
16026 uint16_t n_candidates,
16027 bool is_bt_in_progress)
16028{
16029 QDF_STATUS status = QDF_STATUS_SUCCESS;
16030 tSirBssDescription *bss_desc, *conn_bss_desc;
16031 tCsrScanResultInfo *res, *conn_res;
16032 uint16_t i;
16033
16034 if (!n_candidates || !info) {
16035 sme_err("No candidate info available");
16036 return QDF_STATUS_E_INVAL;
16037 }
16038
16039 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16040 if (!conn_res) {
16041 sme_err("Failed to allocate memory for conn_res");
16042 return QDF_STATUS_E_NOMEM;
16043 }
16044
16045 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
16046 if (!res) {
16047 sme_err("Failed to allocate memory for conn_res");
16048 status = QDF_STATUS_E_NOMEM;
16049 goto free;
16050 }
16051
16052 /* Get the connected BSS descriptor */
16053 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
16054 if (!QDF_IS_STATUS_SUCCESS(status)) {
16055 sme_err("Failed to find connected BSS in scan list");
16056 goto free;
16057 }
16058 conn_bss_desc = &conn_res->BssDescriptor;
16059
16060 for (i = 0; i < n_candidates; i++) {
16061 /* Get candidate BSS descriptors */
16062 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
16063 res);
16064 if (!QDF_IS_STATUS_SUCCESS(status)) {
16065 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
16066 MAC_ADDR_ARRAY(info[i].bssid.bytes));
16067 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
16068 continue;
16069 }
16070
16071 bss_desc = &res->BssDescriptor;
16072 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
16073 &info[i], transition_reason, is_bt_in_progress)) {
16074 /*
16075 * If status is not over written, it means it is a
16076 * candidate for accept.
16077 */
16078 info[i].status = QCA_STATUS_ACCEPT;
16079 }
16080 }
16081
16082 /* success */
16083 status = QDF_STATUS_SUCCESS;
16084
16085free:
16086 /* free allocated memory */
16087 if (conn_res)
16088 qdf_mem_free(conn_res);
16089 if (res)
16090 qdf_mem_free(res);
16091
16092 return status;
16093}
Qiwei Caie689a262018-07-26 15:50:22 +080016094#endif /* FEATURE_BSS_TRANSITION */
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053016095
Vignesh Viswanathan79f7e3f2018-09-30 23:56:10 +053016096bool sme_is_conn_state_connected(mac_handle_t hal, uint8_t session_id)
16097{
16098 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16099
16100 return csr_is_conn_state_connected(mac_ctx, session_id);
16101}
16102
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016103void sme_enable_roaming_on_connected_sta(tHalHandle hal)
16104{
16105 uint8_t session_id;
16106 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16107 QDF_STATUS status;
16108
16109 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
16110 if (session_id != CSR_SESSION_ID_INVALID)
16111 return;
16112
16113 session_id = csr_get_connected_infra(mac_ctx);
16114 if (session_id == CSR_SESSION_ID_INVALID) {
16115 sme_debug("No STA in conencted state");
16116 return;
16117 }
16118
16119 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
16120 session_id);
16121 status = sme_acquire_global_lock(&mac_ctx->sme);
16122 if (QDF_IS_STATUS_SUCCESS(status)) {
16123 csr_roam_offload_scan(mac_ctx, session_id,
16124 ROAM_SCAN_OFFLOAD_START,
16125 REASON_CTX_INIT);
16126 sme_release_global_lock(&mac_ctx->sme);
16127 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016128}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016129
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016130int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
16131{
16132 uint8_t vdev_id, chan;
16133 struct csr_roam_session *session;
16134 tpAniSirGlobal mac_ctx;
16135 tHalHandle h_hal;
16136 int16_t freq = 0;
16137
16138 if (vdev == NULL) {
16139 sme_err("Invalid vdev id is passed");
16140 return 0;
16141 }
16142
16143 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016144 if (!h_hal) {
16145 sme_err("h_hal is null");
16146 return 0;
16147 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016148 mac_ctx = PMAC_STRUCT(h_hal);
16149 vdev_id = wlan_vdev_get_id(vdev);
16150 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16151 sme_err("Invalid vdev id is passed");
16152 return 0;
16153 }
16154
16155 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16156 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
16157 if (chan)
16158 freq = cds_chan_to_freq(chan);
16159
16160 return freq;
16161}
16162
16163enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
16164{
16165 uint8_t vdev_id;
16166 struct csr_roam_session *session;
16167 tpAniSirGlobal mac_ctx;
16168 tHalHandle h_hal;
16169 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
16170
16171 if (vdev == NULL) {
16172 sme_err("Invalid vdev id is passed");
16173 return CH_WIDTH_INVALID;
16174 }
16175
16176 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016177 if (!h_hal) {
16178 sme_err("h_hal is null");
16179 return CH_WIDTH_INVALID;
16180 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016181 mac_ctx = PMAC_STRUCT(h_hal);
16182 vdev_id = wlan_vdev_get_id(vdev);
16183 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16184 sme_err("Invalid vdev id is passed");
16185 return CH_WIDTH_INVALID;
16186 }
16187
16188 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16189
16190 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16191 ch_width = session->connectedProfile.vht_channel_width;
16192
16193 return ch_width;
16194}
16195
16196int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16197 uint16_t *sec20chan_freq)
16198{
16199 uint8_t vdev_id;
16200
16201 vdev_id = wlan_vdev_get_id(vdev);
16202 /* Need to extend */
16203 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016204}
16205
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016206#ifdef WLAN_FEATURE_SAE
16207QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16208 uint8_t sae_status)
16209{
16210 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16211 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16212 struct sir_sae_msg *sae_msg;
16213 struct scheduler_msg sch_msg = {0};
16214
16215 qdf_status = sme_acquire_global_lock(&mac->sme);
16216 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16217 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16218 if (!sae_msg) {
16219 qdf_status = QDF_STATUS_E_NOMEM;
16220 sme_err("SAE: memory allocation failed");
16221 } else {
16222 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16223 sae_msg->length = sizeof(*sae_msg);
16224 sae_msg->session_id = session_id;
16225 sae_msg->sae_status = sae_status;
16226 sme_debug("SAE: sae_status %d session_id %d",
16227 sae_msg->sae_status,
16228 sae_msg->session_id);
16229
16230 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16231 sch_msg.bodyptr = sae_msg;
16232
16233 qdf_status =
gaurank kathpalia36b0c582018-08-28 17:45:43 +053016234 scheduler_post_message(QDF_MODULE_ID_SME,
16235 QDF_MODULE_ID_PE,
16236 QDF_MODULE_ID_PE,
16237 &sch_msg);
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016238 }
16239 sme_release_global_lock(&mac->sme);
16240 }
16241
16242 return qdf_status;
16243}
16244#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016245
16246bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16247{
16248 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16249
16250 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16251 sme_err("Invalid session id: %d", session_id);
16252 return false;
16253 }
16254
16255 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16256}
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016257
16258bool sme_validate_channel_list(tHalHandle hal,
16259 uint8_t *chan_list,
16260 uint8_t num_channels)
16261{
16262 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16263 uint8_t i = 0;
16264 uint8_t j;
16265 bool found;
16266 struct csr_channel *ch_lst_info = &mac_ctx->scan.base_channels;
16267
16268 if (!chan_list || !num_channels) {
16269 sme_err("Chan list empty %pK or num_channels is 0", chan_list);
16270 return false;
16271 }
16272
16273 while (i < num_channels) {
16274 found = false;
16275 for (j = 0; j < ch_lst_info->numChannels; j++) {
16276 if (ch_lst_info->channelList[j] == chan_list[i]) {
16277 found = true;
16278 break;
16279 }
16280 }
16281
16282 if (!found) {
16283 sme_debug("Invalid channel %d", chan_list[i]);
16284 return false;
16285 }
16286
16287 i++;
16288 }
Arif Hussain0e246802018-05-01 18:13:44 -070016289
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016290 return true;
16291}
Arif Hussain0e246802018-05-01 18:13:44 -070016292
16293void sme_set_amsdu(tHalHandle hal, bool enable)
16294{
16295 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16296 mac_ctx->is_usr_cfg_amsdu_enabled = enable;
16297}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016298
16299uint8_t sme_get_mcs_idx(uint16_t max_rate, uint8_t rate_flags,
Hanumanth Reddy Pothula834f9432018-05-30 14:20:32 +053016300 uint8_t *nss, uint8_t *mcs_rate_flags)
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016301{
16302 return wma_get_mcs_idx(max_rate, rate_flags, nss, mcs_rate_flags);
16303}
Chaoli Zhou75b062f2018-06-11 12:36:54 +080016304
16305bool sme_find_session_by_bssid(tHalHandle hal, uint8_t *bssid)
16306{
16307 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16308 bool ret;
16309
16310 ret = csr_find_session_by_bssid(mac_ctx, bssid);
16311
16312 return ret;
16313}
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +053016314
16315QDF_STATUS
16316sme_get_roam_scan_stats(tHalHandle hal, roam_scan_stats_cb cb, void *context,
16317 uint32_t vdev_id)
16318{
16319 QDF_STATUS status = QDF_STATUS_E_FAILURE;
16320 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16321 struct scheduler_msg msg = {0};
16322 struct sir_roam_scan_stats *req;
16323
16324 req = qdf_mem_malloc(sizeof(*req));
16325 if (!req) {
16326 sme_err("Failed allocate memory for roam scan stats req");
16327 return QDF_STATUS_E_NOMEM;
16328 }
16329
16330 req->vdev_id = vdev_id;
16331 req->cb = cb;
16332 req->context = context;
16333
16334 status = sme_acquire_global_lock(&mac->sme);
16335 if (QDF_IS_STATUS_SUCCESS(status)) {
16336 msg.bodyptr = req;
16337 msg.type = WMA_GET_ROAM_SCAN_STATS;
16338 msg.reserved = 0;
gaurank kathpalia36b0c582018-08-28 17:45:43 +053016339 status = scheduler_post_message(QDF_MODULE_ID_SME,
16340 QDF_MODULE_ID_WMA,
16341 QDF_MODULE_ID_WMA,
16342 &msg);
Rajeev Kumar Sirasanagandla4f20b672018-03-12 13:52:50 +053016343 sme_release_global_lock(&mac->sme);
16344 if (!QDF_IS_STATUS_SUCCESS(status)) {
16345 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
16346 FL("post roam scan stats req failed"));
16347 status = QDF_STATUS_E_FAILURE;
16348 qdf_mem_free(req);
16349 }
16350 } else {
16351 sme_err("sme_acquire_global_lock failed");
16352 qdf_mem_free(req);
16353 }
16354
16355 return status;
16356}
Vignesh Viswanathan987f0bb2018-09-17 17:00:29 +053016357
16358void sme_update_score_config(tHalHandle hal,
16359 struct scoring_config *score_config)
16360{
16361 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16362 struct wlan_mlme_scoring_cfg *mlme_scoring_cfg;
16363
16364 mlme_scoring_cfg = &mac_ctx->mlme_cfg->scoring;
16365
16366 score_config->weight_cfg.rssi_weightage =
16367 mlme_scoring_cfg->weight_cfg.rssi_weightage;
16368 score_config->weight_cfg.ht_caps_weightage =
16369 mlme_scoring_cfg->weight_cfg.ht_caps_weightage;
16370 score_config->weight_cfg.vht_caps_weightage =
16371 mlme_scoring_cfg->weight_cfg.vht_caps_weightage;
16372 score_config->weight_cfg.he_caps_weightage =
16373 mlme_scoring_cfg->weight_cfg.he_caps_weightage;
16374 score_config->weight_cfg.chan_width_weightage =
16375 mlme_scoring_cfg->weight_cfg.chan_width_weightage;
16376 score_config->weight_cfg.chan_band_weightage =
16377 mlme_scoring_cfg->weight_cfg.chan_band_weightage;
16378 score_config->weight_cfg.nss_weightage =
16379 mlme_scoring_cfg->weight_cfg.nss_weightage;
16380 score_config->weight_cfg.beamforming_cap_weightage =
16381 mlme_scoring_cfg->weight_cfg.beamforming_cap_weightage;
16382 score_config->weight_cfg.pcl_weightage =
16383 mlme_scoring_cfg->weight_cfg.pcl_weightage;
16384 score_config->weight_cfg.channel_congestion_weightage =
16385 mlme_scoring_cfg->weight_cfg.channel_congestion_weightage;
16386 score_config->weight_cfg.oce_wan_weightage =
16387 mlme_scoring_cfg->weight_cfg.oce_wan_weightage;
16388
16389 score_config->bandwidth_weight_per_index =
16390 mlme_scoring_cfg->bandwidth_weight_per_index;
16391 score_config->nss_weight_per_index =
16392 mlme_scoring_cfg->nss_weight_per_index;
16393 score_config->band_weight_per_index =
16394 mlme_scoring_cfg->band_weight_per_index;
16395
16396 score_config->rssi_score.best_rssi_threshold =
16397 mlme_scoring_cfg->rssi_score.best_rssi_threshold;
16398 score_config->rssi_score.good_rssi_threshold =
16399 mlme_scoring_cfg->rssi_score.good_rssi_threshold;
16400 score_config->rssi_score.bad_rssi_threshold =
16401 mlme_scoring_cfg->rssi_score.bad_rssi_threshold;
16402 score_config->rssi_score.good_rssi_pcnt =
16403 mlme_scoring_cfg->rssi_score.good_rssi_pcnt;
16404 score_config->rssi_score.bad_rssi_pcnt =
16405 mlme_scoring_cfg->rssi_score.bad_rssi_pcnt;
16406 score_config->rssi_score.good_rssi_bucket_size =
16407 mlme_scoring_cfg->rssi_score.good_rssi_bucket_size;
16408 score_config->rssi_score.bad_rssi_bucket_size =
16409 mlme_scoring_cfg->rssi_score.bad_rssi_bucket_size;
16410 score_config->rssi_score.rssi_pref_5g_rssi_thresh =
16411 mlme_scoring_cfg->rssi_score.rssi_pref_5g_rssi_thresh;
16412
16413 score_config->esp_qbss_scoring.num_slot =
16414 mlme_scoring_cfg->esp_qbss_scoring.num_slot;
16415 score_config->esp_qbss_scoring.score_pcnt3_to_0 =
16416 mlme_scoring_cfg->esp_qbss_scoring.score_pcnt3_to_0;
16417 score_config->esp_qbss_scoring.score_pcnt7_to_4 =
16418 mlme_scoring_cfg->esp_qbss_scoring.score_pcnt7_to_4;
16419 score_config->esp_qbss_scoring.score_pcnt11_to_8 =
16420 mlme_scoring_cfg->esp_qbss_scoring.score_pcnt11_to_8;
16421 score_config->esp_qbss_scoring.score_pcnt15_to_12 =
16422 mlme_scoring_cfg->esp_qbss_scoring.score_pcnt15_to_12;
16423
16424 score_config->oce_wan_scoring.num_slot =
16425 mlme_scoring_cfg->oce_wan_scoring.num_slot;
16426 score_config->oce_wan_scoring.score_pcnt3_to_0 =
16427 mlme_scoring_cfg->oce_wan_scoring.score_pcnt3_to_0;
16428 score_config->oce_wan_scoring.score_pcnt7_to_4 =
16429 mlme_scoring_cfg->oce_wan_scoring.score_pcnt7_to_4;
16430 score_config->oce_wan_scoring.score_pcnt11_to_8 =
16431 mlme_scoring_cfg->oce_wan_scoring.score_pcnt11_to_8;
16432 score_config->oce_wan_scoring.score_pcnt15_to_12 =
16433 mlme_scoring_cfg->oce_wan_scoring.score_pcnt15_to_12;
16434}