blob: d28e56af12aceef17cc291150094c5ef3e9b6a2b [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061static tSelfRecoveryStats g_self_recovery_stats;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053063static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053065static void sme_disconnect_connected_sessions(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053067static QDF_STATUS sme_handle_generic_change_country_code(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 void *pMsgBuf);
69
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053070static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072#ifdef WLAN_FEATURE_11W
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053073QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm);
75#endif
76
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077/* Channel Change Response Indication Handler */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053078static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 uint16_t msg_type, void *pMsgBuf);
80
81/* Internal SME APIs */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053082QDF_STATUS sme_acquire_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053084 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085
86 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053087 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053088 (qdf_mutex_acquire(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053089 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 }
91
92 return status;
93}
94
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053095QDF_STATUS sme_release_global_lock(tSmeStruct *psSme)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053097 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098
99 if (psSme) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530100 if (QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530101 (qdf_mutex_release(&psSme->lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530102 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 }
104
105 return status;
106}
107
Tushnim Bhattacharyya518e80f2017-08-30 17:35:33 -0700108tpAniSirGlobal sme_get_mac_context(void)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -0700109{
110 tpAniSirGlobal mac_ctx;
111 tHalHandle h_hal;
112
113 h_hal = cds_get_context(QDF_MODULE_ID_SME);
114 if (NULL == h_hal) {
115 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
116 FL("invalid h_hal"));
117 return NULL;
118 }
119
120 mac_ctx = PMAC_STRUCT(h_hal);
121 if (NULL == mac_ctx) {
122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
123 FL("Invalid MAC context"));
124 return NULL;
125 }
126
127 return mac_ctx;
128}
129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130/**
131 * sme_process_set_hw_mode_resp() - Process set HW mode response
132 * @mac: Global MAC pointer
133 * @msg: HW mode response
134 *
135 * Processes the HW mode response and invokes the HDD callback
136 * to process further
137 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530138static QDF_STATUS sme_process_set_hw_mode_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139{
Krunal Sonia8270f52017-02-23 19:51:25 -0800140 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800141 tSmeCmd *command = NULL;
142 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800143 policy_mgr_pdev_set_hw_mode_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700145 enum policy_mgr_conn_update_reason reason;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530146 struct csr_roam_session *session;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800147 uint32_t session_id;
Sandeep Puligilla344d7252017-09-15 16:23:33 -0700148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 param = (struct sir_set_hw_mode_resp *)msg;
150 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700151 sme_err("HW mode resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 /* Not returning. Need to check if active command list
153 * needs to be freed
154 */
155 }
156
Krunal Sonia8270f52017-02-23 19:51:25 -0800157 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700159 sme_err("No cmd found in active list");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800160 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 }
162
163 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
164 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700165 sme_err("Base address is NULL");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800166 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 }
168
169 if (e_sme_command_set_hw_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700170 sme_err("Command mismatch!");
Tushnim Bhattacharyya4a03db82017-11-10 17:58:28 -0800171 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 }
173
174 callback = command->u.set_hw_mode_cmd.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530175 reason = command->u.set_hw_mode_cmd.reason;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800176 session_id = command->u.set_hw_mode_cmd.session_id;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530177
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700178 sme_debug("reason: %d session: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +0530179 command->u.set_hw_mode_cmd.reason,
180 command->u.set_hw_mode_cmd.session_id);
181
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700182 if (!callback) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700183 sme_err("Callback does not exist");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700184 goto end;
185 }
186
187 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700188 sme_err("Callback failed since HW mode params is NULL");
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700189 goto end;
190 }
191
192 /* Irrespective of the reason for which the hw mode change request
193 * was issued, the policy manager connection table needs to be updated
194 * with the new vdev-mac id mapping, tx/rx spatial streams etc., if the
195 * set hw mode was successful.
196 */
197 callback(param->status,
198 param->cfgd_hw_mode_index,
199 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800200 param->vdev_mac_map,
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -0800201 command->u.set_hw_mode_cmd.next_action,
202 command->u.set_hw_mode_cmd.reason,
203 command->u.set_hw_mode_cmd.session_id,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800204 command->u.set_hw_mode_cmd.context);
Krunal Soni3fa80e22018-01-09 14:16:02 -0800205 if (!CSR_IS_SESSION_VALID(mac, session_id)) {
206 sme_err("session %d is invalid", session_id);
207 goto end;
208 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800209 session = CSR_GET_SESSION(mac, session_id);
Tushnim Bhattacharyya3b99f4b2018-03-26 14:19:24 -0700210 if (reason == POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekar4dd215e2016-04-16 18:48:34 -0700211 /* In the case of hidden SSID, connection update
212 * (set hw mode) is done after the scan with reason
213 * code eCsrScanForSsid completes. The connect/failure
214 * needs to be handled after the response of set hw
215 * mode
216 */
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800217 if (param->status == SET_HW_MODE_STATUS_OK) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700218 sme_debug("search for ssid success");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800219 csr_scan_handle_search_for_ssid(mac,
220 session_id);
221 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700222 sme_debug("search for ssid failure");
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800223 csr_scan_handle_search_for_ssid_failure(mac,
224 session_id);
225 }
Deepak Dhamdhere6f7fbbe2017-02-28 13:35:52 -0800226 csr_saved_scan_cmd_free_fields(mac, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 }
228
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530229end:
Krunal Soni72dba662017-02-15 20:13:17 -0800230 found = csr_nonscan_active_ll_remove_entry(mac, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530232 if (found)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -0800234 csr_release_command(mac, command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800235
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530236 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237}
238
239/**
240 * sme_process_hw_mode_trans_ind() - Process HW mode transition indication
241 * @mac: Global MAC pointer
242 * @msg: HW mode transition response
243 *
244 * Processes the HW mode transition indication and invoke the HDD callback
245 * to process further
246 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530247static QDF_STATUS sme_process_hw_mode_trans_ind(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 uint8_t *msg)
249{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 struct sir_hw_mode_trans_ind *param;
251
252 param = (struct sir_hw_mode_trans_ind *)msg;
253 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700254 sme_err("HW mode trans ind param is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 }
257
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800258 policy_mgr_hw_mode_transition_cb(param->old_hw_mode_index,
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -0800259 param->new_hw_mode_index,
260 param->num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -0800261 param->vdev_mac_map, mac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530263 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264}
265
Naveen Rawate7d86052015-11-13 12:01:43 -0800266/**
267 * free_sme_cmds() - This function frees memory allocated for SME commands
268 * @mac_ctx: Pointer to Global MAC structure
269 *
270 * This function frees memory allocated for SME commands
271 *
272 * @Return: void
273 */
274static void free_sme_cmds(tpAniSirGlobal mac_ctx)
275{
276 uint32_t idx;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530277
Naveen Rawate7d86052015-11-13 12:01:43 -0800278 if (NULL == mac_ctx->sme.pSmeCmdBufAddr)
279 return;
280
281 for (idx = 0; idx < mac_ctx->sme.totalSmeCmd; idx++)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr[idx]);
Naveen Rawate7d86052015-11-13 12:01:43 -0800283
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530284 qdf_mem_free(mac_ctx->sme.pSmeCmdBufAddr);
Naveen Rawate7d86052015-11-13 12:01:43 -0800285 mac_ctx->sme.pSmeCmdBufAddr = NULL;
286}
287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530288static QDF_STATUS init_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530290 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 tSmeCmd *pCmd;
292 uint32_t cmd_idx;
Naveen Rawate7d86052015-11-13 12:01:43 -0800293 uint32_t sme_cmd_ptr_ary_sz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294
295 pMac->sme.totalSmeCmd = SME_TOTAL_COMMAND;
296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 status = csr_ll_open(pMac->hHdd, &pMac->sme.smeCmdFreeList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530299 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 goto end;
301
Naveen Rawate7d86052015-11-13 12:01:43 -0800302 /* following pointer contains array of pointers for tSmeCmd* */
303 sme_cmd_ptr_ary_sz = sizeof(void *) * pMac->sme.totalSmeCmd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530304 pMac->sme.pSmeCmdBufAddr = qdf_mem_malloc(sme_cmd_ptr_ary_sz);
Naveen Rawate7d86052015-11-13 12:01:43 -0800305 if (NULL == pMac->sme.pSmeCmdBufAddr) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530306 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800307 goto end;
308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530310 status = QDF_STATUS_SUCCESS;
Naveen Rawate7d86052015-11-13 12:01:43 -0800311 for (cmd_idx = 0; cmd_idx < pMac->sme.totalSmeCmd; cmd_idx++) {
312 /*
313 * Since total size of all commands together can be huge chunk
314 * of memory, allocate SME cmd individually. These SME CMDs are
315 * moved between pending and active queues. And these freeing of
316 * these queues just manipulates the list but does not actually
317 * frees SME CMD pointers. Hence store each SME CMD address in
318 * the array, sme.pSmeCmdBufAddr. This will later facilitate
319 * freeing up of all SME CMDs with just a for loop.
320 */
321 pMac->sme.pSmeCmdBufAddr[cmd_idx] =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530322 qdf_mem_malloc(sizeof(tSmeCmd));
Naveen Rawate7d86052015-11-13 12:01:43 -0800323 if (NULL == pMac->sme.pSmeCmdBufAddr[cmd_idx]) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530324 status = QDF_STATUS_E_NOMEM;
Naveen Rawate7d86052015-11-13 12:01:43 -0800325 free_sme_cmds(pMac);
326 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 }
Naveen Rawate7d86052015-11-13 12:01:43 -0800328 pCmd = (tSmeCmd *)pMac->sme.pSmeCmdBufAddr[cmd_idx];
329 csr_ll_insert_tail(&pMac->sme.smeCmdFreeList,
330 &pCmd->Link, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 }
332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530334 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700335 sme_err("Failed to initialize sme command list: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336
337 return status;
338}
339
Krunal Sonia8270f52017-02-23 19:51:25 -0800340void sme_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341{
Krunal Sonia8270f52017-02-23 19:51:25 -0800342 sme_cmd->command = eSmeNoCommand;
343 csr_ll_insert_tail(&mac_ctx->sme.smeCmdFreeList, &sme_cmd->Link,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530344 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345}
346
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530347static QDF_STATUS free_sme_cmd_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530349 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 csr_ll_close(&pMac->sme.smeCmdFreeList);
352
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530353 status = qdf_mutex_acquire(&pMac->sme.lkSmeGlobalLock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530354 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700355 sme_err("Failed to acquire the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 goto done;
357 }
358
Naveen Rawate7d86052015-11-13 12:01:43 -0800359 free_sme_cmds(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530361 status = qdf_mutex_release(&pMac->sme.lkSmeGlobalLock);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530362 if (status != QDF_STATUS_SUCCESS)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700363 sme_err("Failed to release the lock status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364done:
365 return status;
366}
367
Jeff Johnson49c02f92016-10-07 10:29:09 -0700368static void dump_csr_command_info(tpAniSirGlobal pMac, tSmeCmd *pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369{
370 switch (pCmd->command) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 case eSmeCommandRoam:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700372 sme_debug("roam command reason is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 pCmd->u.roamCmd.roamReason);
374 break;
375
376 case eSmeCommandWmStatusChange:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700377 sme_debug("WMStatusChange command type is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 pCmd->u.wmStatusChangeCmd.Type);
379 break;
380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700382 sme_debug("default: Unhandled command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 pCmd->command);
384 break;
385 }
386}
387
388tSmeCmd *sme_get_command_buffer(tpAniSirGlobal pMac)
389{
390 tSmeCmd *pRetCmd = NULL, *pTempCmd = NULL;
391 tListElem *pEntry;
392 static int sme_command_queue_full;
393
394 pEntry = csr_ll_remove_head(&pMac->sme.smeCmdFreeList, LL_ACCESS_LOCK);
395
396 /* If we can get another MS Msg buffer, then we are ok. Just link */
397 /* the entry onto the linked list. (We are using the linked list */
398 /* to keep track of tfhe message buffers). */
399 if (pEntry) {
400 pRetCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
401 /* reset when free list is available */
402 sme_command_queue_full = 0;
403 } else {
404 int idx = 1;
405
406 /* Cannot change pRetCmd here since it needs to return later. */
Krunal Sonia8270f52017-02-23 19:51:25 -0800407 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530408 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530410
411 sme_err("Out of command buffer.... command (0x%X) stuck",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
413 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530414 if (eSmeCsrCommandMask & pTempCmd->command)
415 /* CSR command is stuck. See what the reason
416 * code is for that command
417 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 } /* if(pTempCmd) */
420
421 /* dump what is in the pending queue */
Krunal Soni20126cb2017-02-15 16:26:57 -0800422 csr_nonscan_pending_ll_lock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -0800424 csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 LL_ACCESS_NOLOCK);
426 while (pEntry && !sme_command_queue_full) {
427 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
428 /* Print only 1st five commands from pending queue. */
429 if (idx <= 5)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530430 sme_err("Out of command buffer.... SME pending command #%d (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 idx, pTempCmd->command);
432 idx++;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530433 if (eSmeCsrCommandMask & pTempCmd->command)
434 /* CSR command is stuck. See what the reason
435 * code is for that command
436 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 dump_csr_command_info(pMac, pTempCmd);
Krunal Soni72dba662017-02-15 20:13:17 -0800438 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 LL_ACCESS_NOLOCK);
440 }
Krunal Soni20126cb2017-02-15 16:26:57 -0800441 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442
Abhishek Singh5ea86532016-04-27 14:10:53 +0530443 if (pMac->roam.configParam.enable_fatal_event)
444 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
445 WLAN_LOG_INDICATOR_HOST_DRIVER,
446 WLAN_LOG_REASON_SME_OUT_OF_CMD_BUF,
447 false,
448 pMac->sme.enableSelfRecovery ? true : false);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530449 else
Anurag Chouhan4085ff72017-10-05 18:09:56 +0530450 cds_trigger_recovery(QDF_GET_MSG_BUFF_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 }
452
453 /* memset to zero */
454 if (pRetCmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530455 qdf_mem_set((uint8_t *)&pRetCmd->command,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456 sizeof(pRetCmd->command), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530457 qdf_mem_set((uint8_t *)&pRetCmd->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 sizeof(pRetCmd->sessionId), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530459 qdf_mem_set((uint8_t *)&pRetCmd->u, sizeof(pRetCmd->u), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 }
461
462 return pRetCmd;
463}
464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465/**
Krunal Sonia8270f52017-02-23 19:51:25 -0800466 * sme_ser_handle_active_cmd() - handle command activation callback from
467 * new serialization module
468 * @cmd: pointer to new serialization command
469 *
470 * This API is to handle command activation callback from new serialization
471 * callback
472 *
473 * Return: QDF_STATUS_SUCCESS
474 */
475static
476QDF_STATUS sme_ser_handle_active_cmd(struct wlan_serialization_command *cmd)
477{
478 tSmeCmd *sme_cmd;
479 tHalHandle hal;
480 tpAniSirGlobal mac_ctx;
481 QDF_STATUS status = QDF_STATUS_SUCCESS;
482 bool do_continue;
483
484 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700485 sme_err("No serialization command found");
Krunal Sonia8270f52017-02-23 19:51:25 -0800486 return QDF_STATUS_E_FAILURE;
487 }
488
489 hal = cds_get_context(QDF_MODULE_ID_SME);
490 mac_ctx = PMAC_STRUCT(hal);
491 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700492 sme_err("No mac_ctx 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;
Krunal Sonia8270f52017-02-23 19:51:25 -0800509 case eSmeCommandAddTs:
510 case eSmeCommandDelTs:
511#ifndef WLAN_MDM_CODE_REDUCTION_OPT
512 do_continue = qos_process_command(mac_ctx, sme_cmd);
513 if (do_continue)
514 status = QDF_STATUS_E_FAILURE;
515#endif
516 break;
Krunal Sonia8270f52017-02-23 19:51:25 -0800517 case e_sme_command_set_hw_mode:
518 csr_process_set_hw_mode(mac_ctx, sme_cmd);
519 break;
520 case e_sme_command_nss_update:
521 csr_process_nss_update_req(mac_ctx, sme_cmd);
522 break;
523 case e_sme_command_set_dual_mac_config:
524 csr_process_set_dual_mac_config(mac_ctx, sme_cmd);
525 break;
526 case e_sme_command_set_antenna_mode:
527 csr_process_set_antenna_mode(mac_ctx, sme_cmd);
528 break;
529 default:
530 /* something is wrong */
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700531 sme_err("unknown command %d", sme_cmd->command);
Krunal Sonia8270f52017-02-23 19:51:25 -0800532 status = QDF_STATUS_E_FAILURE;
533 break;
534 }
Krunal Sonia8270f52017-02-23 19:51:25 -0800535 return status;
536}
537
538QDF_STATUS sme_ser_cmd_callback(void *buf,
539 enum wlan_serialization_cb_reason reason)
540{
541 struct wlan_serialization_command *cmd = buf;
542 tHalHandle hal;
543 tpAniSirGlobal mac_ctx;
544 QDF_STATUS status = QDF_STATUS_SUCCESS;
545 tSmeCmd *sme_cmd;
546
547 hal = cds_get_context(QDF_MODULE_ID_SME);
548 mac_ctx = PMAC_STRUCT(hal);
549 if (!mac_ctx) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700550 sme_err("mac_ctx is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800551 return QDF_STATUS_E_FAILURE;
552 }
553 /*
554 * Do not acquire lock here as sme global lock is already acquired in
555 * caller or MC thread context
556 */
557 if (!cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700558 sme_err("serialization command is null");
Krunal Sonia8270f52017-02-23 19:51:25 -0800559 return QDF_STATUS_E_FAILURE;
560 }
561
562 switch (reason) {
563 case WLAN_SER_CB_ACTIVATE_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700564 sme_debug("WLAN_SER_CB_ACTIVATE_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800565 status = sme_ser_handle_active_cmd(cmd);
566 break;
567 case WLAN_SER_CB_CANCEL_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700568 sme_debug("WLAN_SER_CB_CANCEL_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800569 break;
570 case WLAN_SER_CB_RELEASE_MEM_CMD:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700571 sme_debug("WLAN_SER_CB_RELEASE_MEM_CMD callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800572 sme_cmd = cmd->umac_cmd;
573 csr_release_command_buffer(mac_ctx, sme_cmd);
574 break;
575 case WLAN_SER_CB_ACTIVE_CMD_TIMEOUT:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700576 sme_debug("WLAN_SER_CB_ACTIVE_CMD_TIMEOUT callback");
Krunal Sonia8270f52017-02-23 19:51:25 -0800577 break;
578 default:
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700579 sme_debug("STOP: unknown reason code");
Krunal Sonia8270f52017-02-23 19:51:25 -0800580 return QDF_STATUS_E_FAILURE;
581 }
582 return status;
583}
584
Wen Gong3f003382018-05-14 14:26:37 +0800585#ifdef WLAN_FEATURE_MEMDUMP_ENABLE
Krunal Sonia8270f52017-02-23 19:51:25 -0800586/**
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530587 * sme_get_sessionid_from_activelist() - gets session id
588 * @mac: mac context
589 *
590 * This function is used to get session id from sme command
591 * active list
592 *
593 * Return: returns session id
594 */
Jeff Johnson49c02f92016-10-07 10:29:09 -0700595static uint32_t sme_get_sessionid_from_activelist(tpAniSirGlobal mac)
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530596{
597 tListElem *entry;
598 tSmeCmd *command;
599 uint32_t session_id = CSR_SESSION_ID_INVALID;
600
Krunal Sonia8270f52017-02-23 19:51:25 -0800601 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530602 if (entry) {
603 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
604 session_id = command->sessionId;
605 }
606
607 return session_id;
608}
609
610/**
611 * sme_state_info_dump() - prints state information of sme layer
612 * @buf: buffer pointer
613 * @size: size of buffer to be filled
614 *
615 * This function is used to dump state information of sme layer
616 *
617 * Return: None
618 */
619static void sme_state_info_dump(char **buf_ptr, uint16_t *size)
620{
621 uint32_t session_id, active_session_id;
622 tHalHandle hal;
623 tpAniSirGlobal mac;
624 uint16_t len = 0;
625 char *buf = *buf_ptr;
626 eCsrConnectState connect_state;
627
628 hal = cds_get_context(QDF_MODULE_ID_SME);
629 if (hal == NULL) {
630 QDF_ASSERT(0);
631 return;
632 }
633
634 mac = PMAC_STRUCT(hal);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530635
636 active_session_id = sme_get_sessionid_from_activelist(mac);
637 if (active_session_id != CSR_SESSION_ID_INVALID) {
638 len += qdf_scnprintf(buf + len, *size - len,
639 "\n active command sessionid %d", active_session_id);
640 }
641
642 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
643 if (CSR_IS_SESSION_VALID(mac, session_id)) {
644 connect_state =
645 mac->roam.roamSession[session_id].connectState;
646 if ((eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED ==
647 connect_state)
648 || (eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED ==
649 connect_state)) {
650 len += qdf_scnprintf(buf + len, *size - len,
651 "\n NeighborRoamState: %d",
652 mac->roam.neighborRoamInfo[session_id].
653 neighborRoamState);
654 len += qdf_scnprintf(buf + len, *size - len,
655 "\n RoamState: %d", mac->roam.
656 curState[session_id]);
657 len += qdf_scnprintf(buf + len, *size - len,
658 "\n RoamSubState: %d", mac->roam.
659 curSubState[session_id]);
660 len += qdf_scnprintf(buf + len, *size - len,
661 "\n ConnectState: %d",
662 connect_state);
663 }
664 }
665 }
666
667 *size -= len;
668 *buf_ptr += len;
669}
670
671/**
672 * sme_register_debug_callback() - registration function sme layer
673 * to print sme state information
674 *
675 * Return: None
676 */
677static void sme_register_debug_callback(void)
678{
679 qdf_register_debug_callback(QDF_MODULE_ID_SME, &sme_state_info_dump);
680}
Wen Gong3f003382018-05-14 14:26:37 +0800681#else /* WLAN_FEATURE_MEMDUMP_ENABLE */
Wen Gongaa6d55d2018-04-26 16:33:21 +0800682static void sme_register_debug_callback(void)
683{
684}
Wen Gong3f003382018-05-14 14:26:37 +0800685#endif /* WLAN_FEATURE_MEMDUMP_ENABLE */
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687/* Global APIs */
688
689/**
690 * sme_open() - Initialze all SME modules and put them at idle state
691 * @hHal: The handle returned by mac_open
692 *
693 * The function initializes each module inside SME, PMC, CSR, etc. Upon
694 * successfully return, all modules are at idle state ready to start.
695 * smeOpen must be called before any other SME APIs can be involved.
696 * smeOpen must be called after mac_open.
697 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530698 * Return: QDF_STATUS_SUCCESS - SME is successfully initialized.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 * Other status means SME is failed to be initialized
700 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530701QDF_STATUS sme_open(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530703 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705
706 pMac->sme.state = SME_STATE_STOP;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530707 pMac->sme.currDeviceMode = QDF_STA_MODE;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530708 if (!QDF_IS_STATUS_SUCCESS(qdf_mutex_create(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 &pMac->sme.lkSmeGlobalLock))) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700710 sme_err("sme_open failed init lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530711 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 }
713 status = csr_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530714 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700715 sme_err("csr_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 return status;
717 }
718
719 status = sme_ps_open(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530720 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700721 sme_err("sme_ps_open failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 return status;
723 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724
725#ifndef WLAN_MDM_CODE_REDUCTION_OPT
726 status = sme_qos_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530727 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700728 sme_err("Qos open, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 return status;
730 }
731#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 status = init_sme_cmd_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530733 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 status = rrm_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530737 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700738 sme_err("rrm_open failed, status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 return status;
740 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 sme_trace_init(pMac);
Padma, Santhosh Kumar9aba02f2016-08-11 16:30:25 +0530742 sme_register_debug_callback();
Krunal Soni33787902017-08-29 11:39:28 -0700743 wlan_serialization_legacy_init_callback();
744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 return status;
746}
747
748/*
749 * sme_init_chan_list, triggers channel setup based on country code.
750 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530751QDF_STATUS sme_init_chan_list(tHalHandle hal, uint8_t *alpha2,
Amar Singhala297bfa2015-10-15 15:07:29 -0700752 enum country_src cc_src)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753{
754 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
755
Amar Singhala297bfa2015-10-15 15:07:29 -0700756 if ((cc_src == SOURCE_USERSPACE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 (pmac->roam.configParam.fSupplicantCountryCodeHasPriority)) {
758 pmac->roam.configParam.Is11dSupportEnabled = false;
759 }
760
761 return csr_init_chan_list(pmac, alpha2);
762}
763
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530764/*
765 * sme_set11dinfo() - Set the 11d information about valid channels
766 * and there power using information from nvRAM
767 * This function is called only for AP.
768 *
769 * This is a synchronous call
770 *
771 * hHal - The handle returned by mac_open.
772 * pSmeConfigParams - a pointer to a caller allocated object of
773 * typedef struct _smeConfigParams.
774 *
775 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
776 *
777 * Other status means SME is failed to update the config parameters.
778 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530780QDF_STATUS sme_set11dinfo(tHalHandle hHal, tpSmeConfigParams pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530782 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530784 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO, NO_SESSION, 0));
786 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700787 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 return status;
789 }
790
791 status = csr_set_channels(hHal, &pSmeConfigParams->csrConfig);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700792 if (!QDF_IS_STATUS_SUCCESS(status))
793 sme_err("csr_set_channels failed with status: %d", status);
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 return status;
796}
797
798/**
799 * sme_set_scan_disable() - Dynamically enable/disable scan
800 * @h_hal: Handle to HAL
801 *
802 * This command gives the user an option to dynamically
803 * enable or disable scans.
804 *
805 * Return: None
806 */
807void sme_set_scan_disable(tHalHandle h_hal, int value)
808{
809 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530810
Sandeep Puligilla24b7aa72017-10-13 18:05:14 -0700811 sme_info("scan disable %d", value);
Abhishek Singhcaebce02017-10-12 11:07:57 +0530812 ucfg_scan_set_enable(mac_ctx->psoc, !value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813}
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530814/*
815 * sme_get_soft_ap_domain() - Get the current regulatory domain of softAp.
816 * This is a synchronous call
817 *
818 * hHal - The handle returned by HostapdAdapter.
819 * v_REGDOMAIN_t - The current Regulatory Domain requested for SoftAp.
820 * Return QDF_STATUS_SUCCESS - SME successfully completed the request.
821 * Other status means, failed to get the current regulatory domain.
822 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530824QDF_STATUS sme_get_soft_ap_domain(tHalHandle hHal, v_REGDOMAIN_t
825 *domainIdSoftAp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530827 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
829
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530830 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN,
832 NO_SESSION, 0));
833 if (NULL == domainIdSoftAp) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700834 sme_err("Uninitialized domain Id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 return status;
836 }
837
838 *domainIdSoftAp = pMac->scan.domainIdCurrent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530839 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840
841 return status;
842}
843
Krunal Sonie3531942016-04-12 17:43:53 -0700844/**
845 * sme_update_fine_time_measurement_capab() - Update the FTM capabitlies from
846 * incoming val
847 * @hal: Handle for Hal layer
848 * @val: New FTM capability value
849 *
850 * Return: None
851 */
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530852void sme_update_fine_time_measurement_capab(tHalHandle hal, uint8_t session_id,
853 uint32_t val)
Krunal Sonie3531942016-04-12 17:43:53 -0700854{
855 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530856 QDF_STATUS status;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530857
Naveen Rawatd2657be2017-10-10 14:31:23 -0700858 ucfg_wifi_pos_set_ftm_cap(mac_ctx->psoc, val);
Krunal Sonie3531942016-04-12 17:43:53 -0700859
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530860 if (!val) {
Krunal Sonie3531942016-04-12 17:43:53 -0700861 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 0;
862 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
863 rrmConfig.rm_capability)->fine_time_meas_rpt = 0;
864 } else {
865 mac_ctx->rrm.rrmPEContext.rrmEnabledCaps.fine_time_meas_rpt = 1;
866 ((tpRRMCaps)mac_ctx->rrm.rrmSmeContext.
867 rrmConfig.rm_capability)->fine_time_meas_rpt = 1;
868 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530869
870 /* Inform this RRM IE change to FW */
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530871 status = sme_acquire_global_lock(&mac_ctx->sme);
872 if (QDF_IS_STATUS_SUCCESS(status)) {
873 csr_roam_offload_scan(mac_ctx, session_id,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +0530874 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
875 REASON_CONNECT_IES_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530876 sme_release_global_lock(&mac_ctx->sme);
877 } else {
878 sme_err("Failed to acquire SME lock");
879 }
Krunal Sonie3531942016-04-12 17:43:53 -0700880}
881
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530882/*
883 * sme_update_config() - Change configurations for all SME moduels
884 * The function updates some configuration for modules in SME, CSR, etc
885 * during SMEs close open sequence.
886 * Modules inside SME apply the new configuration at the next transaction.
887 * This is a synchronous call
888 *
889 * hHal - The handle returned by mac_open.
890 * pSmeConfigParams - a pointer to a caller allocated object of
891 * typedef struct _smeConfigParams.
892 * Return QDF_STATUS_SUCCESS - SME update the config parameters successfully.
893 * Other status means SME is failed to update the config parameters.
894 */
895QDF_STATUS sme_update_config(tHalHandle hHal, tpSmeConfigParams
896 pSmeConfigParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530898 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
900
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530901 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG, NO_SESSION,
903 0));
904 if (NULL == pSmeConfigParams) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700905 sme_err("SME config params empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 return status;
907 }
908
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530909 status = csr_change_default_config_param(pMac, &pSmeConfigParams->
910 csrConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530912 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700913 sme_err("csr_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530916 status = rrm_change_default_config_param(hHal, &pSmeConfigParams->
917 rrmConfig);
918
919 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -0700920 sme_err("rrm_change_default_config_param failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 status);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530922
923 /* For SOC, CFG is set before start We don't want to apply global CFG
924 * in connect state because that may cause some side affect
925 */
926 if (csr_is_all_session_disconnected(pMac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 csr_set_global_cfgs(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929 /*
930 * If scan offload is enabled then lim has allow the sending of
931 * scan request to firmware even in powersave mode. The firmware has
932 * to take care of exiting from power save mode
933 */
934 status = sme_cfg_set_int(hHal, WNI_CFG_SCAN_IN_POWERSAVE, true);
935
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +0530936 if (QDF_STATUS_SUCCESS != status)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530937 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 "Could not pass on WNI_CFG_SCAN_IN_POWERSAVE to CFG");
Kapil Gupta4f0c0c12017-02-07 15:21:15 +0530939
940 pMac->snr_monitor_enabled = pSmeConfigParams->snr_monitor_enabled;
941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 return status;
943}
944
945/**
Abhishek Singh158fe252017-03-23 11:09:34 +0530946 * sme_update_scan_roam_params() - Update the scan roaming params
947 * @mac_ctx: mac ctx
948 *
949 * Return: void.
950 */
951static void sme_update_scan_roam_params(tpAniSirGlobal mac_ctx)
952{
953 struct roam_filter_params scan_params = {0};
954 struct roam_ext_params *roam_params_src;
955 uint8_t i;
956 QDF_STATUS status;
957
958 roam_params_src = &mac_ctx->roam.configParam.roam_params;
959
960 scan_params.num_bssid_avoid_list =
961 roam_params_src->num_bssid_avoid_list;
Abhishek Singh158fe252017-03-23 11:09:34 +0530962
963 if (scan_params.num_bssid_avoid_list >
964 MAX_AVOID_LIST_BSSID)
965 scan_params.num_bssid_avoid_list =
966 MAX_AVOID_LIST_BSSID;
967
968 for (i = 0; i < scan_params.num_bssid_avoid_list; i++) {
969 qdf_copy_macaddr(&scan_params.bssid_avoid_list[i],
970 &roam_params_src->bssid_avoid_list[i]);
971 }
972
973 status = ucfg_scan_update_roam_params(mac_ctx->psoc, &scan_params);
974 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda2c263352017-03-17 17:49:53 -0700975 sme_err("ailed to update scan roam params with status=%d",
Abhishek Singh158fe252017-03-23 11:09:34 +0530976 status);
977}
978
979/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 * sme_update_roam_params() - Store/Update the roaming params
981 * @hal: Handle for Hal layer
982 * @session_id: SME Session ID
983 * @roam_params_src: The source buffer to copy
984 * @update_param: Type of parameter to be updated
985 *
986 * Return: Return the status of the updation.
987 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530988QDF_STATUS sme_update_roam_params(tHalHandle hal,
Srinivas Girigowda72f30392017-07-13 18:55:09 -0700989 uint8_t session_id, struct roam_ext_params *roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 int update_param)
991{
992 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
993 struct roam_ext_params *roam_params_dst;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +0530994 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 uint8_t i;
996
997 roam_params_dst = &mac_ctx->roam.configParam.roam_params;
998 switch (update_param) {
999 case REASON_ROAM_EXT_SCAN_PARAMS_CHANGED:
1000 roam_params_dst->raise_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001001 roam_params_src->raise_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 roam_params_dst->drop_rssi_thresh_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001003 roam_params_src->drop_rssi_thresh_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 roam_params_dst->raise_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001005 roam_params_src->raise_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 roam_params_dst->drop_factor_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001007 roam_params_src->drop_factor_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 roam_params_dst->max_raise_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001009 roam_params_src->max_raise_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 roam_params_dst->max_drop_rssi_5g =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001011 roam_params_src->max_drop_rssi_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 roam_params_dst->alert_rssi_threshold =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001013 roam_params_src->alert_rssi_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 roam_params_dst->is_5g_pref_enabled = true;
1015 break;
1016 case REASON_ROAM_SET_SSID_ALLOWED:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301017 qdf_mem_set(&roam_params_dst->ssid_allowed_list, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 sizeof(tSirMacSSid) * MAX_SSID_ALLOWED_LIST);
1019 roam_params_dst->num_ssid_allowed_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001020 roam_params_src->num_ssid_allowed_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
1022 roam_params_dst->ssid_allowed_list[i].length =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001023 roam_params_src->ssid_allowed_list[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301024 qdf_mem_copy(roam_params_dst->ssid_allowed_list[i].ssId,
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001025 roam_params_src->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 roam_params_dst->ssid_allowed_list[i].length);
1027 }
1028 break;
1029 case REASON_ROAM_SET_FAVORED_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301030 qdf_mem_set(&roam_params_dst->bssid_favored, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 sizeof(tSirMacAddr) * MAX_BSSID_FAVORED);
1032 roam_params_dst->num_bssid_favored =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001033 roam_params_src->num_bssid_favored;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301035 qdf_mem_copy(&roam_params_dst->bssid_favored[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001036 &roam_params_src->bssid_favored[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 sizeof(tSirMacAddr));
1038 roam_params_dst->bssid_favored_factor[i] =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001039 roam_params_src->bssid_favored_factor[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 }
1041 break;
1042 case REASON_ROAM_SET_BLACKLIST_BSSID:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301043 qdf_mem_set(&roam_params_dst->bssid_avoid_list, 0,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301044 QDF_MAC_ADDR_SIZE * MAX_BSSID_AVOID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 roam_params_dst->num_bssid_avoid_list =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001046 roam_params_src->num_bssid_avoid_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301048 qdf_copy_macaddr(&roam_params_dst->bssid_avoid_list[i],
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001049 &roam_params_src->bssid_avoid_list[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 }
1051 break;
1052 case REASON_ROAM_GOOD_RSSI_CHANGED:
1053 roam_params_dst->good_rssi_roam =
Srinivas Girigowda72f30392017-07-13 18:55:09 -07001054 roam_params_src->good_rssi_roam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 break;
1056 default:
1057 break;
1058 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301059
1060 status = sme_acquire_global_lock(&mac_ctx->sme);
1061 if (QDF_IS_STATUS_SUCCESS(status)) {
1062 csr_roam_offload_scan(mac_ctx, session_id,
1063 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1064 update_param);
1065 sme_release_global_lock(&mac_ctx->sme);
1066 } else {
1067 sme_err("Failed to acquire SME lock");
1068 }
Abhishek Singh158fe252017-03-23 11:09:34 +05301069
1070 sme_update_scan_roam_params(mac_ctx);
1071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 return 0;
1073}
1074
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301075/*
1076 * sme_process_ready_to_suspend() -
1077 * On getting ready to suspend indication, this function calls
1078 * callback registered (HDD callbacks) with SME to inform ready
1079 * to suspend indication.
1080 *
1081 * hHal - Handle returned by mac_open.
1082 * pReadyToSuspend - Parameter received along with ready to suspend
1083 * indication from WMA.
1084 * Return: None
1085 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001086static void sme_process_ready_to_suspend(tHalHandle hHal,
1087 tpSirReadyToSuspendInd pReadyToSuspend)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088{
1089 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1090
1091 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301092 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 "%s: pMac is null", __func__);
1094 return;
1095 }
1096
1097 if (NULL != pMac->readyToSuspendCallback) {
1098 pMac->readyToSuspendCallback(pMac->readyToSuspendContext,
1099 pReadyToSuspend->suspended);
1100 pMac->readyToSuspendCallback = NULL;
1101 }
1102}
1103
1104#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07001106/**
1107 * sme_process_ready_to_ext_wow() - inform ready to ExtWoW indication.
1108 * @hHal - Handle returned by mac_open.
1109 * @pReadyToExtWoW - Parameter received along with ready to Ext WoW
1110 * indication from WMA.
1111 *
1112 * On getting ready to Ext WoW indication, this function calls callback
1113 * registered (HDD callback)with SME to inform ready to ExtWoW indication.
1114 *
1115 * Return: None
1116 */
Jeff Johnson49c02f92016-10-07 10:29:09 -07001117static void sme_process_ready_to_ext_wow(tHalHandle hHal,
1118 tpSirReadyToExtWoWInd pReadyToExtWoW)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119{
1120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1121
1122 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 "%s: pMac is null", __func__);
1125 return;
1126 }
1127
1128 if (NULL != pMac->readyToExtWoWCallback) {
1129 pMac->readyToExtWoWCallback(pMac->readyToExtWoWContext,
1130 pReadyToExtWoW->status);
1131 pMac->readyToExtWoWCallback = NULL;
1132 pMac->readyToExtWoWContext = NULL;
1133 }
1134
1135}
1136#endif
1137
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301138/*
1139 * sme_hdd_ready_ind() - SME sends eWNI_SME_SYS_READY_IND to PE to inform
1140 * that the NIC is ready tio run.
1141 * The function is called by HDD at the end of initialization stage so PE/HAL
1142 * can enable the NIC to running state.
1143 * This is a synchronous call
1144 *
1145 * @hHal - The handle returned by mac_open.
1146 * Return QDF_STATUS_SUCCESS - eWNI_SME_SYS_READY_IND is sent to PE
1147 * successfully.
1148 * Other status means SME failed to send the message to PE.
1149 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301150QDF_STATUS sme_hdd_ready_ind(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151{
Abhishek Singhde410b72017-05-22 15:25:39 +05301152 tSirSmeReadyReq *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301153 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1155
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301156 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND, NO_SESSION, 0));
1158 do {
1159
Abhishek Singhde410b72017-05-22 15:25:39 +05301160 msg = qdf_mem_malloc(sizeof(*msg));
1161 if (!msg) {
1162 sme_err("Memory allocation failed! for msg");
1163 return QDF_STATUS_E_NOMEM;
1164 }
1165 msg->messageType = eWNI_SME_SYS_READY_IND;
1166 msg->length = sizeof(*msg);
Abhishek Singhde410b72017-05-22 15:25:39 +05301167 msg->csr_roam_synch_cb = csr_roam_synch_callback;
Sandeep Puligilla1426d612017-04-12 18:22:06 -07001168 msg->sme_msg_cb = sme_process_msg_callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301170 if (eSIR_FAILURE != u_mac_post_ctrl_msg(hHal, (tSirMbMsg *)
1171 msg)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301172 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001174 sme_err("u_mac_post_ctrl_msg failed to send eWNI_SME_SYS_READY_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 break;
1176 }
1177
1178 status = csr_ready(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301179 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001180 sme_err("csr_ready failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 break;
1182 }
1183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 pMac->sme.state = SME_STATE_READY;
1185 } while (0);
1186
1187 return status;
1188}
1189
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001190QDF_STATUS sme_get_valid_channels(uint8_t *chan_list, uint32_t *list_len)
1191{
1192 tpAniSirGlobal mac_ctx = sme_get_mac_context();
1193 QDF_STATUS status = QDF_STATUS_SUCCESS;
1194
1195 if (NULL == mac_ctx) {
1196 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1197 FL("Invalid MAC context"));
1198 return QDF_STATUS_E_FAILURE;
1199 }
1200
1201 if (eSIR_SUCCESS != wlan_cfg_get_str(mac_ctx,
1202 WNI_CFG_VALID_CHANNEL_LIST, chan_list, list_len))
1203 status = QDF_STATUS_E_INVAL;
1204
1205 return status;
1206}
1207
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001208#ifdef WLAN_CONV_SPECTRAL_ENABLE
1209static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1210{
1211 struct spectral_legacy_cbacks spectral_cb;
1212 QDF_STATUS status;
1213
1214 spectral_cb.vdev_get_chan_freq = sme_get_oper_chan_freq;
1215 spectral_cb.vdev_get_ch_width = sme_get_oper_ch_width;
1216 spectral_cb.vdev_get_sec20chan_freq_mhz = sme_get_sec20chan_freq_mhz;
1217 status = spectral_register_legacy_cb(mac_ctx->psoc, &spectral_cb);
1218
1219 return status;
1220}
1221#else
1222static QDF_STATUS sme_register_spectral_cb(tpAniSirGlobal mac_ctx)
1223{
1224 return QDF_STATUS_SUCCESS;
1225}
1226#endif
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301227/*
1228 * sme_start() - Put all SME modules at ready state.
1229 * The function starts each module in SME, PMC, CSR, etc. . Upon
1230 * successfully return, all modules are ready to run.
1231 * This is a synchronous call
1232 *
1233 * hHal - The handle returned by mac_open.
1234 * Return QDF_STATUS_SUCCESS - SME is ready.
1235 * Other status means SME is failed to start
1236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301237QDF_STATUS sme_start(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301239 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001241 struct policy_mgr_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
1243 do {
1244 status = csr_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301245 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001246 sme_err("csr_start failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 break;
1248 }
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001249 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Tushnim Bhattacharyyac3c375e2017-08-04 23:39:55 -07001250 sme_cbacks.sme_get_valid_channels = sme_get_valid_channels;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001251 sme_cbacks.sme_nss_update_request = sme_nss_update_request;
1252 sme_cbacks.sme_pdev_set_hw_mode = sme_pdev_set_hw_mode;
1253 sme_cbacks.sme_pdev_set_pcl = sme_pdev_set_pcl;
1254 sme_cbacks.sme_soc_set_dual_mac_config =
1255 sme_soc_set_dual_mac_config;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07001256 sme_cbacks.sme_change_mcc_beacon_interval =
1257 sme_change_mcc_beacon_interval;
1258 sme_cbacks.sme_get_ap_channel_from_scan =
1259 sme_get_ap_channel_from_scan;
1260 sme_cbacks.sme_scan_result_purge = sme_scan_result_purge;
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001261 status = policy_mgr_register_sme_cb(pMac->psoc, &sme_cbacks);
1262 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07001263 sme_err("Failed to register sme cb with Policy Manager: %d",
Tushnim Bhattacharyya91049632017-03-17 17:31:27 -07001264 status);
1265 break;
1266 }
Sandeep Puligilla8e89d572018-04-02 18:07:45 -07001267 sme_register_spectral_cb(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 pMac->sme.state = SME_STATE_START;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07001270 /* START RRM */
1271 status = rrm_start(pMac);
1272 if (!QDF_IS_STATUS_SUCCESS(status)) {
1273 sme_err("Failed to start RRM");
1274 break;
1275 }
1276 } while (0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 return status;
1278}
1279
Arif Hussaincd151632017-02-11 16:57:19 -08001280static QDF_STATUS dfs_msg_processor(tpAniSirGlobal mac,
1281 struct scheduler_msg *msg)
1282{
1283 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001284 struct csr_roam_info roam_info = { 0 };
Arif Hussaincd151632017-02-11 16:57:19 -08001285 tSirSmeCSAIeTxCompleteRsp *csa_ie_tx_complete_rsp;
1286 uint32_t session_id = 0;
1287 eRoamCmdStatus roam_status;
1288 eCsrRoamResult roam_result;
1289
1290 switch (msg->type) {
1291 case eWNI_SME_DFS_RADAR_FOUND:
1292 {
1293 session_id = msg->bodyval;
1294 roam_status = eCSR_ROAM_DFS_RADAR_IND;
1295 roam_result = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301296 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001297 "sapdfs: Radar indication event occurred");
1298 break;
1299 }
1300 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
1301 {
1302 csa_ie_tx_complete_rsp =
1303 (tSirSmeCSAIeTxCompleteRsp *) msg->bodyptr;
1304 if (!csa_ie_tx_complete_rsp) {
1305 sme_err("eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND null msg");
1306 return QDF_STATUS_E_FAILURE;
1307 }
1308 session_id = csa_ie_tx_complete_rsp->sessionId;
1309 roam_status = eCSR_ROAM_DFS_CHAN_SW_NOTIFY;
1310 roam_result = eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301311 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001312 "eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND session=%d",
1313 session_id);
1314 break;
1315 }
1316 case eWNI_SME_DFS_CAC_COMPLETE:
1317 {
1318 session_id = msg->bodyval;
1319 roam_status = eCSR_ROAM_CAC_COMPLETE_IND;
1320 roam_result = eCSR_ROAM_RESULT_CAC_END_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Arif Hussaincd151632017-02-11 16:57:19 -08001322 "sapdfs: Received eWNI_SME_DFS_CAC_COMPLETE vdevid%d",
1323 session_id);
1324 break;
1325 }
1326 default:
1327 {
1328 sme_err("Invalid DFS message: 0x%x", msg->type);
1329 status = QDF_STATUS_E_FAILURE;
1330 return status;
1331 }
1332 }
1333
1334 /* Indicate Radar Event to SAP */
1335 csr_roam_call_callback(mac, session_id, &roam_info, 0,
1336 roam_status, roam_result);
1337 return status;
1338}
1339
1340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#ifdef WLAN_FEATURE_11W
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301342/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 * Handle the unprotected management frame indication from LIM and
1344 * forward it to HDD.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301345 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301346QDF_STATUS sme_unprotected_mgmt_frm_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 tpSirSmeUnprotMgmtFrameInd pSmeMgmtFrm)
1348{
1349 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301350 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001351 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 uint32_t SessionId = pSmeMgmtFrm->sessionId;
1353
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001354 roam_info.nFrameLength = pSmeMgmtFrm->frameLen;
1355 roam_info.pbFrames = pSmeMgmtFrm->frameBuf;
1356 roam_info.frameType = pSmeMgmtFrm->frameType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
1358 /* forward the mgmt frame to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001359 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 eCSR_ROAM_UNPROT_MGMT_FRAME_IND, 0);
1361
1362 return status;
1363}
1364#endif
1365
Kapil Gupta8878ad92017-02-13 11:56:04 +05301366QDF_STATUS sme_update_new_channel_event(tHalHandle hal, uint8_t session_id)
1367{
1368 QDF_STATUS status = QDF_STATUS_SUCCESS;
1369 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Jeff Johnson172237b2017-11-07 15:32:59 -08001370 struct csr_roam_info *roamInfo;
Kapil Gupta8878ad92017-02-13 11:56:04 +05301371 eRoamCmdStatus roamStatus;
1372 eCsrRoamResult roamResult;
1373
1374 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
Krunal Soni3fa80e22018-01-09 14:16:02 -08001375 if (!roamInfo) {
1376 sme_err("mem alloc failed for roam info");
1377 return QDF_STATUS_E_FAILURE;
1378 }
Kapil Gupta8878ad92017-02-13 11:56:04 +05301379 roamInfo->dfs_event.sessionId = session_id;
1380
1381 roamStatus = eCSR_ROAM_CHANNEL_COMPLETE_IND;
1382 roamResult = eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND;
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301383 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Kapil Gupta8878ad92017-02-13 11:56:04 +05301384 "sapdfs: Updated new channel event");
1385
1386 /* Indicate channel Event to SAP */
1387 csr_roam_call_callback(mac, session_id, roamInfo, 0,
1388 roamStatus, roamResult);
1389
1390 qdf_mem_free(roamInfo);
1391 return status;
1392}
1393
1394
Abhishek Singh518323d2015-10-19 17:42:01 +05301395/**
1396 * sme_extended_change_channel_ind()- function to indicate ECSA
1397 * action frame is received in lim to SAP
1398 * @mac_ctx: pointer to global mac structure
1399 * @msg_buf: contain new channel and session id.
1400 *
1401 * This function is called to post ECSA action frame
1402 * receive event to SAP.
1403 *
1404 * Return: success if msg indicated to SAP else return failure
1405 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301406static QDF_STATUS sme_extended_change_channel_ind(tpAniSirGlobal mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05301407 void *msg_buf)
1408{
1409 struct sir_sme_ext_cng_chan_ind *ext_chan_ind;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301410 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05301411 uint32_t session_id = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001412 struct csr_roam_info roamInfo = {0};
Abhishek Singh518323d2015-10-19 17:42:01 +05301413 eRoamCmdStatus roam_status;
1414 eCsrRoamResult roam_result;
1415
Abhishek Singh518323d2015-10-19 17:42:01 +05301416 ext_chan_ind = msg_buf;
1417 if (NULL == ext_chan_ind) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001418 sme_err("ext_chan_ind is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301419 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05301420 }
1421 session_id = ext_chan_ind->session_id;
1422 roamInfo.target_channel = ext_chan_ind->new_channel;
1423 roam_status = eCSR_ROAM_EXT_CHG_CHNL_IND;
1424 roam_result = eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001425 sme_debug("sapdfs: Received eWNI_SME_EXT_CHANGE_CHANNEL_IND for session id [%d]",
1426 session_id);
Abhishek Singh518323d2015-10-19 17:42:01 +05301427
1428 /* Indicate Ext Channel Change event to SAP */
1429 csr_roam_call_callback(mac_ctx, session_id, &roamInfo, 0,
1430 roam_status, roam_result);
1431 return status;
1432}
1433
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001434#ifdef FEATURE_WLAN_ESE
1435/**
1436 * sme_update_is_ese_feature_enabled() - enable/disable ESE support at runtime
1437 * @hHal: HAL handle
1438 * @sessionId: session id
1439 * @isEseIniFeatureEnabled: ese ini enabled
1440 *
1441 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
1442 * isEseIniFeatureEnabled. This is a synchronous call
1443 *
1444 * Return: QDF_STATUS enumeration
1445 */
1446QDF_STATUS sme_update_is_ese_feature_enabled(tHalHandle hHal,
1447 uint8_t sessionId, const bool isEseIniFeatureEnabled)
1448{
1449 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301450 QDF_STATUS status;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001451
1452 if (pMac->roam.configParam.isEseIniFeatureEnabled ==
1453 isEseIniFeatureEnabled) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301454 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001455 "%s: ESE Mode is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
1456 __func__,
1457 pMac->roam.configParam.isEseIniFeatureEnabled,
1458 isEseIniFeatureEnabled);
1459 return QDF_STATUS_SUCCESS;
1460 }
1461
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001463 "%s: EseEnabled is changed from %d to %d", __func__,
1464 pMac->roam.configParam.isEseIniFeatureEnabled,
1465 isEseIniFeatureEnabled);
1466 pMac->roam.configParam.isEseIniFeatureEnabled = isEseIniFeatureEnabled;
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07001467 csr_neighbor_roam_update_fast_roaming_enabled(
1468 pMac, sessionId, isEseIniFeatureEnabled);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001469
1470 if (true == isEseIniFeatureEnabled)
1471 sme_update_fast_transition_enabled(hHal, true);
1472
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301473 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
1474 status = sme_acquire_global_lock(&pMac->sme);
1475 if (QDF_IS_STATUS_SUCCESS(status)) {
1476 csr_roam_offload_scan(pMac, sessionId,
1477 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1478 REASON_ESE_INI_CFG_CHANGED);
1479 sme_release_global_lock(&pMac->sme);
1480 } else {
1481 sme_err("Failed to acquire SME lock");
1482 return status;
1483 }
1484 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001485 return QDF_STATUS_SUCCESS;
1486}
1487
1488/**
1489 * sme_set_plm_request() - set plm request
1490 * @hHal: HAL handle
1491 * @pPlmReq: Pointer to input plm request
1492 *
1493 * Return: QDF_STATUS enumeration
1494 */
1495QDF_STATUS sme_set_plm_request(tHalHandle hHal, tpSirPlmReq pPlmReq)
1496{
1497 QDF_STATUS status;
1498 bool ret = false;
1499 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Varun Reddy Yeturu87c8ad82017-10-03 17:48:12 -07001500 uint8_t ch_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001501 uint8_t count, valid_count = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001502 struct scheduler_msg msg = {0};
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301503 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
1504 pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001505
1506 status = sme_acquire_global_lock(&pMac->sme);
1507 if (!QDF_IS_STATUS_SUCCESS(status))
1508 return status;
1509
1510 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001511 sme_err("session %d not found", pPlmReq->sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001512 sme_release_global_lock(&pMac->sme);
1513 return QDF_STATUS_E_FAILURE;
1514 }
1515
1516 if (!pSession->sessionActive) {
1517 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1518 FL("Invalid Sessionid"));
1519 sme_release_global_lock(&pMac->sme);
1520 return QDF_STATUS_E_FAILURE;
1521 }
1522
1523 if (!pPlmReq->enable)
1524 goto send_plm_start;
1525 /* validating channel numbers */
1526 for (count = 0; count < pPlmReq->plmNumCh; count++) {
1527 ret = csr_is_supported_channel(pMac, pPlmReq->plmChList[count]);
1528 if (ret && pPlmReq->plmChList[count] > 14) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001529 if (CHANNEL_STATE_DFS == wlan_reg_get_channel_state(
1530 pMac->pdev,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001531 pPlmReq->plmChList[count])) {
1532 /* DFS channel is provided, no PLM bursts can be
1533 * transmitted. Ignoring these channels.
1534 */
1535 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301536 QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001537 FL("DFS channel %d ignored for PLM"),
1538 pPlmReq->plmChList[count]);
1539 continue;
1540 }
1541 } else if (!ret) {
1542 /* Not supported, ignore the channel */
Abhishek Singhe4a1f882017-08-10 17:59:44 +05301543 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001544 FL("Unsupported channel %d ignored for PLM"),
1545 pPlmReq->plmChList[count]);
1546 continue;
1547 }
1548 ch_list[valid_count] = pPlmReq->plmChList[count];
1549 valid_count++;
1550 } /* End of for () */
1551
1552 /* Copying back the valid channel list to plm struct */
1553 qdf_mem_set((void *)pPlmReq->plmChList,
1554 pPlmReq->plmNumCh, 0);
1555 if (valid_count)
1556 qdf_mem_copy(pPlmReq->plmChList, ch_list,
1557 valid_count);
1558 /* All are invalid channels, FW need to send the PLM
1559 * report with "incapable" bit set.
1560 */
1561 pPlmReq->plmNumCh = valid_count;
1562
1563send_plm_start:
1564 /* PLM START */
1565 msg.type = WMA_SET_PLM_REQ;
1566 msg.reserved = 0;
1567 msg.bodyptr = pPlmReq;
1568
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001569 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001570 &msg))) {
1571 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1572 FL("Not able to post WMA_SET_PLM_REQ to WMA"));
1573 sme_release_global_lock(&pMac->sme);
1574 return QDF_STATUS_E_FAILURE;
1575 }
1576
1577 sme_release_global_lock(&pMac->sme);
1578 return status;
1579}
1580
1581/**
1582 * sme_tsm_ie_ind() - sme tsm ie indication
1583 * @hHal: HAL handle
1584 * @pSmeTsmIeInd: Pointer to tsm ie indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 *
1586 * Handle the tsm ie indication from LIM and forward it to HDD.
1587 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001588 * Return: QDF_STATUS enumeration
1589 */
1590static QDF_STATUS sme_tsm_ie_ind(tHalHandle hHal, tSirSmeTsmIEInd *pSmeTsmIeInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591{
1592 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301593 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08001594 struct csr_roam_info roam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 uint32_t SessionId = pSmeTsmIeInd->sessionId;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301596
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001597 roam_info.tsmIe.tsid = pSmeTsmIeInd->tsmIe.tsid;
1598 roam_info.tsmIe.state = pSmeTsmIeInd->tsmIe.state;
1599 roam_info.tsmIe.msmt_interval = pSmeTsmIeInd->tsmIe.msmt_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600 /* forward the tsm ie information to HDD */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07001601 csr_roam_call_callback(pMac, SessionId, &roam_info, 0,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301602 eCSR_ROAM_TSM_IE_IND, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 return status;
1604}
1605
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001606/**
1607 * sme_set_cckm_ie() - set cckm ie
1608 * @hHal: HAL handle
1609 * @sessionId: session id
1610 * @pCckmIe: Pointer to CCKM Ie
1611 * @cckmIeLen: Length of @pCckmIe
1612 *
1613 * Function to store the CCKM IE passed from supplicant and use
1614 * it while packing reassociation request.
1615 *
1616 * Return: QDF_STATUS enumeration
1617 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301618QDF_STATUS sme_set_cckm_ie(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 uint8_t *pCckmIe, uint8_t cckmIeLen)
1620{
1621 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301622 QDF_STATUS status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301623
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301625 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 csr_set_cckm_ie(pMac, sessionId, pCckmIe, cckmIeLen);
1627 sme_release_global_lock(&pMac->sme);
1628 }
1629 return status;
1630}
1631
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001632/**
1633 * sme_set_ese_beacon_request() - set ese beacon request
1634 * @hHal: HAL handle
1635 * @sessionId: session id
1636 * @pEseBcnReq: Ese beacon report
1637 *
1638 * function to set ESE beacon request parameters
1639 *
1640 * Return: QDF_STATUS enumeration
1641 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301642QDF_STATUS sme_set_ese_beacon_request(tHalHandle hHal, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 const tCsrEseBeaconReq *pEseBcnReq)
1644{
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07001645 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1647 tpSirBeaconReportReqInd pSmeBcnReportReq = NULL;
1648 tCsrEseBeaconReqParams *pBeaconReq = NULL;
1649 uint8_t counter = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301650 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 tpRrmSMEContext pSmeRrmContext = &pMac->rrm.rrmSmeContext;
1652
1653 if (pSmeRrmContext->eseBcnReqInProgress == true) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001654 sme_err("A Beacon Report Req is already in progress");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301655 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 }
1657
1658 /* Store the info in RRM context */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301659 qdf_mem_copy(&pSmeRrmContext->eseBcnReqInfo, pEseBcnReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 sizeof(tCsrEseBeaconReq));
1661
1662 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301663 pSmeBcnReportReq = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 if (NULL == pSmeBcnReportReq) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001665 sme_err("Memory Allocation Failure!!! ESE BcnReq Ind to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301666 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 }
1668
1669 pSmeRrmContext->eseBcnReqInProgress = true;
1670
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001671 sme_debug("Sending Beacon Report Req to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672
1673 pSmeBcnReportReq->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
1674 pSmeBcnReportReq->length = sizeof(tSirBeaconReportReqInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301675 qdf_mem_copy(pSmeBcnReportReq->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 pSession->connectedProfile.bssid.bytes,
1677 sizeof(tSirMacAddr));
1678 pSmeBcnReportReq->channelInfo.channelNum = 255;
1679 pSmeBcnReportReq->channelList.numChannels = pEseBcnReq->numBcnReqIe;
1680 pSmeBcnReportReq->msgSource = eRRM_MSG_SOURCE_ESE_UPLOAD;
1681
1682 for (counter = 0; counter < pEseBcnReq->numBcnReqIe; counter++) {
1683 pBeaconReq =
1684 (tCsrEseBeaconReqParams *) &pEseBcnReq->bcnReq[counter];
1685 pSmeBcnReportReq->fMeasurementtype[counter] =
1686 pBeaconReq->scanMode;
1687 pSmeBcnReportReq->measurementDuration[counter] =
1688 SYS_TU_TO_MS(pBeaconReq->measurementDuration);
1689 pSmeBcnReportReq->channelList.channelNumber[counter] =
1690 pBeaconReq->channel;
1691 }
1692
1693 status = sme_rrm_process_beacon_report_req_ind(pMac, pSmeBcnReportReq);
1694
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301695 if (status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 pSmeRrmContext->eseBcnReqInProgress = false;
1697
Hanumanth Reddy Pothula7f7a2712016-09-07 18:44:47 +05301698 qdf_mem_free(pSmeBcnReportReq);
1699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return status;
1701}
1702
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001703/**
1704 * sme_get_tsm_stats() - SME get tsm stats
1705 * @hHal: HAL handle
1706 * @callback: SME sends back the requested stats using the callback
1707 * @staId: The station ID for which the stats is requested for
1708 * @bssId: bssid
1709 * @pContext: user context to be passed back along with the callback
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001710 * @tid: Traffic id
1711 *
1712 * API register a callback to get TSM Stats.
1713 *
1714 * Return: QDF_STATUS enumeration
1715 */
1716QDF_STATUS sme_get_tsm_stats(tHalHandle hHal,
1717 tCsrTsmStatsCallback callback,
1718 uint8_t staId, struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07001719 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001720{
1721 QDF_STATUS status = QDF_STATUS_E_FAILURE;
1722 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1723
1724 status = sme_acquire_global_lock(&pMac->sme);
1725 if (QDF_IS_STATUS_SUCCESS(status)) {
1726 status = csr_get_tsm_stats(pMac, callback,
1727 staId, bssId, pContext,
Jeff Johnson30f84552017-09-13 14:55:25 -07001728 tid);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001729 sme_release_global_lock(&pMac->sme);
1730 }
1731 return status;
1732}
1733
1734/**
1735 * sme_set_ese_roam_scan_channel_list() - To set ese roam scan channel list
1736 * @hHal: pointer HAL handle returned by mac_open
1737 * @sessionId: sme session id
1738 * @pChannelList: Output channel list
1739 * @numChannels: Output number of channels
1740 *
1741 * This routine is called to set ese roam scan channel list.
1742 * This is a synchronous call
1743 *
1744 * Return: QDF_STATUS
1745 */
1746QDF_STATUS sme_set_ese_roam_scan_channel_list(tHalHandle hHal,
1747 uint8_t sessionId,
1748 uint8_t *pChannelList,
1749 uint8_t numChannels)
1750{
1751 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1752 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001753 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
1754 tpCsrChannelInfo curchnl_list_info = NULL;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001755 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
1756 uint8_t newChannelList[128] = { 0 };
1757 uint8_t i = 0, j = 0;
1758
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08001759 if (sessionId >= CSR_ROAM_SESSION_MAX) {
1760 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1761 FL("Invalid sme session id: %d"), sessionId);
1762 return QDF_STATUS_E_INVAL;
1763 }
1764
1765 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
1766 curchnl_list_info =
1767 &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1768
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001769 status = sme_acquire_global_lock(&pMac->sme);
1770 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301771 sme_err("Failed to acquire SME lock");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001772 return status;
1773 }
1774 if (NULL != curchnl_list_info->ChannelList) {
1775 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1776 j += snprintf(oldChannelList + j,
1777 sizeof(oldChannelList) - j, "%d",
1778 curchnl_list_info->ChannelList[i]);
1779 }
1780 }
1781 status = csr_create_roam_scan_channel_list(pMac, sessionId,
1782 pChannelList, numChannels,
1783 csr_get_current_band(hHal));
1784 if (QDF_IS_STATUS_SUCCESS(status)) {
1785 if (NULL != curchnl_list_info->ChannelList) {
1786 j = 0;
1787 for (i = 0; i < curchnl_list_info->numOfChannels; i++) {
1788 j += snprintf(newChannelList + j,
1789 sizeof(newChannelList) - j, "%d",
1790 curchnl_list_info->ChannelList[i]);
1791 }
1792 }
1793 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1794 "ESE roam scan chnl list successfully set to %s-old value is %s-roam state is %d",
1795 newChannelList, oldChannelList,
1796 pNeighborRoamInfo->neighborRoamState);
1797 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301798
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001799 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
1800 csr_roam_offload_scan(pMac, sessionId,
1801 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
1802 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05301803
1804 sme_release_global_lock(&pMac->sme);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001805 return status;
1806}
1807
1808#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
Jeff Johnson49c02f92016-10-07 10:29:09 -07001810static
1811QDF_STATUS sme_ibss_peer_info_response_handler(tHalHandle hHal,
1812 tpSirIbssGetPeerInfoRspParams
1813 pIbssPeerInfoParams)
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08001814{
1815 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1816
1817 if (NULL == pMac) {
1818 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
1819 "%s: pMac is null", __func__);
1820 return QDF_STATUS_E_FAILURE;
1821 }
1822 if (pMac->sme.peerInfoParams.peerInfoCbk == NULL) {
1823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
1824 "%s: HDD callback is null", __func__);
1825 return QDF_STATUS_E_FAILURE;
1826 }
1827 pMac->sme.peerInfoParams.peerInfoCbk(pMac->sme.peerInfoParams.pUserData,
1828 &pIbssPeerInfoParams->
1829 ibssPeerInfoRspParams);
1830 return QDF_STATUS_SUCCESS;
1831}
1832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 * sme_process_dual_mac_config_resp() - Process set Dual mac config response
1835 * @mac: Global MAC pointer
1836 * @msg: Dual mac config response
1837 *
1838 * Processes the dual mac configuration response and invokes the HDD callback
1839 * to process further
1840 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301841static QDF_STATUS sme_process_dual_mac_config_resp(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 uint8_t *msg)
1843{
1844 tListElem *entry = NULL;
1845 tSmeCmd *command = NULL;
1846 bool found;
1847 dual_mac_cb callback = NULL;
1848 struct sir_dual_mac_config_resp *param;
1849
1850 param = (struct sir_dual_mac_config_resp *)msg;
1851 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001852 sme_err("Dual mac config resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 /* Not returning. Need to check if active command list
1854 * needs to be freed
1855 */
1856 }
1857
Krunal Sonia8270f52017-02-23 19:51:25 -08001858 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001860 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301861 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 }
1863
1864 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1865 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001866 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301867 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 }
1869
1870 if (e_sme_command_set_dual_mac_config != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001871 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301872 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 }
1874
1875 callback = command->u.set_dual_mac_cmd.set_dual_mac_cb;
1876 if (callback) {
1877 if (!param) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001878 sme_err("Callback failed-Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001880 sme_debug("Calling HDD callback for Dual mac config");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 callback(param->status,
1882 command->u.set_dual_mac_cmd.scan_config,
1883 command->u.set_dual_mac_cmd.fw_mode_config);
1884 }
1885 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001886 sme_err("Callback does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 }
1888
Krunal Soni72dba662017-02-15 20:13:17 -08001889 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 if (found)
1891 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001892 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301894 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895}
1896
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001897/**
1898 * sme_process_antenna_mode_resp() - Process set antenna mode
1899 * response
1900 * @mac: Global MAC pointer
1901 * @msg: antenna mode response
1902 *
1903 * Processes the antenna mode response and invokes the HDD
1904 * callback to process further
1905 */
1906static QDF_STATUS sme_process_antenna_mode_resp(tpAniSirGlobal mac,
1907 uint8_t *msg)
1908{
1909 tListElem *entry;
1910 tSmeCmd *command;
1911 bool found;
1912 antenna_mode_cb callback;
1913 struct sir_antenna_mode_resp *param;
1914
1915 param = (struct sir_antenna_mode_resp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301916 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001917 sme_err("set antenna mode resp is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001918 /* Not returning. Need to check if active command list
1919 * needs to be freed
1920 */
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001921
Krunal Sonia8270f52017-02-23 19:51:25 -08001922 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001923 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001924 sme_err("No cmd found in active list");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001925 return QDF_STATUS_E_FAILURE;
1926 }
1927
1928 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
1929 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001930 sme_err("Base address is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001931 return QDF_STATUS_E_FAILURE;
1932 }
1933
1934 if (e_sme_command_set_antenna_mode != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001935 sme_err("Command mismatch!");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001936 return QDF_STATUS_E_FAILURE;
1937 }
1938
1939 callback =
1940 command->u.set_antenna_mode_cmd.set_antenna_mode_resp;
1941 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301942 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001943 sme_err("Set antenna mode call back is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301944 else
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001945 callback(param->status);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001946 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001947 sme_err("Callback does not exist");
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001948 }
1949
Krunal Soni72dba662017-02-15 20:13:17 -08001950 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001951 if (found)
1952 /* Now put this command back on the available command list */
Krunal Soni78618d92017-02-14 21:46:31 -08001953 csr_release_command(mac, command);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001954
Archana Ramachandrana20ef812015-11-13 16:12:13 -08001955 return QDF_STATUS_SUCCESS;
1956}
1957
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05301958/*
1959 * sme_process_msg() - The main message processor for SME.
1960 * The function is called by a message dispatcher when to process a message
1961 * targeted for SME.
1962 * This is a synchronous call
1963 *
1964 * hHal - The handle returned by mac_open.
1965 * pMsg - A pointer to a caller allocated object of tSirMsgQ.
1966 * Return QDF_STATUS_SUCCESS - SME successfully process the message.
1967 * Other status means SME failed to process the message to HAL.
1968 */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001969QDF_STATUS sme_process_msg(tHalHandle hHal, struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05301973 struct sir_peer_info *peer_stats;
1974 struct sir_peer_info_resp *peer_info_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975
1976 if (pMsg == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001977 sme_err("Empty message for SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 return status;
1979 }
1980 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301981 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07001982 sme_warn("Locking failed, bailing out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 return status;
1986 }
1987 if (!SME_IS_START(pMac)) {
Rajeev Kumar3887f9b2018-01-10 11:24:01 -08001988 sme_debug("message type %d in stop state ignored", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 goto release_lock;
1992 }
1993 switch (pMsg->type) {
1994#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 case eWNI_SME_HO_FAIL_IND:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 FL("LFR3: Rcvd eWNI_SME_HO_FAIL_IND"));
1998 csr_process_ho_fail_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301999 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 break;
2001#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 case WNI_CFG_SET_CNF:
2003 case WNI_CFG_DNLD_CNF:
2004 case WNI_CFG_GET_RSP:
2005 case WNI_CFG_ADD_GRP_ADDR_CNF:
2006 case WNI_CFG_DEL_GRP_ADDR_CNF:
2007 break;
2008 case eWNI_SME_ADDTS_RSP:
2009 case eWNI_SME_DELTS_RSP:
2010 case eWNI_SME_DELTS_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 case eWNI_SME_FT_AGGR_QOS_RSP:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 /* QoS */
2013 if (pMsg->bodyptr) {
2014#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2015 status = sme_qos_msg_processor(pMac, pMsg->type,
2016 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018#endif
2019 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002020 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 }
2022 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 case eWNI_SME_NEIGHBOR_REPORT_IND:
2024 case eWNI_SME_BEACON_REPORT_REQ_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 if (pMsg->bodyptr) {
2026 status = sme_rrm_msg_processor(pMac, pMsg->type,
2027 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302028 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302030 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 }
2032 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 case eWNI_SME_ADD_STA_SELF_RSP:
2034 if (pMsg->bodyptr) {
2035 status = csr_process_add_sta_session_rsp(pMac,
2036 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002039 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 }
2041 break;
2042 case eWNI_SME_DEL_STA_SELF_RSP:
2043 if (pMsg->bodyptr) {
2044 status = csr_process_del_sta_session_rsp(pMac,
2045 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302046 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002048 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 case eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE:
2052 if (pMsg->bodyptr) {
2053 status = sme_handle_generic_change_country_code(
2054 (void *)pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302055 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002057 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 }
2059 break;
Sandeep Puligilla8d6011b2017-11-08 00:06:18 -08002060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061#ifdef WLAN_FEATURE_11W
2062 case eWNI_SME_UNPROT_MGMT_FRM_IND:
2063 if (pMsg->bodyptr) {
2064 sme_unprotected_mgmt_frm_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302065 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002067 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002068 }
2069 break;
2070#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002071#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 case eWNI_SME_TSM_IE_IND:
2073 if (pMsg->bodyptr) {
2074 sme_tsm_ie_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302075 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002077 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 }
2079 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002080#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 case eWNI_SME_ROAM_SCAN_OFFLOAD_RSP:
2082 status = csr_roam_offload_scan_rsp_hdlr((void *)pMac,
2083 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302084 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 break;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002086 case eWNI_SME_IBSS_PEER_INFO_RSP:
2087 if (pMsg->bodyptr) {
Jeff Johnson49c02f92016-10-07 10:29:09 -07002088 sme_ibss_peer_info_response_handler(pMac,
2089 pMsg->bodyptr);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002090 qdf_mem_free(pMsg->bodyptr);
2091 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002092 sme_err("Empty message for: %d", pMsg->type);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08002093 }
2094 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 case eWNI_SME_READY_TO_SUSPEND_IND:
2096 if (pMsg->bodyptr) {
2097 sme_process_ready_to_suspend(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302098 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002100 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 }
2102 break;
2103#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
2104 case eWNI_SME_READY_TO_EXTWOW_IND:
2105 if (pMsg->bodyptr) {
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07002106 sme_process_ready_to_ext_wow(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302107 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002109 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 }
2111 break;
2112#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2114 case eWNI_SME_AUTO_SHUTDOWN_IND:
2115 if (pMac->sme.pAutoShutdownNotificationCb) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05302116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 FL("Auto shutdown notification"));
2118 pMac->sme.pAutoShutdownNotificationCb();
2119 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302120 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 break;
2122#endif
2123 case eWNI_SME_DFS_RADAR_FOUND:
Arif Hussaincd151632017-02-11 16:57:19 -08002124 case eWNI_SME_DFS_CAC_COMPLETE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 case eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND:
Arif Hussaincd151632017-02-11 16:57:19 -08002126 status = dfs_msg_processor(pMac, pMsg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302127 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 break;
2129 case eWNI_SME_CHANNEL_CHANGE_RSP:
2130 if (pMsg->bodyptr) {
2131 status = sme_process_channel_change_resp(pMac,
2132 pMsg->type,
2133 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302134 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002136 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 }
2138 break;
2139#ifdef WLAN_FEATURE_STATS_EXT
2140 case eWNI_SME_STATS_EXT_EVENT:
2141 if (pMsg->bodyptr) {
2142 status = sme_stats_ext_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302143 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002145 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 }
2147 break;
2148#endif
Will Huang558f8082017-05-31 16:22:24 +08002149 case eWNI_SME_GET_PEER_INFO_IND:
2150 if (pMac->sme.pget_peer_info_ind_cb)
2151 pMac->sme.pget_peer_info_ind_cb(pMsg->bodyptr,
2152 pMac->sme.pget_peer_info_cb_context);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302153 if (pMsg->bodyptr) {
2154 peer_info_rsp = (struct sir_peer_info_resp *)
2155 (pMsg->bodyptr);
2156 peer_stats = (struct sir_peer_info *)
2157 (peer_info_rsp->info);
2158 if (peer_stats) {
2159 pMac->peer_rssi = peer_stats[0].rssi;
2160 pMac->peer_txrate = peer_stats[0].tx_rate;
2161 pMac->peer_rxrate = peer_stats[0].rx_rate;
2162 }
2163 }
Will Huang558f8082017-05-31 16:22:24 +08002164 qdf_mem_free(pMsg->bodyptr);
2165 break;
2166 case eWNI_SME_GET_PEER_INFO_EXT_IND:
2167 if (pMac->sme.pget_peer_info_ext_ind_cb)
2168 pMac->sme.pget_peer_info_ext_ind_cb(pMsg->bodyptr,
2169 pMac->sme.pget_peer_info_ext_cb_context);
2170 qdf_mem_free(pMsg->bodyptr);
2171 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 case eWNI_SME_CSA_OFFLOAD_EVENT:
2173 if (pMsg->bodyptr) {
2174 csr_scan_flush_bss_entry(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302175 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 }
2177 break;
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07002178 case eWNI_SME_TSF_EVENT:
2179 if (pMac->sme.get_tsf_cb) {
2180 pMac->sme.get_tsf_cb(pMac->sme.get_tsf_cxt,
2181 (struct stsf *)pMsg->bodyptr);
2182 }
2183 if (pMsg->bodyptr)
2184 qdf_mem_free(pMsg->bodyptr);
2185 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186#ifdef WLAN_FEATURE_NAN
2187 case eWNI_SME_NAN_EVENT:
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05302188 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_WMA_MSG,
2189 NO_SESSION, pMsg->type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (pMsg->bodyptr) {
2191 sme_nan_event(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302192 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 }
2194 break;
2195#endif /* WLAN_FEATURE_NAN */
2196 case eWNI_SME_LINK_STATUS_IND:
2197 {
2198 tAniGetLinkStatus *pLinkStatus =
2199 (tAniGetLinkStatus *) pMsg->bodyptr;
2200 if (pLinkStatus) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302201 if (pMac->sme.linkStatusCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 pMac->sme.linkStatusCallback(
2203 pLinkStatus->linkStatus,
2204 pMac->sme.linkStatusContext);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 pMac->sme.linkStatusCallback = NULL;
2207 pMac->sme.linkStatusContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302208 qdf_mem_free(pLinkStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 }
2210 break;
2211 }
2212 case eWNI_SME_MSG_GET_TEMPERATURE_IND:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302213 if (pMac->sme.pGetTemperatureCb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 pMac->sme.pGetTemperatureCb(pMsg->bodyval,
2215 pMac->sme.pTemperatureCbContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 break;
2217 case eWNI_SME_SNR_IND:
2218 {
2219 tAniGetSnrReq *pSnrReq = (tAniGetSnrReq *) pMsg->bodyptr;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 if (pSnrReq) {
2222 if (pSnrReq->snrCallback) {
2223 ((tCsrSnrCallback)
2224 (pSnrReq->snrCallback))
2225 (pSnrReq->snr, pSnrReq->staId,
2226 pSnrReq->pDevContext);
2227 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302228 qdf_mem_free(pSnrReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 }
2230 break;
2231 }
2232#ifdef FEATURE_WLAN_EXTSCAN
2233 case eWNI_SME_EXTSCAN_FULL_SCAN_RESULT_IND:
2234 if (pMac->sme.pExtScanIndCb)
2235 pMac->sme.pExtScanIndCb(pMac->hHdd,
2236 eSIR_EXTSCAN_FULL_SCAN_RESULT_IND,
2237 pMsg->bodyptr);
2238 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002239 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 pMsg->type);
2241
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302242 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002243 break;
2244 case eWNI_SME_EPNO_NETWORK_FOUND_IND:
2245 if (pMac->sme.pExtScanIndCb)
2246 pMac->sme.pExtScanIndCb(pMac->hHdd,
2247 eSIR_EPNO_NETWORK_FOUND_IND,
2248 pMsg->bodyptr);
2249 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002250 sme_err("callback not registered to process: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 pMsg->type);
2252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302253 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 break;
2255#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 case eWNI_SME_SET_HW_MODE_RESP:
2257 if (pMsg->bodyptr) {
2258 status = sme_process_set_hw_mode_resp(pMac,
2259 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302260 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002262 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 }
2264 break;
2265 case eWNI_SME_HW_MODE_TRANS_IND:
2266 if (pMsg->bodyptr) {
2267 status = sme_process_hw_mode_trans_ind(pMac,
2268 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302269 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002271 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 }
2273 break;
2274 case eWNI_SME_NSS_UPDATE_RSP:
2275 if (pMsg->bodyptr) {
2276 status = sme_process_nss_update_resp(pMac,
2277 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302278 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002280 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 }
2282 break;
2283 case eWNI_SME_OCB_SET_CONFIG_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302284 if (pMac->sme.ocb_set_config_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 pMac->sme.ocb_set_config_callback(
2286 pMac->sme.ocb_set_config_context,
2287 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302288 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002289 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 pMac->sme.ocb_set_config_callback = NULL;
2291 pMac->sme.ocb_set_config_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302292 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 break;
2294 case eWNI_SME_OCB_GET_TSF_TIMER_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302295 if (pMac->sme.ocb_get_tsf_timer_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 pMac->sme.ocb_get_tsf_timer_callback(
2297 pMac->sme.ocb_get_tsf_timer_context,
2298 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302299 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002300 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 pMac->sme.ocb_get_tsf_timer_callback = NULL;
2302 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302303 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 break;
2305 case eWNI_SME_DCC_GET_STATS_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302306 if (pMac->sme.dcc_get_stats_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 pMac->sme.dcc_get_stats_callback(
2308 pMac->sme.dcc_get_stats_context,
2309 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302310 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002311 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 pMac->sme.dcc_get_stats_callback = NULL;
2313 pMac->sme.dcc_get_stats_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302314 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 break;
2316 case eWNI_SME_DCC_UPDATE_NDL_RSP:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302317 if (pMac->sme.dcc_update_ndl_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 pMac->sme.dcc_update_ndl_callback(
2319 pMac->sme.dcc_update_ndl_context,
2320 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302321 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002322 sme_err("No callback for Msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 pMac->sme.dcc_update_ndl_callback = NULL;
2324 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302325 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 break;
2327 case eWNI_SME_DCC_STATS_EVENT:
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302328 if (pMac->sme.dcc_stats_event_callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 pMac->sme.dcc_stats_event_callback(
2330 pMac->sme.dcc_stats_event_context,
2331 pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302332 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002333 sme_err("No callback for Msg type: %d", pMsg->type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302334 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 break;
2336 case eWNI_SME_SET_DUAL_MAC_CFG_RESP:
2337 if (pMsg->bodyptr) {
2338 status = sme_process_dual_mac_config_resp(pMac,
2339 pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002342 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 }
gaurank kathpaliaebe3fc82018-05-07 09:39:46 +05302344 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 case eWNI_SME_SET_THERMAL_LEVEL_IND:
2346 if (pMac->sme.set_thermal_level_cb)
2347 pMac->sme.set_thermal_level_cb(pMac->hHdd,
2348 pMsg->bodyval);
2349 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05302350 case eWNI_SME_EXT_CHANGE_CHANNEL_IND:
2351 status = sme_extended_change_channel_ind(pMac, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302352 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302353 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002354 case eWNI_SME_SET_ANTENNA_MODE_RESP:
2355 if (pMsg->bodyptr) {
2356 status = sme_process_antenna_mode_resp(pMac,
2357 pMsg->bodyptr);
2358 qdf_mem_free(pMsg->bodyptr);
2359 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002360 sme_err("Empty message for: %d", pMsg->type);
Archana Ramachandrana20ef812015-11-13 16:12:13 -08002361 }
2362 break;
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05302363 case eWNI_SME_LOST_LINK_INFO_IND:
2364 if (pMac->sme.lost_link_info_cb)
2365 pMac->sme.lost_link_info_cb(pMac->hHdd,
2366 (struct sir_lost_link_info *)pMsg->bodyptr);
2367 qdf_mem_free(pMsg->bodyptr);
2368 break;
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302369 case eWNI_SME_RSO_CMD_STATUS_IND:
2370 if (pMac->sme.rso_cmd_status_cb)
2371 pMac->sme.rso_cmd_status_cb(pMac->hHdd, pMsg->bodyptr);
lifeng66831662017-05-19 16:01:35 +08002372 qdf_mem_free(pMsg->bodyptr);
2373 break;
Zhang Qiana6e9c102016-12-22 16:47:24 +08002374 case eWMI_SME_LL_STATS_IND:
2375 if (pMac->sme.link_layer_stats_ext_cb)
2376 pMac->sme.link_layer_stats_ext_cb(pMac->hHdd,
2377 pMsg->bodyptr);
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +05302378 qdf_mem_free(pMsg->bodyptr);
2379 break;
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +05302380 case eWNI_SME_BT_ACTIVITY_INFO_IND:
2381 if (pMac->sme.bt_activity_info_cb)
2382 pMac->sme.bt_activity_info_cb(pMac->hHdd,
2383 pMsg->bodyval);
2384 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 default:
2386
2387 if ((pMsg->type >= eWNI_SME_MSG_TYPES_BEGIN)
2388 && (pMsg->type <= eWNI_SME_MSG_TYPES_END)) {
2389 /* CSR */
2390 if (pMsg->bodyptr) {
2391 status = csr_msg_processor(hHal, pMsg->bodyptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302392 qdf_mem_free(pMsg->bodyptr);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302393 } else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002394 sme_err("Empty message for: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002396 sme_warn("Unknown message type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 if (pMsg->bodyptr)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302398 qdf_mem_free(pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 }
2400 } /* switch */
2401release_lock:
2402 sme_release_global_lock(&pMac->sme);
2403 return status;
2404}
2405
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002406QDF_STATUS sme_mc_process_handler(struct scheduler_msg *msg)
2407{
2408 tpAniSirGlobal mac_ctx = cds_get_context(QDF_MODULE_ID_SME);
2409
2410 if (mac_ctx == NULL) {
2411 QDF_ASSERT(0);
2412 return QDF_STATUS_E_FAILURE;
2413 }
2414
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08002415 return sme_process_msg((tHalHandle)mac_ctx, msg);
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002416}
Krunal Sonid32c6bc2016-10-18 18:00:21 -07002417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418/**
2419 * sme_process_nss_update_resp() - Process nss update response
2420 * @mac: Global MAC pointer
2421 * @msg: nss update response
2422 *
2423 * Processes the nss update response and invokes the HDD
2424 * callback to process further
2425 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302426static QDF_STATUS sme_process_nss_update_resp(tpAniSirGlobal mac, uint8_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427{
2428 tListElem *entry = NULL;
2429 tSmeCmd *command = NULL;
2430 bool found;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -08002431 policy_mgr_nss_update_cback callback = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 struct sir_beacon_tx_complete_rsp *param;
2433
2434 param = (struct sir_beacon_tx_complete_rsp *)msg;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302435 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002436 sme_err("nss update resp param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 /* Not returning. Need to check if active command list
2438 * needs to be freed
2439 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440
Krunal Sonia8270f52017-02-23 19:51:25 -08002441 entry = csr_nonscan_active_ll_peek_head(mac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 if (!entry) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002443 sme_err("No cmd found in active list");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302444 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 }
2446
2447 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
2448 if (!command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002449 sme_err("Base address is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302450 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 }
2452
2453 if (e_sme_command_nss_update != command->command) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002454 sme_err("Command mismatch!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302455 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 }
2457
2458 callback = command->u.nss_update_cmd.nss_update_cb;
2459 if (callback) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302460 if (!param)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002461 sme_err("Callback failed since nss update params is NULL");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302462 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 callback(command->u.nss_update_cmd.context,
2464 param->tx_status,
2465 param->session_id,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302466 command->u.nss_update_cmd.next_action,
2467 command->u.nss_update_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002469 sme_err("Callback does not exisit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 }
2471
Krunal Soni72dba662017-02-15 20:13:17 -08002472 found = csr_nonscan_active_ll_remove_entry(mac, entry, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 if (found) {
2474 /* Now put this command back on the avilable command list */
Krunal Soni78618d92017-02-14 21:46:31 -08002475 csr_release_command(mac, command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 }
Krunal Sonia8270f52017-02-23 19:51:25 -08002477
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302478 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002479}
2480
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302481/*
2482 * sme_stop() - Stop all SME modules and put them at idle state
2483 *
2484 * The function stops each module in SME, PMC, CSR, etc. . Upon
2485 * return, all modules are at idle state ready to start.
2486 * This is a synchronous call
2487 *
2488 * hHal - The handle returned by mac_open
2489 * tHalStopType - reason for stopping
2490 * Return QDF_STATUS_SUCCESS - SME is stopped.
2491 * Other status means SME is failed to stop but caller should still
2492 * consider SME is stopped.
2493 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302494QDF_STATUS sme_stop(tHalHandle hHal, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302496 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2497 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2499
Sandeep Puligilla66d09c42017-09-06 17:10:27 -07002500 status = rrm_stop(pMac);
2501 if (!QDF_IS_STATUS_SUCCESS(status)) {
2502 sme_err("rrm_stop failed with status: %d", status);
2503 }
2504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 status = csr_stop(pMac, stopType);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302506 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002507 sme_err("csr_stop failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 fail_status = status;
2509 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302511 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513
2514 pMac->sme.state = SME_STATE_STOP;
2515
2516 return status;
2517}
2518
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302519/*
2520 * sme_close() - Release all SME modules and their resources.
2521 * The function release each module in SME, PMC, CSR, etc. . Upon
2522 * return, all modules are at closed state.
2523 *
2524 * No SME APIs can be involved after smeClose except smeOpen.
2525 * smeClose must be called before mac_close.
2526 * This is a synchronous call
2527 *
2528 * hHal - The handle returned by mac_open
2529 * Return QDF_STATUS_SUCCESS - SME is successfully close.
2530 *
2531 * Other status means SME is failed to be closed but caller still cannot
2532 * call any other SME functions except smeOpen.
2533 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302534QDF_STATUS sme_close(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302536 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2537 QDF_STATUS fail_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2539
2540 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302541 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002542
2543 /* Note: pSession will be invalid from here on, do not access */
2544 status = csr_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002546 sme_err("csr_close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 fail_status = status;
2548 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2550 status = sme_qos_close(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002552 sme_err("Qos close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 fail_status = status;
2554 }
2555#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 status = sme_ps_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302557 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002558 sme_err("sme_ps_close failed status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 fail_status = status;
2560 }
2561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 status = rrm_close(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302563 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07002564 sme_err("RRM close failed with status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 fail_status = status;
2566 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 free_sme_cmd_list(pMac);
2569
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302570 if (!QDF_IS_STATUS_SUCCESS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302571 (qdf_mutex_destroy(&pMac->sme.lkSmeGlobalLock)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302572 fail_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302574 if (!QDF_IS_STATUS_SUCCESS(fail_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 status = fail_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576
2577 pMac->sme.state = SME_STATE_STOP;
2578
2579 return status;
2580}
2581
2582/**
Abhishek Singhc9941602016-08-09 16:06:22 +05302583 * sme_remove_bssid_from_scan_list() - wrapper to remove the bssid from
2584 * scan list
2585 * @hal: hal context.
2586 * @bssid: bssid to be removed
2587 *
2588 * This function remove the given bssid from scan list.
2589 *
2590 * Return: QDF status.
2591 */
2592QDF_STATUS sme_remove_bssid_from_scan_list(tHalHandle hal,
2593 tSirMacAddr bssid)
2594{
2595 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2596 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
2597
2598 status = sme_acquire_global_lock(&mac_ctx->sme);
2599 if (QDF_IS_STATUS_SUCCESS(status)) {
2600 csr_remove_bssid_from_scan_list(mac_ctx, bssid);
2601 sme_release_global_lock(&mac_ctx->sme);
2602 }
2603
2604 return status;
2605}
2606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302608/*
2609 * sme_scan_get_result
2610 * A wrapper function to request scan results from CSR.
2611 * This is a synchronous call
2612 *
2613 * pFilter - If pFilter is NULL, all cached results are returned
2614 * phResult - an object for the result.
2615 * Return QDF_STATUS
2616 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302617QDF_STATUS sme_scan_get_result(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 tCsrScanResultFilter *pFilter,
2619 tScanResultHandle *phResult)
2620{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302621 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2623
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302624 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS, sessionId,
2626 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302628 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 status = csr_scan_get_result(hHal, pFilter, phResult);
2630 sme_release_global_lock(&pMac->sme);
2631 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632
2633 return status;
2634}
2635
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05302636QDF_STATUS sme_scan_get_result_for_bssid(tHalHandle hal_handle,
2637 struct qdf_mac_addr *bssid,
2638 tCsrScanResultInfo *res)
2639{
2640 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
2641 QDF_STATUS status;
2642
2643 status = sme_acquire_global_lock(&mac_ctx->sme);
2644 if (QDF_IS_STATUS_SUCCESS(status)) {
2645 status = csr_scan_get_result_for_bssid(hal_handle, bssid, res);
2646 sme_release_global_lock(&mac_ctx->sme);
2647 }
2648
2649 return status;
2650}
2651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652/**
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002653 * sme_get_ap_channel_from_scan() - a wrapper function to get
Srinivas Girigowda828ef232017-10-13 22:31:27 -07002654 * AP's channel id from
2655 * CSR by filtering the
2656 * result which matches
2657 * our roam profile.
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002658 * @profile: SAP profile
2659 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2660 * best ap from scan cache.
2661 *
2662 * This function is written to get AP's channel id from CSR by filtering
2663 * the result which matches our roam profile. This is a synchronous call.
2664 *
2665 * Return: QDF_STATUS.
2666 */
2667QDF_STATUS sme_get_ap_channel_from_scan(void *profile,
2668 tScanResultHandle *scan_cache,
2669 uint8_t *ap_chnl_id)
2670{
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002671 return sme_get_ap_channel_from_scan_cache((struct csr_roam_profile *)
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002672 profile,
2673 scan_cache,
2674 ap_chnl_id);
2675}
2676
2677/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 * sme_get_ap_channel_from_scan_cache() - a wrapper function to get AP's
2679 * channel id from CSR by filtering the
2680 * result which matches our roam profile.
2681 * @profile: SAP adapter
2682 * @ap_chnl_id: pointer to channel id of SAP. Fill the value after finding the
2683 * best ap from scan cache.
2684 *
2685 * This function is written to get AP's channel id from CSR by filtering
2686 * the result which matches our roam profile. This is a synchronous call.
2687 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302688 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002690QDF_STATUS sme_get_ap_channel_from_scan_cache(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002691 struct csr_roam_profile *profile, tScanResultHandle *scan_cache,
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002692 uint8_t *ap_chnl_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302694 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002695 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 tCsrScanResultFilter *scan_filter = NULL;
2697 tScanResultHandle filtered_scan_result = NULL;
2698 tSirBssDescription first_ap_profile;
2699
2700 if (NULL == mac_ctx) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302701 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 FL("mac_ctx is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302705 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 if (NULL == scan_filter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 FL("scan_filter mem alloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302709 return QDF_STATUS_E_FAILURE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302710 }
2711 qdf_mem_set(&first_ap_profile, sizeof(tSirBssDescription), 0);
2712 if (NULL == profile) {
2713 scan_filter->EncryptionType.numEntries = 1;
2714 scan_filter->EncryptionType.encryptionType[0]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 = eCSR_ENCRYPT_TYPE_NONE;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302716 } else {
2717 /* Here is the profile we need to connect to */
2718 status = csr_roam_prepare_filter_from_profile(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 profile,
2720 scan_filter);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302721 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302723 if (QDF_STATUS_SUCCESS == status) {
2724 /* Save the WPS info */
2725 if (NULL != profile) {
2726 scan_filter->bWPSAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 profile->bWPSAssociation;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302728 scan_filter->bOSENAssociation =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 profile->bOSENAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302731 scan_filter->bWPSAssociation = 0;
2732 scan_filter->bOSENAssociation = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302734 } else {
2735 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
2736 FL("Preparing the profile filter failed"));
2737 qdf_mem_free(scan_filter);
2738 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 }
2740 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302741 if (QDF_STATUS_SUCCESS == status) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07002742 status = csr_scan_get_result(mac_ctx, scan_filter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 &filtered_scan_result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302744 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 csr_get_bssdescr_from_scan_handle(filtered_scan_result,
2746 &first_ap_profile);
2747 *scan_cache = filtered_scan_result;
2748 if (0 != first_ap_profile.channelId) {
2749 *ap_chnl_id = first_ap_profile.channelId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302750 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh5d8d7332017-08-10 15:15:24 +05302751 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 FL("Found best AP & its on chnl[%d]"),
2753 first_ap_profile.channelId);
2754 } else {
2755 /*
2756 * This means scan result is empty
2757 * so set the channel to zero, caller should
2758 * take of zero channel id case.
2759 */
2760 *ap_chnl_id = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302761 QDF_TRACE(QDF_MODULE_ID_SME,
2762 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002763 FL("Scan is empty, set chnl to 0"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302764 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 }
2766 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302767 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 FL("Failed to get scan get result"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302769 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 }
2771 csr_free_scan_filter(mac_ctx, scan_filter);
2772 sme_release_global_lock(&mac_ctx->sme);
2773 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302774 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 FL("Aquiring lock failed"));
Krunal Sonif9882222016-01-22 17:16:50 -08002776 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302777 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302779 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 return status;
2781}
2782
2783/**
2784 * sme_store_joinreq_param() - This function will pass station's join
2785 * request to store to csr.
2786 * @hal_handle: pointer to hal context.
2787 * @profile: pointer to station's roam profile.
2788 * @scan_cache: pointer to station's scan cache.
2789 * @roam_id: reference to roam_id variable being passed.
2790 * @session_id: station's session id.
2791 *
2792 * This function will pass station's join request further down to csr
2793 * to store it. this stored parameter will be used later.
2794 *
2795 * Return: true or false based on function's overall success.
2796 **/
2797bool sme_store_joinreq_param(tHalHandle hal_handle,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07002798 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 tScanResultHandle scan_cache,
2800 uint32_t *roam_id,
2801 uint32_t session_id)
2802{
2803 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302804 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 bool ret_status = true;
2806
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302807 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ,
2809 session_id, 0));
2810 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302811 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 if (false == csr_store_joinreq_param(mac_ctx, profile,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302813 scan_cache, roam_id, session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 sme_release_global_lock(&mac_ctx->sme);
2816 } else {
2817 ret_status = false;
2818 }
2819
2820 return ret_status;
2821}
2822
2823/**
2824 * sme_clear_joinreq_param() - This function will pass station's clear
2825 * the join request to csr.
2826 * @hal_handle: pointer to hal context.
2827 * @session_id: station's session id.
2828 *
2829 * This function will pass station's clear join request further down to csr
2830 * to cleanup.
2831 *
2832 * Return: true or false based on function's overall success.
2833 **/
2834bool sme_clear_joinreq_param(tHalHandle hal_handle,
2835 uint32_t session_id)
2836{
2837 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302838 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 bool ret_status = true;
2840
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302841 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ,
2843 session_id, 0));
2844 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302845 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 if (false == csr_clear_joinreq_param(mac_ctx,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302847 session_id))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 ret_status = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 sme_release_global_lock(&mac_ctx->sme);
2850 } else {
2851 ret_status = false;
2852 }
2853
2854 return ret_status;
2855}
2856
2857/**
2858 * sme_issue_stored_joinreq() - This function will issues station's stored
2859 * the join request to csr.
2860 * @hal_handle: pointer to hal context.
2861 * @roam_id: reference to roam_id variable being passed.
2862 * @session_id: station's session id.
2863 *
2864 * This function will issue station's stored join request further down to csr
2865 * to proceed forward.
2866 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302867 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302869QDF_STATUS sme_issue_stored_joinreq(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 uint32_t *roam_id,
2871 uint32_t session_id)
2872{
2873 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302874 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2875 QDF_STATUS ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302877 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ,
2879 session_id, 0));
2880 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302881 if (QDF_STATUS_SUCCESS == status) {
2882 if (QDF_STATUS_SUCCESS != csr_issue_stored_joinreq(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 roam_id,
2884 session_id)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302885 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 }
2887 sme_release_global_lock(&mac_ctx->sme);
2888 } else {
2889 csr_clear_joinreq_param(mac_ctx, session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302890 ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 }
2892 return ret_status;
2893}
2894
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302895/*
2896 * sme_scan_flush_result() -
2897 * A wrapper function to request CSR to clear scan results.
2898 * This is a synchronous call
2899 *
2900 * Return QDF_STATUS
2901 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302902QDF_STATUS sme_scan_flush_result(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302904 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2906
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302907 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2909 0, 0));
2910 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302911 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 status = csr_scan_flush_result(hHal);
2913 sme_release_global_lock(&pMac->sme);
2914 }
2915
2916 return status;
2917}
2918
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302919/*
2920 * sme_filter_scan_results() -
2921 * A wrapper function to request CSR to clear scan results.
2922 * This is a synchronous call
2923 *
2924 * tHalHandle - HAL context handle
2925 * sessionId - session id
2926 * Return QDF_STATUS
2927 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302928QDF_STATUS sme_filter_scan_results(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302930 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2932
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302933 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS,
2935 sessionId, 0));
2936 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302937 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 csr_scan_filter_results(pMac);
2939 sme_release_global_lock(&pMac->sme);
2940 }
2941
2942 return status;
2943}
2944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302945QDF_STATUS sme_scan_flush_p2p_result(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302947 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2949
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302950 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS,
2952 sessionId, 0));
2953 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302954 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 status = csr_scan_flush_selective_result(hHal, true);
2956 sme_release_global_lock(&pMac->sme);
2957 }
2958
2959 return status;
2960}
2961
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302962/*
2963 * sme_scan_result_get_first() -
2964 * A wrapper function to request CSR to returns the first element of
2965 * scan result.
2966 * This is a synchronous call
2967 *
2968 * hScanResult - returned from csr_scan_get_result
2969 * Return tCsrScanResultInfo * - NULL if no result
2970 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971tCsrScanResultInfo *sme_scan_result_get_first(tHalHandle hHal,
2972 tScanResultHandle hScanResult)
2973{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2976 tCsrScanResultInfo *pRet = NULL;
2977
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302978 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST,
2980 NO_SESSION, 0));
2981 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 pRet = csr_scan_result_get_first(pMac, hScanResult);
2984 sme_release_global_lock(&pMac->sme);
2985 }
2986
2987 return pRet;
2988}
2989
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05302990/*
2991 * sme_scan_result_get_next() -
2992 * A wrapper function to request CSR to returns the next element of
2993 * scan result. It can be called without calling csr_scan_result_get_first first
2994 * This is a synchronous call
2995 *
2996 * hScanResult - returned from csr_scan_get_result
2997 * Return Null if no result or reach the end
2998 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999tCsrScanResultInfo *sme_scan_result_get_next(tHalHandle hHal,
3000 tScanResultHandle hScanResult)
3001{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303002 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3004 tCsrScanResultInfo *pRet = NULL;
3005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303007 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 pRet = csr_scan_result_get_next(pMac, hScanResult);
3009 sme_release_global_lock(&pMac->sme);
3010 }
3011
3012 return pRet;
3013}
3014
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303015/*
3016 * sme_scan_result_purge() -
3017 * A wrapper function to request CSR to remove all items(tCsrScanResult)
3018 * in the list and free memory for each item
3019 * This is a synchronous call
3020 *
3021 * hScanResult - returned from csr_scan_get_result. hScanResult is
3022 * considered gone by
3023 * calling this function and even before this function reutrns.
3024 * Return QDF_STATUS
3025 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003026QDF_STATUS sme_scan_result_purge(tScanResultHandle hScanResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303028 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003029 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303031 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE,
3033 NO_SESSION, 0));
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003034 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303035 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07003036 status = csr_scan_result_purge(mac_ctx, hScanResult);
3037 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 }
3039
3040 return status;
3041}
3042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043eCsrPhyMode sme_get_phy_mode(tHalHandle hHal)
3044{
3045 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 return pMac->roam.configParam.phyMode;
3048}
3049
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303050/*
jiadbdefb252018-01-03 14:27:06 +08003051 * sme_get_channel_bonding_mode5_g() - get the channel bonding mode for 5G band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303052 *
3053 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003054 * mode - channel bonding mode
3055 *
3056 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303057 */
jiadbdefb252018-01-03 14:27:06 +08003058QDF_STATUS sme_get_channel_bonding_mode5_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059{
3060 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003061 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062
jiadbdefb252018-01-03 14:27:06 +08003063 if (!mode) {
3064 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3065 "%s: invalid mode", __func__);
3066 return QDF_STATUS_E_FAILURE;
3067 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068
jiadbdefb252018-01-03 14:27:06 +08003069 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3070 if (!smeConfig) {
3071 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3072 "%s: failed to alloc smeConfig", __func__);
3073 return QDF_STATUS_E_NOMEM;
3074 }
3075
3076 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3077 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3078 "%s: sme_get_config_param failed", __func__);
3079 qdf_mem_free(smeConfig);
3080 return QDF_STATUS_E_FAILURE;
3081 }
3082
3083 *mode = smeConfig->csrConfig.channelBondingMode5GHz;
3084 qdf_mem_free(smeConfig);
3085
3086 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087}
3088
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303089/*
jiadbdefb252018-01-03 14:27:06 +08003090 * sme_get_channel_bonding_mode24_g() - get the channel bonding mode for 2.4G
3091 * band
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303092 *
3093 * hHal - HAL handle
jiadbdefb252018-01-03 14:27:06 +08003094 * mode - channel bonding mode
3095 *
3096 * Return QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303097 */
jiadbdefb252018-01-03 14:27:06 +08003098QDF_STATUS sme_get_channel_bonding_mode24_g(tHalHandle hHal, uint32_t *mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099{
3100 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
jiadbdefb252018-01-03 14:27:06 +08003101 tSmeConfigParams *smeConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
jiadbdefb252018-01-03 14:27:06 +08003103 if (!mode) {
3104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3105 "%s: invalid mode", __func__);
3106 return QDF_STATUS_E_FAILURE;
3107 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108
jiadbdefb252018-01-03 14:27:06 +08003109 smeConfig = qdf_mem_malloc(sizeof(*smeConfig));
3110 if (!smeConfig) {
3111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3112 "%s: failed to alloc smeConfig", __func__);
3113 return QDF_STATUS_E_NOMEM;
3114 }
3115
3116 if (sme_get_config_param(pMac, smeConfig) != QDF_STATUS_SUCCESS) {
3117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3118 "%s: sme_get_config_param failed", __func__);
3119 qdf_mem_free(smeConfig);
3120 return QDF_STATUS_E_FAILURE;
3121 }
3122
3123 *mode = smeConfig->csrConfig.channelBondingMode24GHz;
3124 qdf_mem_free(smeConfig);
3125
3126 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127}
3128
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303129/*
3130 * sme_roam_connect() -
3131 * A wrapper function to request CSR to inititiate an association
3132 * This is an asynchronous call.
3133 *
3134 * sessionId - the sessionId returned by sme_open_session.
3135 * pProfile - description of the network to which to connect
3136 * hBssListIn - a list of BSS descriptor to roam to. It is returned
3137 * from csr_scan_get_result
3138 * pRoamId - to get back the request ID
3139 * Return QDF_STATUS
3140 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303141QDF_STATUS sme_roam_connect(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003142 struct csr_roam_profile *pProfile,
3143 uint32_t *pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003144{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3147
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303148 if (!pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303149 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303151 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 TRACE_CODE_SME_RX_HDD_MSG_CONNECT, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303154 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3156 status =
3157 csr_roam_connect(pMac, sessionId, pProfile,
3158 pRoamId);
3159 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003160 sme_err("Invalid sessionID: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303161 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 }
3163 sme_release_global_lock(&pMac->sme);
3164 } else {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003165 sme_err("sme_acquire_global_lock failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 }
3167
3168 return status;
3169}
3170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303171/*
3172 * sme_set_phy_mode() -
3173 * Changes the PhyMode.
3174 *
3175 * hHal - The handle returned by mac_open.
3176 * phyMode new phyMode which is to set
3177 * Return QDF_STATUS SUCCESS.
3178 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303179QDF_STATUS sme_set_phy_mode(tHalHandle hHal, eCsrPhyMode phyMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180{
3181 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3182
3183 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303184 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 "%s: invalid context", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303186 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 }
3188
3189 pMac->roam.configParam.phyMode = phyMode;
3190 pMac->roam.configParam.uCfgDot11Mode =
3191 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303192 pMac->roam.configParam.phyMode,
3193 pMac->roam.configParam.
3194 ProprietaryRatesEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303196 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197}
3198
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303199/*
3200 * sme_roam_reassoc() -
3201 * A wrapper function to request CSR to inititiate a re-association
3202 *
3203 * pProfile - can be NULL to join the currently connected AP. In that
3204 * case modProfileFields should carry the modified field(s) which could trigger
3205 * reassoc
3206 * modProfileFields - fields which are part of tCsrRoamConnectedProfile
3207 * that might need modification dynamically once STA is up & running and this
3208 * could trigger a reassoc
3209 * pRoamId - to get back the request ID
3210 * Return QDF_STATUS
3211 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303212QDF_STATUS sme_roam_reassoc(tHalHandle hHal, uint8_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07003213 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 tCsrRoamModifyProfileFields modProfileFields,
3215 uint32_t *pRoamId, bool fForce)
3216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3219
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303220 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 TRACE_CODE_SME_RX_HDD_ROAM_REASSOC, sessionId, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303223 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303225 if ((NULL == pProfile) && (fForce == 1))
3226 status = csr_reassoc(pMac, sessionId,
3227 &modProfileFields, pRoamId,
3228 fForce);
3229 else
3230 status = csr_roam_reassoc(pMac, sessionId,
3231 pProfile,
3232 modProfileFields, pRoamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303234 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 }
3236 sme_release_global_lock(&pMac->sme);
3237 }
3238
3239 return status;
3240}
3241
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303242/*
3243 * sme_roam_connect_to_last_profile() -
3244 * A wrapper function to request CSR to disconnect and reconnect with
3245 * the same profile
3246 * This is an asynchronous call.
3247 *
3248 * Return QDF_STATUS. It returns fail if currently connected
3249 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303250QDF_STATUS sme_roam_connect_to_last_profile(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303252 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3254
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303255 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3257 sessionId, 0));
3258 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303259 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303260 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3261 status = csr_roam_connect_to_last_profile(pMac,
3262 sessionId);
3263 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 sme_release_global_lock(&pMac->sme);
3266 }
3267
3268 return status;
3269}
3270
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303271/*
3272 * sme_roam_disconnect() -
3273 * A wrapper function to request CSR to disconnect from a network
3274 * This is an asynchronous call.
3275 *
3276 * reason -- To indicate the reason for disconnecting. Currently, only
3277 * eCSR_DISCONNECT_REASON_MIC_ERROR is meanful.
3278 * Return QDF_STATUS
3279 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280QDF_STATUS sme_roam_disconnect(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 eCsrRoamDisconnectReason reason)
3282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303283 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3285
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303286 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT, sessionId,
3288 reason));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303290 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303291 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 status = csr_roam_disconnect(pMac, sessionId, reason);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303293 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 sme_release_global_lock(&pMac->sme);
3296 }
3297
3298 return status;
3299}
3300
Abhishek Singhca408032016-09-13 15:26:12 +05303301/* sme_dhcp_done_ind() - send dhcp done ind
3302 * @hal: hal context
3303 * @session_id: session id
3304 *
3305 * Return: void.
3306 */
3307void sme_dhcp_done_ind(tHalHandle hal, uint8_t session_id)
3308{
3309 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303310 struct csr_roam_session *session;
Abhishek Singhca408032016-09-13 15:26:12 +05303311
3312 if (!mac_ctx)
3313 return;
3314
3315 session = CSR_GET_SESSION(mac_ctx, session_id);
3316 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003317 sme_err("Session: %d not found", session_id);
Abhishek Singhca408032016-09-13 15:26:12 +05303318 return;
3319 }
3320 session->dhcp_done = true;
3321}
3322
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303323/*
3324 * sme_roam_stop_bss() -
3325 * To stop BSS for Soft AP. This is an asynchronous API.
3326 *
3327 * hHal - Global structure
3328 * sessionId - sessionId of SoftAP
3329 * Return QDF_STATUS SUCCESS Roam callback will be called to indicate
3330 * actual results
3331 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332QDF_STATUS sme_roam_stop_bss(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303334 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303338 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303339 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3340 status = csr_roam_issue_stop_bss_cmd(pMac, sessionId,
Himanshu Agarwal75c8d792017-12-19 18:31:04 +05303341 false);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303342 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 sme_release_global_lock(&pMac->sme);
3345 }
3346
3347 return status;
3348}
3349
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303350/**
3351 * sme_roam_disconnect_sta() - disassociate a station
3352 * @hHal: Global structure
3353 * @sessionId: SessionId of SoftAP
3354 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3355 *
3356 * To disassociate a station. This is an asynchronous API.
3357 *
3358 * Return: QDF_STATUS_SUCCESS on success.Roam callback will
3359 * be called to indicate actual result.
3360 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303361QDF_STATUS sme_roam_disconnect_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003362 struct csr_del_sta_params *p_del_sta_params)
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
3372 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303374 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 status = csr_roam_issue_disassociate_sta_cmd(pMac,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303376 sessionId, p_del_sta_params);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303377 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303378 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 sme_release_global_lock(&pMac->sme);
3380 }
3381
3382 return status;
3383}
3384
3385/**
3386 * sme_roam_deauth_sta() - deauthenticate a station
3387 * @hHal: Global structure
3388 * @sessionId: SessionId of SoftAP
3389 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3390 *
3391 * To disassociate a station. This is an asynchronous API.
3392 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303393 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 * code on error. Roam callback will be called to indicate actual
3395 * result
3396 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303397QDF_STATUS sme_roam_deauth_sta(tHalHandle hHal, uint8_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08003398 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303400 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3402
3403 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303404 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405 return status;
3406 }
3407
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303408 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303409 TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA,
3410 sessionId, pDelStaParams->reason_code));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303412 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303413 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 status =
3415 csr_roam_issue_deauth_sta_cmd(pMac, sessionId,
3416 pDelStaParams);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303417 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303418 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 sme_release_global_lock(&pMac->sme);
3420 }
3421
3422 return status;
3423}
3424
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303425/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303426 * sme_roam_get_associated_stas() -
3427 * To probe the list of associated stations from various modules
3428 * of CORE stack.
3429 * This is an asynchronous API.
3430 *
3431 * sessionId - sessionId of SoftAP
3432 * modId - Module from whom list of associtated stations is
3433 * to be probed. If an invalid module is passed then
3434 * by default QDF_MODULE_ID_PE will be probed.
3435 * pUsrContext - Opaque HDD context
3436 * pfnSapEventCallback - Sap event callback in HDD
3437 * pAssocBuf - Caller allocated memory to be filled with associatd
3438 * stations info
3439 * Return QDF_STATUS
3440 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441QDF_STATUS sme_roam_get_associated_stas(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303442 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 void *pfnSapEventCallback,
3444 uint8_t *pAssocStasBuf)
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 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303450 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451 return status;
3452 }
3453
3454 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303455 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303456 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 status =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303458 csr_roam_get_associated_stas(pMac, sessionId,
3459 modId,
3460 pUsrContext,
3461 pfnSapEventCallback,
3462 pAssocStasBuf);
3463 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303464 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 sme_release_global_lock(&pMac->sme);
3466 }
3467
3468 return status;
3469}
3470
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303471/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303472 * sme_roam_get_connect_state() -
3473 * A wrapper function to request CSR to return the current connect state
3474 * of Roaming
3475 * This is a synchronous call.
3476 *
3477 * Return QDF_STATUS
3478 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303479QDF_STATUS sme_roam_get_connect_state(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 eCsrConnectState *pState)
3481{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303482 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3484
3485 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303487 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3488 status = csr_roam_get_connect_state(pMac, sessionId,
3489 pState);
3490 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303491 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 sme_release_global_lock(&pMac->sme);
3493 }
3494
3495 return status;
3496}
3497
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303498/*
3499 * sme_roam_get_connect_profile() -
3500 * A wrapper function to request CSR to return the current connect
3501 * profile. Caller must call csr_roam_free_connect_profile after it is done
3502 * and before reuse for another csr_roam_get_connect_profile call.
3503 * This is a synchronous call.
3504 *
3505 * pProfile - pointer to a caller allocated structure
3506 * tCsrRoamConnectedProfile
3507 * eturn QDF_STATUS. Failure if not connected
3508 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303509QDF_STATUS sme_roam_get_connect_profile(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 tCsrRoamConnectedProfile *pProfile)
3511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303512 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3514
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303515 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE,
3517 sessionId, 0));
3518 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303520 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3521 status = csr_roam_get_connect_profile(pMac, sessionId,
3522 pProfile);
3523 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 sme_release_global_lock(&pMac->sme);
3526 }
3527
3528 return status;
3529}
3530
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003531/**
3532 * sme_roam_free_connect_profile - a wrapper function to request CSR to free and
3533 * reinitialize the profile returned previously by csr_roam_get_connect_profile.
3534 *
3535 * @profile - pointer to a caller allocated structure tCsrRoamConnectedProfile
3536 *
3537 * Return: none
3538 */
3539void sme_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303541 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542 TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE,
3543 NO_SESSION, 0));
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08003544 csr_roam_free_connect_profile(profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545}
3546
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303547/*
3548 * sme_roam_set_pmkid_cache() -
3549 * A wrapper function to request CSR to return the PMKID candidate list
3550 * This is a synchronous call.
3551
3552 * pPMKIDCache - caller allocated buffer point to an array of
3553 * tPmkidCacheInfo
3554 * numItems - a variable that has the number of tPmkidCacheInfo
3555 * allocated when retruning, this is either the number needed
3556 * or number of items put into pPMKIDCache
3557 * update_entire_cache - this bool value specifies if the entire pmkid
3558 * cache should be overwritten or should it be
3559 * updated entry by entry.
3560 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3561 * big enough and pNumItems has the number of
3562 * tPmkidCacheInfo.
3563 * \Note: pNumItems is a number of tPmkidCacheInfo,
3564 * not sizeof(tPmkidCacheInfo) * something
3565 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303566QDF_STATUS sme_roam_set_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 tPmkidCacheInfo *pPMKIDCache,
3568 uint32_t numItems, bool update_entire_cache)
3569{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303570 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3572
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303573 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE, sessionId,
3575 numItems));
3576 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303577 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303578 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3579 status = csr_roam_set_pmkid_cache(pMac, sessionId,
3580 pPMKIDCache,
3581 numItems, update_entire_cache);
3582 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 sme_release_global_lock(&pMac->sme);
3585 }
3586
3587 return status;
3588}
3589
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303590QDF_STATUS sme_roam_del_pmkid_from_cache(tHalHandle hHal, uint8_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303591 tPmkidCacheInfo *pmksa,
3592 bool flush_cache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303594 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303596
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303597 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Sreelakshmi Konamki6744cff2015-09-07 12:10:39 +05303598 TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE,
3599 sessionId, flush_cache));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303601 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303602 if (CSR_IS_SESSION_VALID(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 status = csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +05303604 pmksa, flush_cache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303605 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 sme_release_global_lock(&pMac->sme);
3608 }
3609 return status;
3610}
3611
gaurank kathpalia99d06c12018-05-16 16:28:35 +05303612void sme_get_pmk_info(tHalHandle hal, uint8_t session_id,
3613 tPmkidCacheInfo *pmk_cache)
3614{
3615 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
3616 QDF_STATUS status = sme_acquire_global_lock(&mac_ctx->sme);
3617
3618 if (QDF_IS_STATUS_SUCCESS(status)) {
3619 if (CSR_IS_SESSION_VALID(mac_ctx, session_id))
3620 csr_get_pmk_info(mac_ctx, session_id, pmk_cache);
3621 sme_release_global_lock(&mac_ctx->sme);
3622 }
3623}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303625/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 * \fn sme_roam_set_psk_pmk
3627 * \brief a wrapper function to request CSR to save PSK/PMK
3628 * This is a synchronous call.
3629 * \param hHal - Global structure
3630 * \param sessionId - SME sessionId
3631 * \param pPSK_PMK - pointer to an array of Psk[]/Pmk
3632 * \param pmk_len - Length could be only 16 bytes in case if LEAP
3633 * connections. Need to pass this information to
3634 * firmware.
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303635 * \return QDF_STATUS -status whether PSK/PMK is set or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637QDF_STATUS sme_roam_set_psk_pmk(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 uint8_t *pPSK_PMK, size_t pmk_len)
3639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303645 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3646 status = csr_roam_set_psk_pmk(pMac, sessionId, pPSK_PMK,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 pmk_len);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303648 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 sme_release_global_lock(&pMac->sme);
3651 }
3652 return status;
3653}
3654#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655
Jeff Johnson0a078b52018-06-01 16:15:54 -07003656QDF_STATUS sme_roam_get_wpa_rsn_req_ie(tHalHandle hal, uint8_t session_id,
3657 uint32_t *len, uint8_t *buf)
3658{
3659 QDF_STATUS status;
3660 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3661
3662 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303663 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003664 if (CSR_IS_SESSION_VALID(mac, session_id))
3665 status = csr_roam_get_wpa_rsn_req_ie(mac, session_id,
3666 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303667 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303668 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003669 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 }
3671
3672 return status;
3673}
3674
Jeff Johnson0a078b52018-06-01 16:15:54 -07003675QDF_STATUS sme_roam_get_wpa_rsn_rsp_ie(tHalHandle hal, uint8_t session_id,
3676 uint32_t *len, uint8_t *buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677{
Jeff Johnson0a078b52018-06-01 16:15:54 -07003678 QDF_STATUS status;
3679 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680
Jeff Johnson0a078b52018-06-01 16:15:54 -07003681 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson0a078b52018-06-01 16:15:54 -07003683 if (CSR_IS_SESSION_VALID(mac, session_id))
3684 status = csr_roam_get_wpa_rsn_rsp_ie(mac, session_id,
3685 len, buf);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303686 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303687 status = QDF_STATUS_E_INVAL;
Jeff Johnson0a078b52018-06-01 16:15:54 -07003688 sme_release_global_lock(&mac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 }
3690
3691 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692}
3693
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303694/*
3695 * sme_roam_get_num_pmkid_cache() -
3696 * A wrapper function to request CSR to return number of PMKID cache
3697 * entries
3698 * This is a synchronous call.
3699 *
3700 * Return uint32_t - the number of PMKID cache entries
3701 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702uint32_t sme_roam_get_num_pmkid_cache(tHalHandle hHal, uint8_t sessionId)
3703{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3706 uint32_t numPmkidCache = 0;
3707
3708 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303709 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
3711 numPmkidCache =
3712 csr_roam_get_num_pmkid_cache(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303713 status = QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303714 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 sme_release_global_lock(&pMac->sme);
3717 }
3718
3719 return numPmkidCache;
3720}
3721
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303722/*
3723 * sme_roam_get_pmkid_cache() -
3724 * A wrapper function to request CSR to return PMKID cache from CSR
3725 * This is a synchronous call.
3726 *
3727 * pNum - caller allocated memory that has the space of the number of
3728 * pBuf tPmkidCacheInfo as input. Upon returned, *pNum has the
3729 * needed or actually number in tPmkidCacheInfo.
3730 * pPmkidCache - Caller allocated memory that contains PMKID cache, if
3731 * any, upon return
3732 * Return QDF_STATUS - when fail, it usually means the buffer allocated is not
3733 * big enough
3734 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735QDF_STATUS sme_roam_get_pmkid_cache(tHalHandle hHal, uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303736 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303738 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3740
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303741 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742 TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE, sessionId,
3743 0));
3744 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303745 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303746 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3747 status = csr_roam_get_pmkid_cache(pMac, sessionId, pNum,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 pPmkidCache);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303749 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303750 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 sme_release_global_lock(&pMac->sme);
3752 }
3753
3754 return status;
3755}
3756
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303757/*
3758 * sme_get_config_param() -
3759 * A wrapper function that HDD calls to get the global settings
3760 * currently maintained by CSR.
3761 * This is a synchronous call.
3762 *
3763 * pParam - caller allocated memory
3764 * Return QDF_STATUS
3765 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766QDF_STATUS sme_get_config_param(tHalHandle hHal, tSmeConfigParams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303768 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3770
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303771 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003772 TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM, NO_SESSION, 0));
3773 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303774 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 status = csr_get_config_param(pMac, &pParam->csrConfig);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303776 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07003777 sme_err("csr_get_config_param failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 sme_release_global_lock(&pMac->sme);
3779 return status;
3780 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303781 qdf_mem_copy(&pParam->rrmConfig,
Krunal Soni1878d3a2016-01-14 13:00:44 -08003782 &pMac->rrm.rrmSmeContext.rrmConfig,
3783 sizeof(pMac->rrm.rrmSmeContext.rrmConfig));
Kapil Guptaab7961d2017-06-06 13:54:09 +05303784 pParam->snr_monitor_enabled = pMac->snr_monitor_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 sme_release_global_lock(&pMac->sme);
3786 }
3787
3788 return status;
3789}
3790
3791/**
3792 * sme_cfg_set_int() - Sets the cfg parameter value.
3793 * @hal: Handle to hal.
3794 * @cfg_id: Configuration parameter ID.
Jeff Johnson560dc562017-03-17 15:19:31 -07003795 * @value: value to be saved in the cfg parameter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003796 *
3797 * This function sets the string value in cfg parameter.
3798 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303801QDF_STATUS sme_cfg_set_int(tHalHandle hal, uint16_t cfg_id, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802{
3803 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303804 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805
3806 if (eSIR_SUCCESS != cfg_set_int(pmac, cfg_id, value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303807 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808
3809 return status;
3810}
3811
3812/**
3813 * sme_cfg_set_str() - Sets the cfg parameter string.
3814 * @hal: Handle to hal.
3815 * @cfg_id: Configuration parameter ID.
3816 * @str: Pointer to the string buffer.
3817 * @length: Length of the string.
3818 *
3819 * This function sets the string value in cfg parameter.
3820 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303821 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303823QDF_STATUS sme_cfg_set_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 uint32_t length)
3825{
3826 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303827 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828
3829 if (eSIR_SUCCESS != cfg_set_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303830 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
3832 return status;
3833}
3834
3835/**
3836 * sme_cfg_get_int() - Gets the cfg parameter value.
3837 * @hal: Handle to hal.
3838 * @cfg_id: Configuration parameter ID.
3839 * @cfg_value: Pointer to variable in which cfg value
Jeff Johnson560dc562017-03-17 15:19:31 -07003840 * will be saved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 *
3842 * This function gets the value of the cfg parameter.
3843 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303844 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303846QDF_STATUS sme_cfg_get_int(tHalHandle hal, uint16_t cfg_id, uint32_t *cfg_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847{
3848 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303849 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850
3851 if (eSIR_SUCCESS != wlan_cfg_get_int(pmac, cfg_id, cfg_value))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303852 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853
3854 return status;
3855}
3856
3857/**
3858 * sme_cfg_get_str() - Gets the cfg parameter string.
3859 * @hal: Handle to hal.
3860 * @cfg_id: Configuration parameter ID.
3861 * @str: Pointer to the string buffer.
3862 * @length: Pointer to length of the string.
3863 *
3864 * This function gets the string value of the cfg parameter.
3865 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303866 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303868QDF_STATUS sme_cfg_get_str(tHalHandle hal, uint16_t cfg_id, uint8_t *str,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 uint32_t *length)
3870{
3871 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873
3874 if (eSIR_SUCCESS != wlan_cfg_get_str(pmac, cfg_id, str, length))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303875 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
3877 return status;
3878}
3879
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303880/*
3881 * sme_get_modify_profile_fields() -
3882 * HDD or SME - QOS calls this function to get the current values of
3883 * connected profile fields, changing which can cause reassoc.
3884 * This function must be called after CFG is downloaded and STA is in connected
3885 * state. Also, make sure to call this function to get the current profile
3886 * fields before calling the reassoc. So that pModifyProfileFields will have
3887 * all the latest values plus the one(s) has been updated as part of reassoc
3888 * request.
3889 *
3890 * pModifyProfileFields - pointer to the connected profile fields
3891 * changing which can cause reassoc
3892 * Return QDF_STATUS
3893 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303894QDF_STATUS sme_get_modify_profile_fields(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 tCsrRoamModifyProfileFields *
3896 pModifyProfileFields)
3897{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303898 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3900
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303901 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS, sessionId,
3903 0));
3904 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303905 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303906 if (CSR_IS_SESSION_VALID(pMac, sessionId))
3907 status = csr_get_modify_profile_fields(pMac, sessionId,
3908 pModifyProfileFields);
3909 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303910 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 sme_release_global_lock(&pMac->sme);
3912 }
3913
3914 return status;
3915}
3916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303917/*
3918 * sme_set_dhcp_till_power_active_flag() -
3919 * Sets/Clears DHCP related flag to disable/enable auto PS
3920 *
3921 * hal - The handle returned by mac_open.
3922 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923void sme_set_dhcp_till_power_active_flag(tHalHandle hal, uint8_t flag)
3924{
3925 tpAniSirGlobal mac = PMAC_STRUCT(hal);
3926 struct ps_global_info *ps_global_info = &mac->sme.ps_global_info;
3927
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303928 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG, NO_SESSION,
3930 flag));
3931 /* Set/Clear the DHCP flag which will disable/enable auto PS */
3932 ps_global_info->remain_in_power_active_till_dhcp = flag;
3933}
3934
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303935/*
3936 * sme_register11d_scan_done_callback() -
3937 * Register a routine of type csr_scan_completeCallback which is
3938 * called whenever an 11d scan is done
3939 *
3940 * hHal - The handle returned by mac_open.
3941 * callback - 11d scan complete routine to be registered
3942 * Return QDF_STATUS
3943 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303944QDF_STATUS sme_register11d_scan_done_callback(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05303945 csr_scan_completeCallback callback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303947 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3949
3950 pMac->scan.callback11dScanDone = callback;
3951
3952 return status;
3953}
3954
Arun Khandavalli4b55da72016-07-19 19:55:01 +05303955/**
3956 * sme_deregister11d_scan_done_callback() - De-register scandone callback
3957 * @h_hal: Handler return by mac_open
3958 *
3959 * This function De-registers the scandone callback to SME
3960 *
3961 * Return: None
3962 */
3963void sme_deregister11d_scan_done_callback(tHalHandle h_hal)
3964{
3965 tpAniSirGlobal pmac;
3966
3967 if (!h_hal) {
3968 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
3969 FL("hHal is not valid"));
3970 return;
3971 }
3972
3973 pmac = PMAC_STRUCT(h_hal);
3974 pmac->scan.callback11dScanDone = NULL;
3975}
3976
3977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978#ifdef FEATURE_OEM_DATA_SUPPORT
3979/**
3980 * sme_register_oem_data_rsp_callback() - Register a routine of
3981 * type send_oem_data_rsp_msg
3982 * @h_hal: Handle returned by mac_open.
3983 * @callback: Callback to send response
3984 * to oem application.
3985 *
3986 * sme_oem_data_rsp_callback is used to register sme_send_oem_data_rsp_msg
3987 * callback function.
3988 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303989 * Return: QDF_STATUS.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303991QDF_STATUS sme_register_oem_data_rsp_callback(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 sme_send_oem_data_rsp_msg callback)
3993{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303994 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 tpAniSirGlobal pmac = PMAC_STRUCT(h_hal);
3996
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07003997 pmac->sme.oem_data_rsp_callback = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998
3999 return status;
4000
4001}
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304002
4003/**
4004 * sme_deregister_oem_data_rsp_callback() - De-register OEM datarsp callback
4005 * @h_hal: Handler return by mac_open
4006 * This function De-registers the OEM data response callback to SME
4007 *
4008 * Return: None
4009 */
4010void sme_deregister_oem_data_rsp_callback(tHalHandle h_hal)
4011{
4012 tpAniSirGlobal pmac;
4013
4014 if (!h_hal) {
4015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4016 FL("hHal is not valid"));
4017 return;
4018 }
4019 pmac = PMAC_STRUCT(h_hal);
4020
Krishna Kumaar Natarajanbbbf2ef2016-08-03 14:06:26 -07004021 pmac->sme.oem_data_rsp_callback = NULL;
Arun Khandavalli4b55da72016-07-19 19:55:01 +05304022}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023
4024/**
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004025 * sme_oem_update_capability() - update UMAC's oem related capability.
4026 * @hal: Handle returned by mac_open
4027 * @oem_cap: pointer to oem_capability
4028 *
4029 * This function updates OEM capability to UMAC. Currently RTT
4030 * related capabilities are updated. More capabilities can be
4031 * added in future.
4032 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304033 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004034 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304035QDF_STATUS sme_oem_update_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004036 struct sme_oem_capability *cap)
4037{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004039 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4040 uint8_t *bytes;
4041
4042 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4043
4044 if (cap->ftm_rr)
4045 bytes[4] |= RM_CAP_FTM_RANGE_REPORT;
4046 if (cap->lci_capability)
4047 bytes[4] |= RM_CAP_CIVIC_LOC_MEASUREMENT;
4048
4049 return status;
4050}
4051
4052/**
4053 * sme_oem_get_capability() - get oem capability
4054 * @hal: Handle returned by mac_open
4055 * @oem_cap: pointer to oem_capability
4056 *
4057 * This function is used to get the OEM capability from UMAC.
4058 * Currently RTT related capabilities are received. More
4059 * capabilities can be added in future.
4060 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304061 * Return: QDF_STATUS
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004062 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063QDF_STATUS sme_oem_get_capability(tHalHandle hal,
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004064 struct sme_oem_capability *cap)
4065{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304066 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004067 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
4068 uint8_t *bytes;
4069
4070 bytes = pmac->rrm.rrmSmeContext.rrmConfig.rm_capability;
4071
4072 cap->ftm_rr = bytes[4] & RM_CAP_FTM_RANGE_REPORT;
4073 cap->lci_capability = bytes[4] & RM_CAP_CIVIC_LOC_MEASUREMENT;
4074
4075 return status;
4076}
Naveen Rawat910726a2017-03-06 11:42:51 -08004077#endif
Krishna Kumaar Natarajan53ca2902015-12-04 14:01:46 -08004078
4079/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 * sme_roam_set_key() - To set encryption key.
4081 * @hal: hal global context
4082 * @session_id: session id
4083 * @set_key: pointer to a caller allocated object of tCsrSetContextInfo
4084 * @ptr_roam_id: Upon success return, this is the id caller can use to
4085 * identify the request in roamcallback
4086 *
4087 * This function should be called only when connected. This is an asynchronous
4088 * API.
4089 *
4090 * Return: Status of operation
4091 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304092QDF_STATUS sme_roam_set_key(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 tCsrRoamSetKey *set_key, uint32_t *ptr_roam_id)
4094{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304095 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
4097 uint32_t roam_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304098 struct csr_roam_session *session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
4100
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304101 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_SET_KEY,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 session_id, 0));
4103 if (set_key->keyLength > CSR_MAX_KEY_LEN) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004104 sme_err("Invalid key length: %d", set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304105 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 }
4107 /*Once Setkey is done, we can go in BMPS */
4108 if (set_key->keyLength)
4109 ps_global_info->remain_in_power_active_till_dhcp = false;
4110
4111 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304112 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 return status;
4114
4115 roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
4116 if (ptr_roam_id)
4117 *ptr_roam_id = roam_id;
4118
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004119 sme_debug("keyLength: %d", set_key->keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004121 sme_debug("Session_id: %d roam_id: %d", session_id, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 session = CSR_GET_SESSION(mac_ctx, session_id);
4123 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004124 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304126 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 }
4128 if (CSR_IS_INFRA_AP(&session->connectedProfile)
4129 && set_key->keyDirection == eSIR_TX_DEFAULT) {
4130 if ((eCSR_ENCRYPT_TYPE_WEP40 == set_key->encType)
4131 || (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
4132 set_key->encType)) {
4133 session->pCurRoamProfile->negotiatedUCEncryptionType =
4134 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4135 }
4136 if ((eCSR_ENCRYPT_TYPE_WEP104 == set_key->encType)
4137 || (eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
4138 set_key->encType)) {
4139 session->pCurRoamProfile->negotiatedUCEncryptionType =
4140 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4141 }
4142 }
4143 status = csr_roam_set_key(mac_ctx, session_id, set_key, roam_id);
4144 sme_release_global_lock(&mac_ctx->sme);
4145 return status;
4146}
4147
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304148/**
4149 * sme_roam_set_default_key_index - To set default wep key idx
4150 * @hal: pointer to hal handler
4151 * @session_id: session id
4152 * @default_idx: default wep key index
4153 *
4154 * This function prepares a message and post to WMA to set wep default
4155 * key index
4156 *
4157 * Return: Success:QDF_STATUS_SUCCESS Failure: Error value
4158 */
4159QDF_STATUS sme_roam_set_default_key_index(tHalHandle hal, uint8_t session_id,
4160 uint8_t default_idx)
4161{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004162 struct scheduler_msg msg = {0};
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304163 struct wep_update_default_key_idx *update_key;
4164
4165 update_key = qdf_mem_malloc(sizeof(*update_key));
4166 if (!update_key) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004167 sme_err("Failed to allocate memory for update key");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304168 return QDF_STATUS_E_NOMEM;
4169 }
4170
4171 update_key->session_id = session_id;
4172 update_key->default_idx = default_idx;
4173
4174 msg.type = WMA_UPDATE_WEP_DEFAULT_KEY;
4175 msg.reserved = 0;
4176 msg.bodyptr = (void *)update_key;
4177
4178 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004179 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004180 sme_err("Failed to post WMA_UPDATE_WEP_DEFAULT_KEY to WMA");
Masti, Narayanraddiab712a72016-08-04 11:59:11 +05304181 qdf_mem_free(update_key);
4182 return QDF_STATUS_E_FAILURE;
4183 }
4184
4185 return QDF_STATUS_SUCCESS;
4186}
4187
4188
Jeff Johnson8bd23352017-09-26 11:39:24 -07004189/**
4190 * sme_get_rssi() - API to retrieve current RSSI
4191 * @hHal: HAL handle for device
4192 * @callback: SME sends back the requested stats using the callback
4193 * @staId: The station ID for which the RSSI is requested for
4194 * @bssid: The bssid of the connected session
4195 * @lastRSSI: RSSI value at time of request. In case fw cannot provide
4196 * RSSI, do not hold up but return this value.
4197 * @pContext: user context to be passed back along with the callback
4198 *
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304199 * A wrapper function that client calls to register a callback to get RSSI
4200 *
Jeff Johnson8bd23352017-09-26 11:39:24 -07004201 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304202 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304203QDF_STATUS sme_get_rssi(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304204 tCsrRssiCallback callback, uint8_t staId,
4205 struct qdf_mac_addr bssId, int8_t lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004206 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304208 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4210
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304211 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 TRACE_CODE_SME_RX_HDD_GET_RSSI, NO_SESSION, 0));
4213 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304214 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 status = csr_get_rssi(pMac, callback,
4216 staId, bssId, lastRSSI,
Jeff Johnson8bd23352017-09-26 11:39:24 -07004217 pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 sme_release_global_lock(&pMac->sme);
4219 }
4220 return status;
4221}
4222
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304223/*
4224 * sme_get_snr() -
4225 * A wrapper function that client calls to register a callback to get SNR
4226 *
4227 * callback - SME sends back the requested stats using the callback
4228 * staId - The station ID for which the stats is requested for
4229 * pContext - user context to be passed back along with the callback
4230 * p_cds_context - cds context
4231 * \return QDF_STATUS
4232 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304233QDF_STATUS sme_get_snr(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304235 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304237 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4239
4240 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304241 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 status = csr_get_snr(pMac, callback, staId, bssId, pContext);
4243 sme_release_global_lock(&pMac->sme);
4244 }
4245 return status;
4246}
4247
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004248#ifndef QCA_SUPPORT_CP_STATS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304249/*
4250 * sme_get_statistics() -
4251 * A wrapper function that client calls to register a callback to get
4252 * different PHY level statistics from CSR.
4253 *
4254 * requesterId - different client requesting for statistics,
4255 * HDD, UMA/GAN etc
4256 * statsMask - The different category/categories of stats requester
4257 * is looking for
4258 * callback - SME sends back the requested stats using the callback
4259 * periodicity - If requester needs periodic update in millisec, 0 means
4260 * it's an one time request
4261 * cache - If requester is happy with cached stats
4262 * staId - The station ID for which the stats is requested for
4263 * pContext - user context to be passed back along with the callback
4264 * sessionId - sme session interface
4265 * Return QDF_STATUS
4266 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304267QDF_STATUS sme_get_statistics(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 eCsrStatsRequesterType requesterId,
4269 uint32_t statsMask, tCsrStatsCallback callback,
Naveen Rawatd0ca4412017-06-16 14:19:19 -07004270 uint8_t staId, void *pContext, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304272 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304276 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304277 status = csr_get_statistics(pMac, requesterId, statsMask,
4278 callback, staId, pContext,
4279 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 sme_release_global_lock(&pMac->sme);
4281 }
4282
4283 return status;
4284
4285}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07004286#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304288QDF_STATUS sme_get_link_status(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 tCsrLinkStatusCallback callback,
4290 void *pContext, uint8_t sessionId)
4291{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304292 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4294 tAniGetLinkStatus *pMsg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004295 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296
4297 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304298 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304299 pMsg = qdf_mem_malloc(sizeof(tAniGetLinkStatus));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304301 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 "%s: Not able to allocate memory for link status",
4303 __func__);
4304 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304305 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 }
4307
4308 pMsg->msgType = WMA_LINK_STATUS_GET_REQ;
4309 pMsg->msgLen = (uint16_t) sizeof(tAniGetLinkStatus);
4310 pMsg->sessionId = sessionId;
4311 pMac->sme.linkStatusContext = pContext;
4312 pMac->sme.linkStatusCallback = callback;
4313
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004314 message.type = WMA_LINK_STATUS_GET_REQ;
4315 message.bodyptr = pMsg;
4316 message.reserved = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304318 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004319 (scheduler_post_msg(QDF_MODULE_ID_WMA,
4320 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304321 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 "%s: Post LINK STATUS MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304323 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 pMac->sme.linkStatusContext = NULL;
4325 pMac->sme.linkStatusCallback = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304326 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004327 }
4328
4329 sme_release_global_lock(&pMac->sme);
4330 }
4331
4332 return status;
4333}
4334
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304335/*
4336 * sme_get_country_code() -
4337 * To return the current country code. If no country code is applied,
4338 * default country code is used to fill the buffer.
4339 * If 11d supported is turned off, an error is return and the last
4340 * applied/default country code is used.
4341 * This is a synchronous API.
4342 *
4343 * pBuf - pointer to a caller allocated buffer for returned country code.
4344 * pbLen For input, this parameter indicates how big is the buffer.
4345 * Upon return, this parameter has the number of bytes for
4346 * country. If pBuf doesn't have enough space, this function
4347 * returns fail status and this parameter contains the number
4348 * that is needed.
4349 *
4350 * Return QDF_STATUS SUCCESS.
4351 *
4352 * FAILURE or RESOURCES The API finished and failed.
4353 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304354QDF_STATUS sme_get_country_code(tHalHandle hHal, uint8_t *pBuf, uint8_t *pbLen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355{
4356 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4357
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304358 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE, NO_SESSION, 0));
4360
4361 return csr_get_country_code(pMac, pBuf, pbLen);
4362}
4363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364/* some support functions */
4365bool sme_is11d_supported(tHalHandle hHal)
4366{
4367 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4368
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07004369 return wlan_reg_11d_enabled_on_host(pMac->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370}
4371
4372bool sme_is11h_supported(tHalHandle hHal)
4373{
4374 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4375
4376 return csr_is11h_supported(pMac);
4377}
4378
4379bool sme_is_wmm_supported(tHalHandle hHal)
4380{
4381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4382
4383 return csr_is_wmm_supported(pMac);
4384}
4385
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304386/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304387 * sme_generic_change_country_code() -
4388 * Change Country code from upperlayer during WLAN driver operation.
4389 * This is a synchronous API.
4390 *
4391 * hHal - The handle returned by mac_open.
4392 * pCountry New Country Code String
4393 * reg_domain regulatory domain
4394 * Return QDF_STATUS SUCCESS.
4395 * FAILURE or RESOURCES The API finished and failed.
4396 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304397QDF_STATUS sme_generic_change_country_code(tHalHandle hHal,
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004398 uint8_t *pCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004402 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 tAniGenericChangeCountryCodeReq *pMsg;
4404
4405 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304406 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 "%s: pMac is null", __func__);
4408 return status;
4409 }
4410
4411 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304412 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304413 pMsg = qdf_mem_malloc(sizeof(tAniGenericChangeCountryCodeReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414
4415 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004416 sme_err("sme_generic_change_country_code: failed to allocate mem for req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304418 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 }
4420
4421 pMsg->msgType = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4422 pMsg->msgLen =
4423 (uint16_t) sizeof(tAniGenericChangeCountryCodeReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304424 qdf_mem_copy(pMsg->countryCode, pCountry, 2);
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07004425 pMsg->countryCode[2] = ' ';
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426
4427 msg.type = eWNI_SME_GENERIC_CHANGE_COUNTRY_CODE;
4428 msg.bodyptr = pMsg;
4429 msg.reserved = 0;
4430
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304431 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004432 scheduler_post_msg(QDF_MODULE_ID_SME, &msg)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004433 sme_err("sme_generic_change_country_code failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304434 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304435 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 sme_release_global_lock(&pMac->sme);
4438 }
4439
4440 return status;
4441}
4442
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304443/*
4444 * sme_dhcp_start_ind() -
4445 * API to signal the FW about the DHCP Start event.
4446 *
4447 * hHal - HAL handle for device.
4448 * device_mode - mode(AP,SAP etc) of the device.
4449 * macAddr - MAC address of the adapter.
4450 * sessionId - session ID.
4451 * Return QDF_STATUS SUCCESS.
4452 * FAILURE or RESOURCES The API finished and failed.
4453 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304454QDF_STATUS sme_dhcp_start_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 uint8_t device_mode,
4456 uint8_t *macAddr, uint8_t sessionId)
4457{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304458 QDF_STATUS status;
4459 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004461 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304463 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464
4465 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304466 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 pSession = CSR_GET_SESSION(pMac, sessionId);
4468
4469 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004470 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304472 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 }
Arif Hussain3316f402016-11-10 13:08:03 -08004474 pSession->dhcp_done = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304476 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304478 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 "%s: Not able to allocate memory for dhcp start",
4480 __func__);
4481 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304482 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 }
4484 pMsg->msgType = WMA_DHCP_START_IND;
4485 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4486 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304487 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304488 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304489 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004490 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004492 message.type = WMA_DHCP_START_IND;
4493 message.bodyptr = pMsg;
4494 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304495 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004496 sessionId, message.type));
4497 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4498 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304499 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304500 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 "%s: Post DHCP Start MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304503 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 }
4505 sme_release_global_lock(&pMac->sme);
4506 }
4507 return status;
4508}
4509
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304510/*
4511 * sme_dhcp_stop_ind() -
4512 * API to signal the FW about the DHCP complete event.
4513 *
4514 * hHal - HAL handle for device.
4515 * device_mode - mode(AP, SAP etc) of the device.
4516 * macAddr - MAC address of the adapter.
4517 * sessionId - session ID.
4518 * Return QDF_STATUS SUCCESS.
4519 * FAILURE or RESOURCES The API finished and failed.
4520 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304521QDF_STATUS sme_dhcp_stop_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 uint8_t device_mode,
4523 uint8_t *macAddr, uint8_t sessionId)
4524{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304525 QDF_STATUS status;
4526 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004528 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 tAniDHCPInd *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304530 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531
4532 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304533 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 pSession = CSR_GET_SESSION(pMac, sessionId);
4535
4536 if (!pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004537 sme_err("Session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304539 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 }
Arif Hussain3316f402016-11-10 13:08:03 -08004541 pSession->dhcp_done = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304543 pMsg = (tAniDHCPInd *) qdf_mem_malloc(sizeof(tAniDHCPInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 if (NULL == pMsg) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304545 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 "%s: Not able to allocate memory for dhcp stop",
4547 __func__);
4548 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304549 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 }
4551
4552 pMsg->msgType = WMA_DHCP_STOP_IND;
4553 pMsg->msgLen = (uint16_t) sizeof(tAniDHCPInd);
4554 pMsg->device_mode = device_mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304555 qdf_mem_copy(pMsg->adapterMacAddr.bytes, macAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304556 QDF_MAC_ADDR_SIZE);
Anurag Chouhanc5548422016-02-24 18:33:27 +05304557 qdf_copy_macaddr(&pMsg->peerMacAddr,
Srinivas Girigowda296105a2015-09-24 16:31:16 -07004558 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004560 message.type = WMA_DHCP_STOP_IND;
4561 message.bodyptr = pMsg;
4562 message.reserved = 0;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05304563 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004564 sessionId, message.type));
4565 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4566 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304568 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 "%s: Post DHCP Stop MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304570 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304571 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572 }
4573
4574 sme_release_global_lock(&pMac->sme);
4575 }
4576 return status;
4577}
4578
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304579/*
4580 * sme_TXFailMonitorStopInd() -
4581 * API to signal the FW to start monitoring TX failures
4582 *
4583 * Return QDF_STATUS SUCCESS.
4584 * FAILURE or RESOURCES The API finished and failed.
4585 */
4586QDF_STATUS sme_tx_fail_monitor_start_stop_ind(tHalHandle hHal, uint8_t
4587 tx_fail_count,
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004588 void *txFailIndCallback)
4589{
4590 QDF_STATUS status;
4591 QDF_STATUS qdf_status;
4592 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004593 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004594 tAniTXFailMonitorInd *pMsg;
4595
4596 status = sme_acquire_global_lock(&pMac->sme);
4597 if (QDF_STATUS_SUCCESS == status) {
4598 pMsg = (tAniTXFailMonitorInd *)
4599 qdf_mem_malloc(sizeof(tAniTXFailMonitorInd));
4600 if (NULL == pMsg) {
4601 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4602 "%s: Failed to allocate memory", __func__);
4603 sme_release_global_lock(&pMac->sme);
4604 return QDF_STATUS_E_NOMEM;
4605 }
4606
4607 pMsg->msgType = WMA_TX_FAIL_MONITOR_IND;
4608 pMsg->msgLen = (uint16_t) sizeof(tAniTXFailMonitorInd);
4609
4610 /* tx_fail_count = 0 should disable the Monitoring in FW */
4611 pMsg->tx_fail_count = tx_fail_count;
4612 pMsg->txFailIndCallback = txFailIndCallback;
4613
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004614 message.type = WMA_TX_FAIL_MONITOR_IND;
4615 message.bodyptr = pMsg;
4616 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004617
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08004618 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
4619 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08004620 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4621 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
4622 "%s: Post TX Fail monitor Start MSG fail",
4623 __func__);
4624 qdf_mem_free(pMsg);
4625 status = QDF_STATUS_E_FAILURE;
4626 }
4627 sme_release_global_lock(&pMac->sme);
4628 }
4629 return status;
4630}
4631
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304632/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304633 * sme_neighbor_report_request() -
4634 * API to request neighbor report.
4635 *
4636 * hHal - The handle returned by mac_open.
4637 * pRrmNeighborReq - Pointer to a caller allocated object of type
4638 * tRrmNeighborReq. Caller owns the memory and is
4639 * responsible for freeing it.
4640 * Return QDF_STATUS
4641 * QDF_STATUS_E_FAILURE - failure
4642 * QDF_STATUS_SUCCESS success
4643 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644QDF_STATUS sme_neighbor_report_request(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 tpRrmNeighborReq pRrmNeighborReq,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304646 tpRrmNeighborRspCallbackInfo callbackInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304650
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304651 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ, NO_SESSION,
4653 0));
4654
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05304655 if (pRrmNeighborReq->neighbor_report_offload) {
4656 status = csr_invoke_neighbor_report_request(sessionId,
4657 pRrmNeighborReq,
4658 false);
4659 return status;
4660 }
4661
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304662 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 status =
4664 sme_rrm_neighbor_report_request(hHal, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304665 pRrmNeighborReq, callbackInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 sme_release_global_lock(&pMac->sme);
4667 }
4668
4669 return status;
4670}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304672/*
4673 * sme_get_wcnss_wlan_compiled_version() -
4674 * This API returns the version of the WCNSS WLAN API with
4675 * which the HOST driver was built
4676 *
4677 * hHal - The handle returned by mac_open.
4678 * pVersion - Points to the Version structure to be filled
4679 * Return QDF_STATUS
4680 * QDF_STATUS_E_INVAL - failure
4681 * QDF_STATUS_SUCCESS success
4682 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304683QDF_STATUS sme_get_wcnss_wlan_compiled_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 tSirVersionType *pVersion)
4685{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304686 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304689 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304691 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304693 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694
4695 sme_release_global_lock(&pMac->sme);
4696 }
4697
4698 return status;
4699}
4700
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304701/*
4702 * sme_get_wcnss_wlan_reported_version() -
4703 * This API returns the version of the WCNSS WLAN API with
4704 * which the WCNSS driver reports it was built
4705 * hHal - The handle returned by mac_open.
4706 * pVersion - Points to the Version structure to be filled
4707 * Return QDF_STATUS
4708 * QDF_STATUS_E_INVAL - failure
4709 * QDF_STATUS_SUCCESS success
4710 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304711QDF_STATUS sme_get_wcnss_wlan_reported_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 tSirVersionType *pVersion)
4713{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304714 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4716
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304717 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304719 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304721 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722
4723 sme_release_global_lock(&pMac->sme);
4724 }
4725
4726 return status;
4727}
4728
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304729/*
4730 * sme_get_wcnss_software_version() -
4731 * This API returns the version string of the WCNSS driver
4732 *
4733 * hHal - The handle returned by mac_open.
4734 * pVersion - Points to the Version string buffer to be filled
4735 * versionBufferSize - THe size of the Version string buffer
4736 * Return QDF_STATUS
4737 * QDF_STATUS_E_INVAL - failure
4738 * QDF_STATUS_SUCCESS success
4739 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304740QDF_STATUS sme_get_wcnss_software_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 uint8_t *pVersion,
4742 uint32_t versionBufferSize)
4743{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304744 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304748 if (pVersion != NULL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 status =
Jeff Johnsonabb74042017-08-31 11:44:55 -07004750 wma_get_wcnss_software_version(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 pVersion,
4752 versionBufferSize);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304753 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304754 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 sme_release_global_lock(&pMac->sme);
4756 }
4757
4758 return status;
4759}
4760
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304761/*
4762 * sme_get_wcnss_hardware_version() -
4763 * This API returns the version string of the WCNSS hardware
4764 *
4765 * hHal - The handle returned by mac_open.
4766 * pVersion - Points to the Version string buffer to be filled
4767 * versionBufferSize - THe size of the Version string buffer
4768 * Return QDF_STATUS
4769 * QDF_STATUS_E_INVAL - failure
4770 * QDF_STATUS_SUCCESS success
4771 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304772QDF_STATUS sme_get_wcnss_hardware_version(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004773 uint8_t *pVersion,
4774 uint32_t versionBufferSize)
4775{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304776 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
4778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304779 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 if (pVersion != NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304781 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304783 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784
4785 sme_release_global_lock(&pMac->sme);
4786 }
4787
4788 return status;
4789}
4790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791#ifdef FEATURE_OEM_DATA_SUPPORT
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004792/**
4793 * sme_oem_data_req() - send oem data request to WMA
4794 * @hal: HAL handle
4795 * @hdd_oem_req: OEM data request from HDD
4796 *
4797 * Return: QDF_STATUS
4798 */
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004799QDF_STATUS sme_oem_data_req(tHalHandle hal, struct oem_data_req *hdd_oem_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004800{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304801 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajanc1fa17d2016-08-03 14:19:20 -07004802 struct oem_data_req *oem_data_req;
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004803 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004805 SME_ENTER();
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004806 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
4807 if (!wma_handle) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004808 sme_err("wma_handle is NULL");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004809 return QDF_STATUS_E_FAILURE;
4810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004812 oem_data_req = qdf_mem_malloc(sizeof(*oem_data_req));
4813 if (!oem_data_req) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004814 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004815 return QDF_STATUS_E_NOMEM;
4816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004818 oem_data_req->data_len = hdd_oem_req->data_len;
4819 oem_data_req->data = qdf_mem_malloc(oem_data_req->data_len);
4820 if (!oem_data_req->data) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004821 sme_err("mem alloc failed");
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004822 return QDF_STATUS_E_NOMEM;
4823 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004825 qdf_mem_copy(oem_data_req->data, hdd_oem_req->data,
4826 oem_data_req->data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004828 status = wma_start_oem_data_req(wma_handle, oem_data_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304830 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004831 sme_err("Post oem data request msg fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304832 else
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004833 sme_debug("OEM request(length: %d) sent to WMA",
4834 oem_data_req->data_len);
Krishna Kumaar Natarajanc5e06ac2016-06-30 16:49:19 -07004835
4836 if (oem_data_req->data_len)
4837 qdf_mem_free(oem_data_req->data);
4838 qdf_mem_free(oem_data_req);
4839
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07004840 SME_EXIT();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 return status;
4842}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843#endif /*FEATURE_OEM_DATA_SUPPORT */
4844
Krunal Soni8d184fa2017-11-20 21:52:05 -08004845QDF_STATUS sme_open_session(tHalHandle hal, struct sme_session_params *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846{
Arif Hussainee677012017-01-26 17:50:13 -08004847 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004848 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Arif Hussainee677012017-01-26 17:50:13 -08004849 struct cdp_pdev *pdev;
4850 ol_txrx_peer_handle peer;
4851 uint8_t peer_id;
Krishna Kumaar Natarajanb9e1d712017-06-20 17:14:37 -07004852 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304854 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_DEBUG,
Rajeev Kumar7414c8c2017-04-06 15:42:52 -07004855 "%s: type=%d, session_id %d subType=%d addr:%pM",
Krunal Soni8d184fa2017-11-20 21:52:05 -08004856 __func__, params->type_of_persona,
4857 params->sme_session_id, params->subtype_of_persona,
4858 params->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859
Arif Hussainee677012017-01-26 17:50:13 -08004860 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4861
4862 if (NULL == pdev) {
4863 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4864 "%s: Failed to get pdev handler", __func__);
4865 return status;
4866 }
4867
Krunal Soni8d184fa2017-11-20 21:52:05 -08004868 status = sme_acquire_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004869 if (QDF_IS_STATUS_ERROR(status))
4870 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871
Krunal Soni8d184fa2017-11-20 21:52:05 -08004872 peer = cdp_peer_find_by_addr(soc, pdev, params->self_mac_addr,
4873 &peer_id);
Arif Hussainee677012017-01-26 17:50:13 -08004874 if (peer) {
4875 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_ERROR,
4876 "%s: Peer=%d exist with same MAC",
4877 __func__, peer_id);
4878 status = QDF_STATUS_E_INVAL;
4879 } else {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004880 status = csr_roam_open_session(mac_ctx, params);
Arif Hussainee677012017-01-26 17:50:13 -08004881 }
Krunal Soni8d184fa2017-11-20 21:52:05 -08004882 sme_release_global_lock(&mac_ctx->sme);
Dustin Brownd28772b2017-03-17 14:16:07 -07004883
4884 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_OPEN_SESSION,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004885 params->sme_session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886
4887 return status;
4888}
4889
Krunal Soni8d184fa2017-11-20 21:52:05 -08004890QDF_STATUS sme_close_session(tHalHandle hal, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304892 QDF_STATUS status;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004893 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304895 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Krunal Soni8d184fa2017-11-20 21:52:05 -08004896 TRACE_CODE_SME_RX_HDD_CLOSE_SESSION, session_id, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -08004899 status = csr_roam_close_session(pMac, session_id, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 sme_release_global_lock(&pMac->sme);
4901 }
4902
4903 return status;
4904}
4905
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304906/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304907 * sme_change_mcc_beacon_interval() -
4908 * To update P2P-GO beaconInterval. This function should be called after
4909 * disassociating all the station is done
4910 * This is an asynchronous API.
4911 *
4912 * @sessionId: Session Identifier
4913 * Return QDF_STATUS SUCCESS
4914 * FAILURE or RESOURCES
4915 * The API finished and failed.
4916 */
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004917QDF_STATUS sme_change_mcc_beacon_interval(uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304919 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004920 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921
Krunal Soni3fa80e22018-01-09 14:16:02 -08004922 if (!mac_ctx) {
4923 sme_err("mac_ctx is NULL");
4924 return status;
4925 }
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004926 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304927 if (QDF_IS_STATUS_SUCCESS(status)) {
Archana Ramachandran2eb7a612017-03-23 22:58:42 -07004928 status = csr_send_chng_mcc_beacon_interval(mac_ctx,
4929 sessionId);
4930 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 }
4932 return status;
4933}
4934
4935/**
4936 * sme_set_host_offload(): API to set the host offload feature.
4937 * @hHal: The handle returned by mac_open.
4938 * @sessionId: Session Identifier
4939 * @request: Pointer to the offload request.
4940 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304941 * Return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304943QDF_STATUS sme_set_host_offload(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 tpSirHostOffloadReq request)
4945{
4946 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304947 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304949 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD, sessionId, 0));
4951 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304952 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953#ifdef WLAN_NS_OFFLOAD
4954 if (SIR_IPV6_NS_OFFLOAD == request->offloadType) {
4955 status = sme_set_ps_ns_offload(hHal, request,
4956 sessionId);
4957 } else
4958#endif /* WLAN_NS_OFFLOAD */
4959 {
4960 status = sme_set_ps_host_offload(hHal, request,
4961 sessionId);
4962 }
4963 sme_release_global_lock(&pMac->sme);
4964 }
4965
4966 return status;
4967}
4968
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304969/*
4970 * sme_set_keep_alive() -
4971 * API to set the Keep Alive feature.
4972 *
4973 * hHal - The handle returned by mac_open.
4974 * request - Pointer to the Keep Alive request.
4975 * Return QDF_STATUS
4976 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304977QDF_STATUS sme_set_keep_alive(tHalHandle hHal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 tpSirKeepAliveReq request)
4979{
4980 tpSirKeepAliveReq request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004981 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004982 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304983 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984
Abhishek Singhe4a1f882017-08-10 17:59:44 +05304985 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986 FL("WMA_SET_KEEP_ALIVE message"));
4987
4988 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304989 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990 FL("Session not Found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304991 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304993 request_buf = qdf_mem_malloc(sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304995 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05304996 "Not able to allocate memory for keep alive request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304997 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 }
4999
Anurag Chouhanc5548422016-02-24 18:33:27 +05305000 qdf_copy_macaddr(&request->bssid, &pSession->connectedProfile.bssid);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305001 qdf_mem_copy(request_buf, request, sizeof(tSirKeepAliveReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002
Abhishek Singhe4a1f882017-08-10 17:59:44 +05305003 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004 "buff TP %d input TP %d ", request_buf->timePeriod,
5005 request->timePeriod);
5006 request_buf->sessionId = session_id;
5007
5008 msg.type = WMA_SET_KEEP_ALIVE;
5009 msg.reserved = 0;
5010 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305011 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5012 session_id, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305013 if (QDF_STATUS_SUCCESS !=
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005014 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305016 "Not able to post WMA_SET_KEEP_ALIVE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305017 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305018 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 }
5020
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305021 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022}
5023
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305024/*
5025 * sme_get_operation_channel() -
5026 * API to get current channel on which STA is parked his function gives
5027 * channel information only of infra station or IBSS station
5028 *
5029 * hHal, pointer to memory location and sessionId
5030 * Returns QDF_STATUS_SUCCESS
5031 * QDF_STATUS_E_FAILURE
5032 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305033QDF_STATUS sme_get_operation_channel(tHalHandle hHal, uint32_t *pChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 uint8_t sessionId)
5035{
5036 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305037 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038
5039 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5040 pSession = CSR_GET_SESSION(pMac, sessionId);
5041
5042 if ((pSession->connectedProfile.BSSType ==
5043 eCSR_BSS_TYPE_INFRASTRUCTURE)
5044 || (pSession->connectedProfile.BSSType ==
5045 eCSR_BSS_TYPE_IBSS)
5046 || (pSession->connectedProfile.BSSType ==
5047 eCSR_BSS_TYPE_INFRA_AP)
5048 || (pSession->connectedProfile.BSSType ==
5049 eCSR_BSS_TYPE_START_IBSS)) {
5050 *pChannel = pSession->connectedProfile.operationChannel;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305051 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 }
5053 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305054 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005055} /* sme_get_operation_channel ends here */
5056
Abhishek Singh7996eb72015-12-30 17:24:02 +05305057/**
5058 * sme_register_mgmt_frame_ind_callback() - Register a callback for
5059 * management frame indication to PE.
5060 *
5061 * @hal: hal pointer
5062 * @callback: callback pointer to be registered
5063 *
5064 * This function is used to register a callback for management
5065 * frame indication to PE.
5066 *
5067 * Return: Success if msg is posted to PE else Failure.
5068 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305069QDF_STATUS sme_register_mgmt_frame_ind_callback(tHalHandle hal,
Abhishek Singh7996eb72015-12-30 17:24:02 +05305070 sir_mgmt_frame_ind_callback callback)
5071{
5072 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5073 struct sir_sme_mgmt_frame_cb_req *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305074 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305075
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305076 if (QDF_STATUS_SUCCESS ==
Abhishek Singh7996eb72015-12-30 17:24:02 +05305077 sme_acquire_global_lock(&mac_ctx->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305078 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh7996eb72015-12-30 17:24:02 +05305079 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005080 sme_err("Not able to allocate memory");
Abhishek Singh7996eb72015-12-30 17:24:02 +05305081 sme_release_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305082 return QDF_STATUS_E_NOMEM;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305083 }
Abhishek Singh7996eb72015-12-30 17:24:02 +05305084 msg->message_type = eWNI_SME_REGISTER_MGMT_FRAME_CB;
5085 msg->length = sizeof(*msg);
5086
5087 msg->callback = callback;
Rajeev Kumard138ac52017-01-30 18:38:37 -08005088 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh7996eb72015-12-30 17:24:02 +05305089 sme_release_global_lock(&mac_ctx->sme);
5090 return status;
5091 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305092 return QDF_STATUS_E_FAILURE;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305093}
5094
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305095/*
5096 * sme_RegisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005097 * To register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305098 *
5099 * frameType - type of the frame that needs to be passed to HDD.
5100 * matchData - data which needs to be matched before passing frame
5101 * to HDD.
5102 * matchDataLen - Length of matched data.
5103 * Return QDF_STATUS
5104 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305105QDF_STATUS sme_register_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 uint16_t frameType, uint8_t *matchData,
5107 uint16_t matchLen)
5108{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305109 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305113 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005114 tSirRegisterMgmtFrame *pMsg;
5115 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305116 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5117 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118
5119 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005120 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305122 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 }
5124
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305125 if (!CSR_IS_SESSION_ANY(sessionId) &&
5126 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305127 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 "%s Invalid Sessionid", __func__);
5129 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305130 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 }
5132
5133 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5134
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305135 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305137 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005138 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5140 pMsg->length = len;
5141 pMsg->sessionId = sessionId;
5142 pMsg->registerFrame = true;
5143 pMsg->frameType = frameType;
5144 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305145 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005146 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 }
5148 sme_release_global_lock(&pMac->sme);
5149 }
5150 return status;
5151}
5152
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305153/*
5154 * sme_DeregisterMgtFrame() -
Jeff Johnson698eacd2018-05-12 17:00:03 -07005155 * To De-register management frame of specified type and subtype.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305156 *
5157 * frameType - type of the frame that needs to be passed to HDD.
5158 * matchData - data which needs to be matched before passing frame
5159 * to HDD.
5160 * matchDataLen - Length of matched data.
5161 * Return QDF_STATUS
5162 */
5163QDF_STATUS sme_deregister_mgmt_frame(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164 uint16_t frameType, uint8_t *matchData,
5165 uint16_t matchLen)
5166{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305167 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005168 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5169
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305170 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR, sessionId,
5172 0));
5173 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305174 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 tSirRegisterMgmtFrame *pMsg;
5176 uint16_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305177 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
5178 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179
5180 if (!CSR_IS_SESSION_ANY(sessionId) && !pSession) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005181 sme_err("Session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 }
5185
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305186 if (!CSR_IS_SESSION_ANY(sessionId) &&
5187 !pSession->sessionActive) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305188 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005189 "%s Invalid Sessionid", __func__);
5190 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305191 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 }
5193
5194 len = sizeof(tSirRegisterMgmtFrame) + matchLen;
5195
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305196 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305198 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 pMsg->messageType = eWNI_SME_REGISTER_MGMT_FRAME_REQ;
5201 pMsg->length = len;
5202 pMsg->registerFrame = false;
5203 pMsg->frameType = frameType;
5204 pMsg->matchLen = matchLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305205 qdf_mem_copy(pMsg->matchData, matchData, matchLen);
Rajeev Kumard138ac52017-01-30 18:38:37 -08005206 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 }
5208 sme_release_global_lock(&pMac->sme);
5209 }
5210 return status;
5211}
5212
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305213/**
5214 * sme_prepare_mgmt_tx() - Prepares mgmt frame
5215 * @hal: The handle returned by mac_open
5216 * @session_id: session id
5217 * @buf: pointer to frame
5218 * @len: frame length
5219 *
5220 * Return: QDF_STATUS
5221 */
5222static QDF_STATUS sme_prepare_mgmt_tx(tHalHandle hal, uint8_t session_id,
5223 const uint8_t *buf, uint32_t len)
5224{
5225 QDF_STATUS status = QDF_STATUS_SUCCESS;
5226 struct sir_mgmt_msg *msg;
5227 uint16_t msg_len;
5228 struct scheduler_msg sch_msg = {0};
5229
5230 sme_debug("prepares auth frame");
5231
5232 msg_len = sizeof(*msg) + len;
5233 msg = qdf_mem_malloc(msg_len);
5234 if (msg == NULL) {
5235 status = QDF_STATUS_E_NOMEM;
5236 } else {
5237 msg->type = eWNI_SME_SEND_MGMT_FRAME_TX;
5238 msg->msg_len = msg_len;
5239 msg->session_id = session_id;
5240 msg->data = (uint8_t *)msg + sizeof(*msg);
5241 qdf_mem_copy(msg->data, buf, len);
5242
5243 sch_msg.type = eWNI_SME_SEND_MGMT_FRAME_TX;
5244 sch_msg.bodyptr = msg;
5245 status = scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
5246 }
5247 return status;
5248}
5249
5250QDF_STATUS sme_send_mgmt_tx(tHalHandle hal, uint8_t session_id,
5251 const uint8_t *buf, uint32_t len)
5252{
5253 QDF_STATUS status = QDF_STATUS_SUCCESS;
5254 tpAniSirGlobal mac = PMAC_STRUCT(hal);
5255
5256 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
5257 TRACE_CODE_SME_RX_HDD_SEND_MGMT_TX, session_id, 0));
5258
5259 status = sme_acquire_global_lock(&mac->sme);
5260 if (QDF_IS_STATUS_SUCCESS(status)) {
5261 status = sme_prepare_mgmt_tx(hal, session_id, buf, len);
5262 sme_release_global_lock(&mac->sme);
5263 }
5264
5265 return status;
5266}
5267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268#ifdef WLAN_FEATURE_EXTWOW_SUPPORT
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005269/**
5270 * sme_configure_ext_wow() - configure Extr WoW
5271 * @hHal - The handle returned by mac_open.
5272 * @wlanExtParams - Depicts the wlan Ext params.
5273 * @callback - ext_wow callback to be registered.
5274 * @callback_context - ext_wow callback context
5275 *
5276 * SME will pass this request to lower mac to configure Extr WoW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305277 * Return: QDF_STATUS
Krishna Kumaar Natarajand9131902015-10-19 11:52:47 -07005278 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305279QDF_STATUS sme_configure_ext_wow(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 tpSirExtWoWParams wlanExtParams,
5281 csr_readyToExtWoWCallback callback,
5282 void *callback_context)
5283{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305284 QDF_STATUS status = QDF_STATUS_SUCCESS;
5285 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005287 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305288 tpSirExtWoWParams MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289
5290 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305291 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305293 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW, NO_SESSION, 0));
5295
5296 pMac->readyToExtWoWCallback = callback;
5297 pMac->readyToExtWoWContext = callback_context;
5298
5299 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305300 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301
5302 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_copy(MsgPtr, wlanExtParams, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005304 message.bodyptr = MsgPtr;
5305 message.type = WMA_WLAN_EXT_WOW;
5306 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5307 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305308 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 pMac->readyToExtWoWCallback = NULL;
5310 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305311 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305312 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 }
5314 sme_release_global_lock(&pMac->sme);
5315 } else {
5316 pMac->readyToExtWoWCallback = NULL;
5317 pMac->readyToExtWoWContext = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305318 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 }
5320
5321 return status;
5322}
5323
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305324/*
5325 * sme_configure_app_type1_params() -
5326 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5327 *
5328 * hHal - The handle returned by mac_open.
5329 * wlanAppType1Params- Depicts the wlan App Type 1(Indoor) params
5330 * Return QDF_STATUS
5331 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305332QDF_STATUS sme_configure_app_type1_params(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 tpSirAppType1Params wlanAppType1Params)
5334{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305335 QDF_STATUS status = QDF_STATUS_SUCCESS;
5336 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005338 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305339 tpSirAppType1Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340
5341 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305342 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305344 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1, NO_SESSION,
5346 0));
5347
5348 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305349 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005350 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305351 qdf_mem_copy(MsgPtr, wlanAppType1Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005352 message.bodyptr = MsgPtr;
5353 message.type = WMA_WLAN_SET_APP_TYPE1_PARAMS;
5354 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5355 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305356 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305357 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305358 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 }
5360 sme_release_global_lock(&pMac->sme);
5361 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305362 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363 }
5364
5365 return status;
5366}
5367
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305368/*
5369 * sme_configure_app_type2_params() -
5370 * SME will pass this request to lower mac to configure Indoor WoW parameters.
5371 *
5372 * hHal - The handle returned by mac_open.
5373 * wlanAppType2Params- Depicts the wlan App Type 2 (Outdoor) params
5374 * Return QDF_STATUS
5375 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305376QDF_STATUS sme_configure_app_type2_params(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305377 tpSirAppType2Params wlanAppType2Params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305379 QDF_STATUS status = QDF_STATUS_SUCCESS;
5380 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005382 struct scheduler_msg message = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305383 tpSirAppType2Params MsgPtr = qdf_mem_malloc(sizeof(*MsgPtr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384
5385 if (!MsgPtr)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305386 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305388 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2, NO_SESSION,
5390 0));
5391
5392 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305393 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 /* serialize the req through MC thread */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305395 qdf_mem_copy(MsgPtr, wlanAppType2Params, sizeof(*MsgPtr));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005396 message.bodyptr = MsgPtr;
5397 message.type = WMA_WLAN_SET_APP_TYPE2_PARAMS;
5398 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
5399 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305400 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305401 qdf_mem_free(MsgPtr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305402 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 }
5404 sme_release_global_lock(&pMac->sme);
5405 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_free(MsgPtr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 }
5408
5409 return status;
5410}
5411#endif
5412
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305413/*
5414 * sme_get_infra_session_id
5415 * To get the session ID for infra session, if connected
5416 * This is a synchronous API.
5417 *
5418 * hHal - The handle returned by mac_open.
5419 * sessionid, -1 if infra session is not connected
5420 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421int8_t sme_get_infra_session_id(tHalHandle hHal)
5422{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305423 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 int8_t sessionid = -1;
5425 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5426
5427 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305428 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429
5430 sessionid = csr_get_infra_session_id(pMac);
5431
5432 sme_release_global_lock(&pMac->sme);
5433 }
5434
5435 return sessionid;
5436}
5437
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305438/*
5439 * sme_get_infra_operation_channel() -
5440 * To get the operating channel for infra session, if connected
5441 * This is a synchronous API.
5442 *
5443 * hHal - The handle returned by mac_open.
5444 * sessionId - the sessionId returned by sme_open_session.
5445 * Return operating channel, 0 if infra session is not connected
5446 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447uint8_t sme_get_infra_operation_channel(tHalHandle hHal, uint8_t sessionId)
5448{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305449 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5451 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305454 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455
5456 channel = csr_get_infra_operation_channel(pMac, sessionId);
5457
5458 sme_release_global_lock(&pMac->sme);
5459 }
5460
5461 return channel;
5462}
5463
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305464/* This routine will return poerating channel on which other BSS is operating
5465 * to be used for concurrency mode. If other BSS is not up or not connected it
5466 * will return 0
5467 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468uint8_t sme_get_concurrent_operation_channel(tHalHandle hHal)
5469{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305470 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5472 uint8_t channel = 0;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305473
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305475 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476
5477 channel = csr_get_concurrent_operation_channel(pMac);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305478 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
5479 "%s: Other Concurrent Channel: %d", __func__, channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005480 sme_release_global_lock(&pMac->sme);
5481 }
5482
5483 return channel;
5484}
5485
5486#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5487uint16_t sme_check_concurrent_channel_overlap(tHalHandle hHal, uint16_t sap_ch,
5488 eCsrPhyMode sapPhyMode,
5489 uint8_t cc_switch_mode)
5490{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305491 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5493 uint16_t channel = 0;
5494
5495 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305496 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 channel =
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305498 csr_check_concurrent_channel_overlap(pMac, sap_ch,
5499 sapPhyMode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 cc_switch_mode);
5501 sme_release_global_lock(&pMac->sme);
5502 }
5503
5504 return channel;
5505}
5506#endif
5507
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305508/**
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005509 * sme_set_tsfcb() - Set callback for TSF capture
Manikandan Mohan976e7562016-03-15 16:33:31 -07005510 * @h_hal: Handler return by mac_open
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005511 * @cb_fn: Callback function pointer
5512 * @db_ctx: Callback data
5513 *
5514 * Return: QDF_STATUS
5515 */
Manikandan Mohan976e7562016-03-15 16:33:31 -07005516QDF_STATUS sme_set_tsfcb(tHalHandle h_hal,
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005517 int (*cb_fn)(void *cb_ctx, struct stsf *ptsf), void *cb_ctx)
5518{
Manikandan Mohan976e7562016-03-15 16:33:31 -07005519 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005520 QDF_STATUS status;
5521
Manikandan Mohan976e7562016-03-15 16:33:31 -07005522 status = sme_acquire_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005523 if (QDF_IS_STATUS_SUCCESS(status)) {
Manikandan Mohan976e7562016-03-15 16:33:31 -07005524 mac->sme.get_tsf_cb = cb_fn;
5525 mac->sme.get_tsf_cxt = cb_ctx;
5526 sme_release_global_lock(&mac->sme);
Manikandan Mohandcc21ba2016-03-15 14:31:56 -07005527 }
5528 return status;
5529}
5530
Arun Khandavalli4b55da72016-07-19 19:55:01 +05305531/**
5532 * sme_reset_tsfcb() - Reset callback for TSF capture
5533 * @h_hal: Handler return by mac_open
5534 *
5535 * This function reset the tsf capture callback to SME
5536 *
5537 * Return: QDF_STATUS
5538 */
5539QDF_STATUS sme_reset_tsfcb(tHalHandle h_hal)
5540{
5541 tpAniSirGlobal mac;
5542 QDF_STATUS status;
5543
5544 if (!h_hal) {
5545 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5546 FL("h_hal is not valid"));
5547 return QDF_STATUS_E_INVAL;
5548 }
5549 mac = PMAC_STRUCT(h_hal);
5550
5551 status = sme_acquire_global_lock(&mac->sme);
5552 if (QDF_IS_STATUS_SUCCESS(status)) {
5553 mac->sme.get_tsf_cb = NULL;
5554 mac->sme.get_tsf_cxt = NULL;
5555 sme_release_global_lock(&mac->sme);
5556 }
5557 return status;
5558}
5559
Manikandan Mohan976e7562016-03-15 16:33:31 -07005560#ifdef WLAN_FEATURE_TSF
5561/*
5562 * sme_set_tsf_gpio() - set gpio pin that be toggled when capture tef
5563 * @h_hal: Handler return by mac_open
5564 * @pinvalue: gpio pin id
5565 *
5566 * Return: QDF_STATUS
5567 */
5568QDF_STATUS sme_set_tsf_gpio(tHalHandle h_hal, uint32_t pinvalue)
5569{
5570 QDF_STATUS status;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005571 struct scheduler_msg tsf_msg = {0};
Manikandan Mohan976e7562016-03-15 16:33:31 -07005572 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
5573
5574 status = sme_acquire_global_lock(&mac->sme);
5575 if (QDF_IS_STATUS_SUCCESS(status)) {
5576 tsf_msg.type = WMA_TSF_GPIO_PIN;
5577 tsf_msg.reserved = 0;
5578 tsf_msg.bodyval = pinvalue;
5579
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005580 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &tsf_msg);
Manikandan Mohan976e7562016-03-15 16:33:31 -07005581 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005582 sme_err("Unable to post WMA_TSF_GPIO_PIN");
Manikandan Mohan976e7562016-03-15 16:33:31 -07005583 status = QDF_STATUS_E_FAILURE;
5584 }
5585 sme_release_global_lock(&mac->sme);
5586 }
5587 return status;
5588}
5589#endif
5590
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005591QDF_STATUS sme_get_cfg_valid_channels(uint8_t *aValidChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 uint32_t *len)
5593{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305594 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005595 tpAniSirGlobal mac_ctx = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005597 if (NULL == mac_ctx) {
5598 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
5599 FL("Invalid MAC context"));
5600 return QDF_STATUS_E_FAILURE;
5601 }
5602
5603 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305604 if (QDF_IS_STATUS_SUCCESS(status)) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005605 status = csr_get_cfg_valid_channels(mac_ctx,
5606 aValidChannels, len);
5607 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608 }
5609
5610 return status;
5611}
5612
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005613static uint8_t *sme_reg_hint_to_str(const enum country_src src)
5614{
5615 switch (src) {
5616 case SOURCE_CORE:
5617 return "WORLD MODE";
5618
5619 case SOURCE_DRIVER:
5620 return "BDF file";
5621
5622 case SOURCE_USERSPACE:
5623 return "user-space";
5624
5625 case SOURCE_11D:
5626 return "802.11D IEs in beacons";
5627
5628 default:
5629 return "unknown";
5630 }
5631}
5632
Amar Singhal6edf9732016-11-20 21:43:40 -08005633void sme_set_cc_src(tHalHandle hHal, enum country_src cc_src)
5634{
5635 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
5636
5637 mac_ctx->reg_hint_src = cc_src;
Amar Singhalf0a94ad2017-11-27 15:20:00 -08005638
5639 sme_debug("Country source is %s",
5640 sme_reg_hint_to_str(cc_src));
Amar Singhal6edf9732016-11-20 21:43:40 -08005641}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642
5643/**
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005644 * sme_handle_generic_change_country_code() - handles country ch req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 * @mac_ctx: mac global context
5646 * @msg: request msg packet
5647 *
5648 * If Supplicant country code is priority than 11d is disabled.
5649 * If 11D is enabled, we update the country code after every scan.
5650 * Hence when Supplicant country code is priority, we don't need 11D info.
5651 * Country code from Supplicant is set as current country code.
5652 *
5653 * Return: status of operation
5654 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305655static QDF_STATUS
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005656sme_handle_generic_change_country_code(tpAniSirGlobal mac_ctx,
5657 void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305659 QDF_STATUS status = QDF_STATUS_SUCCESS;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005660 v_REGDOMAIN_t reg_domain_id = 0;
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005661 bool user_ctry_priority =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005662 mac_ctx->roam.configParam.fSupplicantCountryCodeHasPriority;
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005663 tAniGenericChangeCountryCodeReq *msg = pMsgBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664
Amar Singhal6edf9732016-11-20 21:43:40 -08005665 if (SOURCE_11D != mac_ctx->reg_hint_src) {
5666 if (SOURCE_DRIVER != mac_ctx->reg_hint_src) {
5667 if (user_ctry_priority)
5668 mac_ctx->roam.configParam.Is11dSupportEnabled =
5669 false;
5670 else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305671 if (mac_ctx->roam.configParam.
5672 Is11dSupportEnabled &&
5673 mac_ctx->scan.countryCode11d[0] != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005675 sme_debug("restore 11d");
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005676
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305677 status =
5678 csr_get_regulatory_domain_for_country(
Amar Singhal6edf9732016-11-20 21:43:40 -08005679 mac_ctx,
5680 mac_ctx->scan.countryCode11d,
5681 &reg_domain_id,
5682 SOURCE_11D);
5683 return QDF_STATUS_E_FAILURE;
5684 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005685 }
5686 }
5687 } else {
5688 /* if kernel gets invalid country code; it
5689 * resets the country code to world
5690 */
5691 if (('0' != msg->countryCode[0]) ||
5692 ('0' != msg->countryCode[1]))
5693 qdf_mem_copy(mac_ctx->scan.countryCode11d,
5694 msg->countryCode,
5695 WNI_CFG_COUNTRY_CODE_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005696 }
Amar Singhal7f1f3ec2015-10-13 17:14:08 -07005697
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005698 qdf_mem_copy(mac_ctx->scan.countryCodeCurrent,
5699 msg->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 WNI_CFG_COUNTRY_CODE_LEN);
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 /* get the channels based on new cc */
5703 status = csr_get_channel_and_power_list(mac_ctx);
5704
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305705 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005706 sme_err("fail to get Channels");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 return status;
5708 }
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 /* reset info based on new cc, and we are done */
5711 csr_apply_channel_power_info_wrapper(mac_ctx);
5712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 csr_scan_filter_results(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005714
5715 /* scans after the country is set by User hints or
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 * Country IE
5717 */
5718 mac_ctx->scan.curScanType = eSIR_ACTIVE_SCAN;
Amar Singhal9d5b1fe2016-10-16 20:16:05 -07005719
Amar Singhal6edf9732016-11-20 21:43:40 -08005720 mac_ctx->reg_hint_src = SOURCE_UNKNOWN;
5721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722 sme_disconnect_connected_sessions(mac_ctx);
Amar Singhalb6d0dc42016-10-19 09:45:05 -07005723
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725}
5726
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005727QDF_STATUS sme_update_channel_list(tHalHandle hal)
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305728{
Jeff Johnson330c0bf2018-06-01 15:13:12 -07005729 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
5730 QDF_STATUS status;
Mukul Sharmaecf8e092017-12-19 22:36:31 +05305731
5732 status = sme_acquire_global_lock(&mac_ctx->sme);
5733 if (QDF_IS_STATUS_SUCCESS(status)) {
5734 /* Update umac channel (enable/disable) from cds channels */
5735 status = csr_get_channel_and_power_list(mac_ctx);
5736 if (status != QDF_STATUS_SUCCESS) {
5737 sme_err("fail to get Channels");
5738 sme_release_global_lock(&mac_ctx->sme);
5739 return status;
5740 }
5741
5742 csr_apply_channel_power_info_wrapper(mac_ctx);
5743 csr_scan_filter_results(mac_ctx);
5744 sme_disconnect_connected_sessions(mac_ctx);
5745 sme_release_global_lock(&mac_ctx->sme);
5746 }
5747
5748 return status;
5749}
5750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751static bool
5752sme_search_in_base_ch_lst(tpAniSirGlobal mac_ctx, uint8_t curr_ch)
5753{
5754 uint8_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305755 struct csr_channel *ch_lst_info;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757 ch_lst_info = &mac_ctx->scan.base_channels;
5758 for (i = 0; i < ch_lst_info->numChannels; i++) {
5759 if (ch_lst_info->channelList[i] == curr_ch)
5760 return true;
5761 }
5762
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 return false;
5764}
5765/**
5766 * sme_disconnect_connected_sessions() - Disconnect STA and P2P client session
5767 * if channel is not supported
5768 * @mac_ctx: mac global context
5769 *
5770 * If new country code does not support the channel on which STA/P2P client
5771 * is connetced, it sends the disconnect to the AP/P2P GO
5772 *
5773 * Return: void
5774 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305775static void sme_disconnect_connected_sessions(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776{
5777 uint8_t session_id, found = false;
5778 uint8_t curr_ch;
5779
5780 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
5781 if (!csr_is_session_client_and_connected(mac_ctx, session_id))
5782 continue;
5783 found = false;
5784 /* Session is connected.Check the channel */
5785 curr_ch = csr_get_infra_operation_channel(mac_ctx,
5786 session_id);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005787 sme_debug("Current Operating channel : %d, session :%d",
5788 curr_ch, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005789 found = sme_search_in_base_ch_lst(mac_ctx, curr_ch);
5790 if (!found) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07005791 sme_debug("Disconnect Session: %d", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792 csr_roam_disconnect(mac_ctx, session_id,
5793 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5794 }
5795 }
5796}
5797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798#ifdef WLAN_FEATURE_PACKET_FILTERING
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305799QDF_STATUS sme_8023_multicast_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005800 tpSirRcvFltMcAddrList pMulticastAddrs)
5801{
5802 tpSirRcvFltMcAddrList request_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005803 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305805 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
5808 "%s: ulMulticastAddrCnt: %d, multicastAddr[0]: %pK", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 pMulticastAddrs->ulMulticastAddrCnt,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005810 pMulticastAddrs->multicastAddr[0].bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005812 /* Find the connected Infra / P2P_client connected session */
Krunal Sonifea06802017-04-13 14:44:48 -07005813 pSession = CSR_GET_SESSION(pMac, sessionId);
5814 if (!CSR_IS_SESSION_VALID(pMac, sessionId) ||
5815 (!csr_is_conn_state_infra(pMac, sessionId) &&
5816 !csr_is_ndi_started(pMac, sessionId))) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05305817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08005818 "%s: Unable to find the session Id: %d", __func__,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305820 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 }
5822
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305823 request_buf = qdf_mem_malloc(sizeof(tSirRcvFltMcAddrList));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305825 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305826 "%s: Not able to allocate memory for 8023 Multicast List request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305828 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829 }
5830
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005831 if (!csr_is_conn_state_connected_infra(pMac, sessionId) &&
5832 !csr_is_ndi_started(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305833 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Ravi Joshi4f447cb2016-07-19 13:42:01 -07005834 "%s: Request ignored, session %d is not connected or started",
5835 __func__, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305836 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305837 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 }
5839
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305840 qdf_mem_copy(request_buf, pMulticastAddrs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 sizeof(tSirRcvFltMcAddrList));
5842
Anurag Chouhanc5548422016-02-24 18:33:27 +05305843 qdf_copy_macaddr(&request_buf->self_macaddr, &pSession->selfMacAddr);
5844 qdf_copy_macaddr(&request_buf->bssid,
Srinivas Girigowda98530492015-11-20 17:39:24 -08005845 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846
5847 msg.type = WMA_8023_MULTICAST_LIST_REQ;
5848 msg.reserved = 0;
5849 msg.bodyptr = request_buf;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305850 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5851 sessionId, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005852 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005853 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305854 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305855 "%s: Not able to post WMA_8023_MULTICAST_LIST message to WMA",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305857 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305858 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 }
5860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863#endif /* WLAN_FEATURE_PACKET_FILTERING */
5864
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305865/*
5866 * sme_is_channel_valid() -
5867 * To check if the channel is valid for currently established domain
5868 * This is a synchronous API.
5869 *
5870 * hHal - The handle returned by mac_open.
5871 * channel - channel to verify
5872 * Return true/false, true if channel is valid
5873 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874bool sme_is_channel_valid(tHalHandle hHal, uint8_t channel)
5875{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305876 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005877 bool valid = false;
5878 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5879
5880 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305881 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005882
5883 valid = csr_roam_is_channel_valid(pMac, channel);
5884
5885 sme_release_global_lock(&pMac->sme);
5886 }
5887
5888 return valid;
5889}
5890
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305891/*
5892 * sme_set_freq_band() -
5893 * Used to set frequency band.
5894 *
5895 * hHal
5896 * sessionId - Session Identifier
5897 * band value to be configured
5898 * Return QDF_STATUS
5899 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005900QDF_STATUS sme_set_freq_band(tHalHandle hHal, uint8_t sessionId,
5901 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005902{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305903 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5905
5906 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305907 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 status = csr_set_band(hHal, sessionId, eBand);
5909 sme_release_global_lock(&pMac->sme);
5910 }
5911 return status;
5912}
5913
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305914/*
5915 * sme_get_freq_band() -
5916 * Used to get the current band settings.
5917 *
5918 * hHal
5919 * pBand pointer to hold band value
5920 * Return QDF_STATUS
5921 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005922QDF_STATUS sme_get_freq_band(tHalHandle hHal, enum band_info *pBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305924 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
5926
5927 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305928 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 *pBand = csr_get_current_band(hHal);
5930 sme_release_global_lock(&pMac->sme);
5931 }
5932 return status;
5933}
5934
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305935/*
5936 * sme_set_max_tx_power_per_band() -
5937 * Set the Maximum Transmit Power specific to band dynamically.
5938 * Note: this setting will not persist over reboots.
5939 *
5940 * band
5941 * power to set in dB
5942 * Return QDF_STATUS
5943 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005944QDF_STATUS sme_set_max_tx_power_per_band(enum band_info band, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005946 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947 tpMaxTxPowerPerBandParams pMaxTxPowerPerBandParams = NULL;
5948
5949 pMaxTxPowerPerBandParams =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305950 qdf_mem_malloc(sizeof(tMaxTxPowerPerBandParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 if (NULL == pMaxTxPowerPerBandParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305952 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 "%s:Not able to allocate memory for pMaxTxPowerPerBandParams",
5954 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305955 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 }
5957
5958 pMaxTxPowerPerBandParams->power = dB;
5959 pMaxTxPowerPerBandParams->bandInfo = band;
5960
5961 msg.type = WMA_SET_MAX_TX_POWER_PER_BAND_REQ;
5962 msg.reserved = 0;
5963 msg.bodyptr = pMaxTxPowerPerBandParams;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05305964 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
5965 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08005966 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08005967 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305968 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 "%s:Not able to post WMA_SET_MAX_TX_POWER_PER_BAND_REQ",
5970 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305971 qdf_mem_free(pMaxTxPowerPerBandParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305972 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 }
5974
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305975 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976}
5977
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05305978/*
5979 * sme_set_max_tx_power() -
5980 * Set the Maximum Transmit Power dynamically. Note: this setting will
5981 * not persist over reboots.
5982 *
5983 * hHal
5984 * pBssid BSSID to set the power cap for
5985 * pBssid pSelfMacAddress self MAC Address
5986 * pBssid power to set in dB
5987 * Return QDF_STATUS
5988 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05305989QDF_STATUS sme_set_max_tx_power(tHalHandle hHal, struct qdf_mac_addr pBssid,
5990 struct qdf_mac_addr pSelfMacAddress, int8_t dB)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07005992 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 tpMaxTxPowerParams pMaxTxParams = NULL;
5994
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305995 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW, NO_SESSION, 0));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305997 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 if (NULL == pMaxTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305999 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006000 "%s: Not able to allocate memory for pMaxTxParams",
6001 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306002 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 }
6004
Anurag Chouhanc5548422016-02-24 18:33:27 +05306005 qdf_copy_macaddr(&pMaxTxParams->bssId, &pBssid);
6006 qdf_copy_macaddr(&pMaxTxParams->selfStaMacAddr, &pSelfMacAddress);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 pMaxTxParams->power = dB;
6008
6009 msg.type = WMA_SET_MAX_TX_POWER_REQ;
6010 msg.reserved = 0;
6011 msg.bodyptr = pMaxTxParams;
6012
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006013 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006014 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 "%s: Not able to post WMA_SET_MAX_TX_POWER_REQ message to WMA",
6017 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306018 qdf_mem_free(pMaxTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306019 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020 }
6021
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306022 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023}
6024
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306025/*
6026 * sme_set_custom_mac_addr() -
6027 * Set the customer Mac Address.
6028 *
6029 * customMacAddr customer MAC Address
6030 * Return QDF_STATUS
6031 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306032QDF_STATUS sme_set_custom_mac_addr(tSirMacAddr customMacAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006034 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006035 tSirMacAddr *pBaseMacAddr;
6036
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306037 pBaseMacAddr = qdf_mem_malloc(sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038 if (NULL == pBaseMacAddr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306039 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 FL("Not able to allocate memory for pBaseMacAddr"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306041 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042 }
6043
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306044 qdf_mem_copy(*pBaseMacAddr, customMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045
6046 msg.type = SIR_HAL_SET_BASE_MACADDR_IND;
6047 msg.reserved = 0;
6048 msg.bodyptr = pBaseMacAddr;
6049
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006050 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006051 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306052 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306053 "Not able to post SIR_HAL_SET_BASE_MACADDR_IND message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306054 qdf_mem_free(pBaseMacAddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306055 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 }
6057
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306058 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059}
6060
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306061/*
6062 * sme_set_tx_power() -
6063 * Set Transmit Power dynamically.
6064 *
6065 * hHal
6066 * sessionId Target Session ID
6067 * BSSID
6068 * dev_mode dev_mode such as station, P2PGO, SAP
6069 * dBm power to set
6070 * Return QDF_STATUS
6071 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306072QDF_STATUS sme_set_tx_power(tHalHandle hHal, uint8_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306073 struct qdf_mac_addr pBSSId,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08006074 enum QDF_OPMODE dev_mode, int dBm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006076 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 tpMaxTxPowerParams pTxParams = NULL;
6078 int8_t power = (int8_t) dBm;
6079
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306080 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 TRACE_CODE_SME_RX_HDD_SET_TXPOW, sessionId, 0));
6082
6083 /* make sure there is no overflow */
6084 if ((int)power != dBm) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306085 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086 "%s: error, invalid power = %d", __func__, dBm);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306087 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 }
6089
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306090 pTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 if (NULL == pTxParams) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306092 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006093 "%s: Not able to allocate memory for pTxParams",
6094 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306095 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 }
6097
Anurag Chouhanc5548422016-02-24 18:33:27 +05306098 qdf_copy_macaddr(&pTxParams->bssId, &pBSSId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 pTxParams->power = power; /* unit is dBm */
6100 pTxParams->dev_mode = dev_mode;
6101 msg.type = WMA_SET_TX_POWER_REQ;
6102 msg.reserved = 0;
6103 msg.bodyptr = pTxParams;
6104
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006105 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08006106 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306107 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 "%s: failed to post WMA_SET_TX_POWER_REQ to WMA",
6109 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306110 qdf_mem_free(pTxParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306111 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 }
6113
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306114 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006115}
6116
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05306117QDF_STATUS sme_update_fils_setting(tHalHandle hal, uint8_t session_id,
6118 uint8_t param_val)
6119{
6120 QDF_STATUS status;
6121 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
6122
6123 pMac->roam.configParam.is_fils_enabled = !param_val;
6124
6125 pMac->roam.configParam.enable_bcast_probe_rsp = !param_val;
6126 status = wma_cli_set_command((int)session_id,
6127 (int)WMI_VDEV_PARAM_ENABLE_BCAST_PROBE_RESPONSE,
6128 !param_val, VDEV_CMD);
6129 if (status)
6130 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6131 "%s: Failed to set enable bcast probe setting",
6132 __func__);
6133
6134 return status;
6135}
6136
6137QDF_STATUS sme_update_session_param(tHalHandle hal, uint8_t session_id,
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306138 uint32_t param_type, uint32_t param_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306140 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306141 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 uint16_t len;
6143
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306144 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306145 if (QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306146 struct sir_update_session_param *msg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306147 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx,
6148 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306150 if (!session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006151 sme_err("Session: %d not found", session_id);
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306152 sme_release_global_lock(&mac_ctx->sme);
6153 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006154 }
6155
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +05306156 if (param_type == SIR_PARAM_IGNORE_ASSOC_DISALLOWED)
6157 mac_ctx->ignore_assoc_disallowed = param_val;
6158
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306159 if (!session->sessionActive)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306160 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006161
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306162 len = sizeof(*msg);
6163 msg = qdf_mem_malloc(len);
6164 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306165 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 else {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306167 msg->message_type = eWNI_SME_SESSION_UPDATE_PARAM;
6168 msg->length = len;
6169 msg->session_id = session_id;
6170 msg->param_type = param_type;
6171 msg->param_val = param_val;
Rajeev Kumard138ac52017-01-30 18:38:37 -08006172 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006173 }
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05306174 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006175 }
6176 return status;
6177}
6178
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306179/*
6180 * sme_set_tm_level() -
6181 * Set Thermal Mitigation Level to RIVA
6182 *
6183 * hHal - The handle returned by mac_open.
6184 * newTMLevel - new Thermal Mitigation Level
6185 * tmMode - Thermal Mitigation handle mode, default 0
6186 * Return QDF_STATUS
6187 */
6188QDF_STATUS sme_set_tm_level(tHalHandle hHal, uint16_t newTMLevel, uint16_t
6189 tmMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306191 QDF_STATUS status = QDF_STATUS_SUCCESS;
6192 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006193 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006194 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006195 tAniSetTmLevelReq *setTmLevelReq = NULL;
6196
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306197 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 TRACE_CODE_SME_RX_HDD_SET_TMLEVEL, NO_SESSION, 0));
6199 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306200 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 setTmLevelReq =
6202 (tAniSetTmLevelReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306203 qdf_mem_malloc(sizeof(tAniSetTmLevelReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 if (NULL == setTmLevelReq) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306205 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206 "%s: Not able to allocate memory for sme_set_tm_level",
6207 __func__);
6208 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306209 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 }
6211
6212 setTmLevelReq->tmMode = tmMode;
6213 setTmLevelReq->newTmLevel = newTMLevel;
6214
6215 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006216 message.bodyptr = setTmLevelReq;
6217 message.type = WMA_SET_TM_LEVEL_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05306218 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006219 NO_SESSION, message.type));
6220 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
6221 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306222 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306223 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006224 "%s: Post Set TM Level MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306225 qdf_mem_free(setTmLevelReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306226 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 }
6228 sme_release_global_lock(&pMac->sme);
6229 }
6230 return status;
6231}
6232
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306233/*
6234 * sme_feature_caps_exchange() - SME interface to exchange capabilities between
6235 * Host and FW.
6236 *
6237 * hHal - HAL handle for device
6238 * Return NONE
6239 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240void sme_feature_caps_exchange(tHalHandle hHal)
6241{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306242 MTRACE(qdf_trace
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306243 (QDF_MODULE_ID_SME, TRACE_CODE_SME_RX_HDD_CAPS_EXCH,
6244 NO_SESSION, 0));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006245}
6246
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306247/*
6248 * sme_disable_feature_capablity() - SME interface to disable Active mode
6249 * offload capablity in Host.
6250 *
6251 * hHal - HAL handle for device
6252 * Return NONE
6253 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006254void sme_disable_feature_capablity(uint8_t feature_index)
6255{
6256}
6257
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306258/*
6259 * sme_reset_power_values_for5_g
6260 * Reset the power values for 5G band with default power values.
6261 *
6262 * hHal - HAL handle for device
6263 * Return NONE
6264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265void sme_reset_power_values_for5_g(tHalHandle hHal)
6266{
6267 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306268
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306269 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 TRACE_CODE_SME_RX_HDD_RESET_PW5G, NO_SESSION, 0));
6271 csr_save_channel_power_for_band(pMac, true);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306272 /* Store the channel+power info in the global place: Cfg */
6273 csr_apply_power2_current(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274}
6275
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306276/*
6277 * sme_update_roam_prefer5_g_hz() -
6278 * Enable/disable Roam prefer 5G runtime option
6279 * This function is called through dynamic setConfig callback function
6280 * to configure the Roam prefer 5G runtime option
6281 *
6282 * hHal - HAL handle for device
6283 * nRoamPrefer5GHz Enable/Disable Roam prefer 5G runtime option
6284 * Return Success or failure
6285 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306287QDF_STATUS sme_update_roam_prefer5_g_hz(tHalHandle hHal,
6288 bool nRoamPrefer5GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006289{
6290 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306291 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306293 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 TRACE_CODE_SME_RX_HDD_UPDATE_RP5G, NO_SESSION, 0));
6295 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306296 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306297 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006298 "%s: gRoamPrefer5GHz is changed from %d to %d",
6299 __func__, pMac->roam.configParam.nRoamPrefer5GHz,
6300 nRoamPrefer5GHz);
6301 pMac->roam.configParam.nRoamPrefer5GHz = nRoamPrefer5GHz;
6302 sme_release_global_lock(&pMac->sme);
6303 }
6304
6305 return status;
6306}
6307
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306308/*
6309 * sme_set_roam_intra_band() -
6310 * enable/disable Intra band roaming
6311 * This function is called through dynamic setConfig callback function
6312 * to configure the intra band roaming
6313 * hHal - HAL handle for device
6314 * nRoamIntraBand Enable/Disable Intra band roaming
6315 * Return Success or failure
6316 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306317QDF_STATUS sme_set_roam_intra_band(tHalHandle hHal, const bool nRoamIntraBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006318{
6319 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306320 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006321
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306322 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323 TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND, NO_SESSION, 0));
6324 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306325 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 "%s: gRoamIntraBand is changed from %d to %d",
6328 __func__, pMac->roam.configParam.nRoamIntraBand,
6329 nRoamIntraBand);
6330 pMac->roam.configParam.nRoamIntraBand = nRoamIntraBand;
6331 sme_release_global_lock(&pMac->sme);
6332 }
6333
6334 return status;
6335}
6336
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306337/*
6338 * sme_update_roam_scan_n_probes() -
6339 * Function to update roam scan N probes
6340 * This function is called through dynamic setConfig callback function
6341 * to update roam scan N probes
6342 * hHal - HAL handle for device
6343 * sessionId - Session Identifier
6344 * nProbes number of probe requests to be sent out
6345 * Return Success or failure
6346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306347QDF_STATUS sme_update_roam_scan_n_probes(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006348 const uint8_t nProbes)
6349{
6350 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306351 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306353 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006354 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES,
6355 NO_SESSION, 0));
6356 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306357 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306358 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 "%s: gRoamScanNProbes is changed from %d to %d",
6360 __func__, pMac->roam.configParam.nProbes, nProbes);
6361 pMac->roam.configParam.nProbes = nProbes;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306362
6363 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6364 csr_roam_offload_scan(pMac, sessionId,
6365 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6366 REASON_NPROBES_CHANGED);
6367 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006368 sme_release_global_lock(&pMac->sme);
6369 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006370 return status;
6371}
6372
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306373/*
6374 * sme_update_roam_scan_home_away_time() -
6375 * Function to update roam scan Home away time
6376 * This function is called through dynamic setConfig callback function
6377 * to update roam scan home away time
6378 *
6379 * hHal - HAL handle for device
6380 * sessionId - Session Identifier
6381 * nRoamScanAwayTime Scan home away time
6382 * bSendOffloadCmd If true then send offload command to firmware
6383 * If false then command is not sent to firmware
6384 * Return Success or failure
6385 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306386QDF_STATUS sme_update_roam_scan_home_away_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006387 uint8_t sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306388 const uint16_t nRoamScanHomeAwayTime,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006389 const bool bSendOffloadCmd)
6390{
6391 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306392 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006393
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306394 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006395 TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME,
6396 NO_SESSION, 0));
6397 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306398 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306399 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 "%s: gRoamScanHomeAwayTime is changed from %d to %d",
6401 __func__,
6402 pMac->roam.configParam.nRoamScanHomeAwayTime,
6403 nRoamScanHomeAwayTime);
6404 pMac->roam.configParam.nRoamScanHomeAwayTime =
6405 nRoamScanHomeAwayTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306406
6407 if (pMac->roam.configParam.isRoamOffloadScanEnabled &&
6408 bSendOffloadCmd) {
6409 csr_roam_offload_scan(pMac, sessionId,
6410 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6411 REASON_HOME_AWAY_TIME_CHANGED);
6412 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006413 sme_release_global_lock(&pMac->sme);
6414 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006415 return status;
6416}
6417
Abhishek Singh518323d2015-10-19 17:42:01 +05306418/**
6419 * sme_ext_change_channel()- function to post send ECSA
6420 * action frame to csr.
6421 * @hHal: Hal context
6422 * @channel: new channel to switch
6423 * @session_id: senssion it should be sent on.
6424 *
6425 * This function is called to post ECSA frame to csr.
6426 *
6427 * Return: success if msg is sent else return failure
6428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306429QDF_STATUS sme_ext_change_channel(tHalHandle h_hal, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +05306430 uint8_t session_id)
6431{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306432 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05306433 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
6434 uint8_t channel_state;
6435
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006436 sme_err("Set Channel: %d", channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306437 channel_state =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07006438 wlan_reg_get_channel_state(mac_ctx->pdev, channel);
Abhishek Singh518323d2015-10-19 17:42:01 +05306439
6440 if (CHANNEL_STATE_DISABLE == channel_state) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006441 sme_err("Invalid channel: %d", channel);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306442 return QDF_STATUS_E_INVAL;
Abhishek Singh518323d2015-10-19 17:42:01 +05306443 }
6444
6445 status = sme_acquire_global_lock(&mac_ctx->sme);
6446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306447 if (QDF_STATUS_SUCCESS == status) {
Abhishek Singh518323d2015-10-19 17:42:01 +05306448 /* update the channel list to the firmware */
6449 status = csr_send_ext_change_channel(mac_ctx,
6450 channel, session_id);
6451 sme_release_global_lock(&mac_ctx->sme);
6452 }
6453
6454 return status;
6455}
6456
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306457/*
6458 * sme_get_roam_intra_band() -
6459 * get Intra band roaming
6460 *
6461 * hHal - HAL handle for device
6462 * Return Success or failure
6463 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006464bool sme_get_roam_intra_band(tHalHandle hHal)
6465{
6466 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306467
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306468 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469 TRACE_CODE_SME_RX_HDD_GET_ROAMIBAND, NO_SESSION, 0));
6470 return pMac->roam.configParam.nRoamIntraBand;
6471}
6472
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306473/*
6474 * sme_get_roam_scan_n_probes() -
6475 * get N Probes
6476 *
6477 * hHal - HAL handle for device
6478 * Return Success or failure
6479 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480uint8_t sme_get_roam_scan_n_probes(tHalHandle hHal)
6481{
6482 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484 return pMac->roam.configParam.nProbes;
6485}
6486
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306487/*
6488 * sme_get_roam_scan_home_away_time() -
6489 * get Roam scan home away time
6490 *
6491 * hHal - HAL handle for device
6492 * Return Success or failure
6493 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006494uint16_t sme_get_roam_scan_home_away_time(tHalHandle hHal)
6495{
6496 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006498 return pMac->roam.configParam.nRoamScanHomeAwayTime;
6499}
6500
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306501/*
6502 * sme_update_roam_rssi_diff() -
6503 * Update RoamRssiDiff
6504 * This function is called through dynamic setConfig callback function
6505 * to configure RoamRssiDiff
6506 * Usage: adb shell iwpriv wlan0 setConfig RoamRssiDiff=[0 .. 125]
6507 *
6508 * hHal - HAL handle for device
6509 * sessionId - Session Identifier
6510 * RoamRssiDiff - minimum rssi difference between potential
6511 * candidate and current AP.
6512 * Return Success or failure
6513 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306515QDF_STATUS sme_update_roam_rssi_diff(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006516 uint8_t RoamRssiDiff)
6517{
6518 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306519 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006520
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006521 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6522 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6523 FL("Invalid sme session id: %d"), sessionId);
6524 return QDF_STATUS_E_INVAL;
6525 }
6526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006527 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306528 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306529 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530 "LFR runtime successfully set roam rssi diff to %d - old value is %d - roam state is %s",
6531 RoamRssiDiff,
6532 pMac->roam.configParam.RoamRssiDiff,
6533 mac_trace_get_neighbour_roam_state(pMac->roam.
6534 neighborRoamInfo
6535 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306536 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006537 pMac->roam.configParam.RoamRssiDiff = RoamRssiDiff;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306538
6539 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
6540 csr_roam_offload_scan(pMac, sessionId,
6541 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6542 REASON_RSSI_DIFF_CHANGED);
6543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006544 sme_release_global_lock(&pMac->sme);
6545 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006546 return status;
6547}
6548
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306549#ifdef WLAN_FEATURE_FILS_SK
6550QDF_STATUS sme_update_fils_config(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006551 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306552{
6553 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6554 QDF_STATUS status = QDF_STATUS_SUCCESS;
6555 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6556 &mac->roam.neighborRoamInfo[session_id];
6557
6558 if (session_id >= CSR_ROAM_SESSION_MAX) {
6559 sme_err("Invalid sme session id: %d", session_id);
6560 return QDF_STATUS_E_INVAL;
6561 }
6562
6563 if (!src_profile) {
6564 sme_err("src roam profile NULL");
6565 return QDF_STATUS_E_INVAL;
6566 }
6567
6568 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6569 (neighbor_roam_info->neighborRoamState !=
6570 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6571 sme_info("Fast roam is disabled or not connected(%d)",
6572 neighbor_roam_info->neighborRoamState);
6573 return QDF_STATUS_E_PERM;
6574 }
6575
6576 csr_update_fils_config(mac, session_id, src_profile);
Sridhar Selvaraje5260442017-08-19 10:12:03 +05306577 if (csr_roamIsRoamOffloadEnabled(mac)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05306578 status = sme_acquire_global_lock(&mac->sme);
6579 if (QDF_IS_STATUS_SUCCESS(status)) {
6580 sme_debug("Updating fils config to fw");
6581 csr_roam_offload_scan(mac, session_id,
6582 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6583 REASON_FILS_PARAMS_CHANGED);
6584 sme_release_global_lock(&mac->sme);
6585 } else {
6586 sme_err("Failed to acquire SME lock");
6587 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306588 } else {
6589 sme_info("LFR3 not enabled");
6590 return QDF_STATUS_E_INVAL;
6591 }
6592
6593 return status;
6594}
6595
6596void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006597 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306598{
6599 int i;
6600 struct scheduler_msg msg;
6601 QDF_STATUS status;
6602 struct hlp_params *params;
6603 tpAniSirGlobal mac = PMAC_STRUCT(hal);
6604 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
6605 tpCsrNeighborRoamControlInfo neighbor_roam_info =
6606 &mac->roam.neighborRoamInfo[session_id];
6607
6608 if (!session) {
6609 sme_err("session NULL");
6610 return;
6611 }
6612
6613 if (!mac->roam.configParam.isFastRoamIniFeatureEnabled ||
6614 (neighbor_roam_info->neighborRoamState !=
6615 eCSR_NEIGHBOR_ROAM_STATE_CONNECTED)) {
6616 sme_debug("Fast roam is disabled or not connected(%d)",
6617 neighbor_roam_info->neighborRoamState);
6618 return;
6619 }
6620
6621 params = qdf_mem_malloc(sizeof(*params));
6622 if (!params) {
6623 sme_err("Mem alloc for HLP IE fails");
6624 return;
6625 }
6626 if ((profile->hlp_ie_len +
6627 SIR_IPV4_ADDR_LEN) > FILS_MAX_HLP_DATA_LEN) {
6628 sme_err("HLP IE len exceeds %d",
6629 profile->hlp_ie_len);
6630 qdf_mem_free(params);
6631 return;
6632 }
6633
6634 params->vdev_id = session_id;
6635 params->hlp_ie_len = profile->hlp_ie_len + SIR_IPV4_ADDR_LEN;
6636
6637 for (i = 0; i < SIR_IPV4_ADDR_LEN; i++)
6638 params->hlp_ie[i] = (if_addr >> (i * 8)) & 0xFF;
6639
6640 qdf_mem_copy(params->hlp_ie + SIR_IPV4_ADDR_LEN,
6641 profile->hlp_ie, profile->hlp_ie_len);
6642
6643 msg.type = SIR_HAL_HLP_IE_INFO;
6644 msg.reserved = 0;
6645 msg.bodyptr = params;
6646 status = sme_acquire_global_lock(&mac->sme);
6647 if (status != QDF_STATUS_SUCCESS) {
6648 sme_err("sme lock acquire fails");
6649 qdf_mem_free(params);
6650 return;
6651 }
6652
6653 if (!QDF_IS_STATUS_SUCCESS
6654 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
6655 sme_err("Not able to post WMA_HLP_IE_INFO message to HAL");
6656 sme_release_global_lock(&mac->sme);
6657 qdf_mem_free(params);
6658 return;
6659 }
6660
6661 sme_release_global_lock(&mac->sme);
6662}
6663
Jeff Johnson172237b2017-11-07 15:32:59 -08006664void sme_free_join_rsp_fils_params(struct csr_roam_info *roam_info)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306665{
6666 struct fils_join_rsp_params *roam_fils_params;
6667
6668 if (!roam_info) {
6669 sme_err("FILS Roam Info NULL");
6670 return;
6671 }
6672
6673 roam_fils_params = roam_info->fils_join_rsp;
6674 if (!roam_fils_params) {
6675 sme_err("FILS Roam Param NULL");
6676 return;
6677 }
6678
6679 if (roam_fils_params->fils_pmk)
6680 qdf_mem_free(roam_fils_params->fils_pmk);
6681
6682 qdf_mem_free(roam_fils_params);
6683
6684 roam_info->fils_join_rsp = NULL;
6685}
6686
6687#else
6688inline void sme_send_hlp_ie_info(tHalHandle hal, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006689 struct csr_roam_profile *profile, uint32_t if_addr)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05306690{}
6691#endif
6692
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306693/*
6694 * sme_update_fast_transition_enabled() - enable/disable Fast Transition
6695 * support at runtime
6696 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6697 * isFastTransitionEnabled.
6698 * This is a synchronous call
6699 *
6700 * hHal - The handle returned by mac_open.
6701 * Return QDF_STATUS_SUCCESS - SME update isFastTransitionEnabled config
6702 * successfully.
6703 * Other status means SME is failed to update isFastTransitionEnabled.
6704 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306705QDF_STATUS sme_update_fast_transition_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006706 bool isFastTransitionEnabled)
6707{
6708 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306709 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306711 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006712 TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED, NO_SESSION,
6713 0));
6714 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306715 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306716 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717 "%s: FastTransitionEnabled is changed from %d to %d",
6718 __func__,
6719 pMac->roam.configParam.isFastTransitionEnabled,
6720 isFastTransitionEnabled);
6721 pMac->roam.configParam.isFastTransitionEnabled =
6722 isFastTransitionEnabled;
6723 sme_release_global_lock(&pMac->sme);
6724 }
6725
6726 return status;
6727}
6728
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306729/*
6730 * sme_update_wes_mode() -
6731 * Update WES Mode
6732 * This function is called through dynamic setConfig callback function
6733 * to configure isWESModeEnabled
6734 *
6735 * hHal - HAL handle for device
6736 * isWESModeEnabled - WES mode
6737 * sessionId - Session Identifier
6738 * Return QDF_STATUS_SUCCESS - SME update isWESModeEnabled config successfully.
6739 * Other status means SME is failed to update isWESModeEnabled.
6740 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006741
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306742QDF_STATUS sme_update_wes_mode(tHalHandle hHal, bool isWESModeEnabled,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006743 uint8_t sessionId)
6744{
6745 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306746 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006748 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6749 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6750 FL("Invalid sme session id: %d"), sessionId);
6751 return QDF_STATUS_E_INVAL;
6752 }
6753
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006754 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306755 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306756 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006757 "LFR runtime successfully set WES Mode to %d - old value is %d - roam state is %s",
6758 isWESModeEnabled,
6759 pMac->roam.configParam.isWESModeEnabled,
6760 mac_trace_get_neighbour_roam_state(pMac->roam.
6761 neighborRoamInfo
6762 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306763 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006764 pMac->roam.configParam.isWESModeEnabled = isWESModeEnabled;
6765 sme_release_global_lock(&pMac->sme);
6766 }
6767
6768 return status;
6769}
6770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306771/*
6772 * sme_set_roam_scan_control() -
6773 * Set roam scan control
6774 * This function is called to set roam scan control
6775 * if roam scan control is set to 0, roaming scan cache is cleared
6776 * any value other than 0 is treated as invalid value
6777 * hHal - HAL handle for device
6778 * sessionId - Session Identifier
6779 * Return QDF_STATUS_SUCCESS - SME update config successfully.
6780 * Other status means SME failure to update
6781 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306782QDF_STATUS sme_set_roam_scan_control(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 bool roamScanControl)
6784{
6785 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306786 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006787
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306788 MTRACE(qdf_trace(QDF_MODULE_ID_SME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006789 TRACE_CODE_SME_RX_HDD_SET_SCANCTRL, NO_SESSION, 0));
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08006790
6791 if (sessionId >= CSR_ROAM_SESSION_MAX) {
6792 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
6793 FL("Invalid sme session id: %d"), sessionId);
6794 return QDF_STATUS_E_INVAL;
6795 }
6796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006797 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306798 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306799 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006800 "LFR runtime successfully set roam scan control to %d - old value is %d - roam state is %s",
6801 roamScanControl,
6802 pMac->roam.configParam.nRoamScanControl,
6803 mac_trace_get_neighbour_roam_state(pMac->roam.
6804 neighborRoamInfo
6805 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306806 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006807 pMac->roam.configParam.nRoamScanControl = roamScanControl;
6808 if (0 == roamScanControl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306809 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810 "LFR runtime successfully cleared roam scan cache");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306811 csr_flush_cfg_bg_scan_roam_channel_list(pMac,
6812 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006813 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
6814 csr_roam_offload_scan(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306815 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
6816 REASON_FLUSH_CHANNEL_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006817 }
6818 }
6819 sme_release_global_lock(&pMac->sme);
6820 }
6821 return status;
6822}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306824/*
6825 * sme_update_is_fast_roam_ini_feature_enabled() - enable/disable LFR
6826 * support at runtime
6827 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6828 * isFastRoamIniFeatureEnabled.
6829 * This is a synchronous call
6830 *
6831 * hHal - The handle returned by mac_open.
6832 * sessionId - Session Identifier
6833 * Return QDF_STATUS_SUCCESS - SME update isFastRoamIniFeatureEnabled config
6834 * successfully.
6835 * Other status means SME is failed to update isFastRoamIniFeatureEnabled.
6836 */
6837QDF_STATUS sme_update_is_fast_roam_ini_feature_enabled(tHalHandle hHal,
6838 uint8_t sessionId, const bool isFastRoamIniFeatureEnabled)
6839{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006840 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
6841
6842 if (pMac->roam.configParam.isFastRoamIniFeatureEnabled ==
6843 isFastRoamIniFeatureEnabled) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306844 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 "%s: FastRoam is already enabled or disabled, nothing to do (returning) old(%d) new(%d)",
6846 __func__,
6847 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6848 isFastRoamIniFeatureEnabled);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306849 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006850 }
6851
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306852 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853 "%s: FastRoamEnabled is changed from %d to %d", __func__,
6854 pMac->roam.configParam.isFastRoamIniFeatureEnabled,
6855 isFastRoamIniFeatureEnabled);
6856 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
6857 isFastRoamIniFeatureEnabled;
6858 csr_neighbor_roam_update_fast_roaming_enabled(pMac, sessionId,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306859 isFastRoamIniFeatureEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006860
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862}
6863
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306864/**
6865 * sme_config_fast_roaming() - enable/disable LFR support at runtime
6866 * @hal - The handle returned by macOpen.
6867 * @session_id - Session Identifier
6868 * @is_fast_roam_enabled - flag to enable/disable roaming
6869 *
6870 * When Supplicant issues enabled/disable fast roaming on the basis
6871 * of the Bssid modification in network block (e.g. AutoJoin mode N/W block)
6872 *
6873 * Return: QDF_STATUS
6874 */
6875
6876QDF_STATUS sme_config_fast_roaming(tHalHandle hal, uint8_t session_id,
6877 const bool is_fast_roam_enabled)
6878{
6879 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306880 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306881 QDF_STATUS status;
6882
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006883 /*
6884 * supplicant_disabled_roaming flag is set to true in
6885 * wlan_hdd_cfg80211_connect_start when supplicant initiate connect
6886 * request with BSSID. This flag is reset when supplicant sends
6887 * vendor command to enable roaming after association.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006888 *
6889 * This request from wpa_supplicant will be skipped in this function
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006890 * if roaming is disabled using driver command or INI and
6891 * supplicant_disabled_roaming flag remains set. So make sure to set
6892 * supplicant_disabled_roaming flag as per wpa_supplicant even if roam
6893 * request from wpa_supplicant ignored.
Arif Hussaina48a9c02017-01-31 14:37:45 -08006894 */
6895 if (session && session->pCurRoamProfile)
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006896 session->pCurRoamProfile->supplicant_disabled_roaming =
6897 !is_fast_roam_enabled;
Arif Hussaina48a9c02017-01-31 14:37:45 -08006898
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306899 if (!mac_ctx->roam.configParam.isFastRoamIniFeatureEnabled) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006900 sme_debug("Fast roam is disabled through ini");
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306901 if (!is_fast_roam_enabled)
6902 return QDF_STATUS_SUCCESS;
6903 return QDF_STATUS_E_FAILURE;
6904 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05306905
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306906 status = csr_neighbor_roam_update_fast_roaming_enabled(mac_ctx,
6907 session_id, is_fast_roam_enabled);
6908 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07006909 sme_err("update fast roaming failed. status: %d", status);
Mukul Sharma69c44cd2016-09-12 18:33:57 +05306910 return QDF_STATUS_E_FAILURE;
6911 }
6912
6913 return QDF_STATUS_SUCCESS;
6914}
6915
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05306916/*
6917 * sme_update_is_mawc_ini_feature_enabled() -
6918 * Enable/disable LFR MAWC support at runtime
6919 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
6920 * isMAWCIniFeatureEnabled.
6921 * This is a synchronous call
6922 *
6923 * hHal - The handle returned by mac_open.
6924 * Return QDF_STATUS_SUCCESS - SME update MAWCEnabled config successfully.
6925 * Other status means SME is failed to update MAWCEnabled.
6926 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306927QDF_STATUS sme_update_is_mawc_ini_feature_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006928 const bool MAWCEnabled)
6929{
6930 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306931 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006932
6933 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306934 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05306935 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006936 "%s: MAWCEnabled is changed from %d to %d", __func__,
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07006937 pMac->roam.configParam.csr_mawc_config.mawc_enabled,
6938 MAWCEnabled);
6939 pMac->roam.configParam.csr_mawc_config.mawc_enabled =
6940 MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 sme_release_global_lock(&pMac->sme);
6942 }
6943
6944 return status;
6945
6946}
6947
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006948/**
6949 * sme_stop_roaming() - Stop roaming for a given sessionId
6950 * This is a synchronous call
6951 *
6952 * @hHal - The handle returned by mac_open
6953 * @sessionId - Session Identifier
6954 *
6955 * Return QDF_STATUS_SUCCESS on success
6956 * Other status on failure
6957 */
6958QDF_STATUS sme_stop_roaming(tHalHandle hal, uint8_t session_id, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006959{
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006960 struct scheduler_msg wma_msg = {0};
6961 tSirRetStatus status;
6962 tSirRoamOffloadScanReq *req;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006963 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
6964 tpCsrNeighborRoamControlInfo roam_info;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006965 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07006967 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006968 sme_err("incorrect session/vdev ID");
6969 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006970 }
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006971
6972 session = CSR_GET_SESSION(mac_ctx, session_id);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306973
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306974 /*
6975 * set the driver_disabled_roaming flag to true even if roaming
6976 * is not enabled on this session so that roam start requests for
6977 * this session can be blocked until driver enables roaming
6978 */
6979 if (reason == ecsr_driver_disabled && session->pCurRoamProfile) {
6980 session->pCurRoamProfile->driver_disabled_roaming = true;
6981 sme_debug("driver_disabled_roaming set for session %d",
6982 session_id);
6983 }
6984
Abhishek Singh1f217ec2017-12-22 11:48:27 +05306985 roam_info = &mac_ctx->roam.neighborRoamInfo[session_id];
6986 if (!roam_info->b_roam_scan_offload_started) {
6987 sme_debug("Roaming already disabled for session %d", session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07006988 return QDF_STATUS_SUCCESS;
6989 }
Naveen Rawat5c35ae42017-04-18 15:35:07 -07006990 req = qdf_mem_malloc(sizeof(*req));
6991 if (!req) {
6992 sme_err("failed to allocated memory");
6993 return QDF_STATUS_E_NOMEM;
6994 }
6995
6996 req->Command = ROAM_SCAN_OFFLOAD_STOP;
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05306997 if ((reason == eCsrForcedDisassoc) || reason == ecsr_driver_disabled)
Abhishek Singh533c9da2017-05-04 10:23:34 +05306998 req->reason = REASON_ROAM_STOP_ALL;
6999 else
Varun Reddy Yeturubc1bea02018-02-01 18:12:34 -08007000 req->reason = REASON_SME_ISSUED;
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007001 req->sessionId = session_id;
7002 if (csr_neighbor_middle_of_roaming(mac_ctx, session_id))
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007003 req->middle_of_roaming = 1;
7004 else
7005 csr_roam_reset_roam_params(mac_ctx);
7006
7007 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
7008 wma_msg.bodyptr = req;
7009
7010 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
7011 if (eSIR_SUCCESS != status) {
7012 sme_err("WMA_ROAM_SCAN_OFFLOAD_REQ failed, session_id: %d",
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007013 session_id);
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007014 qdf_mem_free(req);
7015 return QDF_STATUS_E_FAULT;
7016 }
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -07007017 roam_info->b_roam_scan_offload_started = false;
7018 roam_info->last_sent_cmd = ROAM_SCAN_OFFLOAD_STOP;
Naveen Rawat5c35ae42017-04-18 15:35:07 -07007019
7020 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007021}
7022
Abhishek Singhd5686472017-09-20 15:18:50 +05307023void sme_indicate_disconnect_inprogress(tHalHandle hal, uint8_t session_id)
7024{
7025 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
7026 QDF_STATUS status = QDF_STATUS_SUCCESS;
7027 struct csr_roam_session *session;
7028
7029 status = sme_acquire_global_lock(&mac_ctx->sme);
7030 if (QDF_IS_STATUS_SUCCESS(status)) {
7031 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
7032 session = CSR_GET_SESSION(mac_ctx, session_id);
7033 if (session)
7034 session->discon_in_progress = true;
7035 }
7036 sme_release_global_lock(&mac_ctx->sme);
7037 }
7038}
7039
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307040/*
7041 * sme_start_roaming() - Start roaming for a given sessionId
7042 * This is a synchronous call
7043 *
7044 * hHal - The handle returned by mac_open
7045 * sessionId - Session Identifier
7046 * Return QDF_STATUS_SUCCESS on success
7047 * Other status on failure
7048 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307049QDF_STATUS sme_start_roaming(tHalHandle hHal, uint8_t sessionId, uint8_t reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007050{
7051 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307052 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007053
7054 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307055 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007056 csr_roam_offload_scan(pMac, sessionId, ROAM_SCAN_OFFLOAD_START,
7057 reason);
7058 sme_release_global_lock(&pMac->sme);
7059 }
7060
7061 return status;
7062}
7063
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307064/*
7065 * sme_update_enable_fast_roam_in_concurrency() - enable/disable LFR if
7066 * Concurrent session exists
7067 * This is a synchronuous call
7068 *
7069 * hHal - The handle returned by mac_open.
7070 * Return QDF_STATUS_SUCCESS
7071 * Other status means SME is failed
7072 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307073QDF_STATUS sme_update_enable_fast_roam_in_concurrency(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007074 bool
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307075 bFastRoamInConIniFeatureEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007076{
7077
7078 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307079 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007080
7081 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307082 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007083 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7084 bFastRoamInConIniFeatureEnabled;
7085 if (0 == pMac->roam.configParam.isRoamOffloadScanEnabled) {
7086 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
7087 0;
7088 }
7089 sme_release_global_lock(&pMac->sme);
7090 }
7091
7092 return status;
7093}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007094
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307095/*
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307096 * sme_set_roam_opportunistic_scan_threshold_diff() -
7097 * Update Opportunistic Scan threshold diff
7098 * This function is called through dynamic setConfig callback function
7099 * to configure nOpportunisticThresholdDiff
7100 *
7101 * hHal - HAL handle for device
7102 * sessionId - Session Identifier
7103 * nOpportunisticThresholdDiff - Opportunistic Scan threshold diff
7104 * Return QDF_STATUS_SUCCESS - SME update nOpportunisticThresholdDiff config
7105 * successfully.
7106 * else SME is failed to update nOpportunisticThresholdDiff.
7107 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307108QDF_STATUS sme_set_roam_opportunistic_scan_threshold_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 uint8_t sessionId,
7110 const uint8_t
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307111 nOpportunisticThresholdDiff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007112{
7113 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307114 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007115
7116 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307117 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007118 status = csr_neighbor_roam_update_config(pMac, sessionId,
7119 nOpportunisticThresholdDiff,
7120 REASON_OPPORTUNISTIC_THRESH_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307121 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122 pMac->roam.configParam.neighborRoamConfig.
7123 nOpportunisticThresholdDiff =
7124 nOpportunisticThresholdDiff;
7125 }
7126 sme_release_global_lock(&pMac->sme);
7127 }
7128 return status;
7129}
7130
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307131/*
7132 * sme_get_roam_opportunistic_scan_threshold_diff()
7133 * gets Opportunistic Scan threshold diff
7134 * This is a synchronous call
7135 *
7136 * hHal - The handle returned by mac_open
7137 * Return uint8_t - nOpportunisticThresholdDiff
7138 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139uint8_t sme_get_roam_opportunistic_scan_threshold_diff(tHalHandle hHal)
7140{
7141 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007143 return pMac->roam.configParam.neighborRoamConfig.
7144 nOpportunisticThresholdDiff;
7145}
7146
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307147/*
7148 * sme_set_roam_rescan_rssi_diff() - Update roam rescan rssi diff
7149 * This function is called through dynamic setConfig callback function
7150 * to configure nRoamRescanRssiDiff
7151 *
7152 * hHal - HAL handle for device
7153 * sessionId - Session Identifier
7154 * nRoamRescanRssiDiff - roam rescan rssi diff
7155 * Return QDF_STATUS_SUCCESS - SME update nRoamRescanRssiDiff config
7156 * successfully.
7157 * else SME is failed to update nRoamRescanRssiDiff.
7158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307159QDF_STATUS sme_set_roam_rescan_rssi_diff(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 uint8_t sessionId,
7161 const uint8_t nRoamRescanRssiDiff)
7162{
7163 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307164 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007165
7166 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307167 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007168 status = csr_neighbor_roam_update_config(pMac, sessionId,
7169 nRoamRescanRssiDiff,
7170 REASON_ROAM_RESCAN_RSSI_DIFF_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307171 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172 pMac->roam.configParam.neighborRoamConfig.
7173 nRoamRescanRssiDiff = nRoamRescanRssiDiff;
7174 }
7175 sme_release_global_lock(&pMac->sme);
7176 }
7177 return status;
7178}
7179
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307180/*
7181 * sme_get_roam_rescan_rssi_diff()
7182 * gets roam rescan rssi diff
7183 * This is a synchronous call
7184 *
7185 * hHal - The handle returned by mac_open
7186 * Return int8_t - nRoamRescanRssiDiff
7187 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007188uint8_t sme_get_roam_rescan_rssi_diff(tHalHandle hHal)
7189{
7190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007192 return pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff;
7193}
7194
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307195/*
7196 * sme_set_roam_bmiss_first_bcnt() -
7197 * Update Roam count for first beacon miss
7198 * This function is called through dynamic setConfig callback function
7199 * to configure nRoamBmissFirstBcnt
7200 * hHal - HAL handle for device
7201 * sessionId - Session Identifier
7202 * nRoamBmissFirstBcnt - Roam first bmiss count
7203 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFirstBcnt
7204 * successfully.
7205 * else SME is failed to update nRoamBmissFirstBcnt
7206 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307207QDF_STATUS sme_set_roam_bmiss_first_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007208 uint8_t sessionId,
7209 const uint8_t nRoamBmissFirstBcnt)
7210{
7211 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307212 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007213
7214 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307215 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007216 status = csr_neighbor_roam_update_config(pMac, sessionId,
7217 nRoamBmissFirstBcnt,
7218 REASON_ROAM_BMISS_FIRST_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307219 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 pMac->roam.configParam.neighborRoamConfig.
7221 nRoamBmissFirstBcnt = nRoamBmissFirstBcnt;
7222 }
7223 sme_release_global_lock(&pMac->sme);
7224 }
7225 return status;
7226}
7227
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307228/*
7229 * sme_get_roam_bmiss_first_bcnt() -
7230 * get neighbor roam beacon miss first count
7231 *
7232 * hHal - The handle returned by mac_open.
7233 * Return uint8_t - neighbor roam beacon miss first count
7234 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007235uint8_t sme_get_roam_bmiss_first_bcnt(tHalHandle hHal)
7236{
7237 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307238
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007239 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt;
7240}
7241
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307242/*
7243 * sme_set_roam_bmiss_final_bcnt() -
7244 * Update Roam count for final beacon miss
7245 * This function is called through dynamic setConfig callback function
7246 * to configure nRoamBmissFinalBcnt
7247 * hHal - HAL handle for device
7248 * sessionId - Session Identifier
7249 * nRoamBmissFinalBcnt - Roam final bmiss count
7250 * Return QDF_STATUS_SUCCESS - SME update nRoamBmissFinalBcnt
7251 * successfully.
7252 * else SME is failed to update nRoamBmissFinalBcnt
7253 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307254QDF_STATUS sme_set_roam_bmiss_final_bcnt(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007255 uint8_t sessionId,
7256 const uint8_t nRoamBmissFinalBcnt)
7257{
7258 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307259 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007260
7261 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307262 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007263 status = csr_neighbor_roam_update_config(pMac, sessionId,
7264 nRoamBmissFinalBcnt,
7265 REASON_ROAM_BMISS_FINAL_BCNT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307266 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007267 pMac->roam.configParam.neighborRoamConfig.
7268 nRoamBmissFinalBcnt = nRoamBmissFinalBcnt;
7269 }
7270 sme_release_global_lock(&pMac->sme);
7271 }
7272 return status;
7273}
7274
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307275/*
7276 * sme_get_roam_bmiss_final_bcnt() -
7277 * gets Roam count for final beacon miss
7278 * This is a synchronous call
7279 *
7280 * hHal - The handle returned by mac_open
7281 * Return uint8_t - nRoamBmissFinalBcnt
7282 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007283uint8_t sme_get_roam_bmiss_final_bcnt(tHalHandle hHal)
7284{
7285 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287 return pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt;
7288}
7289
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307290/*
7291 * sme_set_roam_beacon_rssi_weight() -
7292 * Update Roam beacon rssi weight
7293 * This function is called through dynamic setConfig callback function
7294 * to configure nRoamBeaconRssiWeight
7295 *
7296 * hHal - HAL handle for device
7297 * sessionId - Session Identifier
7298 * nRoamBeaconRssiWeight - Roam beacon rssi weight
7299 * Return QDF_STATUS_SUCCESS - SME update nRoamBeaconRssiWeight config
7300 * successfully.
7301 * else SME is failed to update nRoamBeaconRssiWeight
7302 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307303QDF_STATUS sme_set_roam_beacon_rssi_weight(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007304 uint8_t sessionId,
7305 const uint8_t nRoamBeaconRssiWeight)
7306{
7307 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307308 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007309
7310 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307311 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007312 status = csr_neighbor_roam_update_config(pMac, sessionId,
7313 nRoamBeaconRssiWeight,
7314 REASON_ROAM_BEACON_RSSI_WEIGHT_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307315 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007316 pMac->roam.configParam.neighborRoamConfig.
7317 nRoamBeaconRssiWeight = nRoamBeaconRssiWeight;
7318 }
7319 sme_release_global_lock(&pMac->sme);
7320 }
7321 return status;
7322}
7323
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307324/*
7325 * sme_get_roam_beacon_rssi_weight() -
7326 * gets Roam beacon rssi weight
7327 * This is a synchronous call
7328 *
7329 * hHal - The handle returned by mac_open
7330 * Return uint8_t - nRoamBeaconRssiWeight
7331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007332uint8_t sme_get_roam_beacon_rssi_weight(tHalHandle hHal)
7333{
7334 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007336 return pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight;
7337}
7338
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307339/*
7340 * sme_set_neighbor_lookup_rssi_threshold() - update neighbor lookup
7341 * rssi threshold
7342 * This is a synchronous call
7343 *
7344 * hHal - The handle returned by mac_open.
7345 * sessionId - Session Identifier
7346 * Return QDF_STATUS_SUCCESS - SME update config successful.
7347 * Other status means SME is failed to update
7348 */
7349QDF_STATUS sme_set_neighbor_lookup_rssi_threshold(tHalHandle hHal,
7350 uint8_t sessionId, uint8_t neighborLookupRssiThreshold)
7351{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007352 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307353 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007354
7355 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307356 if (QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturuff4feb02016-04-20 12:26:11 -07007357 status = csr_neighbor_roam_update_config(pMac,
7358 sessionId, neighborLookupRssiThreshold,
7359 REASON_LOOKUP_THRESH_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307360 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 pMac->roam.configParam.neighborRoamConfig.
7362 nNeighborLookupRssiThreshold =
7363 neighborLookupRssiThreshold;
7364 }
7365 sme_release_global_lock(&pMac->sme);
7366 }
7367 return status;
7368}
7369
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307370/*
7371 * sme_set_delay_before_vdev_stop() - update delay before VDEV_STOP
7372 * This is a synchronous call
7373 *
7374 * hal - The handle returned by macOpen.
7375 * session_id - Session Identifier
7376 * delay_before_vdev_stop - value to be set
7377 * Return QDF_STATUS_SUCCESS - SME update config successful.
7378 * Other status means SME is failed to update
7379 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307380QDF_STATUS sme_set_delay_before_vdev_stop(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 uint8_t session_id,
7382 uint8_t delay_before_vdev_stop)
7383{
7384 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307385 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007386
7387 if (session_id >= CSR_ROAM_SESSION_MAX) {
7388 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7389 FL("Invalid sme session id: %d"), session_id);
7390 return QDF_STATUS_E_INVAL;
7391 }
7392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007393 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307394 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307395 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7396 "LFR param delay_before_vdev_stop changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007397 pMac->roam.configParam.neighborRoamConfig.
7398 delay_before_vdev_stop,
7399 delay_before_vdev_stop);
7400 pMac->roam.neighborRoamInfo[session_id].cfgParams.
7401 delay_before_vdev_stop = delay_before_vdev_stop;
7402 pMac->roam.configParam.neighborRoamConfig.
7403 delay_before_vdev_stop = delay_before_vdev_stop;
7404 sme_release_global_lock(&pMac->sme);
7405 }
7406 return status;
7407}
7408
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307409/*
7410 * sme_get_neighbor_lookup_rssi_threshold() - get neighbor lookup
7411 * rssi threshold
7412 * This is a synchronous call
7413 *
7414 * hHal - The handle returned by mac_open.
7415 * Return QDF_STATUS_SUCCESS - SME update config successful.
7416 * Other status means SME is failed to update
7417 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418uint8_t sme_get_neighbor_lookup_rssi_threshold(tHalHandle hHal)
7419{
7420 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307421
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007422 return pMac->roam.configParam.neighborRoamConfig.
7423 nNeighborLookupRssiThreshold;
7424}
7425
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307426/*
7427 * sme_set_neighbor_scan_refresh_period() - set neighbor scan results
7428 * refresh period
7429 * This is a synchronous call
7430 *
7431 * hHal - The handle returned by mac_open.
7432 * sessionId - Session Identifier
7433 * Return QDF_STATUS_SUCCESS - SME update config successful.
7434 * Other status means SME is failed to update
7435 */
7436QDF_STATUS sme_set_neighbor_scan_refresh_period(tHalHandle hHal,
7437 uint8_t sessionId, uint16_t neighborScanResultsRefreshPeriod)
7438{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307440 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307441 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7443
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007444 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7446 FL("Invalid sme session id: %d"), sessionId);
7447 return QDF_STATUS_E_INVAL;
7448 }
7449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007450 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307451 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007452 pNeighborRoamConfig =
7453 &pMac->roam.configParam.neighborRoamConfig;
7454 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307455 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007456 "LFR runtime successfully set roam scan refresh period to %d- old value is %d - roam state is %s",
7457 neighborScanResultsRefreshPeriod,
7458 pMac->roam.configParam.neighborRoamConfig.
7459 nNeighborResultsRefreshPeriod,
7460 mac_trace_get_neighbour_roam_state(pMac->roam.
7461 neighborRoamInfo
7462 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307463 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007464 pNeighborRoamConfig->nNeighborResultsRefreshPeriod =
7465 neighborScanResultsRefreshPeriod;
7466 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod =
7467 neighborScanResultsRefreshPeriod;
7468
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307469 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7470 csr_roam_offload_scan(pMac, sessionId,
7471 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7472 REASON_NEIGHBOR_SCAN_REFRESH_PERIOD_CHANGED);
7473 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 sme_release_global_lock(&pMac->sme);
7475 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007477 return status;
7478}
7479
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307480/*
7481 * sme_update_roam_scan_offload_enabled() - enable/disable roam scan
7482 * offload feaure
7483 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
7484 * gRoamScanOffloadEnabled.
7485 * This is a synchronous call
7486 *
7487 * hHal - The handle returned by mac_open.
7488 * Return QDF_STATUS_SUCCESS - SME update config successfully.
7489 * Other status means SME is failed to update.
7490 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307491QDF_STATUS sme_update_roam_scan_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007492 bool nRoamScanOffloadEnabled)
7493{
7494 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307495 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496
7497 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307498 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307500 "gRoamScanOffloadEnabled is changed from %d to %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501 pMac->roam.configParam.isRoamOffloadScanEnabled,
7502 nRoamScanOffloadEnabled);
7503 pMac->roam.configParam.isRoamOffloadScanEnabled =
7504 nRoamScanOffloadEnabled;
7505 sme_release_global_lock(&pMac->sme);
7506 }
7507
7508 return status;
7509}
7510
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307511/*
7512 * sme_get_neighbor_scan_refresh_period() - get neighbor scan results
7513 * refresh period
7514 * This is a synchronous call
7515 *
7516 * \param hHal - The handle returned by mac_open.
7517 * \return uint16_t - Neighbor scan results refresh period value
7518 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007519uint16_t sme_get_neighbor_scan_refresh_period(tHalHandle hHal)
7520{
7521 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523 return pMac->roam.configParam.neighborRoamConfig.
7524 nNeighborResultsRefreshPeriod;
7525}
7526
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307527/*
7528 * sme_get_empty_scan_refresh_period() - get empty scan refresh period
7529 * This is a synchronuous call
7530 *
7531 * hHal - The handle returned by mac_open.
7532 * Return QDF_STATUS_SUCCESS - SME update config successful.
7533 * Other status means SME is failed to update
7534 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007535uint16_t sme_get_empty_scan_refresh_period(tHalHandle hHal)
7536{
7537 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007539 return pMac->roam.configParam.neighborRoamConfig.
7540 nEmptyScanRefreshPeriod;
7541}
7542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307543/*
7544 * sme_update_empty_scan_refresh_period
7545 * Update nEmptyScanRefreshPeriod
7546 * This function is called through dynamic setConfig callback function
7547 * to configure nEmptyScanRefreshPeriod
7548 * Usage: adb shell iwpriv wlan0 setConfig
7549 * nEmptyScanRefreshPeriod=[0 .. 60]
7550 *
7551 * hHal - HAL handle for device
7552 * sessionId - Session Identifier
7553 * nEmptyScanRefreshPeriod - scan period following empty scan results.
7554 * Return Success or failure
7555 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007556
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307557QDF_STATUS sme_update_empty_scan_refresh_period(tHalHandle hHal, uint8_t
7558 sessionId, uint16_t
7559 nEmptyScanRefreshPeriod)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007560{
7561 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307562 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307563 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7565
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007566 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7568 FL("Invalid sme session id: %d"), sessionId);
7569 return QDF_STATUS_E_INVAL;
7570 }
7571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007572 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307573 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 pNeighborRoamConfig =
7575 &pMac->roam.configParam.neighborRoamConfig;
7576 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307577 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007578 "LFR runtime successfully set roam scan period to %d -old value is %d - roam state is %s",
7579 nEmptyScanRefreshPeriod,
7580 pMac->roam.configParam.neighborRoamConfig.
7581 nEmptyScanRefreshPeriod,
7582 mac_trace_get_neighbour_roam_state(pMac->roam.
7583 neighborRoamInfo
7584 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307585 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007586 pNeighborRoamConfig->nEmptyScanRefreshPeriod =
7587 nEmptyScanRefreshPeriod;
7588 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod =
7589 nEmptyScanRefreshPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307590
7591 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7592 csr_roam_offload_scan(pMac, sessionId,
7593 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7594 REASON_EMPTY_SCAN_REF_PERIOD_CHANGED);
7595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007596 sme_release_global_lock(&pMac->sme);
7597 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007599 return status;
7600}
7601
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307602/*
7603 * sme_set_neighbor_scan_min_chan_time() -
7604 * Update nNeighborScanMinChanTime
7605 * This function is called through dynamic setConfig callback function
7606 * to configure gNeighborScanChannelMinTime
7607 * Usage: adb shell iwpriv wlan0 setConfig
7608 * gNeighborScanChannelMinTime=[0 .. 60]
7609 *
7610 * hHal - HAL handle for device
7611 * nNeighborScanMinChanTime - Channel minimum dwell time
7612 * sessionId - Session Identifier
7613 * Return Success or failure
7614 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307615QDF_STATUS sme_set_neighbor_scan_min_chan_time(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616 const uint16_t
7617 nNeighborScanMinChanTime,
7618 uint8_t sessionId)
7619{
7620 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307621 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007623 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7624 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7625 FL("Invalid sme session id: %d"), sessionId);
7626 return QDF_STATUS_E_INVAL;
7627 }
7628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007629 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307630 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307631 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007632 "LFR runtime successfully set channel min dwell time to %d - old value is %d - roam state is %s",
7633 nNeighborScanMinChanTime,
7634 pMac->roam.configParam.neighborRoamConfig.
7635 nNeighborScanMinChanTime,
7636 mac_trace_get_neighbour_roam_state(pMac->roam.
7637 neighborRoamInfo
7638 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307639 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007640
7641 pMac->roam.configParam.neighborRoamConfig.
7642 nNeighborScanMinChanTime = nNeighborScanMinChanTime;
7643 pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7644 minChannelScanTime = nNeighborScanMinChanTime;
7645 sme_release_global_lock(&pMac->sme);
7646 }
7647
7648 return status;
7649}
7650
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307651/*
7652 * sme_set_neighbor_scan_max_chan_time() -
7653 * Update nNeighborScanMaxChanTime
7654 * This function is called through dynamic setConfig callback function
7655 * to configure gNeighborScanChannelMaxTime
7656 * Usage: adb shell iwpriv wlan0 setConfig
7657 * gNeighborScanChannelMaxTime=[0 .. 60]
7658 *
7659 * hHal - HAL handle for device
7660 * sessionId - Session Identifier
7661 * nNeighborScanMinChanTime - Channel maximum dwell time
7662 * Return Success or failure
7663 */
7664QDF_STATUS sme_set_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t
7665 sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007666 const uint16_t
7667 nNeighborScanMaxChanTime)
7668{
7669 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307670 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307671 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007672 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7673
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007674 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7675 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7676 FL("Invalid sme session id: %d"), sessionId);
7677 return QDF_STATUS_E_INVAL;
7678 }
7679
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007680 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307681 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007682 pNeighborRoamConfig =
7683 &pMac->roam.configParam.neighborRoamConfig;
7684 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307685 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007686 "LFR runtime successfully set channel max dwell time to %d - old value is %d - roam state is %s",
7687 nNeighborScanMaxChanTime,
7688 pMac->roam.configParam.neighborRoamConfig.
7689 nNeighborScanMaxChanTime,
7690 mac_trace_get_neighbour_roam_state(pMac->roam.
7691 neighborRoamInfo
7692 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307693 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 pNeighborRoamConfig->nNeighborScanMaxChanTime =
7695 nNeighborScanMaxChanTime;
7696 pNeighborRoamInfo->cfgParams.maxChannelScanTime =
7697 nNeighborScanMaxChanTime;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307698 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7699 csr_roam_offload_scan(pMac, sessionId,
7700 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7701 REASON_SCAN_CH_TIME_CHANGED);
7702 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703 sme_release_global_lock(&pMac->sme);
7704 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007706
7707 return status;
7708}
7709
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307710/*
7711 * sme_get_neighbor_scan_min_chan_time() -
7712 * get neighbor scan min channel time
7713 *
7714 * hHal - The handle returned by mac_open.
7715 * sessionId - Session Identifier
7716 * Return uint16_t - channel min time value
7717 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007718uint16_t sme_get_neighbor_scan_min_chan_time(tHalHandle hHal, uint8_t sessionId)
7719{
7720 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007721
7722 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7723 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7724 FL("Invalid sme session id: %d"), sessionId);
7725 return 0;
7726 }
7727
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7729 minChannelScanTime;
7730}
7731
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307732/*
7733 * sme_get_neighbor_roam_state() -
7734 * get neighbor roam state
7735 *
7736 * hHal - The handle returned by mac_open.
7737 * sessionId - Session Identifier
7738 * Return uint32_t - neighbor roam state
7739 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007740uint32_t sme_get_neighbor_roam_state(tHalHandle hHal, uint8_t sessionId)
7741{
7742 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007743
7744 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7746 FL("Invalid sme session id: %d"), sessionId);
7747 return 0;
7748 }
7749
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007750 return pMac->roam.neighborRoamInfo[sessionId].neighborRoamState;
7751}
7752
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307753/*
7754 * sme_get_current_roam_state() -
7755 * get current roam state
7756 *
7757 * hHal - The handle returned by mac_open.
7758 * sessionId - Session Identifier
7759 * Return uint32_t - current roam state
7760 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007761uint32_t sme_get_current_roam_state(tHalHandle hHal, uint8_t sessionId)
7762{
7763 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007765 return pMac->roam.curState[sessionId];
7766}
7767
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307768/*
7769 * sme_get_current_roam_sub_state() -
7770 * \brief get neighbor roam sub state
7771 *
7772 * hHal - The handle returned by mac_open.
7773 * sessionId - Session Identifier
7774 * Return uint32_t - current roam sub state
7775 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776uint32_t sme_get_current_roam_sub_state(tHalHandle hHal, uint8_t sessionId)
7777{
7778 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307779
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007780 return pMac->roam.curSubState[sessionId];
7781}
7782
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307783/*
7784 * sme_get_lim_sme_state() -
7785 * get Lim Sme state
7786 *
7787 * hHal - The handle returned by mac_open.
7788 * Return uint32_t - Lim Sme state
7789 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790uint32_t sme_get_lim_sme_state(tHalHandle hHal)
7791{
7792 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794 return pMac->lim.gLimSmeState;
7795}
7796
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307797/*
7798 * sme_get_lim_mlm_state() -
7799 * get Lim Mlm state
7800 *
7801 * hHal - The handle returned by mac_open.
7802 * Return uint32_t - Lim Mlm state
7803 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007804uint32_t sme_get_lim_mlm_state(tHalHandle hHal)
7805{
7806 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808 return pMac->lim.gLimMlmState;
7809}
7810
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307811/*
7812 * sme_is_lim_session_valid() -
7813 * is Lim session valid
7814 *
7815 * hHal - The handle returned by mac_open.
7816 * sessionId - Session Identifier
7817 * Return bool - true or false
7818 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819bool sme_is_lim_session_valid(tHalHandle hHal, uint8_t sessionId)
7820{
7821 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Hanumantha Reddy Pothula589fd702015-11-17 15:25:16 +05307822
7823 if (sessionId > pMac->lim.maxBssId)
7824 return false;
7825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007826 return pMac->lim.gpSession[sessionId].valid;
7827}
7828
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307829/*
7830 * sme_get_lim_sme_session_state() -
7831 * get Lim Sme session state
7832 *
7833 * hHal - The handle returned by mac_open.
7834 * sessionId - Session Identifier
7835 * Return uint32_t - Lim Sme session state
7836 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007837uint32_t sme_get_lim_sme_session_state(tHalHandle hHal, uint8_t sessionId)
7838{
7839 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 return pMac->lim.gpSession[sessionId].limSmeState;
7842}
7843
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307844/*
7845 * sme_get_lim_mlm_session_state() -
7846 * \brief get Lim Mlm session state
7847 *
7848 * hHal - The handle returned by mac_open.
7849 * sessionId - Session Identifier
7850 * Return uint32_t - Lim Mlm session state
7851 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007852uint32_t sme_get_lim_mlm_session_state(tHalHandle hHal, uint8_t sessionId)
7853{
7854 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007856 return pMac->lim.gpSession[sessionId].limMlmState;
7857}
7858
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307859/*
7860 * sme_get_neighbor_scan_max_chan_time() -
7861 * get neighbor scan max channel time
7862 *
7863 * hHal - The handle returned by mac_open.
7864 * sessionId - Session Identifier
7865 * Return uint16_t - channel max time value
7866 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007867uint16_t sme_get_neighbor_scan_max_chan_time(tHalHandle hHal, uint8_t sessionId)
7868{
7869 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007870
7871 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7872 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7873 FL("Invalid sme session id: %d"), sessionId);
7874 return 0;
7875 }
7876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007877 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7878 maxChannelScanTime;
7879}
7880
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307881/*
7882 * sme_set_neighbor_scan_period() -
7883 * Update nNeighborScanPeriod
7884 * This function is called through dynamic setConfig callback function
7885 * to configure nNeighborScanPeriod
7886 * Usage: adb shell iwpriv wlan0 setConfig
7887 * nNeighborScanPeriod=[0 .. 1000]
7888 *
7889 * hHal - HAL handle for device
7890 * sessionId - Session Identifier
7891 * nNeighborScanPeriod - neighbor scan period
7892 * Return Success or failure
7893 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307894QDF_STATUS sme_set_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007895 const uint16_t nNeighborScanPeriod)
7896{
7897 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307898 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307899 struct csr_neighbor_roamconfig *pNeighborRoamConfig = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007900 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
7901
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007902 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7903 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7904 FL("Invalid sme session id: %d"), sessionId);
7905 return QDF_STATUS_E_INVAL;
7906 }
7907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007908 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307909 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007910 pNeighborRoamConfig =
7911 &pMac->roam.configParam.neighborRoamConfig;
7912 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307913 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307914 "LFR runtime successfully set neighbor scan period to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007915 nNeighborScanPeriod,
7916 pMac->roam.configParam.neighborRoamConfig.
7917 nNeighborScanTimerPeriod,
7918 mac_trace_get_neighbour_roam_state(pMac->roam.
7919 neighborRoamInfo
7920 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307921 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007922 pNeighborRoamConfig->nNeighborScanTimerPeriod =
7923 nNeighborScanPeriod;
7924 pNeighborRoamInfo->cfgParams.neighborScanPeriod =
7925 nNeighborScanPeriod;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05307926
7927 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
7928 csr_roam_offload_scan(pMac, sessionId,
7929 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
7930 REASON_SCAN_HOME_TIME_CHANGED);
7931 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007932 sme_release_global_lock(&pMac->sme);
7933 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007934
7935 return status;
7936}
7937
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05307938/*
7939 * sme_get_neighbor_scan_period() -
7940 * get neighbor scan period
7941 *
7942 * hHal - The handle returned by mac_open.
7943 * sessionId - Session Identifier
7944 * Return uint16_t - neighbor scan period
7945 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007946uint16_t sme_get_neighbor_scan_period(tHalHandle hHal, uint8_t sessionId)
7947{
7948 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08007949
7950 if (sessionId >= CSR_ROAM_SESSION_MAX) {
7951 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
7952 FL("Invalid sme session id: %d"), sessionId);
7953 return 0;
7954 }
7955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 return pMac->roam.neighborRoamInfo[sessionId].cfgParams.
7957 neighborScanPeriod;
7958}
7959
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307960/**
7961 * sme_set_neighbor_scan_min_period() - Update neighbor_scan_min_period
7962 * This function is called through dynamic setConfig callback function
7963 * to configure neighbor_scan_min_period
7964 *
7965 * @hal - HAL handle for device
7966 * @session_id - Session Identifier
7967 * @neighbor_scan_min_period - neighbor scan min period
7968 *
7969 * Return - QDF_STATUS
7970 */
7971QDF_STATUS sme_set_neighbor_scan_min_period(tHalHandle hal,
7972 uint8_t session_id,
7973 const uint16_t
7974 neighbor_scan_min_period)
7975{
7976 tpAniSirGlobal pmac = PMAC_STRUCT(hal);
7977 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307978 struct csr_neighbor_roamconfig *p_neighbor_roam_config = NULL;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307979 tpCsrNeighborRoamControlInfo p_neighbor_roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05307981 if (session_id >= CSR_ROAM_SESSION_MAX) {
7982 sme_err("Invalid sme session id: %d", session_id);
7983 return QDF_STATUS_E_INVAL;
7984 }
7985
7986 status = sme_acquire_global_lock(&pmac->sme);
7987 if (QDF_IS_STATUS_SUCCESS(status)) {
7988 p_neighbor_roam_config =
7989 &pmac->roam.configParam.neighborRoamConfig;
7990 p_neighbor_roam_info = &pmac->
7991 roam.neighborRoamInfo[session_id];
7992 sme_debug("LFR:set neighbor scan min period, old:%d, "
7993 "new: %d, state: %s",
7994 pmac->roam.configParam.neighborRoamConfig.
7995 neighbor_scan_min_timer_period,
7996 neighbor_scan_min_period,
7997 mac_trace_get_neighbour_roam_state(pmac->roam.
7998 neighborRoamInfo[session_id].
7999 neighborRoamState));
8000 p_neighbor_roam_config->neighbor_scan_min_timer_period =
8001 neighbor_scan_min_period;
8002 p_neighbor_roam_info->cfgParams.neighbor_scan_min_period =
8003 neighbor_scan_min_period;
8004 sme_release_global_lock(&pmac->sme);
8005 }
8006
8007 return status;
8008}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008009
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308010/*
8011 * sme_get_roam_rssi_diff() - get Roam rssi diff
8012 * This is a synchronous call
8013 *
8014 * hHal - The handle returned by mac_open.
8015 * Return uint16_t - Rssi diff value
8016 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008017uint8_t sme_get_roam_rssi_diff(tHalHandle hHal)
8018{
8019 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008021 return pMac->roam.configParam.RoamRssiDiff;
8022}
8023
8024/**
8025 * sme_change_roam_scan_channel_list() - to change scan channel list
8026 * @hHal: pointer HAL handle returned by mac_open
8027 * @sessionId: sme session id
8028 * @pChannelList: Output channel list
8029 * @numChannels: Output number of channels
8030 *
8031 * This routine is called to Change roam scan channel list.
8032 * This is a synchronous call
8033 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308034 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008035 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308036QDF_STATUS sme_change_roam_scan_channel_list(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 uint8_t *pChannelList,
8038 uint8_t numChannels)
8039{
8040 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308041 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008042 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008043 uint8_t oldChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8044 uint8_t newChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN * 2] = { 0 };
8045 uint8_t i = 0, j = 0;
8046 tCsrChannelInfo *chan_info;
8047
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008048 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8050 FL("Invalid sme session id: %d"), sessionId);
8051 return QDF_STATUS_E_INVAL;
8052 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008053
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008054 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308056 if (!QDF_IS_STATUS_SUCCESS(status)) {
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308057 sme_err("Failed to acquire SME lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008058 return status;
8059 }
8060 chan_info = &pNeighborRoamInfo->cfgParams.channelInfo;
8061
8062 if (NULL != chan_info->ChannelList) {
8063 for (i = 0; i < chan_info->numOfChannels; i++) {
8064 if (j < sizeof(oldChannelList))
8065 j += snprintf(oldChannelList + j,
8066 sizeof(oldChannelList) -
8067 j, "%d",
8068 chan_info->ChannelList[i]);
8069 else
8070 break;
8071 }
8072 }
8073 csr_flush_cfg_bg_scan_roam_channel_list(pMac, sessionId);
8074 csr_create_bg_scan_roam_channel_list(pMac, sessionId, pChannelList,
8075 numChannels);
8076 sme_set_roam_scan_control(hHal, sessionId, 1);
8077 if (NULL != chan_info->ChannelList) {
8078 j = 0;
8079 for (i = 0; i < chan_info->numOfChannels; i++) {
8080 if (j < sizeof(newChannelList))
8081 j += snprintf(newChannelList + j,
8082 sizeof(newChannelList) -
8083 j, " %d",
8084 chan_info->ChannelList[i]);
8085 else
8086 break;
8087 }
8088 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308090 "LFR runtime successfully set roam scan channels to %s - old value is %s - roam state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 newChannelList, oldChannelList,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308092 pMac->roam.neighborRoamInfo[sessionId].neighborRoamState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008093
8094 if (pMac->roam.configParam.isRoamOffloadScanEnabled)
8095 csr_roam_offload_scan(pMac, sessionId,
8096 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
8097 REASON_CHANNEL_LIST_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +05308098
8099 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008100 return status;
8101}
8102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103/**
8104 * sme_get_roam_scan_channel_list() - To get roam scan channel list
8105 * @hHal: HAL pointer
8106 * @pChannelList: Output channel list
8107 * @pNumChannels: Output number of channels
8108 * @sessionId: Session Identifier
8109 *
8110 * To get roam scan channel list This is a synchronous call
8111 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308112 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008113 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308114QDF_STATUS sme_get_roam_scan_channel_list(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008115 uint8_t *pChannelList, uint8_t *pNumChannels,
8116 uint8_t sessionId)
8117{
8118 int i = 0;
8119 uint8_t *pOutPtr = pChannelList;
8120 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008121 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308122 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123
Naveen Rawatc36f7eb2016-11-10 20:01:03 -08008124 if (sessionId >= CSR_ROAM_SESSION_MAX) {
8125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8126 FL("Invalid sme session id: %d"), sessionId);
8127 return QDF_STATUS_E_INVAL;
8128 }
8129
8130 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008131 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308132 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008133 return status;
8134 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308135 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136 FL("Roam Scan channel list is NOT yet initialized"));
8137 *pNumChannels = 0;
8138 sme_release_global_lock(&pMac->sme);
8139 return status;
8140 }
8141
8142 *pNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308143 for (i = 0; i < (*pNumChannels); i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008144 pOutPtr[i] =
8145 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList[i];
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 pOutPtr[i] = '\0';
8148 sme_release_global_lock(&pMac->sme);
8149 return status;
8150}
8151
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308152/*
8153 * sme_get_is_ese_feature_enabled() - get ESE feature enabled or not
8154 * This is a synchronuous call
8155 *
8156 * hHal - The handle returned by mac_open.
8157 * Return true (1) - if the ESE feature is enabled
8158 * false (0) - if feature is disabled (compile or runtime)
8159 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008160bool sme_get_is_ese_feature_enabled(tHalHandle hHal)
8161{
8162#ifdef FEATURE_WLAN_ESE
8163 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008165 return csr_roam_is_ese_ini_feature_enabled(pMac);
8166#else
8167 return false;
8168#endif
8169}
8170
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308171/*
8172 * sme_get_wes_mode() - get WES Mode
8173 * This is a synchronous call
8174 *
8175 * hHal - The handle returned by mac_open
8176 * Return uint8_t - WES Mode Enabled(1)/Disabled(0)
8177 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178bool sme_get_wes_mode(tHalHandle hHal)
8179{
8180 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008182 return pMac->roam.configParam.isWESModeEnabled;
8183}
8184
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308185/*
8186 * sme_get_roam_scan_control() - get scan control
8187 * This is a synchronous call
8188 *
8189 * hHal - The handle returned by mac_open.
8190 * Return bool - Enabled(1)/Disabled(0)
8191 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008192bool sme_get_roam_scan_control(tHalHandle hHal)
8193{
8194 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008196 return pMac->roam.configParam.nRoamScanControl;
8197}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308199/*
8200 * sme_get_is_lfr_feature_enabled() - get LFR feature enabled or not
8201 * This is a synchronuous call
8202 * hHal - The handle returned by mac_open.
8203 * Return true (1) - if the feature is enabled
8204 * false (0) - if feature is disabled (compile or runtime)
8205 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008206bool sme_get_is_lfr_feature_enabled(tHalHandle hHal)
8207{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008210 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211}
8212
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308213/*
8214 * sme_get_is_ft_feature_enabled() - get FT feature enabled or not
8215 * This is a synchronuous call
8216 *
8217 * hHal - The handle returned by mac_open.
8218 * Return true (1) - if the feature is enabled
8219 * false (0) - if feature is disabled (compile or runtime)
8220 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008221bool sme_get_is_ft_feature_enabled(tHalHandle hHal)
8222{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008223 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308224
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008225 return pMac->roam.configParam.isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008226}
8227
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008228/**
8229 * sme_is_feature_supported_by_fw() - check if feature is supported by FW
8230 * @feature: enum value of requested feature.
8231 *
8232 * Retrun: 1 if supported; 0 otherwise
8233 */
8234bool sme_is_feature_supported_by_fw(enum cap_bitmap feature)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235{
Krishna Kumaar Natarajand0bbb3c2017-03-13 17:04:58 -07008236 return IS_FEATURE_SUPPORTED_BY_FW(feature);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237}
8238
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308239QDF_STATUS sme_get_link_speed(tHalHandle hHal, tSirLinkSpeedInfo *lsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008240 void *plsContext,
8241 void (*pCallbackfn)(tSirLinkSpeedInfo *indParam,
8242 void *pContext))
8243{
8244
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308245 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsona5317a62017-01-26 08:51:25 -08008246 tpAniSirGlobal pMac;
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308247 void *wma_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248
Jeff Johnsona5317a62017-01-26 08:51:25 -08008249 if (!hHal || !pCallbackfn || !lsReq) {
8250 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8251 FL("Invalid parameter"));
8252 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253 }
Jeff Johnsona5317a62017-01-26 08:51:25 -08008254
Mukul Sharmac3886aa2017-05-04 17:53:22 +05308255 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
8256 if (!wma_handle) {
8257 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8258 "wma handle is NULL");
8259 return QDF_STATUS_E_FAILURE;
8260 }
8261
Jeff Johnsona5317a62017-01-26 08:51:25 -08008262 pMac = PMAC_STRUCT(hHal);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008263 status = sme_acquire_global_lock(&pMac->sme);
8264 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008265 sme_err("Failed to acquire global lock");
Jeff Johnsona5317a62017-01-26 08:51:25 -08008266 return QDF_STATUS_E_FAILURE;
8267 }
8268
8269 pMac->sme.pLinkSpeedCbContext = plsContext;
8270 pMac->sme.pLinkSpeedIndCb = pCallbackfn;
gaurank kathpaliaca8f4612018-06-13 14:21:53 +05308271 status = wma_get_link_speed(wma_handle, lsReq);
Jeff Johnsona5317a62017-01-26 08:51:25 -08008272 sme_release_global_lock(&pMac->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008273 return status;
8274}
8275
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308276QDF_STATUS sme_get_peer_stats(tpAniSirGlobal mac,
8277 struct sir_peer_info_req req)
8278{
8279 QDF_STATUS qdf_status;
8280 struct scheduler_msg message = {0};
8281
8282 qdf_status = sme_acquire_global_lock(&mac->sme);
8283 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8284 sme_debug("Failed to get Lock");
8285 return qdf_status;
8286 }
8287 /* serialize the req through MC thread */
8288 message.bodyptr = qdf_mem_malloc(sizeof(req));
8289 if (NULL == message.bodyptr) {
8290 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8291 "%s: Memory allocation failed.", __func__);
8292 sme_release_global_lock(&mac->sme);
8293 return QDF_STATUS_E_NOMEM;
8294 }
8295 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8296 message.type = WMA_GET_PEER_INFO;
8297 message.reserved = 0;
8298 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8299 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8300 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8301 "%s: Post get peer info msg fail", __func__);
8302 qdf_mem_free(message.bodyptr);
8303 qdf_status = QDF_STATUS_E_FAILURE;
8304 }
8305 sme_release_global_lock(&mac->sme);
8306 return qdf_status;
8307}
8308
Will Huang558f8082017-05-31 16:22:24 +08008309QDF_STATUS sme_get_peer_info(tHalHandle hal, struct sir_peer_info_req req,
8310 void *context,
8311 void (*callbackfn)(struct sir_peer_info_resp *param,
8312 void *pcontext))
8313{
8314
8315 QDF_STATUS status;
8316 QDF_STATUS qdf_status;
8317 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008318 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008319
8320 status = sme_acquire_global_lock(&mac->sme);
8321 if (QDF_STATUS_SUCCESS == status) {
8322 if (NULL == callbackfn) {
8323 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8324 "%s: Indication Call back is NULL",
8325 __func__);
8326 sme_release_global_lock(&mac->sme);
8327 return QDF_STATUS_E_FAILURE;
8328 }
8329
8330 mac->sme.pget_peer_info_ind_cb = callbackfn;
8331 mac->sme.pget_peer_info_cb_context = context;
8332
8333 /* serialize the req through MC thread */
8334 message.bodyptr = qdf_mem_malloc(sizeof(req));
8335 if (NULL == message.bodyptr) {
8336 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8337 "%s: Memory allocation failed.", __func__);
8338 sme_release_global_lock(&mac->sme);
8339 return QDF_STATUS_E_NOMEM;
8340 }
8341 qdf_mem_copy(message.bodyptr, &req, sizeof(req));
8342 message.type = WMA_GET_PEER_INFO;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05308343 message.reserved = 0;
Will Huang558f8082017-05-31 16:22:24 +08008344 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8345 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8346 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8347 "%s: Post get peer info msg fail", __func__);
8348 qdf_mem_free(message.bodyptr);
8349 status = QDF_STATUS_E_FAILURE;
8350 }
8351 sme_release_global_lock(&mac->sme);
8352 }
8353 return status;
8354}
8355
8356QDF_STATUS sme_get_peer_info_ext(tHalHandle hal,
8357 struct sir_peer_info_ext_req *req,
8358 void *context,
8359 void (*callbackfn)(struct sir_peer_info_ext_resp *param,
8360 void *pcontext))
8361{
8362 QDF_STATUS status;
8363 QDF_STATUS qdf_status;
8364 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar658e8492017-12-13 11:35:41 -08008365 struct scheduler_msg message = {0};
Will Huang558f8082017-05-31 16:22:24 +08008366
8367 status = sme_acquire_global_lock(&mac->sme);
8368 if (QDF_STATUS_SUCCESS == status) {
8369 if (NULL == callbackfn) {
8370 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8371 "%s: Indication Call back is NULL",
8372 __func__);
8373 sme_release_global_lock(&mac->sme);
8374 return QDF_STATUS_E_FAILURE;
8375 }
8376
8377 mac->sme.pget_peer_info_ext_ind_cb = callbackfn;
8378 mac->sme.pget_peer_info_ext_cb_context = context;
8379
8380 /* serialize the req through MC thread */
8381 message.bodyptr =
8382 qdf_mem_malloc(sizeof(struct sir_peer_info_ext_req));
8383 if (NULL == message.bodyptr) {
8384 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8385 "%s: Memory allocation failed.", __func__);
8386 sme_release_global_lock(&mac->sme);
8387 return QDF_STATUS_E_NOMEM;
8388 }
8389 qdf_mem_copy(message.bodyptr,
8390 req,
8391 sizeof(struct sir_peer_info_ext_req));
8392 message.type = WMA_GET_PEER_INFO_EXT;
8393 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
8394 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8395 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8396 "%s: Post get rssi msg fail", __func__);
8397 qdf_mem_free(message.bodyptr);
8398 status = QDF_STATUS_E_FAILURE;
8399 }
8400 sme_release_global_lock(&mac->sme);
8401 }
8402 return status;
8403}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008404
8405/*
8406 * SME API to enable/disable WLAN driver initiated SSR
8407 */
8408void sme_update_enable_ssr(tHalHandle hHal, bool enableSSR)
8409{
8410 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308411 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008412
8413 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308414 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07008415 sme_debug("SSR level is changed %d", enableSSR);
Jeff Johnson698eacd2018-05-12 17:00:03 -07008416 /* not serializing this message, as this is only going
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008417 * to set a variable in WMA/WDI
8418 */
8419 WMA_SetEnableSSR(enableSSR);
8420 sme_release_global_lock(&pMac->sme);
8421 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008422}
8423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008424/*convert the ini value to the ENUM used in csr and MAC for CB state*/
8425ePhyChanBondState sme_get_cb_phy_state_from_cb_ini_value(uint32_t cb_ini_value)
8426{
8427 return csr_convert_cb_ini_value_to_phy_cb_state(cb_ini_value);
8428}
8429
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308430/*
8431 * sme_set_curr_device_mode() - Sets the current operating device mode.
8432 *
8433 * hHal - The handle returned by mac_open.
8434 * currDeviceMode - Current operating device mode.
8435 */
Peng Xuf5d60c82015-10-02 17:17:03 -07008436void sme_set_curr_device_mode(tHalHandle hHal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -08008437 enum QDF_OPMODE currDeviceMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008438{
8439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308440
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441 pMac->sme.currDeviceMode = currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008442}
8443
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308444/*
8445 * sme_handoff_request() - a wrapper function to Request a handoff from CSR.
8446 * This is a synchronous call
8447 *
8448 * hHal - The handle returned by mac_open
8449 * sessionId - Session Identifier
8450 * pHandoffInfo - info provided by HDD with the handoff request (namely:
8451 * BSSID, channel etc.)
8452 * Return QDF_STATUS_SUCCESS - SME passed the request to CSR successfully.
8453 * Other status means SME is failed to send the request.
8454 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008455
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308456QDF_STATUS sme_handoff_request(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008457 uint8_t sessionId,
8458 tCsrHandoffRequest *pHandoffInfo)
8459{
8460 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308461 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008462
8463 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308464 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +05308465 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008466 "%s: invoked", __func__);
8467 status = csr_handoff_request(pMac, sessionId, pHandoffInfo);
8468 sme_release_global_lock(&pMac->sme);
8469 }
8470
8471 return status;
8472}
8473
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008474/*
8475 * SME API to check if there is any infra station or
8476 * P2P client is connected
8477 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308478QDF_STATUS sme_is_sta_p2p_client_connected(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008479{
8480 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308481
8482 if (csr_is_infra_connected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308483 return QDF_STATUS_SUCCESS;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308484
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308485 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008486}
8487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008488/**
8489 * sme_add_periodic_tx_ptrn() - Add Periodic TX Pattern
8490 * @hal: global hal handle
8491 * @addPeriodicTxPtrnParams: request message
8492 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308493 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008494 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308495QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008496sme_add_periodic_tx_ptrn(tHalHandle hal,
8497 struct sSirAddPeriodicTxPtrn *addPeriodicTxPtrnParams)
8498{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308499 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008500 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8501 struct sSirAddPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008502 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008503
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008504 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008505
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308506 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008508 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308509 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008510 }
8511
8512 *req_msg = *addPeriodicTxPtrnParams;
8513
8514 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308515 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008516 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008517 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308518 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008519 return status;
8520 }
8521
8522 /* Serialize the req through MC thread */
8523 msg.bodyptr = req_msg;
8524 msg.type = WMA_ADD_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308525 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8526 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008527 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308528 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008529 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008530 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308531 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008532 }
8533 sme_release_global_lock(&mac->sme);
8534 return status;
8535}
8536
8537/**
8538 * sme_del_periodic_tx_ptrn() - Delete Periodic TX Pattern
8539 * @hal: global hal handle
8540 * @delPeriodicTxPtrnParams: request message
8541 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308542 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008543 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308544QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008545sme_del_periodic_tx_ptrn(tHalHandle hal,
8546 struct sSirDelPeriodicTxPtrn *delPeriodicTxPtrnParams)
8547{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308548 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008549 tpAniSirGlobal mac = PMAC_STRUCT(hal);
8550 struct sSirDelPeriodicTxPtrn *req_msg;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008551 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008552
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008553 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308555 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008556 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008557 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308558 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008559 }
8560
8561 *req_msg = *delPeriodicTxPtrnParams;
8562
8563 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308564 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008565 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308567 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008568 return status;
8569 }
8570
8571 /* Serialize the req through MC thread */
8572 msg.bodyptr = req_msg;
8573 msg.type = WMA_DEL_PERIODIC_TX_PTRN_IND;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05308574 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
8575 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008576 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308577 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008578 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008579 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308580 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008581 }
8582 sme_release_global_lock(&mac->sme);
8583 return status;
8584}
8585
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308586/*
8587 * sme_enable_rmc() - enables RMC
8588 * @hHal : Pointer to global HAL handle
8589 * @sessionId : Session ID
8590 *
8591 * Return: QDF_STATUS
8592 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008593QDF_STATUS sme_enable_rmc(tHalHandle hHal, uint32_t sessionId)
8594{
8595 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8596 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008597 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008598 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8599
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008600 SME_ENTER();
8601
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008602 status = sme_acquire_global_lock(&pMac->sme);
8603 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008604 message.bodyptr = NULL;
8605 message.type = WMA_RMC_ENABLE_IND;
8606 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8607 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008608 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8610 "%s: failed to post message to WMA",
8611 __func__);
8612 status = QDF_STATUS_E_FAILURE;
8613 }
8614 sme_release_global_lock(&pMac->sme);
8615 }
8616 return status;
8617}
8618
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308619/*
8620 * sme_disable_rmc() - disables RMC
8621 * @hHal : Pointer to global HAL handle
8622 * @sessionId : Session ID
8623 *
8624 * Return: QDF_STATUS
8625 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008626QDF_STATUS sme_disable_rmc(tHalHandle hHal, uint32_t sessionId)
8627{
8628 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8629 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008630 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008631 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8632
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008633 SME_ENTER();
8634
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008635 status = sme_acquire_global_lock(&pMac->sme);
8636 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008637 message.bodyptr = NULL;
8638 message.type = WMA_RMC_DISABLE_IND;
8639 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8640 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008641 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8642 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8643 "%s: failed to post message to WMA",
8644 __func__);
8645 status = QDF_STATUS_E_FAILURE;
8646 }
8647 sme_release_global_lock(&pMac->sme);
8648 }
8649 return status;
8650}
8651
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308652/*
8653 * sme_send_rmc_action_period() - sends RMC action period param to target
8654 * @hHal : Pointer to global HAL handle
8655 * @sessionId : Session ID
8656 *
8657 * Return: QDF_STATUS
8658 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008659QDF_STATUS sme_send_rmc_action_period(tHalHandle hHal, uint32_t sessionId)
8660{
8661 QDF_STATUS status = QDF_STATUS_SUCCESS;
8662 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8663 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008664 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008665
8666 status = sme_acquire_global_lock(&pMac->sme);
8667 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008668 message.bodyptr = NULL;
8669 message.type = WMA_RMC_ACTION_PERIOD_IND;
8670 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8671 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008672 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8673 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8674 "%s: failed to post message to WMA",
8675 __func__);
8676 status = QDF_STATUS_E_FAILURE;
8677 }
8678 sme_release_global_lock(&pMac->sme);
8679 }
8680
8681 return status;
8682}
8683
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308684/*
8685 * sme_request_ibss_peer_info() - request ibss peer info
8686 * @hHal : Pointer to global HAL handle
8687 * @pUserData : Pointer to user data
8688 * @peerInfoCbk : Peer info callback
8689 * @allPeerInfoReqd : All peer info required or not
8690 * @staIdx : sta index
8691 *
8692 * Return: QDF_STATUS
8693 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008694QDF_STATUS sme_request_ibss_peer_info(tHalHandle hHal, void *pUserData,
8695 pIbssPeerInfoCb peerInfoCbk,
8696 bool allPeerInfoReqd, uint8_t staIdx)
8697{
8698 QDF_STATUS status = QDF_STATUS_E_FAILURE;
8699 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
8700 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008701 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008702 tSirIbssGetPeerInfoReqParams *pIbssInfoReqParams;
8703
8704 status = sme_acquire_global_lock(&pMac->sme);
8705 if (QDF_STATUS_SUCCESS == status) {
8706 pMac->sme.peerInfoParams.peerInfoCbk = peerInfoCbk;
8707 pMac->sme.peerInfoParams.pUserData = pUserData;
8708
8709 pIbssInfoReqParams = (tSirIbssGetPeerInfoReqParams *)
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308710 qdf_mem_malloc(sizeof(tSirIbssGetPeerInfoReqParams));
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008711 if (NULL == pIbssInfoReqParams) {
8712 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8713 "%s: Not able to allocate memory for dhcp start",
8714 __func__);
8715 sme_release_global_lock(&pMac->sme);
8716 return QDF_STATUS_E_NOMEM;
8717 }
8718 pIbssInfoReqParams->allPeerInfoReqd = allPeerInfoReqd;
8719 pIbssInfoReqParams->staIdx = staIdx;
8720
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008721 message.type = WMA_GET_IBSS_PEER_INFO_REQ;
8722 message.bodyptr = pIbssInfoReqParams;
8723 message.reserved = 0;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008724
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008725 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8726 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008727 if (QDF_STATUS_SUCCESS != qdf_status) {
8728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8729 "%s: Post WMA_GET_IBSS_PEER_INFO_REQ MSG failed",
8730 __func__);
8731 qdf_mem_free(pIbssInfoReqParams);
8732 qdf_status = QDF_STATUS_E_FAILURE;
8733 }
8734 sme_release_global_lock(&pMac->sme);
8735 }
8736
8737 return qdf_status;
8738}
8739
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308740/*
8741 * sme_send_cesium_enable_ind() -
8742 * Used to send proprietary cesium enable indication to fw
8743 *
8744 * hHal
8745 * sessionId
8746 * Return QDF_STATUS
8747 */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008748QDF_STATUS sme_send_cesium_enable_ind(tHalHandle hHal, uint32_t sessionId)
8749{
8750 QDF_STATUS status = QDF_STATUS_SUCCESS;
8751 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
8752 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -07008753 struct scheduler_msg message = {0};
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008754
8755 status = sme_acquire_global_lock(&pMac->sme);
8756 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008757 message.bodyptr = NULL;
8758 message.type = WMA_IBSS_CESIUM_ENABLE_IND;
8759 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
8760 &message);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08008761 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
8762 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8763 "%s: failed to post message to WMA",
8764 __func__);
8765 status = QDF_STATUS_E_FAILURE;
8766 }
8767 sme_release_global_lock(&pMac->sme);
8768 }
8769
8770 return status;
8771}
8772
Paul Zhang99fe8842017-12-08 14:43:46 +08008773QDF_STATUS sme_set_wlm_latency_level(tHalHandle hal, uint16_t session_id,
8774 uint16_t latency_level)
8775{
8776 QDF_STATUS status;
8777 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
8778 struct wlm_latency_level_param params;
8779 void *wma = cds_get_context(QDF_MODULE_ID_WMA);
8780
Bala Venkatesh7cf5b662018-05-10 15:18:53 +05308781 if (!wma)
8782 return QDF_STATUS_E_FAILURE;
8783
Paul Zhang99fe8842017-12-08 14:43:46 +08008784 if (!mac_ctx->roam.configParam.wlm_latency_enable) {
8785 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8786 "%s: WLM latency level setting is disabled",
8787 __func__);
8788 return QDF_STATUS_E_FAILURE;
8789 }
Krunal Soni3fa80e22018-01-09 14:16:02 -08008790 if (!wma) {
8791 sme_err("wma is NULL");
8792 return QDF_STATUS_E_FAILURE;
8793 }
Paul Zhang99fe8842017-12-08 14:43:46 +08008794
8795 params.wlm_latency_level = latency_level;
8796 params.wlm_latency_flags =
8797 mac_ctx->roam.configParam.wlm_latency_flags[latency_level];
8798 params.vdev_id = session_id;
8799
8800 status = wma_set_wlm_latency_level(wma, &params);
8801 if (!QDF_IS_STATUS_SUCCESS(status))
8802 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
8803 "%s: failed to set latency level",
8804 __func__);
8805
8806 return status;
8807}
8808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008809void sme_get_command_q_status(tHalHandle hHal)
8810{
8811 tSmeCmd *pTempCmd = NULL;
8812 tListElem *pEntry;
8813 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
8814
8815 if (NULL == pMac) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308816 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008817 "%s: pMac is NULL", __func__);
8818 return;
8819 }
8820
Krunal Sonia8270f52017-02-23 19:51:25 -08008821 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308822 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008823 pTempCmd = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308824
Kabilan Kannan33fcd682018-03-08 14:29:46 -08008825 sme_err("WLAN_BUG_RCA: Currently smeCmdActiveList has command (0x%X)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008826 (pTempCmd) ? pTempCmd->command : eSmeNoCommand);
8827 if (pTempCmd) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308828 if (eSmeCsrCommandMask & pTempCmd->command)
8829 /* CSR command is stuck. See what the reason code is
8830 * for that command
8831 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008832 dump_csr_command_info(pMac, pTempCmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 } /* if(pTempCmd) */
8834
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07008835 sme_err("Currently smeCmdPendingList has %d commands",
Krunal Soni72dba662017-02-15 20:13:17 -08008836 csr_nonscan_pending_ll_count(pMac));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008838}
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008839/**
8840 * sme_set_prefer_80MHz_over_160MHz() - API to set sta_prefer_80MHz_over_160MHz
8841 * @hal: The handle returned by macOpen
8842 * @sta_prefer_80MHz_over_160MHz: sta_prefer_80MHz_over_160MHz config param
8843 */
8844void sme_set_prefer_80MHz_over_160MHz(tHalHandle hal,
8845 bool sta_prefer_80MHz_over_160MHz)
8846{
8847 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308848
Kiran Kumar Lokere1aa9c9a2016-10-05 18:50:59 -07008849 mac_ctx->sta_prefer_80MHz_over_160MHz = sta_prefer_80MHz_over_160MHz;
8850}
8851
Agrawal Ashishb141b092016-09-02 19:59:26 +05308852#ifdef WLAN_FEATURE_DSRC
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008853/**
8854 * sme_set_dot11p_config() - API to set the 802.11p config
8855 * @hHal: The handle returned by macOpen
8856 * @enable_dot11p: 802.11p config param
8857 */
8858void sme_set_dot11p_config(tHalHandle hHal, bool enable_dot11p)
8859{
8860 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05308861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 pMac->enable_dot11p = enable_dot11p;
8863}
8864
8865/**
8866 * copy_sir_ocb_config() - Performs deep copy of an OCB configuration
8867 * @src: the source configuration
8868 *
8869 * Return: pointer to the copied OCB configuration
8870 */
8871static struct sir_ocb_config *sme_copy_sir_ocb_config(
8872 struct sir_ocb_config *src)
8873{
8874 struct sir_ocb_config *dst;
8875 uint32_t length;
8876 void *cursor;
8877
8878 length = sizeof(*src) +
8879 src->channel_count * sizeof(*src->channels) +
8880 src->schedule_size * sizeof(*src->schedule) +
8881 src->dcc_ndl_chan_list_len +
8882 src->dcc_ndl_active_state_list_len;
8883
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308884 dst = qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885 if (!dst)
8886 return NULL;
8887
8888 *dst = *src;
8889
8890 cursor = dst;
8891 cursor += sizeof(*dst);
8892 dst->channels = cursor;
8893 cursor += src->channel_count * sizeof(*src->channels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308894 qdf_mem_copy(dst->channels, src->channels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895 src->channel_count * sizeof(*src->channels));
8896 dst->schedule = cursor;
8897 cursor += src->schedule_size * sizeof(*src->schedule);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308898 qdf_mem_copy(dst->schedule, src->schedule,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 src->schedule_size * sizeof(*src->schedule));
8900 dst->dcc_ndl_chan_list = cursor;
8901 cursor += src->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308902 qdf_mem_copy(dst->dcc_ndl_chan_list, src->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008903 src->dcc_ndl_chan_list_len);
8904 dst->dcc_ndl_active_state_list = cursor;
8905 cursor += src->dcc_ndl_active_state_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308906 qdf_mem_copy(dst->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 src->dcc_ndl_active_state_list,
8908 src->dcc_ndl_active_state_list_len);
8909 return dst;
8910}
8911
8912/**
8913 * sme_ocb_set_config() - Set the OCB configuration
8914 * @hHal: reference to the HAL
8915 * @context: the context of the call
8916 * @callback: the callback to hdd
8917 * @config: the OCB configuration
8918 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308919 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008920 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308921QDF_STATUS sme_ocb_set_config(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008922 ocb_callback callback,
8923 struct sir_ocb_config *config)
8924{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308925 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008926 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008927 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 struct sir_ocb_config *msg_body;
8929
8930 /* Lock the SME structure */
8931 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308932 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933 return status;
8934
8935 /*
8936 * Check if there is a pending request and return an error if one
8937 * exists
8938 */
8939 if (pMac->sme.ocb_set_config_callback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308940 status = QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008941 goto end;
8942 }
8943
8944 msg_body = sme_copy_sir_ocb_config(config);
8945
8946 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308947 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008948 goto end;
8949 }
8950
8951 msg.type = WMA_OCB_SET_CONFIG_CMD;
8952 msg.bodyptr = msg_body;
8953
8954 /* Set the request callback and context */
8955 pMac->sme.ocb_set_config_callback = callback;
8956 pMac->sme.ocb_set_config_context = context;
8957
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008958 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308959 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308960 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008961 FL("Error posting message to WDA: %d"), status);
8962 pMac->sme.ocb_set_config_callback = callback;
8963 pMac->sme.ocb_set_config_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308964 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008965 goto end;
8966 }
8967
8968end:
8969 sme_release_global_lock(&pMac->sme);
8970
8971 return status;
8972}
8973
8974/**
8975 * sme_ocb_set_utc_time() - Set the OCB UTC time
8976 * @hHal: reference to the HAL
8977 * @utc: the UTC time struct
8978 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308979 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008980 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308981QDF_STATUS sme_ocb_set_utc_time(tHalHandle hHal, struct sir_ocb_utc *utc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008982{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308983 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008984 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08008985 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008986 struct sir_ocb_utc *sme_utc;
8987
8988 /* Lock the SME structure */
8989 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308990 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008991 return status;
8992
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308993 sme_utc = qdf_mem_malloc(sizeof(*sme_utc));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008994 if (!sme_utc) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308995 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 FL("Malloc failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308997 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008998 goto end;
8999 }
9000 *sme_utc = *utc;
9001
9002 msg.type = WMA_OCB_SET_UTC_TIME_CMD;
9003 msg.reserved = 0;
9004 msg.bodyptr = sme_utc;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009005 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309006 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309007 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009008 FL("Not able to post message to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309009 qdf_mem_free(utc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009010 goto end;
9011 }
9012
9013end:
9014 sme_release_global_lock(&pMac->sme);
9015
9016 return status;
9017}
9018
9019/**
9020 * sme_ocb_start_timing_advert() - Start sending timing advert frames
9021 * @hHal: reference to the HAL
9022 * @timing_advert: the timing advertisement struct
9023 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309024 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009025 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309026QDF_STATUS sme_ocb_start_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009027 struct sir_ocb_timing_advert *timing_advert)
9028{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309029 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009030 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009031 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009032 void *buf;
9033 struct sir_ocb_timing_advert *sme_timing_advert;
9034
9035 /* Lock the SME structure */
9036 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309037 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 return status;
9039
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309040 buf = qdf_mem_malloc(sizeof(*sme_timing_advert) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009041 timing_advert->template_length);
9042 if (!buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009044 FL("Not able to allocate memory for start TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309045 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009046 goto end;
9047 }
9048
9049 sme_timing_advert = (struct sir_ocb_timing_advert *)buf;
9050 *sme_timing_advert = *timing_advert;
9051 sme_timing_advert->template_value = buf + sizeof(*sme_timing_advert);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309052 qdf_mem_copy(sme_timing_advert->template_value,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009053 timing_advert->template_value, timing_advert->template_length);
9054
9055 msg.type = WMA_OCB_START_TIMING_ADVERT_CMD;
9056 msg.reserved = 0;
9057 msg.bodyptr = buf;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009058 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309059 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309060 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009061 FL("Not able to post msg to WDA"));
9062 goto end;
9063 }
9064
9065end:
9066 sme_release_global_lock(&pMac->sme);
9067
9068 return status;
9069}
9070
9071/**
9072 * sme_ocb_stop_timing_advert() - Stop sending timing advert frames on a channel
9073 * @hHal: reference to the HAL
9074 * @timing_advert: the timing advertisement struct
9075 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309076 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009077 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309078QDF_STATUS sme_ocb_stop_timing_advert(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079 struct sir_ocb_timing_advert *timing_advert)
9080{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309081 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009082 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009083 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009084 struct sir_ocb_timing_advert *sme_timing_advert;
9085
9086 /* Lock the SME structure */
9087 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309088 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009089 return status;
9090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309091 sme_timing_advert = qdf_mem_malloc(sizeof(*timing_advert));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009092 if (!sme_timing_advert) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309093 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009094 FL("Not able to allocate memory for stop TA"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309095 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009096 goto end;
9097 }
9098 *sme_timing_advert = *timing_advert;
9099
9100 msg.type = WMA_OCB_STOP_TIMING_ADVERT_CMD;
9101 msg.reserved = 0;
9102 msg.bodyptr = sme_timing_advert;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009103 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309104 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309105 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 FL("Not able to post msg to WDA"));
9107 goto end;
9108 }
9109
9110end:
9111 sme_release_global_lock(&pMac->sme);
9112
9113 return status;
9114}
9115
9116/**
Naveen Rawatb4d37622015-11-13 16:15:25 -08009117 * sme_ocb_gen_timing_advert_frame() - generate TA frame and populate the buffer
9118 * @hal_handle: reference to the HAL
9119 * @self_addr: the self MAC address
9120 * @buf: the buffer that will contain the frame
9121 * @timestamp_offset: return for the offset of the timestamp field
9122 * @time_value_offset: return for the time_value field in the TA IE
9123 *
9124 * Return: the length of the buffer.
9125 */
9126int sme_ocb_gen_timing_advert_frame(tHalHandle hal_handle,
9127 tSirMacAddr self_addr, uint8_t **buf,
9128 uint32_t *timestamp_offset,
9129 uint32_t *time_value_offset)
9130{
9131 int template_length;
9132 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
9133
9134 template_length = sch_gen_timing_advert_frame(mac_ctx, self_addr, buf,
9135 timestamp_offset,
9136 time_value_offset);
9137 return template_length;
9138}
9139/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009140 * sme_ocb_get_tsf_timer() - Get the TSF timer value
9141 * @hHal: reference to the HAL
9142 * @context: the context of the call
9143 * @callback: the callback to hdd
9144 * @request: the TSF timer request
9145 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309146 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009147 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309148QDF_STATUS sme_ocb_get_tsf_timer(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 ocb_callback callback,
9150 struct sir_ocb_get_tsf_timer *request)
9151{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309152 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009153 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009154 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 struct sir_ocb_get_tsf_timer *msg_body;
9156
9157 /* Lock the SME structure */
9158 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309159 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009160 return status;
9161
9162 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309163 msg_body = qdf_mem_malloc(sizeof(*msg_body));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309165 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009166 goto end;
9167 }
9168 *msg_body = *request;
9169
9170 msg.type = WMA_OCB_GET_TSF_TIMER_CMD;
9171 msg.bodyptr = msg_body;
9172
9173 /* Set the request callback and the context */
9174 pMac->sme.ocb_get_tsf_timer_callback = callback;
9175 pMac->sme.ocb_get_tsf_timer_context = context;
9176
9177 /* Post the message to WDA */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009178 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309179 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309180 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009181 FL("Error posting message to WDA: %d"), status);
9182 pMac->sme.ocb_get_tsf_timer_callback = NULL;
9183 pMac->sme.ocb_get_tsf_timer_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309184 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009185 goto end;
9186 }
9187
9188end:
9189 sme_release_global_lock(&pMac->sme);
9190
9191 return status;
9192}
9193
9194/**
9195 * sme_dcc_get_stats() - Get the DCC stats
9196 * @hHal: reference to the HAL
9197 * @context: the context of the call
9198 * @callback: the callback to hdd
9199 * @request: the get DCC stats request
9200 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309201 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009202 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309203QDF_STATUS sme_dcc_get_stats(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009204 ocb_callback callback,
9205 struct sir_dcc_get_stats *request)
9206{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309207 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009208 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009209 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009210 struct sir_dcc_get_stats *msg_body;
9211
9212 /* Lock the SME structure */
9213 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309214 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009215 return status;
9216
9217 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309218 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219 request->request_array_len);
9220 if (!msg_body) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309221 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009222 goto end;
9223 }
9224 *msg_body = *request;
9225 msg_body->request_array = (void *)msg_body + sizeof(*msg_body);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309226 qdf_mem_copy(msg_body->request_array, request->request_array,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227 request->request_array_len);
9228
9229 msg.type = WMA_DCC_GET_STATS_CMD;
9230 msg.bodyptr = msg_body;
9231
9232 /* Set the request callback and context */
9233 pMac->sme.dcc_get_stats_callback = callback;
9234 pMac->sme.dcc_get_stats_context = context;
9235
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009236 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309238 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009239 FL("Error posting message to WDA: %d"), status);
9240 pMac->sme.dcc_get_stats_callback = callback;
9241 pMac->sme.dcc_get_stats_context = context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309242 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009243 goto end;
9244 }
9245
9246end:
9247 sme_release_global_lock(&pMac->sme);
9248
9249 return status;
9250}
9251
9252/**
9253 * sme_dcc_clear_stats() - Clear the DCC stats
9254 * @hHal: reference to the HAL
9255 * @vdev_id: vdev id for OCB interface
9256 * @dcc_stats_bitmap: the entries in the stats to clear
9257 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309258 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309260QDF_STATUS sme_dcc_clear_stats(tHalHandle hHal, uint32_t vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009261 uint32_t dcc_stats_bitmap)
9262{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309263 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009265 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266 struct sir_dcc_clear_stats *request;
9267
9268 /* Lock the SME structure */
9269 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309270 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009271 return status;
9272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309273 request = qdf_mem_malloc(sizeof(struct sir_dcc_clear_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009274 if (!request) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309275 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009276 FL("Not able to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309277 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009278 goto end;
9279 }
9280
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009281 request->vdev_id = vdev_id;
9282 request->dcc_stats_bitmap = dcc_stats_bitmap;
9283
9284 msg.type = WMA_DCC_CLEAR_STATS_CMD;
9285 msg.bodyptr = request;
9286
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009287 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309288 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309289 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290 FL("Not able to post msg to WDA"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309291 qdf_mem_free(request);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009292 goto end;
9293 }
9294
9295end:
9296 sme_release_global_lock(&pMac->sme);
9297
9298 return status;
9299}
9300
9301/**
9302 * sme_dcc_update_ndl() - Update the DCC settings
9303 * @hHal: reference to the HAL
9304 * @context: the context of the call
9305 * @callback: the callback to hdd
9306 * @request: the update DCC request
9307 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309308 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009309 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309310QDF_STATUS sme_dcc_update_ndl(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009311 ocb_callback callback,
9312 struct sir_dcc_update_ndl *request)
9313{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309314 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009315 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009316 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009317 struct sir_dcc_update_ndl *msg_body;
9318
9319 /* Lock the SME structure */
9320 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309321 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 return status;
9323
9324 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309325 msg_body = qdf_mem_malloc(sizeof(*msg_body) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009326 request->dcc_ndl_chan_list_len +
9327 request->dcc_ndl_active_state_list_len);
9328 if (!msg_body) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309329 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009330 FL("Failed to allocate memory"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309331 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 goto end;
9333 }
9334
9335 *msg_body = *request;
9336
9337 msg_body->dcc_ndl_chan_list = (void *)msg_body + sizeof(*msg_body);
9338 msg_body->dcc_ndl_active_state_list = msg_body->dcc_ndl_chan_list +
9339 request->dcc_ndl_chan_list_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309340 qdf_mem_copy(msg_body->dcc_ndl_chan_list, request->dcc_ndl_chan_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009341 request->dcc_ndl_active_state_list_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309342 qdf_mem_copy(msg_body->dcc_ndl_active_state_list,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009343 request->dcc_ndl_active_state_list,
9344 request->dcc_ndl_active_state_list_len);
9345
9346 msg.type = WMA_DCC_UPDATE_NDL_CMD;
9347 msg.bodyptr = msg_body;
9348
9349 /* Set the request callback and the context */
9350 pMac->sme.dcc_update_ndl_callback = callback;
9351 pMac->sme.dcc_update_ndl_context = context;
9352
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009353 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309354 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309355 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009356 FL("Error posting message to WDA: %d"), status);
9357 pMac->sme.dcc_update_ndl_callback = NULL;
9358 pMac->sme.dcc_update_ndl_context = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309359 qdf_mem_free(msg_body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009360 goto end;
9361 }
9362
9363end:
9364 sme_release_global_lock(&pMac->sme);
9365
9366 return status;
9367}
9368
9369/**
9370 * sme_register_for_dcc_stats_event() - Register for the periodic DCC stats
9371 * event
9372 * @hHal: reference to the HAL
9373 * @context: the context of the call
9374 * @callback: the callback to hdd
9375 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309376 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009377 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309378QDF_STATUS sme_register_for_dcc_stats_event(tHalHandle hHal, void *context,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009379 ocb_callback callback)
9380{
9381 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309382 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009383
9384 status = sme_acquire_global_lock(&pMac->sme);
9385 pMac->sme.dcc_stats_event_callback = callback;
9386 pMac->sme.dcc_stats_event_context = context;
9387 sme_release_global_lock(&pMac->sme);
9388
9389 return 0;
9390}
9391
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309392/**
9393 * sme_deregister_for_dcc_stats_event() - De-Register for the periodic DCC stats
9394 * event
9395 * @h_hal: Hal Handle
9396 *
9397 * This function de-registers the DCC perioc stats callback
9398 *
9399 * Return: QDF_STATUS Enumeration
9400 */
9401QDF_STATUS sme_deregister_for_dcc_stats_event(tHalHandle h_hal)
9402{
9403 tpAniSirGlobal mac;
9404 QDF_STATUS status;
9405
9406 if (!h_hal) {
9407 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9408 FL("h_hal is not valid"));
9409 return QDF_STATUS_E_INVAL;
9410 }
9411 mac = PMAC_STRUCT(h_hal);
9412
9413 status = sme_acquire_global_lock(&mac->sme);
9414 if (!QDF_IS_STATUS_SUCCESS(status)) {
9415 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
9416 FL("Failed to acquire global lock"));
9417 return status;
9418 }
9419 mac->sme.dcc_stats_event_callback = NULL;
9420 mac->sme.dcc_stats_event_context = NULL;
9421 sme_release_global_lock(&mac->sme);
9422
9423 return status;
9424}
Agrawal Ashishb141b092016-09-02 19:59:26 +05309425#endif
Arun Khandavalli4b55da72016-07-19 19:55:01 +05309426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009427void sme_get_recovery_stats(tHalHandle hHal)
9428{
9429 uint8_t i;
9430
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309431 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009432 "Self Recovery Stats");
9433 for (i = 0; i < MAX_ACTIVE_CMD_STATS; i++) {
9434 if (eSmeNoCommand !=
9435 g_self_recovery_stats.activeCmdStats[i].command) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309436 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009437 "timestamp %llu: command 0x%0X: reason %d: session %d",
9438 g_self_recovery_stats.activeCmdStats[i].
9439 timestamp,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309440 g_self_recovery_stats.activeCmdStats[i].command,
9441 g_self_recovery_stats.activeCmdStats[i].reason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009442 g_self_recovery_stats.activeCmdStats[i].
9443 sessionId);
9444 }
9445 }
9446}
9447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309448QDF_STATUS sme_notify_modem_power_state(tHalHandle hHal, uint32_t value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009449{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009450 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009451 tpSirModemPowerStateInd request_buf;
9452 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9453
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309454 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309455 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009456
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309457 request_buf = qdf_mem_malloc(sizeof(tSirModemPowerStateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009458 if (NULL == request_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009460 "%s: Not able to allocate memory for MODEM POWER STATE IND",
9461 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309462 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 }
9464
9465 request_buf->param = value;
9466
9467 msg.type = WMA_MODEM_POWER_STATE_IND;
9468 msg.reserved = 0;
9469 msg.bodyptr = request_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309470 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009471 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309472 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309473 "%s: Not able to post WMA_MODEM_POWER_STATE_IND message to WMA",
9474 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309475 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309476 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 }
9478
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309479 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009480}
9481
9482#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309483QDF_STATUS sme_notify_ht2040_mode(tHalHandle hHal, uint16_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309484 struct qdf_mac_addr macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009485 uint8_t sessionId,
9486 uint8_t channel_type)
9487{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009488 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009489 tUpdateVHTOpMode *pHtOpMode = NULL;
9490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9491
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309492 if (NULL == pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309493 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009494
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309495 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009496 if (NULL == pHtOpMode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498 "%s: Not able to allocate memory for setting OP mode",
9499 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309500 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 }
9502
9503 switch (channel_type) {
9504 case eHT_CHAN_HT20:
9505 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_20MHZ;
9506 break;
9507
9508 case eHT_CHAN_HT40MINUS:
9509 case eHT_CHAN_HT40PLUS:
9510 pHtOpMode->opMode = eHT_CHANNEL_WIDTH_40MHZ;
9511 break;
9512
9513 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309514 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009515 "%s: Invalid OP mode", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309516 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009517 }
9518
9519 pHtOpMode->staId = staId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309520 qdf_mem_copy(pHtOpMode->peer_mac, macAddrSTA.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 sizeof(tSirMacAddr));
9522 pHtOpMode->smesessionId = sessionId;
9523
9524 msg.type = WMA_UPDATE_OP_MODE;
9525 msg.reserved = 0;
9526 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309527 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009528 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309529 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309530 "%s: Not able to post WMA_UPDATE_OP_MODE message to WMA",
9531 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309532 qdf_mem_free(pHtOpMode);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309533 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009534 }
9535
Abhishek Singhe4a1f882017-08-10 17:59:44 +05309536 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson698eacd2018-05-12 17:00:03 -07009537 "%s: Notified FW about OP mode: %d for staId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 __func__, pHtOpMode->opMode, staId);
9539
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309540 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009541}
9542
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309543/*
9544 * sme_set_ht2040_mode() -
9545 * To update HT Operation beacon IE.
9546 *
9547 * Return QDF_STATUS SUCCESS
9548 * FAILURE or RESOURCES
9549 * The API finished and failed.
9550 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309551QDF_STATUS sme_set_ht2040_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 uint8_t channel_type, bool obssEnabled)
9553{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309554 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009555 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
9556 ePhyChanBondState cbMode;
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309557 struct csr_roam_session *session = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009558
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309559 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
9560 sme_err("Session not valid for session id %d", sessionId);
9561 return QDF_STATUS_E_INVAL;
9562 }
9563 session = CSR_GET_SESSION(pMac, sessionId);
9564 sme_debug("Update HT operation beacon IE, channel_type=%d cur cbmode %d",
9565 channel_type, session->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009566
9567 switch (channel_type) {
9568 case eHT_CHAN_HT20:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309569 if (!session->bssParams.cbMode)
9570 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
9572 break;
9573 case eHT_CHAN_HT40MINUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309574 if (session->bssParams.cbMode)
9575 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009576 cbMode = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
9577 break;
9578 case eHT_CHAN_HT40PLUS:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309579 if (session->bssParams.cbMode)
9580 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 cbMode = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
9582 break;
9583 default:
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309584 sme_err("Error!!! Invalid HT20/40 mode !");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309585 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009586 }
Abhishek Singh9d5f4582017-10-11 17:59:48 +05309587 session->bssParams.cbMode = cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009588 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309589 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 status = csr_set_ht2040_mode(pMac, sessionId,
9591 cbMode, obssEnabled);
9592 sme_release_global_lock(&pMac->sme);
9593 }
9594 return status;
9595}
9596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597#endif
9598
9599/*
9600 * SME API to enable/disable idle mode powersave
9601 * This should be called only if powersave offload
9602 * is enabled
9603 */
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309604QDF_STATUS sme_set_idle_powersave_config(bool value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009605{
Anurag Chouhan6d760662016-02-20 16:05:43 +05309606 void *wmaContext = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009607
9608 if (NULL == wmaContext) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309609 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 "%s: wmaContext is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309611 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309613 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009614 " Idle Ps Set Value %d", value);
9615
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309616 if (QDF_STATUS_SUCCESS != wma_set_idle_ps_config(wmaContext, 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 Idle Ps Value %d", value);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309619 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009620 }
Arunk Khandavalli847969d2017-09-25 15:15:36 +05309621
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309622 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623}
9624
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309625int16_t sme_get_ht_config(tHalHandle hHal, uint8_t session_id,
9626 uint16_t ht_capab)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009627{
9628 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309629 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009630
9631 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309632 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009633 "%s: pSession is NULL", __func__);
9634 return -EIO;
9635 }
9636 switch (ht_capab) {
9637 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9638 return pSession->htConfig.ht_rx_ldpc;
9639 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9640 return pSession->htConfig.ht_tx_stbc;
9641 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9642 return pSession->htConfig.ht_rx_stbc;
9643 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009644 return pSession->htConfig.ht_sgi20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009645 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009646 return pSession->htConfig.ht_sgi40;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649 "invalid ht capability");
9650 return -EIO;
9651 }
9652}
9653
9654int sme_update_ht_config(tHalHandle hHal, uint8_t sessionId, uint16_t htCapab,
9655 int value)
9656{
9657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309658 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009659
9660 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309661 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009662 "%s: pSession is NULL", __func__);
9663 return -EIO;
9664 }
9665
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309666 if (QDF_STATUS_SUCCESS != wma_set_htconfig(sessionId, htCapab, value)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009668 "Failed to set ht capability in target");
9669 return -EIO;
9670 }
9671
9672 switch (htCapab) {
9673 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
9674 pSession->htConfig.ht_rx_ldpc = value;
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -07009675 pMac->roam.configParam.rx_ldpc_enable = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009676 break;
9677 case WNI_CFG_HT_CAP_INFO_TX_STBC:
9678 pSession->htConfig.ht_tx_stbc = value;
9679 break;
9680 case WNI_CFG_HT_CAP_INFO_RX_STBC:
9681 pSession->htConfig.ht_rx_stbc = value;
9682 break;
9683 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009684 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009685 pSession->htConfig.ht_sgi20 = value;
9686 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009687 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
Krishna Kumaar Natarajana5c5aad2016-12-05 14:12:13 -08009688 value = value ? 1 : 0; /* HT SGI can be only 1 or 0 */
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07009689 pSession->htConfig.ht_sgi40 = value;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009690 break;
9691 }
9692
Naveen Rawat8029a402017-06-01 10:54:19 -07009693 csr_roam_update_config(pMac, sessionId, htCapab, value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009694 return 0;
9695}
9696
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08009697int sme_set_addba_accept(tHalHandle hal, uint8_t session_id, int value)
9698{
9699 struct sme_addba_accept *addba_accept;
9700 struct scheduler_msg msg = {0};
9701 QDF_STATUS status;
9702
9703 addba_accept = qdf_mem_malloc(sizeof(*addba_accept));
9704 if (!addba_accept) {
9705 sme_err("mem alloc failed for addba_accept");
9706 return -EIO;
9707 }
9708 addba_accept->session_id = session_id;
9709 addba_accept->addba_accept = value;
9710 qdf_mem_zero(&msg, sizeof(msg));
9711 msg.type = eWNI_SME_SET_ADDBA_ACCEPT;
9712 msg.reserved = 0;
9713 msg.bodyptr = addba_accept;
9714 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9715 if (status != QDF_STATUS_SUCCESS) {
9716 sme_err("Not able to post addba reject");
9717 qdf_mem_free(addba_accept);
9718 return -EIO;
9719 }
9720 return 0;
9721}
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08009722
9723int sme_set_ba_buff_size(tHalHandle hal, uint8_t session_id,
9724 uint16_t buff_size)
9725{
9726 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9727 if (!buff_size) {
9728 sme_err("invalid buff size %d", buff_size);
9729 return -EINVAL;
9730 }
9731 mac_ctx->usr_cfg_ba_buff_size = buff_size;
9732 sme_debug("addba buff size is set to %d",
9733 mac_ctx->usr_cfg_ba_buff_size);
9734
9735 return 0;
9736}
9737
9738#define DEFAULT_BA_BUFF_SIZE 64
9739int sme_send_addba_req(tHalHandle hal, uint8_t session_id, uint8_t tid,
9740 uint16_t buff_size)
9741{
9742 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9743 uint16_t ba_buff = 0;
9744 QDF_STATUS status;
9745 struct scheduler_msg msg = {0};
9746 struct send_add_ba_req *send_ba_req;
9747 struct csr_roam_session *csr_session = NULL;
9748
9749 if (!csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9750 sme_err("STA not infra/connected state session_id: %d",
9751 session_id);
9752 return -EINVAL;
9753 }
9754 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
9755 if (!csr_session) {
9756 sme_err("CSR session is NULL");
9757 return -EINVAL;
9758 }
9759 send_ba_req = qdf_mem_malloc(sizeof(*send_ba_req));
9760 if (!send_ba_req) {
9761 sme_err("mem alloc failed");
9762 return -EIO;
9763 }
9764 qdf_mem_copy(send_ba_req->mac_addr,
9765 csr_session->connectedProfile.bssid.bytes,
9766 QDF_MAC_ADDR_SIZE);
9767 ba_buff = buff_size;
9768 if (!buff_size) {
9769 if (mac_ctx->usr_cfg_ba_buff_size)
9770 ba_buff = mac_ctx->usr_cfg_ba_buff_size;
9771 else
9772 ba_buff = DEFAULT_BA_BUFF_SIZE;
9773 }
9774 send_ba_req->param.vdev_id = session_id;
9775 send_ba_req->param.tidno = tid;
9776 send_ba_req->param.buffersize = ba_buff;
9777 msg.type = WMA_SEND_ADDBA_REQ;
9778 msg.bodyptr = send_ba_req;
9779 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
9780 if (QDF_STATUS_SUCCESS != status) {
9781 sme_err("Failed to post WMA_SEND_ADDBA_REQ");
9782 qdf_mem_free(send_ba_req);
9783 return -EIO;
9784 }
9785 sme_debug("ADDBA_REQ sent to FW: tid %d buff_size %d", tid, ba_buff);
9786
9787 return 0;
9788}
9789
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009790int sme_set_no_ack_policy(tHalHandle hal, uint8_t session_id,
9791 uint8_t val, uint8_t ac)
9792{
9793 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9794 uint8_t i, set_val;
Arif Hussaineb8ba362018-03-07 19:15:13 -08009795 struct scheduler_msg msg = {0};
9796 QDF_STATUS status;
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009797
9798 if (ac > MAX_NUM_AC) {
9799 sme_err("invalid ac val %d", ac);
9800 return -EINVAL;
9801 }
9802 if (val)
9803 set_val = 1;
9804 else
9805 set_val = 0;
9806 if (ac == MAX_NUM_AC) {
9807 for (i = 0; i < ac; i++)
9808 mac_ctx->no_ack_policy_cfg[i] = set_val;
9809 } else {
9810 mac_ctx->no_ack_policy_cfg[ac] = set_val;
9811 }
9812 sme_debug("no ack is set to %d for ac %d", set_val, ac);
Arif Hussaineb8ba362018-03-07 19:15:13 -08009813 qdf_mem_zero(&msg, sizeof(msg));
9814 msg.type = eWNI_SME_UPDATE_EDCA_PROFILE;
9815 msg.reserved = 0;
9816 msg.bodyval = session_id;
9817 status = scheduler_post_msg(QDF_MODULE_ID_PE, &msg);
9818 if (status != QDF_STATUS_SUCCESS) {
9819 sme_err("Not able to post update edca profile");
9820 return -EIO;
9821 }
Kiran Kumar Lokere3324f632018-03-01 21:43:21 -08009822
9823 return 0;
9824}
9825
Kiran Kumar Lokerea006a302018-03-07 20:58:13 -08009826int sme_set_auto_rate_he_ltf(tHalHandle hal, uint8_t session_id,
9827 uint8_t cfg_val)
9828{
9829 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9830 uint32_t set_val;
9831 uint32_t bit_mask = 0;
9832 int status;
9833
9834 if (cfg_val > QCA_WLAN_HE_LTF_4X) {
9835 sme_err("invalid HE LTF cfg %d", cfg_val);
9836 return -EINVAL;
9837 }
9838
9839 /*set the corresponding HE LTF cfg BIT*/
9840 if (cfg_val == QCA_WLAN_HE_LTF_AUTO)
9841 bit_mask = HE_LTF_ALL;
9842 else
9843 bit_mask = (1 << (cfg_val - 1));
9844
9845 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9846
9847 SET_AUTO_RATE_HE_LTF_VAL(set_val, bit_mask);
9848
9849 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9850 status = wma_cli_set_command(session_id,
9851 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9852 set_val, VDEV_CMD);
9853 if (status) {
9854 sme_err("failed to set he_ltf_sgi");
9855 return status;
9856 }
9857
9858 sme_debug("HE SGI_LTF is set to 0x%08X",
9859 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9860
9861 return 0;
9862}
9863
9864int sme_set_auto_rate_he_sgi(tHalHandle hal, uint8_t session_id,
9865 uint8_t cfg_val)
9866{
9867 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
9868 uint32_t set_val;
9869 uint32_t sgi_bit_mask = 0;
9870 int status;
9871
9872 if ((cfg_val > AUTO_RATE_GI_3200NS) ||
9873 (cfg_val < AUTO_RATE_GI_400NS)) {
9874 sme_err("invalid auto rate GI cfg %d", cfg_val);
9875 return -EINVAL;
9876 }
9877
9878 sgi_bit_mask = (1 << cfg_val);
9879
9880 set_val = mac_ctx->he_sgi_ltf_cfg_bit_mask;
9881 SET_AUTO_RATE_SGI_VAL(set_val, sgi_bit_mask);
9882
9883 mac_ctx->he_sgi_ltf_cfg_bit_mask = set_val;
9884 status = wma_cli_set_command(session_id,
9885 WMI_VDEV_PARAM_AUTORATE_MISC_CFG,
9886 set_val, VDEV_CMD);
9887 if (status) {
9888 sme_err("failed to set he_ltf_sgi");
9889 return status;
9890 }
9891
9892 sme_debug("auto rate HE SGI_LTF is set to 0x%08X",
9893 mac_ctx->he_sgi_ltf_cfg_bit_mask);
9894
9895 return 0;
9896}
9897
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009898#define HT20_SHORT_GI_MCS7_RATE 722
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309899/*
9900 * sme_send_rate_update_ind() -
9901 * API to Update rate
9902 *
9903 * hHal - The handle returned by mac_open
9904 * rateUpdateParams - Pointer to rate update params
9905 * Return QDF_STATUS
9906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309907QDF_STATUS sme_send_rate_update_ind(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908 tSirRateUpdateInd *rateUpdateParams)
9909{
9910 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309911 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07009912 struct scheduler_msg msg = {0};
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309913 tSirRateUpdateInd *rate_upd = qdf_mem_malloc(sizeof(tSirRateUpdateInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009914
9915 if (rate_upd == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009917 "Rate update struct alloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009919 }
9920 *rate_upd = *rateUpdateParams;
9921
9922 if (rate_upd->mcastDataRate24GHz == HT20_SHORT_GI_MCS7_RATE)
9923 rate_upd->mcastDataRate24GHzTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009924 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 else if (rate_upd->reliableMcastDataRate ==
9926 HT20_SHORT_GI_MCS7_RATE)
9927 rate_upd->reliableMcastDataRateTxFlag =
Naveen Rawatea1564b2018-05-17 15:56:11 -07009928 TX_RATE_HT20 | TX_RATE_SGI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009929
9930 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309931 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932 msg.type = WMA_RATE_UPDATE_IND;
9933 msg.bodyptr = rate_upd;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05309934 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
9935 NO_SESSION, msg.type));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309936 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08009937 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309938 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +05309939 "%s: Not able to post WMA_SET_RMC_RATE_IND to WMA!",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009940 __func__);
9941
9942 sme_release_global_lock(&pMac->sme);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309943 qdf_mem_free(rate_upd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309944 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009945 }
9946
9947 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309948 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009949 }
9950
9951 return status;
9952}
9953
9954/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309955 * sme_update_access_policy_vendor_ie() - update vendor ie and access policy.
9956 * @hal: Pointer to the mac context
9957 * @session_id: sme session id
9958 * @vendor_ie: vendor ie
9959 * @access_policy: vendor ie access policy
9960 *
9961 * This function updates the vendor ie and access policy to lim.
9962 *
9963 * Return: success or failure.
9964 */
9965QDF_STATUS sme_update_access_policy_vendor_ie(tHalHandle hal,
9966 uint8_t session_id, uint8_t *vendor_ie, int access_policy)
9967{
9968 struct sme_update_access_policy_vendor_ie *msg;
9969 uint16_t msg_len;
9970 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309971
9972 msg_len = sizeof(*msg);
9973
9974 msg = qdf_mem_malloc(msg_len);
9975 if (!msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009976 sme_err("failed to allocate memory for sme_update_access_policy_vendor_ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309977 return QDF_STATUS_E_FAILURE;
9978 }
9979
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309980 msg->msg_type = (uint16_t)eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE;
9981 msg->length = (uint16_t)msg_len;
9982
9983 qdf_mem_copy(&msg->ie[0], vendor_ie, sizeof(msg->ie));
9984
9985 msg->sme_session_id = session_id;
9986 msg->access_policy = access_policy;
9987
Srinivas Girigowda2da81e22017-03-16 21:22:19 -07009988 sme_debug("sme_session_id: %hu, access_policy: %d", session_id,
9989 access_policy);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309990
Rajeev Kumard138ac52017-01-30 18:38:37 -08009991 status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05309992
9993 return status;
9994}
9995
9996/**
Agrawal Ashishda3e9502016-09-21 17:43:51 +05309997 * sme_update_short_retry_limit_threshold() - update short frame retry limit TH
9998 * @hal: Handle returned by mac_open
9999 * @session_id: Session ID on which short frame retry limit needs to be
10000 * updated to FW
10001 * @short_limit_count_th: Retry count TH to retry short frame.
10002 *
10003 * This function is used to configure count to retry short frame.
10004 *
10005 * Return: QDF_STATUS
10006 */
10007QDF_STATUS sme_update_short_retry_limit_threshold(tHalHandle hal_handle,
10008 struct sme_short_retry_limit *short_retry_limit_th)
10009{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010010 QDF_STATUS status = QDF_STATUS_SUCCESS;
10011 struct sme_short_retry_limit *srl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010012 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010013
10014 srl = qdf_mem_malloc(sizeof(*srl));
10015 if (NULL == srl) {
10016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10017 "%s: fail to alloc short retry limit", __func__);
10018 return QDF_STATUS_E_FAILURE;
10019 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010020 sme_debug("session_id %d short retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010021 short_retry_limit_th->session_id,
10022 short_retry_limit_th->short_retry_limit);
10023
10024 srl->session_id = short_retry_limit_th->session_id;
10025 srl->short_retry_limit = short_retry_limit_th->short_retry_limit;
10026
10027 qdf_mem_zero(&msg, sizeof(msg));
10028 msg.type = SIR_HAL_SHORT_RETRY_LIMIT_CNT;
10029 msg.reserved = 0;
10030 msg.bodyptr = srl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010031 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010032 if (status != QDF_STATUS_SUCCESS) {
10033 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10034 FL("Not able to post short retry limit count to WDA"));
10035 qdf_mem_free(srl);
10036 return QDF_STATUS_E_FAILURE;
10037 }
10038
10039 return status;
10040}
10041
10042/**
10043 * sme_update_long_retry_limit_threshold() - update long retry limit TH
10044 * @hal: Handle returned by mac_open
10045 * @session_id: Session ID on which long frames retry TH needs to be updated
10046 * to FW
10047 * @long_limit_count_th: Retry count to retry long frame.
10048 *
10049 * This function is used to configure TH to retry long frame.
10050 *
10051 * Return: QDF_STATUS
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010052 */
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010053QDF_STATUS sme_update_long_retry_limit_threshold(tHalHandle hal_handle,
10054 struct sme_long_retry_limit *long_retry_limit_th)
10055{
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010056 QDF_STATUS status = QDF_STATUS_SUCCESS;
10057 struct sme_long_retry_limit *lrl;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010058 struct scheduler_msg msg = {0};
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010059
10060 lrl = qdf_mem_malloc(sizeof(*lrl));
10061 if (NULL == lrl) {
10062 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10063 "%s: fail to alloc long retry limit", __func__);
10064 return QDF_STATUS_E_FAILURE;
10065 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010066 sme_debug("session_id %d long retry limit count: %d",
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010067 long_retry_limit_th->session_id,
10068 long_retry_limit_th->long_retry_limit);
10069
10070 lrl->session_id = long_retry_limit_th->session_id;
10071 lrl->long_retry_limit = long_retry_limit_th->long_retry_limit;
10072
10073 qdf_mem_zero(&msg, sizeof(msg));
10074 msg.type = SIR_HAL_LONG_RETRY_LIMIT_CNT;
10075 msg.reserved = 0;
10076 msg.bodyptr = lrl;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010077 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal Ashishda3e9502016-09-21 17:43:51 +053010078
10079 if (status != QDF_STATUS_SUCCESS) {
10080 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10081 FL("Not able to post long retry limit count to WDA"));
10082 qdf_mem_free(lrl);
10083 return QDF_STATUS_E_FAILURE;
10084 }
10085
10086 return status;
10087}
10088
10089/**
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010090 * sme_update_sta_inactivity_timeout(): Update sta_inactivity_timeout to FW
10091 * @hal: Handle returned by mac_open
10092 * @session_id: Session ID on which sta_inactivity_timeout needs
10093 * to be updated to FW
10094 * @sta_inactivity_timeout: sta inactivity timeout.
10095 *
10096 * If a station does not send anything in sta_inactivity_timeout seconds, an
10097 * empty data frame is sent to it in order to verify whether it is
10098 * still in range. If this frame is not ACKed, the station will be
10099 * disassociated and then deauthenticated.
10100 *
10101 * Return: QDF_STATUS_SUCCESS or non-zero on failure.
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010102 */
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010103QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle,
10104 struct sme_sta_inactivity_timeout *sta_inactivity_timer)
10105{
10106 struct sme_sta_inactivity_timeout *inactivity_time;
10107 void *wma_handle;
10108
10109 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
10110 inactivity_time = qdf_mem_malloc(sizeof(*inactivity_time));
10111 if (NULL == inactivity_time) {
10112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10113 "%s: fail to alloc inactivity_time", __func__);
10114 return QDF_STATUS_E_FAILURE;
10115 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Agrawal, Ashish4e5fa1c2016-09-21 19:03:43 +053010117 FL("sta_inactivity_timeout: %d"),
10118 sta_inactivity_timer->sta_inactivity_timeout);
10119 inactivity_time->session_id = sta_inactivity_timer->session_id;
10120 inactivity_time->sta_inactivity_timeout =
10121 sta_inactivity_timer->sta_inactivity_timeout;
10122
10123 wma_update_sta_inactivity_timeout(wma_handle,
10124 inactivity_time);
10125 return QDF_STATUS_SUCCESS;
10126}
10127
10128/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010129 * sme_get_reg_info() - To get registration info
10130 * @hHal: HAL context
10131 * @chanId: channel id
10132 * @regInfo1: first reg info to fill
10133 * @regInfo2: second reg info to fill
10134 *
10135 * This routine will give you reg info
10136 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010137 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010138 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010139QDF_STATUS sme_get_reg_info(tHalHandle hHal, uint8_t chanId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010140 uint32_t *regInfo1, uint32_t *regInfo2)
10141{
10142 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010143 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010144 uint8_t i;
10145 bool found = false;
10146
10147 status = sme_acquire_global_lock(&pMac->sme);
10148 *regInfo1 = 0;
10149 *regInfo2 = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010150 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010151 return status;
10152
10153 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -070010154 if (pMac->scan.defaultPowerTable[i].chan_num == chanId) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155 SME_SET_CHANNEL_REG_POWER(*regInfo1,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010156 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157
10158 SME_SET_CHANNEL_MAX_TX_POWER(*regInfo2,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010159 pMac->scan.defaultPowerTable[i].tx_power);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 found = true;
10161 break;
10162 }
10163 }
10164 if (!found)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010165 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010166
10167 sme_release_global_lock(&pMac->sme);
10168 return status;
10169}
10170
10171#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010172/*
10173 * sme_auto_shutdown_cb() -
10174 * Used to plug in callback function for receiving auto shutdown evt
10175 *
10176 * hHal
10177 * pCallbackfn : callback function pointer should be plugged in
10178 * Return QDF_STATUS
10179 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010180QDF_STATUS sme_set_auto_shutdown_cb(tHalHandle hHal, void (*pCallbackfn)(void)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010181 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010182 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10184
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010185 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010186 "%s: Plug in Auto shutdown event callback", __func__);
10187
10188 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010189 if (QDF_STATUS_SUCCESS == status) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010190 if (NULL != pCallbackfn)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010191 pMac->sme.pAutoShutdownNotificationCb = pCallbackfn;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010192 sme_release_global_lock(&pMac->sme);
10193 }
10194
10195 return status;
10196}
10197
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010198/*
10199 * sme_set_auto_shutdown_timer() -
10200 * API to set auto shutdown timer value in FW.
10201 *
10202 * hHal - The handle returned by mac_open
10203 * timer_val - The auto shutdown timer value to be set
10204 * Return Configuration message posting status, SUCCESS or Fail
10205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010206QDF_STATUS sme_set_auto_shutdown_timer(tHalHandle hHal, uint32_t timer_val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010208 QDF_STATUS status = QDF_STATUS_SUCCESS;
10209 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10211 tSirAutoShutdownCmdParams *auto_sh_cmd;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010212 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010213
10214 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010215 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010216 auto_sh_cmd = (tSirAutoShutdownCmdParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010217 qdf_mem_malloc(sizeof(tSirAutoShutdownCmdParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010218 if (auto_sh_cmd == NULL) {
Dustin Browna2868622018-03-20 11:38:14 -070010219 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010220 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010221 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010222 }
10223
10224 auto_sh_cmd->timer_val = timer_val;
10225
10226 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010227 message.bodyptr = auto_sh_cmd;
10228 message.type = WMA_SET_AUTO_SHUTDOWN_TIMER_REQ;
10229 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10230 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010231 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010232 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010233 "%s: Post Auto shutdown MSG fail", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010234 qdf_mem_free(auto_sh_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010236 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010237 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010238 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010239 "%s: Posted Auto shutdown MSG", __func__);
10240 sme_release_global_lock(&pMac->sme);
10241 }
10242
10243 return status;
10244}
10245#endif
10246
Nirav Shaheb017be2018-02-15 11:20:58 +053010247#ifdef FEATURE_WLAN_CH_AVOID
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010248/*
10249 * sme_ch_avoid_update_req() -
10250 * API to request channel avoidance update from FW.
10251 *
10252 * hHal - The handle returned by mac_open
Jeff Johnsonc5927de2018-05-11 09:12:53 -070010253 * update_type - The update_type parameter of this request call
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010254 * Return Configuration message posting status, SUCCESS or Fail
10255 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010256QDF_STATUS sme_ch_avoid_update_req(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010257{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010258 QDF_STATUS status = QDF_STATUS_SUCCESS;
10259 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010260 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10261 tSirChAvoidUpdateReq *cauReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010262 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010263
10264 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010265 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010266 cauReq = (tSirChAvoidUpdateReq *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010267 qdf_mem_malloc(sizeof(tSirChAvoidUpdateReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010268 if (NULL == cauReq) {
Dustin Browna2868622018-03-20 11:38:14 -070010269 sme_err("Request Buffer Alloc Fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010270 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010271 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010272 }
10273
10274 cauReq->reserved_param = 0;
10275
10276 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010277 message.bodyptr = cauReq;
10278 message.type = WMA_CH_AVOID_UPDATE_REQ;
10279 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10280 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010281 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010282 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010283 "%s: Post Ch Avoid Update MSG fail",
10284 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010285 qdf_mem_free(cauReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010286 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010287 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010288 }
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010289 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010290 "%s: Posted Ch Avoid Update MSG", __func__);
10291 sme_release_global_lock(&pMac->sme);
10292 }
10293
10294 return status;
10295}
Nirav Shaheb017be2018-02-15 11:20:58 +053010296#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010297
10298/**
10299 * sme_set_miracast() - Function to set miracast value to UMAC
10300 * @hal: Handle returned by macOpen
10301 * @filter_type: 0-Disabled, 1-Source, 2-sink
10302 *
10303 * This function passes down the value of miracast set by
10304 * framework to UMAC
10305 *
10306 * Return: Configuration message posting status, SUCCESS or Fail
10307 *
10308 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010309QDF_STATUS sme_set_miracast(tHalHandle hal, uint8_t filter_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010310{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010311 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312 uint32_t *val;
10313 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
10314
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010315 val = qdf_mem_malloc(sizeof(*val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010316 if (NULL == val || NULL == mac_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010317 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010318 "%s: Invalid pointer", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010319 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010320 }
10321
10322 *val = filter_type;
10323
10324 msg.type = SIR_HAL_SET_MIRACAST;
10325 msg.reserved = 0;
10326 msg.bodyptr = val;
10327
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010328 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010329 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010330 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010331 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10332 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010333 qdf_mem_free(val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010334 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010335 }
10336
10337 mac_ptr->sme.miracast_value = filter_type;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010338 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339}
10340
10341/**
10342 * sme_set_mas() - Function to set MAS value to UMAC
10343 * @val: 1-Enable, 0-Disable
10344 *
10345 * This function passes down the value of MAS to the UMAC. A
10346 * value of 1 will enable MAS and a value of 0 will disable MAS
10347 *
10348 * Return: Configuration message posting status, SUCCESS or Fail
10349 *
10350 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010351QDF_STATUS sme_set_mas(uint32_t val)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010353 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010354 uint32_t *ptr_val;
10355
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010356 ptr_val = qdf_mem_malloc(sizeof(*ptr_val));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010357 if (NULL == ptr_val) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010358 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010359 "%s: could not allocate ptr_val", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010360 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010361 }
10362
10363 *ptr_val = val;
10364
10365 msg.type = SIR_HAL_SET_MAS;
10366 msg.reserved = 0;
10367 msg.bodyptr = ptr_val;
10368
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010369 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010370 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010371 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372 "%s: Not able to post WDA_SET_MAS_ENABLE_DISABLE to WMA!",
10373 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010374 qdf_mem_free(ptr_val);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010375 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010376 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010377 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010378}
10379
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010380/**
10381 * sme_roam_channel_change_req() - Channel change to new target channel
10382 * @hHal: handle returned by mac_open
10383 * @bssid: mac address of BSS
10384 * @ch_params: target channel information
10385 * @profile: CSR profile
10386 *
10387 * API to Indicate Channel change to new target channel
10388 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010389 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010390 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010391QDF_STATUS sme_roam_channel_change_req(tHalHandle hHal,
Amar Singhale4f28ee2015-10-21 14:36:56 -070010392 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010393 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010394 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010395{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010396 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010397 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010398
10399 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010400 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010401
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010402 status = csr_roam_channel_change_req(pMac, bssid, ch_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010403 profile);
10404 sme_release_global_lock(&pMac->sme);
10405 }
10406 return status;
10407}
10408
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010409/*
10410 * sme_process_channel_change_resp() -
10411 * API to Indicate Channel change response message to SAP.
10412 *
10413 * Return QDF_STATUS
10414 */
10415static QDF_STATUS sme_process_channel_change_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 uint16_t msg_type, void *pMsgBuf)
10417{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010418 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080010419 struct csr_roam_info proam_info = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010420 eCsrRoamResult roamResult;
10421 tpSwitchChannelParams pChnlParams = (tpSwitchChannelParams) pMsgBuf;
10422 uint32_t SessionId = pChnlParams->peSessionId;
10423
10424 proam_info.channelChangeRespEvent =
10425 (tSirChanChangeResponse *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010426 qdf_mem_malloc(sizeof(tSirChanChangeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 if (NULL == proam_info.channelChangeRespEvent) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010428 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010429 sme_err("Channel Change Event Allocation Failed: %d\n", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010430 return status;
10431 }
10432 if (msg_type == eWNI_SME_CHANNEL_CHANGE_RSP) {
10433 proam_info.channelChangeRespEvent->sessionId = SessionId;
10434 proam_info.channelChangeRespEvent->newChannelNumber =
10435 pChnlParams->channelNumber;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010436
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010437 if (pChnlParams->status == QDF_STATUS_SUCCESS) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010438 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010439 "sapdfs: Received success eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10440 SessionId);
10441 proam_info.channelChangeRespEvent->channelChangeStatus =
10442 1;
10443 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS;
10444 } else {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053010445 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446 "sapdfs: Received failure eWNI_SME_CHANNEL_CHANGE_RSP for sessionId[%d]",
10447 SessionId);
10448 proam_info.channelChangeRespEvent->channelChangeStatus =
10449 0;
10450 roamResult = eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE;
10451 }
10452
10453 csr_roam_call_callback(pMac, SessionId, &proam_info, 0,
10454 eCSR_ROAM_SET_CHANNEL_RSP, roamResult);
10455
10456 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010457 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010458 sme_err("Invalid Channel Change Resp Message: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010459 status);
10460 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010461 qdf_mem_free(proam_info.channelChangeRespEvent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010462
10463 return status;
10464}
10465
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010466/*
10467 * sme_roam_start_beacon_req() -
10468 * API to Indicate LIM to start Beacon Tx after SAP CAC Wait is completed.
10469 *
10470 * hHal - The handle returned by mac_open
10471 * sessionId - session ID
10472 * dfsCacWaitStatus - CAC WAIT status flag
10473 * Return QDF_STATUS
10474 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010475QDF_STATUS sme_roam_start_beacon_req(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010476 uint8_t dfsCacWaitStatus)
10477{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010478 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010479 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010481 status = sme_acquire_global_lock(&pMac->sme);
10482
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010483 if (QDF_IS_STATUS_SUCCESS(status)) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010484 status = csr_roam_start_beacon_req(pMac, bssid,
10485 dfsCacWaitStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010486 sme_release_global_lock(&pMac->sme);
10487 }
10488 return status;
10489}
10490
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010491/**
10492 * sme_roam_csa_ie_request() - request CSA IE transmission from PE
10493 * @hHal: handle returned by mac_open
10494 * @bssid: SAP bssid
10495 * @targetChannel: target channel information
10496 * @csaIeReqd: CSA IE Request
10497 * @ch_params: channel information
10498 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010499 * Return: QDF_STATUS
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010500 */
Anurag Chouhan6d760662016-02-20 16:05:43 +053010501QDF_STATUS sme_roam_csa_ie_request(tHalHandle hHal, struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010502 uint8_t targetChannel, uint8_t csaIeReqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080010503 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010504{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010505 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010506 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010507
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010508 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010509 if (QDF_IS_STATUS_SUCCESS(status)) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080010510 status = csr_roam_send_chan_sw_ie_request(pMac, bssid,
10511 targetChannel, csaIeReqd, ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010512 sme_release_global_lock(&pMac->sme);
10513 }
10514 return status;
10515}
10516
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010517/*
10518 * sme_init_thermal_info() -
10519 * SME API to initialize the thermal mitigation parameters
10520 *
10521 * hHal
10522 * thermalParam : thermal mitigation parameters
10523 * Return QDF_STATUS
10524 */
10525QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams
10526 thermalParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527{
10528 t_thermal_mgmt *pWmaParam;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010529 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010530 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10531
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010532 pWmaParam = (t_thermal_mgmt *) qdf_mem_malloc(sizeof(t_thermal_mgmt));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010533 if (NULL == pWmaParam) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010534 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010535 "%s: could not allocate tThermalMgmt", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010536 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537 }
10538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010539 pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
10540 pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
Poddar, Siddarth83905022016-04-16 17:56:08 -070010541
10542 pWmaParam->throttle_duty_cycle_tbl[0] =
10543 thermalParam.sme_throttle_duty_cycle_tbl[0];
10544 pWmaParam->throttle_duty_cycle_tbl[1] =
10545 thermalParam.sme_throttle_duty_cycle_tbl[1];
10546 pWmaParam->throttle_duty_cycle_tbl[2] =
10547 thermalParam.sme_throttle_duty_cycle_tbl[2];
10548 pWmaParam->throttle_duty_cycle_tbl[3] =
10549 thermalParam.sme_throttle_duty_cycle_tbl[3];
10550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010551 pWmaParam->thermalLevels[0].minTempThreshold =
10552 thermalParam.smeThermalLevels[0].smeMinTempThreshold;
10553 pWmaParam->thermalLevels[0].maxTempThreshold =
10554 thermalParam.smeThermalLevels[0].smeMaxTempThreshold;
10555 pWmaParam->thermalLevels[1].minTempThreshold =
10556 thermalParam.smeThermalLevels[1].smeMinTempThreshold;
10557 pWmaParam->thermalLevels[1].maxTempThreshold =
10558 thermalParam.smeThermalLevels[1].smeMaxTempThreshold;
10559 pWmaParam->thermalLevels[2].minTempThreshold =
10560 thermalParam.smeThermalLevels[2].smeMinTempThreshold;
10561 pWmaParam->thermalLevels[2].maxTempThreshold =
10562 thermalParam.smeThermalLevels[2].smeMaxTempThreshold;
10563 pWmaParam->thermalLevels[3].minTempThreshold =
10564 thermalParam.smeThermalLevels[3].smeMinTempThreshold;
10565 pWmaParam->thermalLevels[3].maxTempThreshold =
10566 thermalParam.smeThermalLevels[3].smeMaxTempThreshold;
10567
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010568 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010569 msg.type = WMA_INIT_THERMAL_INFO_CMD;
10570 msg.bodyptr = pWmaParam;
10571
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010572 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010573 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010574 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010575 "%s: Not able to post WMA_SET_THERMAL_INFO_CMD to WMA!",
10576 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010577 qdf_mem_free(pWmaParam);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010578 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010579 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010580 }
10581 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010582 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010583 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010584 qdf_mem_free(pWmaParam);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010585 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010586}
10587
10588/**
10589 * sme_add_set_thermal_level_callback() - Plug in set thermal level callback
10590 * @hal: Handle returned by macOpen
10591 * @callback: sme_set_thermal_level_callback
10592 *
10593 * Plug in set thermal level callback
10594 *
10595 * Return: none
10596 */
10597void sme_add_set_thermal_level_callback(tHalHandle hal,
10598 sme_set_thermal_level_callback callback)
10599{
10600 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
10601
10602 pMac->sme.set_thermal_level_cb = callback;
10603}
10604
10605/**
10606 * sme_set_thermal_level() - SME API to set the thermal mitigation level
10607 * @hal: Handler to HAL
10608 * @level: Thermal mitigation level
10609 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010610 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010611 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010612QDF_STATUS sme_set_thermal_level(tHalHandle hal, uint8_t level)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010613{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010614 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010616 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010617
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010618 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010619 qdf_mem_set(&msg, sizeof(msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010620 msg.type = WMA_SET_THERMAL_LEVEL;
10621 msg.bodyval = level;
10622
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010623 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010624 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010625 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010626 "%s: Not able to post WMA_SET_THERMAL_LEVEL to WMA!",
10627 __func__);
10628 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010629 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010630 }
10631 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010632 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010633 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010634 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010635}
10636
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010637/*
10638 * sme_txpower_limit() -
10639 * SME API to set txpower limits
10640 *
10641 * hHal
10642 * psmetx : power limits for 2g/5g
10643 * Return QDF_STATUS
10644 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010645QDF_STATUS sme_txpower_limit(tHalHandle hHal, tSirTxPowerLimit *psmetx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010647 QDF_STATUS status = QDF_STATUS_SUCCESS;
10648 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010649 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010650 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010651 tSirTxPowerLimit *tx_power_limit;
10652
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010653 tx_power_limit = qdf_mem_malloc(sizeof(*tx_power_limit));
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010654 if (!tx_power_limit) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010655 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010656 "%s: Memory allocation for TxPowerLimit failed!",
10657 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010658 return QDF_STATUS_E_FAILURE;
Prashanth Bhatta75fa9a12016-01-11 18:30:08 -080010659 }
10660
10661 *tx_power_limit = *psmetx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010662
10663 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010664 if (QDF_IS_STATUS_SUCCESS(status)) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010665 message.type = WMA_TX_POWER_LIMIT;
10666 message.reserved = 0;
10667 message.bodyptr = tx_power_limit;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010668
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010669 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10670 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010671 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010672 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010673 "%s: not able to post WMA_TX_POWER_LIMIT",
10674 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010675 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010676 qdf_mem_free(tx_power_limit);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010677 }
10678 sme_release_global_lock(&pMac->sme);
10679 }
10680 return status;
10681}
10682
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010683QDF_STATUS sme_update_connect_debug(tHalHandle hHal, uint32_t set_value)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010684{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010685 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010686 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010688 pMac->fEnableDebugLog = set_value;
10689 return status;
10690}
10691
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010692/*
10693 * sme_ap_disable_intra_bss_fwd() -
10694 * SME will send message to WMA to set Intra BSS in txrx
10695 *
10696 * hHal - The handle returned by mac_open
10697 * sessionId - session id ( vdev id)
10698 * disablefwd - bool value that indicate disable intrabss fwd disable
10699 * Return QDF_STATUS
10700 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010701QDF_STATUS sme_ap_disable_intra_bss_fwd(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010702 bool disablefwd)
10703{
10704 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010705 int status = QDF_STATUS_SUCCESS;
10706 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010707 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708 tpDisableIntraBssFwd pSapDisableIntraFwd = NULL;
10709
10710 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010711 pSapDisableIntraFwd = qdf_mem_malloc(sizeof(tDisableIntraBssFwd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010712 if (NULL == pSapDisableIntraFwd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010713 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010714 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010715 }
10716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010717 pSapDisableIntraFwd->sessionId = sessionId;
10718 pSapDisableIntraFwd->disableintrabssfwd = disablefwd;
10719
10720 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010721 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010722 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010723 message.bodyptr = pSapDisableIntraFwd;
10724 message.type = WMA_SET_SAP_INTRABSS_DIS;
10725 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
10726 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010727 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
10728 status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010729 qdf_mem_free(pSapDisableIntraFwd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010730 }
10731 sme_release_global_lock(&pMac->sme);
10732 }
10733 return status;
10734}
10735
10736#ifdef WLAN_FEATURE_STATS_EXT
10737
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010738/*
10739 * sme_stats_ext_register_callback() -
10740 * This function called to register the callback that send vendor event for
10741 * stats ext
10742 *
10743 * callback - callback to be registered
10744 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010745void sme_stats_ext_register_callback(tHalHandle hHal, StatsExtCallback callback)
10746{
10747 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
10748
10749 pMac->sme.StatsExtCallback = callback;
10750}
10751
lifeng66831662017-05-19 16:01:35 +080010752void sme_stats_ext2_register_callback(tHalHandle hal_handle,
10753 void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *))
10754{
10755 tpAniSirGlobal pmac = PMAC_STRUCT(hal_handle);
10756
10757 pmac->sme.stats_ext2_cb = stats_ext2_cb;
10758}
10759
Arun Khandavalli4b55da72016-07-19 19:55:01 +053010760/**
10761 * sme_stats_ext_deregister_callback() - De-register ext stats callback
10762 * @h_hal: Hal Handle
10763 *
10764 * This function is called to de initialize the HDD NAN feature. Currently
10765 * the only operation required is to de-register a callback with SME.
10766 *
10767 * Return: None
10768 */
10769void sme_stats_ext_deregister_callback(tHalHandle h_hal)
10770{
10771 tpAniSirGlobal pmac;
10772
10773 if (!h_hal) {
10774 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10775 FL("hHal is not valid"));
10776 return;
10777 }
10778
10779 pmac = PMAC_STRUCT(h_hal);
10780 pmac->sme.StatsExtCallback = NULL;
10781}
10782
10783
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010784/*
10785 * sme_stats_ext_request() -
10786 * Function called when HDD receives STATS EXT vendor command from userspace
10787 *
10788 * sessionID - vdevID for the stats ext request
10789 * input - Stats Ext Request structure ptr
10790 * Return QDF_STATUS
10791 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010792QDF_STATUS sme_stats_ext_request(uint8_t session_id, tpStatsExtRequestReq input)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070010794 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010795 tpStatsExtRequest data;
10796 size_t data_len;
10797
10798 data_len = sizeof(tStatsExtRequest) + input->request_data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010799 data = qdf_mem_malloc(data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010801 if (data == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010802 return QDF_STATUS_E_NOMEM;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010803
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010804 data->vdev_id = session_id;
10805 data->request_data_len = input->request_data_len;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010806 if (input->request_data_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010807 qdf_mem_copy(data->request_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010808 input->request_data, input->request_data_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010809
10810 msg.type = WMA_STATS_EXT_REQUEST;
10811 msg.reserved = 0;
10812 msg.bodyptr = data;
10813
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080010814 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -080010815 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010816 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010817 "%s: Not able to post WMA_STATS_EXT_REQUEST message to WMA",
10818 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010819 qdf_mem_free(data);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010820 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010821 }
10822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010823 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010824}
10825
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010826/*
10827 * sme_stats_ext_event() -
10828 * This callback function called when SME received eWNI_SME_STATS_EXT_EVENT
10829 * response from WMA
10830 *
10831 * hHal - HAL handle for device
10832 * pMsg - Message body passed from WMA; includes NAN header
10833 * Return QDF_STATUS
10834 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010835QDF_STATUS sme_stats_ext_event(tHalHandle hHal, void *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010836{
10837 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010838 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010839
10840 if (NULL == pMsg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070010841 sme_err("pMsg is NULL in sme_stats_ext_event");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010842 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010843 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010844 if (pMac->sme.StatsExtCallback)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010845 pMac->sme.StatsExtCallback(pMac->hHdd,
10846 (tpStatsExtEvent) pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847 }
10848
10849 return status;
10850}
10851
10852#endif
10853
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010854/*
10855 * sme_update_dfs_scan_mode() -
10856 * Update DFS roam scan mode
10857 * This function is called through dynamic setConfig callback function
10858 * to configure allowDFSChannelRoam.
10859 * hHal - HAL handle for device
10860 * sessionId - Session Identifier
10861 * allowDFSChannelRoam - DFS roaming scan mode 0 (disable),
10862 * 1 (passive), 2 (active)
10863 * Return QDF_STATUS_SUCCESS - SME update DFS roaming scan config
10864 * successfully.
10865 * Other status means SME failed to update DFS roaming scan config.
10866 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010867QDF_STATUS sme_update_dfs_scan_mode(tHalHandle hHal, uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010868 uint8_t allowDFSChannelRoam)
10869{
10870 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010871 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080010873 if (sessionId >= CSR_ROAM_SESSION_MAX) {
10874 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
10875 FL("Invalid sme session id: %d"), sessionId);
10876 return QDF_STATUS_E_INVAL;
10877 }
10878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010879 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010880 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010881 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010882 "LFR runtime successfully set AllowDFSChannelRoam Mode to %d - old value is %d - roam state is %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010883 allowDFSChannelRoam,
10884 pMac->roam.configParam.allowDFSChannelRoam,
10885 mac_trace_get_neighbour_roam_state(pMac->roam.
10886 neighborRoamInfo
10887 [sessionId].
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010888 neighborRoamState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010889 pMac->roam.configParam.allowDFSChannelRoam =
10890 allowDFSChannelRoam;
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010891 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
10892 csr_roam_offload_scan(pMac, sessionId,
10893 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10894 REASON_ROAM_DFS_SCAN_MODE_CHANGED);
10895 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896 sme_release_global_lock(&pMac->sme);
10897 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053010898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010899
10900 return status;
10901}
10902
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010903/*
10904 * sme_get_dfs_scan_mode() - get DFS roam scan mode
10905 * This is a synchronous call
10906 *
10907 * hHal - The handle returned by mac_open.
10908 * Return DFS roaming scan mode 0 (disable), 1 (passive), 2 (active)
10909 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010910uint8_t sme_get_dfs_scan_mode(tHalHandle hHal)
10911{
10912 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010914 return pMac->roam.configParam.allowDFSChannelRoam;
10915}
10916
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010917/*
10918 * sme_modify_add_ie() -
10919 * This function sends msg to updates the additional IE buffers in PE
10920 *
10921 * hHal - global structure
10922 * pModifyIE - pointer to tModifyIE structure
10923 * updateType - type of buffer
10924 * Return Success or failure
10925 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010926QDF_STATUS sme_modify_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010927 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
10928{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010929 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010930 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010932 status = sme_acquire_global_lock(&pMac->sme);
10933
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010934 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010935 status = csr_roam_modify_add_ies(pMac, pModifyIE, updateType);
10936 sme_release_global_lock(&pMac->sme);
10937 }
10938 return status;
10939}
10940
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010941/*
10942 * sme_update_add_ie() -
10943 * This function sends msg to updates the additional IE buffers in PE
10944 *
10945 * hHal - global structure
10946 * pUpdateIE - pointer to structure tUpdateIE
10947 * updateType - type of buffer
10948 * Return Success or failure
10949 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010950QDF_STATUS sme_update_add_ie(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010951 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
10952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010953 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010954 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053010955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010956 status = sme_acquire_global_lock(&pMac->sme);
10957
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010958 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010959 status = csr_roam_update_add_ies(pMac, pUpdateIE, updateType);
10960 sme_release_global_lock(&pMac->sme);
10961 }
10962 return status;
10963}
10964
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010965/**
10966 * sme_update_dsc_pto_up_mapping()
10967 * @hHal: HAL context
10968 * @dscpmapping: pointer to DSCP mapping structure
10969 * @sessionId: SME session id
10970 *
10971 * This routine is called to update dscp mapping
10972 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010973 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010974 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010975QDF_STATUS sme_update_dsc_pto_up_mapping(tHalHandle hHal,
Abhishek Singh12be60f2017-08-11 13:52:42 +053010976 enum sme_qos_wmmuptype *dscpmapping,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010977 uint8_t sessionId)
10978{
10979 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010980 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010981 uint8_t i, j, peSessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010982 struct csr_roam_session *pCsrSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010983 tpPESession pSession = NULL;
10984
10985 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010986 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010987 return status;
10988 pCsrSession = CSR_GET_SESSION(pMac, sessionId);
10989 if (pCsrSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010990 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010991 FL("Session lookup fails for CSR session"));
10992 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010993 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010994 }
10995 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
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("Invalid session Id %u"), sessionId);
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 pSession = pe_find_session_by_bssid(pMac,
11003 pCsrSession->connectedProfile.bssid.bytes,
11004 &peSessionId);
11005
11006 if (pSession == NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011007 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011008 FL(" Session lookup fails for BSSID"));
11009 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011010 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011011 }
11012
11013 if (!pSession->QosMapSet.present) {
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -070011014 sme_debug("QOS Mapping IE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011016 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011017 }
11018 for (i = 0; i < SME_QOS_WMM_UP_MAX; i++) {
11019 for (j = pSession->QosMapSet.dscp_range[i][0];
11020 j <= pSession->QosMapSet.dscp_range[i][1];
11021 j++) {
11022 if ((pSession->QosMapSet.dscp_range[i][0] == 255)
11023 && (pSession->QosMapSet.dscp_range[i][1] ==
11024 255)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011025 QDF_TRACE(QDF_MODULE_ID_SME,
Kiran Kumar Lokere1d411bb2017-11-29 15:24:05 -080011026 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027 FL("User Priority %d isn't used"), i);
11028 break;
11029 } else {
11030 dscpmapping[j] = i;
11031 }
11032 }
11033 }
11034 for (i = 0; i < pSession->QosMapSet.num_dscp_exceptions; i++)
11035 if (pSession->QosMapSet.dscp_exceptions[i][0] != 255)
11036 dscpmapping[pSession->QosMapSet.dscp_exceptions[i][0]] =
11037 pSession->QosMapSet.dscp_exceptions[i][1];
11038
11039 sme_release_global_lock(&pMac->sme);
11040 return status;
11041}
11042
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011043/*
11044 * sme_abort_roam_scan() -
11045 * API to abort current roam scan cycle by roam scan offload module.
11046 *
11047 * hHal - The handle returned by mac_open.
11048 * sessionId - Session Identifier
11049 * Return QDF_STATUS
11050 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011051
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011052QDF_STATUS sme_abort_roam_scan(tHalHandle hHal, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011053{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011055 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11056
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011057 if (pMac->roam.configParam.isRoamOffloadScanEnabled) {
11058 /* acquire the lock for the sme object */
11059 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011060 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011061 csr_roam_offload_scan(pMac, sessionId,
11062 ROAM_SCAN_OFFLOAD_ABORT_SCAN,
11063 REASON_ROAM_ABORT_ROAM_SCAN);
11064 /* release the lock for the sme object */
11065 sme_release_global_lock(&pMac->sme);
11066 }
11067 }
11068
11069 return status;
11070}
11071
11072#ifdef FEATURE_WLAN_EXTSCAN
11073/**
11074 * sme_get_valid_channels_by_band() - to fetch valid channels filtered by band
11075 * @hHal: HAL context
11076 * @wifiBand: RF band information
11077 * @aValidChannels: output array to store channel info
11078 * @pNumChannels: output number of channels
11079 *
11080 * SME API to fetch all valid channels filtered by band
11081 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011082 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011083 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011084QDF_STATUS sme_get_valid_channels_by_band(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011085 uint8_t wifiBand,
11086 uint32_t *aValidChannels,
11087 uint8_t *pNumChannels)
11088{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011089 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011090 uint8_t chanList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011091 uint8_t numChannels = 0;
11092 uint8_t i = 0;
11093 uint32_t totValidChannels = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011094 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011095
11096 if (!aValidChannels || !pNumChannels) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011097 sme_err("Output channel list/NumChannels is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011098 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011099 }
11100
Sreelakshmi Konamki0d17c6a2017-06-08 12:58:54 +053011101 if (wifiBand >= WIFI_BAND_MAX) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011102 sme_err("Invalid wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011103 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011104 }
11105
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080011106 status = sme_get_cfg_valid_channels(&chanList[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011107 &totValidChannels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011108 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011109 sme_err("Fail to get valid channel list (err=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011110 return status;
11111 }
11112
11113 switch (wifiBand) {
11114 case WIFI_BAND_UNSPECIFIED:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011115 sme_debug("Unspec Band, return all %d valid channels",
11116 totValidChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011117 numChannels = totValidChannels;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011118 for (i = 0; i < totValidChannels; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011119 aValidChannels[i] = cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011120 break;
11121
11122 case WIFI_BAND_BG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011123 sme_debug("WIFI_BAND_BG (2.4 GHz)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011124 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011125 if (WLAN_REG_IS_24GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011126 aValidChannels[numChannels++] =
11127 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011128 }
11129 break;
11130
11131 case WIFI_BAND_A:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011132 sme_debug("WIFI_BAND_A (5 GHz without DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011133 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011134 if (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_ABG:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011142 sme_debug("WIFI_BAND_ABG (2.4 GHz + 5 GHz; no DFS)");
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_24GHZ_CH(chanList[i]) ||
11145 WLAN_REG_IS_5GHZ_CH(chanList[i])) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011146 !wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011147 aValidChannels[numChannels++] =
11148 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011149 }
11150 break;
11151
11152 case WIFI_BAND_A_DFS_ONLY:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011153 sme_debug("WIFI_BAND_A_DFS (5 GHz DFS only)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011154 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011155 if (WLAN_REG_IS_5GHZ_CH(chanList[i]) &&
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011156 wlan_reg_is_dfs_ch(mac_ctx->pdev, chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011157 aValidChannels[numChannels++] =
11158 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 }
11160 break;
11161
11162 case WIFI_BAND_A_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011163 sme_debug("WIFI_BAND_A_WITH_DFS (5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011164 for (i = 0; i < totValidChannels; i++) {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011165 if (WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166 aValidChannels[numChannels++] =
11167 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011168 }
11169 break;
11170
11171 case WIFI_BAND_ABG_WITH_DFS:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011172 sme_debug("WIFI_BAND_ABG_WITH_DFS (2.4 GHz+5 GHz with DFS)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011173 for (i = 0; i < totValidChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070011174 if (WLAN_REG_IS_24GHZ_CH(chanList[i]) ||
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011175 WLAN_REG_IS_5GHZ_CH(chanList[i]))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011176 aValidChannels[numChannels++] =
11177 cds_chan_to_freq(chanList[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011178 }
11179 break;
11180
11181 default:
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011182 sme_err("Unknown wifiBand: %d", wifiBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011183 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011184 }
11185 *pNumChannels = numChannels;
11186
11187 return status;
11188}
11189
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011190/*
11191 * sme_ext_scan_get_capabilities() -
11192 * SME API to fetch extscan capabilities
11193 *
11194 * hHal
11195 * pReq: extscan capabilities structure
11196 * Return QDF_STATUS
11197 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011198QDF_STATUS sme_ext_scan_get_capabilities(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011199 tSirGetExtScanCapabilitiesReqParams *
11200 pReq)
11201{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011202 QDF_STATUS status = QDF_STATUS_SUCCESS;
11203 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011204 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011205 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011206
11207 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011208 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011209 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011210 message.bodyptr = pReq;
11211 message.type = WMA_EXTSCAN_GET_CAPABILITIES_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011212 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011213 NO_SESSION, message.type));
11214 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11215 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011216 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11217 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011218
11219 sme_release_global_lock(&pMac->sme);
11220 }
11221 return status;
11222}
11223
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011224/*
11225 * sme_ext_scan_start() -
11226 * SME API to issue extscan start
11227 *
11228 * hHal
11229 * pStartCmd: extscan start structure
11230 * Return QDF_STATUS
11231 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011232QDF_STATUS sme_ext_scan_start(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011233 tSirWifiScanCmdReqParams *pStartCmd)
11234{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011235 QDF_STATUS status = QDF_STATUS_SUCCESS;
11236 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011238 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011239
11240 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011241 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011243 message.bodyptr = pStartCmd;
11244 message.type = WMA_EXTSCAN_START_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011245 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011246 NO_SESSION, message.type));
11247 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11248 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011249 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11250 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011251
11252 sme_release_global_lock(&pMac->sme);
11253 }
11254 return status;
11255}
11256
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011257/*
11258 * sme_ext_scan_stop() -
11259 * SME API to issue extscan stop
11260 *
11261 * hHal
11262 * pStopReq: extscan stop structure
11263 * Return QDF_STATUS
11264 */
11265QDF_STATUS sme_ext_scan_stop(tHalHandle hHal, tSirExtScanStopReqParams
11266 *pStopReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011267{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011268 QDF_STATUS status = QDF_STATUS_SUCCESS;
11269 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011270 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011271 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011272
11273 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011274 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011276 message.bodyptr = pStopReq;
11277 message.type = WMA_EXTSCAN_STOP_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011278 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011279 NO_SESSION, message.type));
11280 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11281 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011282 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11283 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011284 sme_release_global_lock(&pMac->sme);
11285 }
11286 return status;
11287}
11288
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011289/*
11290 * sme_set_bss_hotlist() -
11291 * SME API to set BSSID hotlist
11292 *
11293 * hHal
11294 * pSetHotListReq: extscan set hotlist structure
11295 * Return QDF_STATUS
11296 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011297QDF_STATUS sme_set_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011298 tSirExtScanSetBssidHotListReqParams *
11299 pSetHotListReq)
11300{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011301 QDF_STATUS status = QDF_STATUS_SUCCESS;
11302 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011304 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011305
11306 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011307 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011308 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011309 message.bodyptr = pSetHotListReq;
11310 message.type = WMA_EXTSCAN_SET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011311 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011312 NO_SESSION, message.type));
11313 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11314 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011315 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11316 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317
11318 sme_release_global_lock(&pMac->sme);
11319 }
11320 return status;
11321}
11322
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011323/*
11324 * sme_reset_bss_hotlist() -
11325 * SME API to reset BSSID hotlist
11326 *
11327 * hHal
11328 * pSetHotListReq: extscan set hotlist structure
11329 * Return QDF_STATUS
11330 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011331QDF_STATUS sme_reset_bss_hotlist(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332 tSirExtScanResetBssidHotlistReqParams *
11333 pResetReq)
11334{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011335 QDF_STATUS status = QDF_STATUS_SUCCESS;
11336 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011337 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011338 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011339
11340 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011341 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011342 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011343 message.bodyptr = pResetReq;
11344 message.type = WMA_EXTSCAN_RESET_BSSID_HOTLIST_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011345 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011346 NO_SESSION, message.type));
11347 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11348 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011349 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11350 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011351
11352 sme_release_global_lock(&pMac->sme);
11353 }
11354 return status;
11355}
11356
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011357/*
11358 * sme_set_significant_change() -
11359 * SME API to set significant change
11360 *
11361 * hHal
11362 * pSetSignificantChangeReq: extscan set significant change structure
11363 * Return QDF_STATUS
11364 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011365QDF_STATUS sme_set_significant_change(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011366 tSirExtScanSetSigChangeReqParams *
11367 pSetSignificantChangeReq)
11368{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011369 QDF_STATUS status = QDF_STATUS_SUCCESS;
11370 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011372 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011373
11374 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011375 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011376 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011377 message.bodyptr = pSetSignificantChangeReq;
11378 message.type = WMA_EXTSCAN_SET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011379 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011380 NO_SESSION, message.type));
11381 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11382 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011383 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11384 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011385
11386 sme_release_global_lock(&pMac->sme);
11387 }
11388 return status;
11389}
11390
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011391/*
11392 * sme_reset_significant_change
11393 * SME API to reset significant change
11394 *
11395 * hHal
11396 * pResetReq: extscan reset significant change structure
11397 * Return QDF_STATUS
11398 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011399QDF_STATUS sme_reset_significant_change(tHalHandle hHal,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011400 tSirExtScanResetSignificantChangeReqParams
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401 *pResetReq)
11402{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011403 QDF_STATUS status = QDF_STATUS_SUCCESS;
11404 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011405 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011406 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011407
11408 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011409 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011410 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011411 message.bodyptr = pResetReq;
11412 message.type = WMA_EXTSCAN_RESET_SIGNF_CHANGE_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011413 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011414 NO_SESSION, message.type));
11415 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11416 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011417 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11418 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011419
11420 sme_release_global_lock(&pMac->sme);
11421 }
11422 return status;
11423}
11424
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011425/*
11426 * sme_get_cached_results() -
11427 * SME API to get cached results
11428 *
11429 * hHal
11430 * pCachedResultsReq: extscan get cached results structure
11431 * Return QDF_STATUS
11432 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011433QDF_STATUS sme_get_cached_results(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011434 tSirExtScanGetCachedResultsReqParams *
11435 pCachedResultsReq)
11436{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011437 QDF_STATUS status = QDF_STATUS_SUCCESS;
11438 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011440 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011441
11442 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011443 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011444 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011445 message.bodyptr = pCachedResultsReq;
11446 message.type = WMA_EXTSCAN_GET_CACHED_RESULTS_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011447 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011448 NO_SESSION, message.type));
11449 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11450 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011451 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
11452 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011453
11454 sme_release_global_lock(&pMac->sme);
11455 }
11456 return status;
11457}
11458
11459/**
11460 * sme_set_epno_list() - set epno network list
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011461 * @hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011462 * @input: request message
11463 *
11464 * This function constructs the cds message and fill in message type,
11465 * bodyptr with %input and posts it to WDA queue.
11466 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011467 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011468 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011469QDF_STATUS sme_set_epno_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011470 struct wifi_epno_params *input)
11471{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011472 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011473 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011474 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011475 struct wifi_epno_params *req_msg;
11476 int len, i;
11477
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011478 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011479 len = sizeof(*req_msg) +
11480 (input->num_networks * sizeof(struct wifi_epno_network));
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011481
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011482 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011483 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011484 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011485 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011486 }
11487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011488 req_msg->num_networks = input->num_networks;
11489 req_msg->request_id = input->request_id;
11490 req_msg->session_id = input->session_id;
Mukul Sharmae8c919f2016-10-02 20:35:15 +053011491
11492 /* Fill only when num_networks are non zero */
11493 if (req_msg->num_networks) {
11494 req_msg->min_5ghz_rssi = input->min_5ghz_rssi;
11495 req_msg->min_24ghz_rssi = input->min_24ghz_rssi;
11496 req_msg->initial_score_max = input->initial_score_max;
11497 req_msg->same_network_bonus = input->same_network_bonus;
11498 req_msg->secure_bonus = input->secure_bonus;
11499 req_msg->band_5ghz_bonus = input->band_5ghz_bonus;
11500 req_msg->current_connection_bonus =
11501 input->current_connection_bonus;
11502
11503 for (i = 0; i < req_msg->num_networks; i++) {
11504 req_msg->networks[i].flags = input->networks[i].flags;
11505 req_msg->networks[i].auth_bit_field =
11506 input->networks[i].auth_bit_field;
11507 req_msg->networks[i].ssid.length =
11508 input->networks[i].ssid.length;
11509 qdf_mem_copy(req_msg->networks[i].ssid.ssId,
11510 input->networks[i].ssid.ssId,
11511 req_msg->networks[i].ssid.length);
11512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011513 }
11514
11515 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011516 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011517 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011518 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011519 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 return status;
11521 }
11522
11523 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011524 message.bodyptr = req_msg;
11525 message.type = WMA_SET_EPNO_LIST_REQ;
11526 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011527 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011528 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011529 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011530 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011531 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011532 }
11533 sme_release_global_lock(&mac->sme);
11534 return status;
11535}
11536
11537/**
11538 * sme_set_passpoint_list() - set passpoint network list
11539 * @hal: global hal handle
11540 * @input: request message
11541 *
11542 * This function constructs the cds message and fill in message type,
11543 * bodyptr with @input and posts it to WDA queue.
11544 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011545 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011546 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011547QDF_STATUS sme_set_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011548 struct wifi_passpoint_req *input)
11549{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011550 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011551 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011552 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011553 struct wifi_passpoint_req *req_msg;
11554 int len, i;
11555
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011556 SME_ENTER();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011557 len = sizeof(*req_msg) +
11558 (input->num_networks * sizeof(struct wifi_passpoint_network));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011559 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011561 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011562 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011563 }
11564
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011565 req_msg->num_networks = input->num_networks;
11566 req_msg->request_id = input->request_id;
11567 req_msg->session_id = input->session_id;
11568 for (i = 0; i < req_msg->num_networks; i++) {
11569 req_msg->networks[i].id =
11570 input->networks[i].id;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011571 qdf_mem_copy(req_msg->networks[i].realm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011572 input->networks[i].realm,
11573 strlen(input->networks[i].realm) + 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011574 qdf_mem_copy(req_msg->networks[i].plmn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575 input->networks[i].plmn,
11576 SIR_PASSPOINT_PLMN_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011577 qdf_mem_copy(req_msg->networks[i].roaming_consortium_ids,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011578 input->networks[i].roaming_consortium_ids,
11579 sizeof(req_msg->networks[i].roaming_consortium_ids));
11580 }
11581
11582 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011583 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011584 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011585 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011586 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 return status;
11588 }
11589
11590 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011591 message.bodyptr = req_msg;
11592 message.type = WMA_SET_PASSPOINT_LIST_REQ;
11593 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011594 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011595 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011597 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011598 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011599 }
11600 sme_release_global_lock(&mac->sme);
11601 return status;
11602}
11603
11604/**
11605 * sme_reset_passpoint_list() - reset passpoint network list
11606 * @hHal: global hal handle
11607 * @input: request message
11608 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070011609 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011610 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011611QDF_STATUS sme_reset_passpoint_list(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 struct wifi_passpoint_req *input)
11613{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011614 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011615 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011616 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011617 struct wifi_passpoint_req *req_msg;
11618
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011619 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011620 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011621 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011622 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011623 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011624 }
11625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011626 req_msg->request_id = input->request_id;
11627 req_msg->session_id = input->session_id;
11628
11629 status = sme_acquire_global_lock(&mac->sme);
Vignesh Viswanathancbb5b952017-08-02 14:32:49 +053011630 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011631 sme_err("sme_acquire_global_lock failed!(status=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011632 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011633 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011634 return status;
11635 }
11636
11637 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011638 message.bodyptr = req_msg;
11639 message.type = WMA_RESET_PASSPOINT_LIST_REQ;
11640 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011641 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070011642 sme_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011643 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011644 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011645 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011646 }
11647 sme_release_global_lock(&mac->sme);
11648 return status;
11649}
11650
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011651QDF_STATUS sme_ext_scan_register_callback(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011652 void (*pExtScanIndCb)(void *,
11653 const uint16_t,
11654 void *))
11655{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011656 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011657 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11658
11659 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011660 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011661 pMac->sme.pExtScanIndCb = pExtScanIndCb;
11662 sme_release_global_lock(&pMac->sme);
11663 }
11664 return status;
11665}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666#endif /* FEATURE_WLAN_EXTSCAN */
11667
Wen Gong7952fbd2018-04-18 11:27:23 +080011668/**
11669 * sme_send_wisa_params(): Pass WISA mode to WMA
11670 * @hal: HAL context
11671 * @wisa_params: pointer to WISA params struct
11672 * @sessionId: SME session id
11673 *
11674 * Pass WISA params to WMA
11675 *
11676 * Return: QDF_STATUS
11677 */
11678QDF_STATUS sme_set_wisa_params(tHalHandle hal,
11679 struct sir_wisa_params *wisa_params)
11680{
11681 QDF_STATUS status = QDF_STATUS_SUCCESS;
11682 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11683 struct scheduler_msg message = {0};
11684 struct sir_wisa_params *cds_msg_wisa_params;
11685
11686 cds_msg_wisa_params = qdf_mem_malloc(sizeof(struct sir_wisa_params));
11687 if (!cds_msg_wisa_params)
11688 return QDF_STATUS_E_NOMEM;
11689
11690 *cds_msg_wisa_params = *wisa_params;
11691 status = sme_acquire_global_lock(&mac->sme);
11692 if (QDF_IS_STATUS_SUCCESS(status)) {
11693 message.bodyptr = cds_msg_wisa_params;
11694 message.type = WMA_SET_WISA_PARAMS;
11695 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
11696 sme_release_global_lock(&mac->sme);
11697 }
11698 return status;
11699}
11700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011701#ifdef WLAN_FEATURE_LINK_LAYER_STATS
11702
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011703/*
11704 * sme_ll_stats_clear_req() -
11705 * SME API to clear Link Layer Statistics
11706 *
11707 * hHal
11708 * pclearStatsReq: Link Layer clear stats request params structure
11709 * Return QDF_STATUS
11710 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011711QDF_STATUS sme_ll_stats_clear_req(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011712 tSirLLStatsClearReq *pclearStatsReq)
11713{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011714 QDF_STATUS status = QDF_STATUS_SUCCESS;
11715 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011716 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011717 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011718 tSirLLStatsClearReq *clear_stats_req;
11719
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011720 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011721 "staId = %u", pclearStatsReq->staId);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011722 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011723 "statsClearReqMask = 0x%X",
11724 pclearStatsReq->statsClearReqMask);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011725 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011726 "stopReq = %u", pclearStatsReq->stopReq);
Deepak Dhamdhere6adc08e2017-07-27 09:33:22 -070011727 if (!sme_is_session_id_valid(hHal, pclearStatsReq->staId)) {
11728 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11729 "%s: invalid staId %d",
11730 __func__, pclearStatsReq->staId);
11731 return QDF_STATUS_E_INVAL;
11732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011733
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011734 clear_stats_req = qdf_mem_malloc(sizeof(*clear_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735
11736 if (!clear_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011737 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011738 "%s: Not able to allocate memory for WMA_LL_STATS_CLEAR_REQ",
11739 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011740 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011741 }
11742
11743 *clear_stats_req = *pclearStatsReq;
11744
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011745 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011746 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011747 message.bodyptr = clear_stats_req;
11748 message.type = WMA_LINK_LAYER_STATS_CLEAR_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011749 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011750 NO_SESSION, message.type));
11751 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11752 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011753 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011754 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011755 "%s: not able to post WMA_LL_STATS_CLEAR_REQ",
11756 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011757 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011758 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011759 }
11760 sme_release_global_lock(&pMac->sme);
11761 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011762 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11763 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011764 qdf_mem_free(clear_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011765 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011766 }
11767
11768 return status;
11769}
11770
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011771/*
11772 * sme_ll_stats_set_req() -
11773 * SME API to set the Link Layer Statistics
11774 *
11775 * hHal
11776 * psetStatsReq: Link Layer set stats request params structure
11777 * Return QDF_STATUS
11778 */
11779QDF_STATUS sme_ll_stats_set_req(tHalHandle hHal, tSirLLStatsSetReq
11780 *psetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011781{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011782 QDF_STATUS status = QDF_STATUS_SUCCESS;
11783 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011784 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011785 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011786 tSirLLStatsSetReq *set_stats_req;
11787
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011788 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011789 "%s: MPDU Size = %u", __func__,
11790 psetStatsReq->mpduSizeThreshold);
Abhishek Singhe4a1f882017-08-10 17:59:44 +053011791 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011792 " Aggressive Stats Collections = %u",
11793 psetStatsReq->aggressiveStatisticsGathering);
11794
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011795 set_stats_req = qdf_mem_malloc(sizeof(*set_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011796
11797 if (!set_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011798 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011799 "%s: Not able to allocate memory for WMA_LL_STATS_SET_REQ",
11800 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011801 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011802 }
11803
11804 *set_stats_req = *psetStatsReq;
11805
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011806 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011808 message.bodyptr = set_stats_req;
11809 message.type = WMA_LINK_LAYER_STATS_SET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011810 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011811 NO_SESSION, message.type));
11812 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11813 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011814 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011816 "%s: not able to post WMA_LL_STATS_SET_REQ",
11817 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011818 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011819 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011820 }
11821 sme_release_global_lock(&pMac->sme);
11822 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11824 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011825 qdf_mem_free(set_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011826 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011827 }
11828
11829 return status;
11830}
11831
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011832/*
11833 * sme_ll_stats_get_req() -
11834 * SME API to get the Link Layer Statistics
11835 *
11836 * hHal
11837 * pgetStatsReq: Link Layer get stats request params structure
11838 * Return QDF_STATUS
11839 */
11840QDF_STATUS sme_ll_stats_get_req(tHalHandle hHal, tSirLLStatsGetReq
11841 *pgetStatsReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011842{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011843 QDF_STATUS status = QDF_STATUS_SUCCESS;
11844 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011845 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070011846 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011847 tSirLLStatsGetReq *get_stats_req;
11848
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011849 get_stats_req = qdf_mem_malloc(sizeof(*get_stats_req));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011850
11851 if (!get_stats_req) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011852 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011853 "%s: Not able to allocate memory for WMA_LL_STATS_GET_REQ",
11854 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011855 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011856 }
11857
11858 *get_stats_req = *pgetStatsReq;
11859
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011860 if (QDF_STATUS_SUCCESS == sme_acquire_global_lock(&pMac->sme)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011861 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011862 message.bodyptr = get_stats_req;
11863 message.type = WMA_LINK_LAYER_STATS_GET_REQ;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053011864 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080011865 NO_SESSION, message.type));
11866 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
11867 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011868 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011869 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870 "%s: not able to post WMA_LL_STATS_GET_REQ",
11871 __func__);
11872
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011873 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011874 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011875
11876 }
11877 sme_release_global_lock(&pMac->sme);
11878 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011879 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11880 "%s: sme_acquire_global_lock error", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011881 qdf_mem_free(get_stats_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011882 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 }
11884
11885 return status;
11886}
11887
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011888/*
11889 * sme_set_link_layer_stats_ind_cb() -
11890 * SME API to trigger the stats are available after get request
11891 *
11892 * hHal
11893 * callback_routine - HDD callback which needs to be invoked after
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011894 getting status notification from FW
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011895 * Return QDF_STATUS
11896 */
11897QDF_STATUS sme_set_link_layer_stats_ind_cb(tHalHandle hHal,
11898 void (*callback_routine)(void *callbackCtx, int indType, void *pRsp))
11899{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011900 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011901 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
11902
11903 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011904 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011905 pMac->sme.pLinkLayerStatsIndCallback = callback_routine;
11906 sme_release_global_lock(&pMac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011907 } else
11908 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11909 "%s: sme_acquire_global_lock error", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011910
11911 return status;
11912}
11913
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011914/**
Zhang Qiana6e9c102016-12-22 16:47:24 +080011915 * sme_set_link_layer_ext_cb() - Register callback for link layer statistics
11916 * @hal: Mac global handle
11917 * @ll_stats_ext_cb: HDD callback which needs to be invoked after getting
11918 * status notification from FW
11919 *
11920 * Return: eHalStatus
11921 */
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011922QDF_STATUS sme_set_link_layer_ext_cb(tHalHandle hal, void (*ll_stats_ext_cb)
Jeff Johnson2d292122018-06-02 21:02:02 -070011923 (hdd_handle_t callback_ctx, tSirLLStatsResults
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011924 *rsp))
Zhang Qiana6e9c102016-12-22 16:47:24 +080011925{
11926 QDF_STATUS status;
11927 tpAniSirGlobal mac = PMAC_STRUCT(hal);
11928
11929 status = sme_acquire_global_lock(&mac->sme);
11930 if (status == QDF_STATUS_SUCCESS) {
11931 mac->sme.link_layer_stats_ext_cb = ll_stats_ext_cb;
11932 sme_release_global_lock(&mac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011933 } else
Zhang Qiana6e9c102016-12-22 16:47:24 +080011934 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11935 "%s: sme_qcquire_global_lock error", __func__);
Zhang Qiana6e9c102016-12-22 16:47:24 +080011936 return status;
11937}
11938
11939/**
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011940 * sme_reset_link_layer_stats_ind_cb() - SME API to reset link layer stats
11941 * indication
11942 * @h_hal: Hal Handle
11943 *
11944 * This function reset's the link layer stats indication
11945 *
11946 * Return: QDF_STATUS Enumeration
11947 */
11948
11949QDF_STATUS sme_reset_link_layer_stats_ind_cb(tHalHandle h_hal)
11950{
11951 QDF_STATUS status;
11952 tpAniSirGlobal pmac;
11953
11954 if (!h_hal) {
11955 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11956 FL("hHal is not valid"));
11957 return QDF_STATUS_E_INVAL;
11958 }
11959 pmac = PMAC_STRUCT(h_hal);
11960
11961 status = sme_acquire_global_lock(&pmac->sme);
11962 if (QDF_IS_STATUS_SUCCESS(status)) {
11963 pmac->sme.pLinkLayerStatsIndCallback = NULL;
11964 sme_release_global_lock(&pmac->sme);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053011965 } else
11966 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11967 "%s: sme_acquire_global_lock error", __func__);
Arun Khandavalli4b55da72016-07-19 19:55:01 +053011968
11969 return status;
11970}
11971
Zhang Qian73c348a2017-03-13 16:15:55 +080011972/**
11973 * sme_ll_stats_set_thresh - set threshold for mac counters
11974 * @hal, hal layer handle
11975 * @threshold, threshold for mac counters
11976 *
11977 * Return: QDF_STATUS Enumeration
11978 */
11979QDF_STATUS sme_ll_stats_set_thresh(tHalHandle hal,
11980 struct sir_ll_ext_stats_threshold *threshold)
11981{
11982 QDF_STATUS status;
11983 tpAniSirGlobal mac;
Rajeev Kumar658e8492017-12-13 11:35:41 -080011984 struct scheduler_msg message = {0};
Zhang Qian73c348a2017-03-13 16:15:55 +080011985 struct sir_ll_ext_stats_threshold *thresh;
11986
11987 if (!threshold) {
11988 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11989 FL("threshold is not valid"));
11990 return QDF_STATUS_E_INVAL;
11991 }
11992
11993 if (!hal) {
11994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
11995 FL("hal is not valid"));
11996 return QDF_STATUS_E_INVAL;
11997 }
11998 mac = PMAC_STRUCT(hal);
11999
12000 thresh = qdf_mem_malloc(sizeof(*thresh));
12001 if (!thresh) {
12002 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12003 "%s: Fail to alloc mem", __func__);
12004 return QDF_STATUS_E_NOMEM;
12005 }
12006 *thresh = *threshold;
12007
12008 status = sme_acquire_global_lock(&mac->sme);
12009 if (QDF_IS_STATUS_SUCCESS(status)) {
12010 /* Serialize the req through MC thread */
12011 message.bodyptr = thresh;
12012 message.type = WDA_LINK_LAYER_STATS_SET_THRESHOLD;
12013 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
12014 NO_SESSION, message.type));
12015 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
12016 if (!QDF_IS_STATUS_SUCCESS(status)) {
12017 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12018 "%s: not able to post WDA_LL_STATS_GET_REQ",
12019 __func__);
12020 qdf_mem_free(thresh);
12021 }
12022 sme_release_global_lock(&mac->sme);
12023 } else {
12024 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12025 FL("sme_acquire_global_lock error"));
12026 qdf_mem_free(thresh);
12027 }
12028 return status;
12029}
Arun Khandavalli4b55da72016-07-19 19:55:01 +053012030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012031#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
12032
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012033#ifdef WLAN_POWER_DEBUGFS
12034/**
12035 * sme_power_debug_stats_req() - SME API to collect Power debug stats
12036 * @callback_fn: Pointer to the callback function for Power stats event
12037 * @power_stats_context: Pointer to context
12038 *
12039 * Return: QDF_STATUS
12040 */
12041QDF_STATUS sme_power_debug_stats_req(tHalHandle hal, void (*callback_fn)
12042 (struct power_stats_response *response,
12043 void *context), void *power_stats_context)
12044{
12045 QDF_STATUS status = QDF_STATUS_SUCCESS;
12046 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012047 struct scheduler_msg msg = {0};
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012048
12049 status = sme_acquire_global_lock(&mac_ctx->sme);
12050 if (QDF_IS_STATUS_SUCCESS(status)) {
12051 if (!callback_fn) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012052 sme_err("Indication callback did not registered");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012053 sme_release_global_lock(&mac_ctx->sme);
12054 return QDF_STATUS_E_FAILURE;
12055 }
12056
12057 mac_ctx->sme.power_debug_stats_context = power_stats_context;
12058 mac_ctx->sme.power_stats_resp_callback = callback_fn;
12059 msg.bodyptr = NULL;
12060 msg.type = WMA_POWER_DEBUG_STATS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012061 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012062 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012063 sme_err("not able to post WDA_POWER_DEBUG_STATS_REQ");
Sridhar Selvarajdc400d22016-10-18 17:18:03 +053012064 sme_release_global_lock(&mac_ctx->sme);
12065 }
12066 return status;
12067}
12068#endif
12069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012070#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012071/*
12072 * sme_update_roam_offload_enabled() - enable/disable roam offload feaure
12073 * It is used at in the REG_DYNAMIC_VARIABLE macro definition of
12074 *
12075 * hHal - The handle returned by mac_open.
12076 * nRoamOffloadEnabled - The bool to update with
12077 * Return QDF_STATUS_SUCCESS - SME update config successfully.
12078 * Other status means SME is failed to update.
12079 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012080
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012081QDF_STATUS sme_update_roam_offload_enabled(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012082 bool nRoamOffloadEnabled)
12083{
12084 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012085 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012086
12087 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012088 if (QDF_IS_STATUS_SUCCESS(status)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012089 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012090 "%s: LFR3:gRoamOffloadEnabled is changed from %d to %d",
12091 __func__, pMac->roam.configParam.isRoamOffloadEnabled,
12092 nRoamOffloadEnabled);
12093 pMac->roam.configParam.isRoamOffloadEnabled =
12094 nRoamOffloadEnabled;
12095 sme_release_global_lock(&pMac->sme);
12096 }
12097
12098 return status;
12099}
12100
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012101/**
12102 * sme_update_roam_key_mgmt_offload_enabled() - enable/disable key mgmt offload
12103 * This is a synchronous call
12104 * @hal_ctx: The handle returned by mac_open.
12105 * @session_id: Session Identifier
12106 * @key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012107 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012108 * Return: QDF_STATUS_SUCCESS - SME updated config successfully.
12109 * Other status means SME is failed to update.
12110 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012111
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012112QDF_STATUS sme_update_roam_key_mgmt_offload_enabled(tHalHandle hal_ctx,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012113 uint8_t session_id,
12114 bool key_mgmt_offload_enabled,
12115 struct pmkid_mode_bits *pmkid_modes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012117 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012118 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012119
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012120 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012121 if (QDF_IS_STATUS_SUCCESS(status)) {
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012122 if (CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Abhishek Singhe4a1f882017-08-10 17:59:44 +053012123 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012124 "%s: LFR3: key_mgmt_offload_enabled changed to %d",
12125 __func__, key_mgmt_offload_enabled);
12126 status = csr_roam_set_key_mgmt_offload(mac_ctx,
12127 session_id,
12128 key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080012129 pmkid_modes);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012130 } else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012131 status = QDF_STATUS_E_INVAL;
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070012132 sme_release_global_lock(&mac_ctx->sme);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012133 }
12134
12135 return status;
12136}
Prashanth Bhattabfc25292015-11-05 11:16:21 -080012137#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012138
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012139/*
12140 * sme_get_temperature() -
12141 * SME API to get the pdev temperature
12142 *
12143 * hHal
12144 * temperature context
12145 * pCallbackfn: callback fn with response (temperature)
12146 * Return QDF_STATUS
12147 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012148QDF_STATUS sme_get_temperature(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012149 void *tempContext,
12150 void (*pCallbackfn)(int temperature,
12151 void *pContext))
12152{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012153 QDF_STATUS status = QDF_STATUS_SUCCESS;
12154 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012155 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012156 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012157
12158 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012159 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012160 if ((NULL == pCallbackfn) &&
12161 (NULL == pMac->sme.pGetTemperatureCb)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012163 "Indication Call back did not registered");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012164 sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012165 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012166 } else if (NULL != pCallbackfn) {
12167 pMac->sme.pTemperatureCbContext = tempContext;
12168 pMac->sme.pGetTemperatureCb = pCallbackfn;
12169 }
12170 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012171 message.bodyptr = NULL;
12172 message.type = WMA_GET_TEMPERATURE_REQ;
12173 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12174 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012175 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012176 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012177 FL("Post Get Temperature msg fail"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012178 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012179 }
12180 sme_release_global_lock(&pMac->sme);
12181 }
12182 return status;
12183}
12184
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012185/*
12186 * sme_set_scanning_mac_oui() -
12187 * SME API to set scanning mac oui
12188 *
12189 * hHal
12190 * pScanMacOui: Scanning Mac Oui (input 3 bytes)
12191 * Return QDF_STATUS
12192 */
12193QDF_STATUS sme_set_scanning_mac_oui(tHalHandle hHal, tSirScanMacOui
12194 *pScanMacOui)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012195{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012196 QDF_STATUS status = QDF_STATUS_SUCCESS;
12197 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012198 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012199 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012200
12201 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012202 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012203 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012204 message.bodyptr = pScanMacOui;
12205 message.type = WMA_SET_SCAN_MAC_OUI_REQ;
12206 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
12207 &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012208 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012209 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012210 FL("Msg post Set Scan Mac OUI failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012211 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012212 }
12213 sme_release_global_lock(&pMac->sme);
12214 }
12215 return status;
12216}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012217
12218#ifdef DHCP_SERVER_OFFLOAD
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012219/*
12220 * sme_set_dhcp_srv_offload() -
12221 * SME API to set DHCP server offload info
12222 *
12223 * hHal
12224 * pDhcpSrvInfo : DHCP server offload info struct
12225 * Return QDF_STATUS
12226 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012227QDF_STATUS sme_set_dhcp_srv_offload(tHalHandle hHal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012228 tSirDhcpSrvOffloadInfo *pDhcpSrvInfo)
12229{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012230 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012231 tSirDhcpSrvOffloadInfo *pSmeDhcpSrvInfo;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012232 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012233 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
12234
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012235 pSmeDhcpSrvInfo = qdf_mem_malloc(sizeof(*pSmeDhcpSrvInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012236
12237 if (!pSmeDhcpSrvInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012238 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012239 "%s: Not able to allocate memory for WMA_SET_DHCP_SERVER_OFFLOAD_CMD",
12240 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012241 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012242 }
12243
12244 *pSmeDhcpSrvInfo = *pDhcpSrvInfo;
12245
12246 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012247 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012248 /* serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012249 message.type = WMA_SET_DHCP_SERVER_OFFLOAD_CMD;
12250 message.bodyptr = pSmeDhcpSrvInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012251
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012252 if (!QDF_IS_STATUS_SUCCESS
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012253 (scheduler_post_msg(QDF_MODULE_ID_WMA,
12254 &message))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012255 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070012256 "%s:WMA_SET_DHCP_SERVER_OFFLOAD_CMD failed",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012257 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012258 qdf_mem_free(pSmeDhcpSrvInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012259 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012260 }
12261 sme_release_global_lock(&pMac->sme);
12262 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012263 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012264 "%s: sme_acquire_global_lock error!", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012265 qdf_mem_free(pSmeDhcpSrvInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012266 }
12267
12268 return status;
12269}
12270#endif /* DHCP_SERVER_OFFLOAD */
12271
Krunal Soniaadaa272017-10-04 16:42:55 -070012272QDF_STATUS sme_send_unit_test_cmd(uint32_t vdev_id, uint32_t module_id,
12273 uint32_t arg_count, uint32_t *arg)
12274{
12275 return wma_form_unit_test_cmd_and_send(vdev_id, module_id,
12276 arg_count, arg);
12277}
12278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012279#ifdef WLAN_FEATURE_GPIO_LED_FLASHING
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012280/*
12281 * sme_set_led_flashing() -
12282 * API to set the Led flashing parameters.
12283 *
12284 * hHal - The handle returned by mac_open.
12285 * x0, x1 - led flashing parameters
12286 * Return QDF_STATUS
12287 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012288QDF_STATUS sme_set_led_flashing(tHalHandle hHal, uint8_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012289 uint32_t x0, uint32_t x1)
12290{
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012291 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012292 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012293 struct scheduler_msg message = {0};
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012294 struct flashing_req_params *ledflashing;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012296 ledflashing = qdf_mem_malloc(sizeof(*ledflashing));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012297 if (!ledflashing) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012298 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053012299 "Not able to allocate memory for WMA_LED_TIMING_REQ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012300 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012301 }
12302
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012303 ledflashing->req_id = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012304 ledflashing->pattern_id = type;
12305 ledflashing->led_x0 = x0;
12306 ledflashing->led_x1 = x1;
12307
12308 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012309 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012310 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012311 message.bodyptr = ledflashing;
12312 message.type = WMA_LED_FLASHING_REQ;
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012313 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012314 sme_release_global_lock(&pMac->sme);
12315 }
Jeff Johnson5a6b6602017-10-04 14:44:30 -070012316 if (!QDF_IS_STATUS_SUCCESS(status))
12317 qdf_mem_free(ledflashing);
12318
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012319 return status;
12320}
12321#endif
12322
12323/**
12324 * sme_handle_dfS_chan_scan() - handle DFS channel configuration
12325 * @h_hal: corestack handler
12326 * @dfs_flag: flag indicating dfs channel enable/disable
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012327 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012328 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012329QDF_STATUS sme_handle_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012330{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012331 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012332 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12333
12334 status = sme_acquire_global_lock(&mac->sme);
12335
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012336 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012337
12338 mac->scan.fEnableDFSChnlScan = dfs_flag;
12339
12340 /* update the channel list to the firmware */
12341 status = csr_update_channel_list(mac);
12342
12343 sme_release_global_lock(&mac->sme);
12344 }
12345
12346 return status;
12347}
12348
Min Liu5eaf7242018-03-13 17:32:15 +080012349/**
12350 * sme_enable_dfS_chan_scan() - set DFS channel scan enable/disable
12351 * @h_hal: corestack handler
12352 * @dfs_flag: flag indicating dfs channel enable/disable
12353 * Return: QDF_STATUS
12354 */
12355QDF_STATUS sme_enable_dfs_chan_scan(tHalHandle h_hal, uint8_t dfs_flag)
12356{
12357 QDF_STATUS status = QDF_STATUS_SUCCESS;
12358 tpAniSirGlobal mac;
12359
12360 if (!h_hal) {
12361 sme_err("hal is NULL");
12362 return QDF_STATUS_E_INVAL;
12363 }
12364
12365 mac = PMAC_STRUCT(h_hal);
12366 if (!mac) {
12367 sme_err("mac is NULL");
12368 return QDF_STATUS_E_INVAL;
12369 }
12370
12371 mac->scan.fEnableDFSChnlScan = dfs_flag;
12372
12373 return status;
12374}
12375
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012376#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
12377/**
12378 * sme_validate_sap_channel_switch() - validate target channel switch w.r.t
12379 * concurreny rules set to avoid channel interference.
12380 * @hal - Hal context
12381 * @sap_ch - channel to switch
12382 * @sap_phy_mode - phy mode of SAP
12383 * @cc_switch_mode - concurreny switch mode
12384 * @session_id - sme session id.
12385 *
12386 * Return: true if there is no channel interference else return false
12387 */
12388bool sme_validate_sap_channel_switch(tHalHandle hal,
12389 uint16_t sap_ch, eCsrPhyMode sap_phy_mode, uint8_t cc_switch_mode,
12390 uint8_t session_id)
12391{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012392 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012393 tpAniSirGlobal mac = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012394 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012395 uint16_t intf_channel = 0;
12396
12397 if (!session)
12398 return false;
12399
12400 session->ch_switch_in_progress = true;
12401 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012402 if (QDF_IS_STATUS_SUCCESS(status)) {
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012403 intf_channel = csr_check_concurrent_channel_overlap(mac, sap_ch,
12404 sap_phy_mode,
12405 cc_switch_mode);
12406 sme_release_global_lock(&mac->sme);
12407 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012408 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Edhar, Mahesh Kumardf2ec122015-11-16 11:33:16 +053012409 FL("sme_acquire_global_lock error!"));
12410 session->ch_switch_in_progress = false;
12411 return false;
12412 }
12413
12414 session->ch_switch_in_progress = false;
12415 return (intf_channel == 0) ? true : false;
12416}
12417#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012418
12419/**
12420 * sme_configure_stats_avg_factor() - function to config avg. stats factor
12421 * @hal: hal
12422 * @session_id: session ID
12423 * @stats_avg_factor: average stats factor
12424 *
12425 * This function configures the stats avg factor in firmware
12426 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012427 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012429QDF_STATUS sme_configure_stats_avg_factor(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012430 uint16_t stats_avg_factor)
12431{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012432 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012433 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012434 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12435 struct sir_stats_avg_factor *stats_factor;
12436
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012437 stats_factor = qdf_mem_malloc(sizeof(*stats_factor));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012438
12439 if (!stats_factor) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012440 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012441 "%s: Not able to allocate memory for SIR_HAL_CONFIG_STATS_FACTOR",
12442 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012443 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012444 }
12445
12446 status = sme_acquire_global_lock(&mac->sme);
12447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012448 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012449
12450 stats_factor->vdev_id = session_id;
12451 stats_factor->stats_avg_factor = stats_avg_factor;
12452
12453 /* serialize the req through MC thread */
12454 msg.type = SIR_HAL_CONFIG_STATS_FACTOR;
12455 msg.bodyptr = stats_factor;
12456
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012457 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012458 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012460 "%s: Not able to post SIR_HAL_CONFIG_STATS_FACTOR to WMA!",
12461 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012462 qdf_mem_free(stats_factor);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012463 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012464 }
12465 sme_release_global_lock(&mac->sme);
12466 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012467 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012468 "%s: sme_acquire_global_lock error!",
12469 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012470 qdf_mem_free(stats_factor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012471 }
12472
12473 return status;
12474}
12475
12476/**
12477 * sme_configure_guard_time() - function to configure guard time
12478 * @hal: hal
12479 * @session_id: session id
12480 * @guard_time: guard time
12481 *
12482 * This function configures the guard time in firmware
12483 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012484 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012485 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012486QDF_STATUS sme_configure_guard_time(tHalHandle hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012487 uint32_t guard_time)
12488{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012489 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012490 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012491 tpAniSirGlobal mac = PMAC_STRUCT(hal);
12492 struct sir_guard_time_request *g_time;
12493
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012494 g_time = qdf_mem_malloc(sizeof(*g_time));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012495
12496 if (!g_time) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012498 "%s: Not able to allocate memory for SIR_HAL_CONFIG_GUARD_TIME",
12499 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012500 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501 }
12502
12503 status = sme_acquire_global_lock(&mac->sme);
12504
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012505 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012506
12507 g_time->vdev_id = session_id;
12508 g_time->guard_time = guard_time;
12509
12510 /* serialize the req through MC thread */
12511 msg.type = SIR_HAL_CONFIG_GUARD_TIME;
12512 msg.bodyptr = g_time;
12513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012514 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012515 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012516 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012517 "%s: Not able to post SIR_HAL_CONFIG_GUARD_TIME to WMA!",
12518 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012519 qdf_mem_free(g_time);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012520 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012521 }
12522 sme_release_global_lock(&mac->sme);
12523 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012524 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012525 "%s: sme_acquire_global_lock error!",
12526 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012527 qdf_mem_free(g_time);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012528 }
12529
12530 return status;
12531}
12532
12533/**
12534 * sme_configure_modulated_dtim() - function to configure modulated dtim
12535 * @h_hal: SME API to enable/disable modulated DTIM instantaneously
12536 * @session_id: session ID
12537 * @modulated_dtim: modulated dtim value
12538 *
12539 * This function configures the modulated dtim in firmware
12540 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012541 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012542 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012543QDF_STATUS sme_configure_modulated_dtim(tHalHandle h_hal, uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012544 uint32_t modulated_dtim)
12545{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012546 struct scheduler_msg msg = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012547 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012548 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12549 wma_cli_set_cmd_t *iwcmd;
12550
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012551 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012552 if (NULL == iwcmd) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012553 QDF_TRACE(QDF_MODULE_ID_SME,
12554 QDF_TRACE_LEVEL_FATAL,
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053012555 "%s: qdf_mem_malloc failed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012556 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012557 }
12558
12559 status = sme_acquire_global_lock(&mac->sme);
12560
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012561 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012563 iwcmd->param_value = modulated_dtim;
12564 iwcmd->param_vdev_id = session_id;
12565 iwcmd->param_id = GEN_PARAM_MODULATED_DTIM;
12566 iwcmd->param_vp_dev = GEN_CMD;
12567 msg.type = WMA_CLI_SET_CMD;
12568 msg.reserved = 0;
12569 msg.bodyptr = (void *)iwcmd;
12570
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012571 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012572 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012573 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012574 "%s: Not able to post GEN_PARAM_DYNAMIC_DTIM to WMA!",
12575 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012576 qdf_mem_free(iwcmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012577 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012578 }
12579 sme_release_global_lock(&mac->sme);
12580 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012582 "%s: sme_acquire_global_lock error!",
12583 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012584 qdf_mem_free(iwcmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012585 }
12586
12587 return status;
12588}
12589
Mukul Sharma6398b252017-05-01 17:58:12 +053012590/**
12591 * sme_override_listen_interval() - function to override static LI
12592 * @h_hal: SME API to override listen interval
12593 * @session_id: session ID
12594 * @override_li: new LI value passed by user
12595 *
12596 * This function override (enable/disable) static a.k.a ini based LI
12597 *
12598 * Return: QDF_STATUS
12599 */
12600QDF_STATUS sme_override_listen_interval(tHalHandle h_hal, uint8_t session_id,
12601 uint32_t override_li)
12602{
12603 struct scheduler_msg msg = {0};
12604 QDF_STATUS status = QDF_STATUS_SUCCESS;
12605 tpAniSirGlobal mac = PMAC_STRUCT(h_hal);
12606 wma_cli_set_cmd_t *iwcmd;
12607
12608 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
12609 if (!iwcmd) {
12610 QDF_TRACE(QDF_MODULE_ID_SME,
12611 QDF_TRACE_LEVEL_FATAL,
12612 "%s: qdf_mem_malloc failed", __func__);
12613 return QDF_STATUS_E_NOMEM;
12614 }
12615
12616 status = sme_acquire_global_lock(&mac->sme);
12617
12618 if (status == QDF_STATUS_SUCCESS) {
12619
12620 iwcmd->param_value = override_li;
12621 iwcmd->param_vdev_id = session_id;
12622 iwcmd->param_id = GEN_PARAM_LISTEN_INTERVAL;
12623 iwcmd->param_vp_dev = GEN_CMD;
12624 msg.type = WMA_CLI_SET_CMD;
12625 msg.reserved = 0;
12626 msg.bodyptr = (void *)iwcmd;
12627
12628 if (!QDF_IS_STATUS_SUCCESS(
12629 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
12630 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12631 "%s: Can't post GEN_PARAM_LISTEN_INTERVAL",
12632 __func__);
12633 qdf_mem_free(iwcmd);
12634 status = QDF_STATUS_E_FAILURE;
12635 }
12636 sme_release_global_lock(&mac->sme);
12637 } else {
12638 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
12639 "%s: sme_acquire_global_lock error!",
12640 __func__);
12641 qdf_mem_free(iwcmd);
12642 }
12643
12644 return status;
12645}
12646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012647/*
12648 * sme_wifi_start_logger() - Send the start/stop logging command to WMA
12649 * to either start/stop logging
12650 * @hal: HAL context
12651 * @start_log: Structure containing the wifi start logger params
12652 *
12653 * This function sends the start/stop logging command to WMA
12654 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012655 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012656 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012657QDF_STATUS sme_wifi_start_logger(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012658 struct sir_wifi_start_log start_log)
12659{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012660 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012661 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012662 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012663 struct sir_wifi_start_log *req_msg;
12664 uint32_t len;
12665
12666 len = sizeof(*req_msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012667 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012668 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012669 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012670 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012671 }
12672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 req_msg->verbose_level = start_log.verbose_level;
Poddar, Siddartheefe3482016-09-21 18:12:59 +053012674 req_msg->is_iwpriv_command = start_log.is_iwpriv_command;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012675 req_msg->ring_id = start_log.ring_id;
Srinivas Girigowdac34f11d2016-02-25 16:02:42 -080012676 req_msg->ini_triggered = start_log.ini_triggered;
12677 req_msg->user_triggered = start_log.user_triggered;
Poddar, Siddarth176c4362016-10-03 12:25:00 +053012678 req_msg->size = start_log.size;
Poddar, Siddarthab99a272017-04-10 12:53:26 +053012679 req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012680
12681 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012682 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012683 sme_err("sme_acquire_global_lock failed(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012684 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012685 return status;
12686 }
12687
12688 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012689 message.bodyptr = req_msg;
12690 message.type = SIR_HAL_START_STOP_LOGGING;
12691 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012692 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012693 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012694 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012695 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012696 }
12697 sme_release_global_lock(&mac->sme);
12698
12699 return status;
12700}
12701
12702/**
12703 * sme_neighbor_middle_of_roaming() - Function to know if
12704 * STA is in the middle of roaming states
12705 * @hal: Handle returned by macOpen
12706 * @sessionId: sessionId of the STA session
12707 *
12708 * This function is a wrapper to call
12709 * csr_neighbor_middle_of_roaming to know STA is in the
12710 * middle of roaming states
12711 *
12712 * Return: True or False
12713 *
12714 */
12715bool sme_neighbor_middle_of_roaming(tHalHandle hHal, uint8_t sessionId)
12716{
Sandeep Puligillaca631612016-11-08 11:53:52 -080012717 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hHal);
12718 bool val = false;
12719
12720 if (CSR_IS_SESSION_VALID(mac_ctx, sessionId))
12721 val = csr_neighbor_middle_of_roaming(mac_ctx, sessionId);
12722 else
Rajeev Kumar9176ca42018-05-03 09:20:40 -070012723 sme_debug("Invalid Session: %d", sessionId);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012724
Sandeep Puligillaca631612016-11-08 11:53:52 -080012725 return val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012726}
12727
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +053012728bool sme_is_any_session_in_middle_of_roaming(mac_handle_t hal)
12729{
12730 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12731 uint8_t session_id;
12732
12733 for (session_id = 0; session_id < CSR_ROAM_SESSION_MAX; session_id++) {
12734 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
12735 csr_neighbor_middle_of_roaming(mac_ctx, session_id))
12736 return true;
12737 }
12738
12739 return false;
12740}
12741
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012742/*
12743 * sme_send_flush_logs_cmd_to_fw() - Flush FW logs
12744 * @mac: MAC handle
12745 *
12746 * This function is used to send the command that will
12747 * be used to flush the logs in the firmware
12748 *
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070012749 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012750 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012751QDF_STATUS sme_send_flush_logs_cmd_to_fw(tpAniSirGlobal mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012752{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012753 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070012754 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012756 /* Serialize the req through MC thread */
12757 message.bodyptr = NULL;
12758 message.type = SIR_HAL_FLUSH_LOG_TO_FW;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080012759 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012760 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070012761 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012762 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012763 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012764 return status;
12765}
12766
Jeff Johnsona1e92612017-09-24 15:33:44 -070012767QDF_STATUS sme_enable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012768 sme_ac_enum_type ac, uint8_t tid,
12769 uint8_t pri, uint32_t srvc_int,
12770 uint32_t sus_int,
Abhishek Singh12be60f2017-08-11 13:52:42 +053012771 enum sme_qos_wmm_dir_type dir,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012772 uint8_t psb, uint32_t sessionId,
12773 uint32_t delay_interval)
12774{
12775 void *wma_handle;
12776 t_wma_trigger_uapsd_params uapsd_params;
12777 enum uapsd_ac access_category;
12778
12779 if (!psb) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012780 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012781 "No need to configure auto trigger:psb is 0");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012782 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012783 }
12784
Anurag Chouhan6d760662016-02-20 16:05:43 +053012785 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012786 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012788 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012789 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012790 }
12791
12792 switch (ac) {
12793 case SME_AC_BK:
12794 access_category = UAPSD_BK;
12795 break;
12796 case SME_AC_BE:
12797 access_category = UAPSD_BE;
12798 break;
12799 case SME_AC_VI:
12800 access_category = UAPSD_VI;
12801 break;
12802 case SME_AC_VO:
12803 access_category = UAPSD_VO;
12804 break;
12805 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012806 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012807 }
12808
12809 uapsd_params.wmm_ac = access_category;
12810 uapsd_params.user_priority = pri;
12811 uapsd_params.service_interval = srvc_int;
12812 uapsd_params.delay_interval = delay_interval;
12813 uapsd_params.suspend_interval = sus_int;
12814
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012815 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012816 wma_trigger_uapsd_params(wma_handle, sessionId, &uapsd_params)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818 "Failed to Trigger Uapsd params for sessionId %d",
12819 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012820 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012821 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012822 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012823}
12824
Jeff Johnsona1e92612017-09-24 15:33:44 -070012825QDF_STATUS sme_disable_uapsd_for_ac(uint8_t sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012826 sme_ac_enum_type ac,
12827 uint32_t sessionId)
12828{
12829 void *wma_handle;
12830 enum uapsd_ac access_category;
12831
12832 switch (ac) {
12833 case SME_AC_BK:
12834 access_category = UAPSD_BK;
12835 break;
12836 case SME_AC_BE:
12837 access_category = UAPSD_BE;
12838 break;
12839 case SME_AC_VI:
12840 access_category = UAPSD_VI;
12841 break;
12842 case SME_AC_VO:
12843 access_category = UAPSD_VO;
12844 break;
12845 default:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012846 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012847 }
12848
Anurag Chouhan6d760662016-02-20 16:05:43 +053012849 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012851 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012852 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012853 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012854 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012855 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012856 wma_disable_uapsd_per_ac(wma_handle, sessionId, access_category)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012857 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012858 "Failed to disable uapsd for ac %d for sessionId %d",
12859 ac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012860 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012861 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012862 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012863}
12864
12865/**
12866 * sme_update_nss() - SME API to change the number for spatial streams
12867 * (1 or 2)
12868 * @hal: Handle returned by mac open
12869 * @nss: Number of spatial streams
12870 *
12871 * This function is used to update the number of spatial streams supported.
12872 *
12873 * Return: Success upon successfully changing nss else failure
12874 *
12875 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012876QDF_STATUS sme_update_nss(tHalHandle h_hal, uint8_t nss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012877{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012878 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012879 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
12880 uint32_t i, value = 0;
12881 union {
12882 uint16_t cfg_value16;
12883 tSirMacHTCapabilityInfo ht_cap_info;
12884 } uHTCapabilityInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012885 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012886
12887 status = sme_acquire_global_lock(&mac_ctx->sme);
12888
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012889 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012890 mac_ctx->roam.configParam.enable2x2 = (nss == 1) ? 0 : 1;
12891
12892 /* get the HT capability info*/
12893 sme_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &value);
12894 uHTCapabilityInfo.cfg_value16 = (0xFFFF & value);
12895
12896 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
12897 if (CSR_IS_SESSION_VALID(mac_ctx, i)) {
12898 csr_session = &mac_ctx->roam.roamSession[i];
12899 csr_session->htConfig.ht_tx_stbc =
12900 uHTCapabilityInfo.ht_cap_info.txSTBC;
12901 }
12902 }
12903
12904 sme_release_global_lock(&mac_ctx->sme);
12905 }
12906 return status;
12907}
12908
12909/**
Archana Ramachandran5041b252016-04-25 14:29:25 -070012910 * sme_update_user_configured_nss() - sets the nss based on user request
12911 * @hal: Pointer to HAL
12912 * @nss: number of streams
12913 *
12914 * Return: None
12915 */
12916void sme_update_user_configured_nss(tHalHandle hal, uint8_t nss)
12917{
12918 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12919
12920 mac_ctx->user_configured_nss = nss;
12921}
12922
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070012923int sme_update_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
12924 uint8_t cfg_val)
12925{
12926 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12927 QDF_STATUS status = QDF_STATUS_SUCCESS;
12928 status = sme_cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
12929 cfg_val);
12930 if (status != QDF_STATUS_SUCCESS) {
12931 sme_err("Failed to set SU BFEE CFG");
12932 return -EFAULT;
12933 }
12934
12935 return sme_update_he_tx_bfee_supp(hal, session_id, cfg_val);
12936}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080012937#ifdef WLAN_FEATURE_11AX
12938void sme_update_he_cap_nss(tHalHandle hal, uint8_t session_id,
12939 uint8_t nss)
12940{
12941 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12942 struct csr_roam_session *csr_session;
12943 uint32_t tx_mcs_map = 0;
12944 uint32_t rx_mcs_map = 0;
12945
12946 if (!nss || (nss > 2)) {
12947 sme_err("invalid Nss value %d", nss);
12948 }
12949 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12950 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, &rx_mcs_map);
12951 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, &tx_mcs_map);
12952 if (nss == 1) {
12953 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_DISABLE, 2);
12954 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_DISABLE, 2);
12955 } else {
12956 tx_mcs_map = HE_SET_MCS_4_NSS(tx_mcs_map, HE_MCS_0_11, 2);
12957 rx_mcs_map = HE_SET_MCS_4_NSS(rx_mcs_map, HE_MCS_0_11, 2);
12958 }
12959 sme_info("new HE Nss MCS MAP: Rx 0x%0X, Tx: 0x%0X",
12960 rx_mcs_map, tx_mcs_map);
12961 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, rx_mcs_map);
12962 sme_cfg_set_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, tx_mcs_map);
12963 csr_update_session_he_cap(mac_ctx, csr_session);
12964
12965}
Kiran Kumar Lokere96246e52018-01-24 16:44:35 -080012966
12967int sme_update_he_mcs(tHalHandle hal, uint8_t session_id, uint16_t he_mcs)
12968{
12969 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
12970 struct csr_roam_session *csr_session;
12971 uint16_t mcs_val = 0;
12972 uint16_t mcs_map = HE_MCS_ALL_DISABLED;
12973 uint32_t wni_cfg_tx_param = 0;
12974 uint32_t wni_cfg_rx_param = 0;
12975
12976 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12977 if (!csr_session) {
12978 sme_err("No session for id %d", session_id);
12979 return -EINVAL;
12980 }
12981 if ((he_mcs & 0x3) == HE_MCS_DISABLE) {
12982 sme_err("Invalid HE MCS 0x%0x, can't disable 0-7 for 1ss",
12983 he_mcs);
12984 return -EINVAL;
12985 }
12986 mcs_val = he_mcs & 0x3;
12987 switch (he_mcs) {
12988 case HE_80_MCS0_7:
12989 case HE_80_MCS0_9:
12990 case HE_80_MCS0_11:
12991 if (mac_ctx->roam.configParam.enable2x2) {
12992 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12993 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 2);
12994 } else {
12995 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
12996 }
12997 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_LT_80;
12998 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_LT_80;
12999 break;
13000
13001 case HE_160_MCS0_7:
13002 case HE_160_MCS0_9:
13003 case HE_160_MCS0_11:
13004 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13005 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_160;
13006 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_160;
13007 break;
13008
13009 case HE_80p80_MCS0_7:
13010 case HE_80p80_MCS0_9:
13011 case HE_80p80_MCS0_11:
13012 mcs_map = HE_SET_MCS_4_NSS(mcs_map, mcs_val, 1);
13013 wni_cfg_tx_param = WNI_CFG_HE_TX_MCS_MAP_80_80;
13014 wni_cfg_rx_param = WNI_CFG_HE_RX_MCS_MAP_80_80;
13015 break;
13016
13017 default:
13018 sme_err("Invalid HE MCS 0x%0x", he_mcs);
13019 return -EINVAL;
13020 }
13021 sme_info("new HE MCS 0x%0x", mcs_map);
13022 sme_cfg_set_int(mac_ctx, wni_cfg_tx_param, mcs_map);
13023 sme_cfg_set_int(mac_ctx, wni_cfg_rx_param, mcs_map);
13024 csr_update_session_he_cap(mac_ctx, csr_session);
13025
13026 return 0;
13027}
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013028
13029static int sme_update_he_cap(tHalHandle hal, uint8_t session_id,
13030 uint16_t he_cap, int value)
13031{
13032 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13033 struct csr_roam_session *session;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013034
13035 session = CSR_GET_SESSION(mac_ctx, session_id);
13036 if (!session) {
13037 sme_err("No session for id %d", session_id);
13038 return -EINVAL;
13039 }
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013040 sme_cfg_set_int(mac_ctx, he_cap, value);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013041 csr_update_session_he_cap(mac_ctx, session);
13042
13043 return 0;
13044}
13045
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -070013046int sme_update_he_tx_bfee_supp(tHalHandle hal, uint8_t session_id,
13047 uint8_t cfg_val)
13048{
13049 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_SU_BEAMFORMEE,
13050 cfg_val);
13051}
13052
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013053int sme_update_he_tx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13054{
13055 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013056 uint32_t he_cap_val = 0;
13057
13058 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013059
13060 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013061 WNI_CFG_HE_TX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013062 if (ret)
13063 return ret;
13064
13065 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013066 WNI_CFG_HE_TX_STBC_GT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013067}
13068
13069int sme_update_he_rx_stbc_cap(tHalHandle hal, uint8_t session_id, int value)
13070{
13071 int ret;
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013072 uint32_t he_cap_val = 0;
13073
13074 he_cap_val = value ? 1 : 0;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013075
13076 ret = sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013077 WNI_CFG_HE_RX_STBC_LT80, he_cap_val);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013078 if (ret)
13079 return ret;
13080
13081 return sme_update_he_cap(hal, session_id,
Kiran Kumar Lokere5cc2f0d2018-02-08 17:10:05 -080013082 WNI_CFG_HE_RX_STBC_GT80, he_cap_val);
13083}
13084
13085int sme_update_he_frag_supp(tHalHandle hal, uint8_t session_id,
13086 uint16_t he_frag)
13087{
13088 return sme_update_he_cap(hal, session_id,
13089 WNI_CFG_HE_FRAGMENTATION, he_frag);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -080013090}
Kiran Kumar Lokeree43a4582018-05-08 19:54:03 -070013091
13092int sme_update_he_ldpc_supp(tHalHandle hal, uint8_t session_id,
13093 uint16_t he_ldpc)
13094{
13095 return sme_update_he_cap(hal, session_id, WNI_CFG_HE_LDPC, he_ldpc);
13096}
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -080013097#endif
13098
Archana Ramachandran5041b252016-04-25 14:29:25 -070013099/**
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013100 * sme_set_nud_debug_stats_cb() - set nud debug stats callback
13101 * @hal: global hal handle
13102 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013103 * @context: callback context
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013104 *
13105 * This function stores nud debug stats callback function.
13106 *
13107 * Return: QDF_STATUS enumeration.
13108 */
13109QDF_STATUS sme_set_nud_debug_stats_cb(tHalHandle hal,
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013110 void (*cb)(void *, struct rsp_stats *, void *),
13111 void *context)
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013112{
13113 QDF_STATUS status = QDF_STATUS_SUCCESS;
13114 tpAniSirGlobal mac;
13115
13116 if (!hal) {
13117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13118 FL("hal is not valid"));
13119 return QDF_STATUS_E_INVAL;
13120 }
13121 mac = PMAC_STRUCT(hal);
13122
13123 status = sme_acquire_global_lock(&mac->sme);
13124 if (!QDF_IS_STATUS_SUCCESS(status)) {
13125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13126 FL("sme_acquire_global_lock failed!(status=%d)"),
13127 status);
13128 return status;
13129 }
13130
13131 mac->sme.get_arp_stats_cb = cb;
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013132 mac->sme.get_arp_stats_context = context;
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053013133 sme_release_global_lock(&mac->sme);
13134 return status;
13135}
13136
13137/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013138 * sme_set_rssi_threshold_breached_cb() - set rssi threshold breached callback
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013139 * @h_hal: global hal handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013140 * @cb: callback function pointer
Dundi Raviteja3bcf3a82018-05-22 13:24:18 +053013141 * @context: callback context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142 *
13143 * This function stores the rssi threshold breached callback function.
13144 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013145 * Return: QDF_STATUS enumeration.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013146 */
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013147QDF_STATUS sme_set_rssi_threshold_breached_cb(tHalHandle h_hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013148 void (*cb)(void *, struct rssi_breach_event *))
13149{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013150 QDF_STATUS status = QDF_STATUS_SUCCESS;
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013151 tpAniSirGlobal mac;
13152
13153 if (!h_hal) {
13154 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13155 FL("hHal is not valid"));
13156 return QDF_STATUS_E_INVAL;
13157 }
13158 mac = PMAC_STRUCT(h_hal);
13159
13160 status = sme_acquire_global_lock(&mac->sme);
13161 if (!QDF_IS_STATUS_SUCCESS(status)) {
13162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13163 FL("sme_acquire_global_lock failed!(status=%d)"),
13164 status);
13165 return status;
13166 }
13167
13168 mac->sme.rssi_threshold_breached_cb = cb;
13169 sme_release_global_lock(&mac->sme);
13170 return status;
13171}
13172
13173/**
13174 * sme_set_rssi_threshold_breached_cb() - Reset rssi threshold breached callback
13175 * @hal: global hal handle
13176 *
13177 * This function de-registers the rssi threshold breached callback function.
13178 *
13179 * Return: QDF_STATUS enumeration.
13180 */
13181QDF_STATUS sme_reset_rssi_threshold_breached_cb(tHalHandle hal)
13182{
13183 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013184 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13185
13186 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013187 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013188 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013189 return status;
13190 }
13191
Arun Khandavalli4b55da72016-07-19 19:55:01 +053013192 mac->sme.rssi_threshold_breached_cb = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013193 sme_release_global_lock(&mac->sme);
13194 return status;
13195}
13196
13197/**
13198 * sme_is_any_session_in_connected_state() - SME wrapper API to
13199 * check if any session is in connected state or not.
13200 *
13201 * @hal: Handle returned by mac open
13202 *
13203 * This function is used to check if any valid sme session is in
13204 * connected state or not.
13205 *
13206 * Return: true if any session is connected, else false.
13207 *
13208 */
13209bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
13210{
13211 tpAniSirGlobal mac_ctx = PMAC_STRUCT(h_hal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013212 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013213 bool ret = false;
13214
13215 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013216 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013217 ret = csr_is_any_session_in_connect_state(mac_ctx);
13218 sme_release_global_lock(&mac_ctx->sme);
13219 }
13220 return ret;
13221}
13222
Ravi Kumar Bokka05c14e52017-03-27 14:48:23 +053013223QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
13224 void (*cb)(void *,
13225 struct chip_pwr_save_fail_detected_params *)) {
13226
13227 QDF_STATUS status = QDF_STATUS_SUCCESS;
13228 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13229
13230 status = sme_acquire_global_lock(&mac->sme);
13231 if (status != QDF_STATUS_SUCCESS) {
13232 sme_err("sme_AcquireGlobalLock failed!(status=%d)", status);
13233 return status;
13234 }
13235 mac->sme.chip_power_save_fail_cb = cb;
13236 sme_release_global_lock(&mac->sme);
13237 return status;
13238}
13239
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013240/**
13241 * sme_set_rssi_monitoring() - set rssi monitoring
13242 * @hal: global hal handle
13243 * @input: request message
13244 *
13245 * This function constructs the vos message and fill in message type,
13246 * bodyptr with @input and posts it to WDA queue.
13247 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013248 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013249 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013250QDF_STATUS sme_set_rssi_monitoring(tHalHandle hal,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013251 struct rssi_monitor_req *input)
13252{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013253 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013254 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013255 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013256 struct rssi_monitor_req *req_msg;
13257
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013258 SME_ENTER();
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013259 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013260 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013261 sme_err("memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013262 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013263 }
13264
13265 *req_msg = *input;
13266
13267 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013268 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013269 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013270 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013271 return status;
13272 }
13273
13274 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013275 message.bodyptr = req_msg;
13276 message.type = WMA_SET_RSSI_MONITOR_REQ;
13277 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013278 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013279 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013280 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013281 }
13282 sme_release_global_lock(&mac->sme);
13283
13284 return status;
13285}
13286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013287/*
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013288 * sme_pdev_set_pcl() - Send WMI_PDEV_SET_PCL_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013289 * @hal: Handle returned by macOpen
13290 * @msg: PCL channel list and length structure
13291 *
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013292 * Sends the command to WMA to send WMI_PDEV_SET_PCL_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013293 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 */
Krunal Soni8a090df2018-05-03 15:02:54 -070013295QDF_STATUS sme_pdev_set_pcl(struct policy_mgr_pcl_list *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013296{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013297 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013298 tpAniSirGlobal mac = sme_get_mac_context();
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013299 struct scheduler_msg message = {0};
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013300 struct wmi_pcl_chan_weights *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013301 uint32_t len, i;
13302
Krunal Soni3fa80e22018-01-09 14:16:02 -080013303 if (!mac) {
13304 sme_err("mac is NULL");
13305 return QDF_STATUS_E_FAILURE;
13306 }
Krunal Soni8a090df2018-05-03 15:02:54 -070013307
13308 if (!msg) {
13309 sme_err("msg is NULL");
13310 return QDF_STATUS_E_FAILURE;
13311 }
13312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013313 len = sizeof(*req_msg);
13314
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013315 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013316 if (!req_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013317 sme_err("qdf_mem_malloc failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013318 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013319 }
13320
Krunal Soni8a090df2018-05-03 15:02:54 -070013321 for (i = 0; i < msg->pcl_len; i++) {
13322 req_msg->pcl_list[i] = msg->pcl_list[i];
13323 req_msg->weight_list[i] = msg->weight_list[i];
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +053013324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013325
Krunal Soni8a090df2018-05-03 15:02:54 -070013326 req_msg->pcl_len = msg->pcl_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013327
13328 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013329 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013330 sme_err("sme_acquire_global_lock failed!(status=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013331 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013332 return status;
13333 }
13334
13335 /* Serialize the req through MC thread */
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013336 message.bodyptr = req_msg;
13337 message.type = SIR_HAL_PDEV_SET_PCL_TO_FW;
13338 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013339 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013340 sme_err("scheduler_post_msg failed!(err=%d)", status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013341 qdf_mem_free(req_msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013342 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013343 }
13344 sme_release_global_lock(&mac->sme);
13345
13346 return status;
13347}
13348
13349/*
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013350 * sme_pdev_set_hw_mode() - Send WMI_PDEV_SET_HW_MODE_CMDID to the WMA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013351 * @hal: Handle returned by macOpen
13352 * @msg: HW mode structure containing hw mode and callback details
13353 *
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +053013354 * Sends the command to CSR to send WMI_PDEV_SET_HW_MODE_CMDID to FW
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013355 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013356 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013357QDF_STATUS sme_pdev_set_hw_mode(struct policy_mgr_hw_mode msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013358{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013359 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013360 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 tSmeCmd *cmd = NULL;
13362
Krunal Soni3fa80e22018-01-09 14:16:02 -080013363 if (!mac) {
13364 sme_err("mac is NULL");
13365 return QDF_STATUS_E_FAILURE;
13366 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013367 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013368 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013369 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013370 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013371 }
13372
Krunal Soni78618d92017-02-14 21:46:31 -080013373 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013374 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013375 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013376 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013377 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 }
13379
13380 cmd->command = e_sme_command_set_hw_mode;
Ganesh Kondabattiniae1c6a22017-05-02 18:02:11 +053013381 cmd->sessionId = msg.session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013382 cmd->u.set_hw_mode_cmd.hw_mode_index = msg.hw_mode_index;
13383 cmd->u.set_hw_mode_cmd.set_hw_mode_cb = msg.set_hw_mode_cb;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053013384 cmd->u.set_hw_mode_cmd.reason = msg.reason;
13385 cmd->u.set_hw_mode_cmd.session_id = msg.session_id;
Tushnim Bhattacharyyaeab33dd2017-11-15 15:20:02 -080013386 cmd->u.set_hw_mode_cmd.next_action = msg.next_action;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013387 cmd->u.set_hw_mode_cmd.context = msg.context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013388
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013389 sme_debug("Queuing set hw mode to CSR, session: %d reason: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013390 cmd->u.set_hw_mode_cmd.session_id,
13391 cmd->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013392 csr_queue_sme_command(mac, cmd, false);
13393
13394 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013395 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013396}
13397
13398/**
13399 * sme_register_hw_mode_trans_cb() - HW mode transition callback registration
13400 * @hal: Handle returned by macOpen
13401 * @callback: HDD callback to be registered
13402 *
13403 * Registers the HDD callback with SME. This callback will be invoked when
13404 * HW mode transition event is received from the FW
13405 *
13406 * Return: None
13407 */
13408void sme_register_hw_mode_trans_cb(tHalHandle hal,
13409 hw_mode_transition_cb callback)
13410{
13411 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13412
13413 mac->sme.sme_hw_mode_trans_cb = callback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013414}
13415
13416/**
13417 * sme_nss_update_request() - Send beacon templete update to FW with new
13418 * nss value
13419 * @hal: Handle returned by macOpen
13420 * @vdev_id: the session id
13421 * @new_nss: the new nss value
13422 * @cback: hdd callback
13423 * @next_action: next action to happen at policy mgr after beacon update
13424 *
13425 * Sends the command to CSR to send to PE
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013426 * Return: QDF_STATUS_SUCCESS on successful posting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013427 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013428QDF_STATUS sme_nss_update_request(uint32_t vdev_id,
13429 uint8_t new_nss, policy_mgr_nss_update_cback cback,
13430 uint8_t next_action, struct wlan_objmgr_psoc *psoc,
13431 enum policy_mgr_conn_update_reason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013432{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013433 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013434 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013435 tSmeCmd *cmd = NULL;
13436
Krunal Soni3fa80e22018-01-09 14:16:02 -080013437 if (!mac) {
13438 sme_err("mac is null");
13439 return status;
13440 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013441 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013442 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni78618d92017-02-14 21:46:31 -080013443 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013444 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013445 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013446 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013447 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013448 }
13449 cmd->command = e_sme_command_nss_update;
13450 /* Sessionized modules may require this info */
13451 cmd->sessionId = vdev_id;
13452 cmd->u.nss_update_cmd.new_nss = new_nss;
13453 cmd->u.nss_update_cmd.session_id = vdev_id;
13454 cmd->u.nss_update_cmd.nss_update_cb = cback;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013455 cmd->u.nss_update_cmd.context = psoc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013456 cmd->u.nss_update_cmd.next_action = next_action;
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053013457 cmd->u.nss_update_cmd.reason = reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013458
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013459 sme_debug("Queuing e_sme_command_nss_update to CSR");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 csr_queue_sme_command(mac, cmd, false);
13461 sme_release_global_lock(&mac->sme);
13462 }
13463 return status;
13464}
13465
13466/**
13467 * sme_soc_set_dual_mac_config() - Set dual mac configurations
13468 * @hal: Handle returned by macOpen
13469 * @msg: Structure containing the dual mac config parameters
13470 *
13471 * Queues configuration information to CSR to configure
13472 * WLAN firmware for the dual MAC features
13473 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013474 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013475 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013476QDF_STATUS sme_soc_set_dual_mac_config(struct policy_mgr_dual_mac_config msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013477{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013478 QDF_STATUS status = QDF_STATUS_SUCCESS;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080013479 tpAniSirGlobal mac = sme_get_mac_context();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013480 tSmeCmd *cmd;
13481
Krunal Soni3fa80e22018-01-09 14:16:02 -080013482 if (!mac) {
13483 sme_err("mac is null");
13484 return QDF_STATUS_E_FAILURE;
13485 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013486 status = sme_acquire_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013487 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013488 sme_err("Failed to acquire lock");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013489 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013490 }
13491
Krunal Soni78618d92017-02-14 21:46:31 -080013492 cmd = csr_get_command_buffer(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013493 if (!cmd) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013494 sme_err("Get command buffer failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013495 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013496 return QDF_STATUS_E_NULL_VALUE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013497 }
13498
13499 cmd->command = e_sme_command_set_dual_mac_config;
13500 cmd->u.set_dual_mac_cmd.scan_config = msg.scan_config;
13501 cmd->u.set_dual_mac_cmd.fw_mode_config = msg.fw_mode_config;
13502 cmd->u.set_dual_mac_cmd.set_dual_mac_cb = msg.set_dual_mac_cb;
13503
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013504 sme_debug("set_dual_mac_config scan_config: %x fw_mode_config: %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013505 cmd->u.set_dual_mac_cmd.scan_config,
13506 cmd->u.set_dual_mac_cmd.fw_mode_config);
13507 csr_queue_sme_command(mac, cmd, false);
13508
13509 sme_release_global_lock(&mac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013510 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013511}
13512
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013513#ifdef FEATURE_LFR_SUBNET_DETECTION
13514/**
13515 * sme_gateway_param_update() - to update gateway parameters with WMA
13516 * @Hal: hal handle
13517 * @gw_params: request parameters from HDD
13518 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013519 * Return: QDF_STATUS
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013520 *
13521 * This routine will update gateway parameters to WMA
13522 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013523QDF_STATUS sme_gateway_param_update(tHalHandle Hal,
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013524 struct gateway_param_update_req *gw_params)
13525{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013526 QDF_STATUS qdf_status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013527 struct scheduler_msg message = {0};
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013528 struct gateway_param_update_req *request_buf;
13529
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013530 request_buf = qdf_mem_malloc(sizeof(*request_buf));
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013531 if (NULL == request_buf) {
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 allocate memory for gw param update request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013534 return QDF_STATUS_E_NOMEM;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013535 }
13536
13537 *request_buf = *gw_params;
13538
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013539 message.type = WMA_GW_PARAM_UPDATE_REQ;
13540 message.reserved = 0;
13541 message.bodyptr = request_buf;
13542 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013543 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013544 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013545 "Not able to post WMA_GW_PARAM_UPDATE_REQ message to HAL");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013546 qdf_mem_free(request_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013547 return QDF_STATUS_E_FAILURE;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013548 }
13549
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013550 return QDF_STATUS_SUCCESS;
Ravi Joshi9e891ba2015-11-09 19:03:46 -080013551}
13552#endif /* FEATURE_LFR_SUBNET_DETECTION */
13553
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013554/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013555 * sme_soc_set_antenna_mode() - set antenna mode
13556 * @hal: Handle returned by macOpen
13557 * @msg: Structure containing the antenna mode parameters
13558 *
13559 * Send the command to CSR to send
13560 * WMI_SOC_SET_ANTENNA_MODE_CMDID to FW
13561 *
13562 * Return: QDF_STATUS
13563 */
13564QDF_STATUS sme_soc_set_antenna_mode(tHalHandle hal,
13565 struct sir_antenna_mode_param *msg)
13566{
13567 QDF_STATUS status = QDF_STATUS_SUCCESS;
13568 tpAniSirGlobal mac = PMAC_STRUCT(hal);
13569 tSmeCmd *cmd;
13570
13571 if (NULL == msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013572 sme_err("antenna mode mesg is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013573 return QDF_STATUS_E_FAILURE;
13574 }
13575
13576 status = sme_acquire_global_lock(&mac->sme);
13577 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013578 sme_err("Failed to acquire lock");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013579 return QDF_STATUS_E_RESOURCES;
13580 }
13581
Krunal Soni78618d92017-02-14 21:46:31 -080013582 cmd = csr_get_command_buffer(mac);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013583 if (!cmd) {
13584 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013585 sme_err("Get command buffer failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013586 return QDF_STATUS_E_NULL_VALUE;
13587 }
13588
13589 cmd->command = e_sme_command_set_antenna_mode;
13590 cmd->u.set_antenna_mode_cmd = *msg;
13591
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013592 sme_debug("Antenna mode rx_chains: %d tx_chains: %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080013593 cmd->u.set_antenna_mode_cmd.num_rx_chains,
13594 cmd->u.set_antenna_mode_cmd.num_tx_chains);
13595
13596 csr_queue_sme_command(mac, cmd, false);
13597 sme_release_global_lock(&mac->sme);
13598
13599 return QDF_STATUS_SUCCESS;
13600}
13601
13602/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013603 * sme_set_peer_authorized() - call peer authorized callback
13604 * @peer_addr: peer mac address
13605 * @auth_cb: auth callback
13606 * @vdev_id: vdev id
13607 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053013608 * Return: QDF Status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013609 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013610QDF_STATUS sme_set_peer_authorized(uint8_t *peer_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013611 sme_peer_authorized_fp auth_cb,
13612 uint32_t vdev_id)
13613{
13614 void *wma_handle;
13615
Anurag Chouhan6d760662016-02-20 16:05:43 +053013616 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013617 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013618 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013619 "wma handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013620 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013621 }
13622
13623 wma_set_peer_authorized_cb(wma_handle, auth_cb);
13624 return wma_set_peer_param(wma_handle, peer_addr, WMI_PEER_AUTHORIZE,
13625 1, vdev_id);
13626}
13627
13628/*
Amar Singhal7c1e8982016-05-19 15:08:09 -070013629 * sme_handle_set_fcc_channel() - set spec. tx power for non-fcc channel
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013630 * @hal: HAL pointer
Amar Singhal83a047a2016-05-19 15:56:11 -070013631 * @fcc_constraint: flag to enable/disable the constraint
13632 * @scan_pending: whether there is pending scan
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013633 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013634 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013635 */
Amar Singhal83a047a2016-05-19 15:56:11 -070013636QDF_STATUS sme_handle_set_fcc_channel(tHalHandle hal, bool fcc_constraint,
13637 bool scan_pending)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013638{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013639 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013640 tpAniSirGlobal mac_ptr = PMAC_STRUCT(hal);
13641
13642 status = sme_acquire_global_lock(&mac_ptr->sme);
13643
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013644 if (QDF_STATUS_SUCCESS == status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013645
13646 if (fcc_constraint != mac_ptr->scan.fcc_constraint) {
13647 mac_ptr->scan.fcc_constraint = fcc_constraint;
Amar Singhal83a047a2016-05-19 15:56:11 -070013648 if (scan_pending)
13649 mac_ptr->scan.defer_update_channel_list = true;
13650 else
13651 status = csr_update_channel_list(mac_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013652 }
13653
13654 sme_release_global_lock(&mac_ptr->sme);
13655 }
13656
13657 return status;
13658}
13659/**
13660 * sme_setdef_dot11mode() - Updates pMac with default dot11mode
13661 * @hal: Global MAC pointer
13662 *
13663 * Return: NULL.
13664 */
13665void sme_setdef_dot11mode(tHalHandle hal)
13666{
13667 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669 csr_set_default_dot11_mode(mac_ctx);
13670}
13671
13672/**
13673 * sme_update_roam_scan_hi_rssi_scan_params() - update high rssi scan
13674 * params
13675 * @hal_handle - The handle returned by macOpen.
13676 * @session_id - Session Identifier
13677 * @notify_id - Identifies 1 of the 4 parameters to be modified
13678 * @val New value of the parameter
13679 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013680 * Return: QDF_STATUS - SME update config successful.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013681 * Other status means SME failed to update
13682 */
13683
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013684QDF_STATUS sme_update_roam_scan_hi_rssi_scan_params(tHalHandle hal_handle,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013685 uint8_t session_id,
13686 uint32_t notify_id,
13687 int32_t val)
13688{
13689 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013690 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013691 struct csr_neighbor_roamconfig *nr_config = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013692 tpCsrNeighborRoamControlInfo nr_info = NULL;
13693 uint32_t reason = 0;
13694
Naveen Rawatc36f7eb2016-11-10 20:01:03 -080013695 if (session_id >= CSR_ROAM_SESSION_MAX) {
13696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13697 FL("Invalid sme session id: %d"), session_id);
13698 return QDF_STATUS_E_INVAL;
13699 }
13700
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013701 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013702 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013703 nr_config = &mac_ctx->roam.configParam.neighborRoamConfig;
13704 nr_info = &mac_ctx->roam.neighborRoamInfo[session_id];
13705 switch (notify_id) {
13706 case eCSR_HI_RSSI_SCAN_MAXCOUNT_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013707 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013708 "%s: gRoamScanHirssiMaxCount %d => %d",
13709 __func__, nr_config->nhi_rssi_scan_max_count,
13710 val);
13711 nr_config->nhi_rssi_scan_max_count = val;
13712 nr_info->cfgParams.hi_rssi_scan_max_count = val;
13713 reason = REASON_ROAM_SCAN_HI_RSSI_MAXCOUNT_CHANGED;
13714 break;
13715
13716 case eCSR_HI_RSSI_SCAN_RSSI_DELTA_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013718 FL("gRoamScanHiRssiDelta %d => %d"),
13719 nr_config->nhi_rssi_scan_rssi_delta,
13720 val);
13721 nr_config->nhi_rssi_scan_rssi_delta = val;
13722 nr_info->cfgParams.hi_rssi_scan_rssi_delta = val;
13723 reason = REASON_ROAM_SCAN_HI_RSSI_DELTA_CHANGED;
13724 break;
13725
13726 case eCSR_HI_RSSI_SCAN_DELAY_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013727 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013728 FL("gRoamScanHiRssiDelay %d => %d"),
13729 nr_config->nhi_rssi_scan_delay,
13730 val);
13731 nr_config->nhi_rssi_scan_delay = val;
13732 nr_info->cfgParams.hi_rssi_scan_delay = val;
13733 reason = REASON_ROAM_SCAN_HI_RSSI_DELAY_CHANGED;
13734 break;
13735
13736 case eCSR_HI_RSSI_SCAN_RSSI_UB_ID:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013737 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013738 FL("gRoamScanHiRssiUpperBound %d => %d"),
13739 nr_config->nhi_rssi_scan_rssi_ub,
13740 val);
13741 nr_config->nhi_rssi_scan_rssi_ub = val;
13742 nr_info->cfgParams.hi_rssi_scan_rssi_ub = val;
13743 reason = REASON_ROAM_SCAN_HI_RSSI_UB_CHANGED;
13744 break;
13745
13746 default:
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013747 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013748 FL("invalid parameter notify_id %d"),
13749 notify_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013750 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013751 break;
13752 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053013753
13754 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled &&
13755 status == QDF_STATUS_SUCCESS) {
13756 csr_roam_offload_scan(mac_ctx, session_id,
13757 ROAM_SCAN_OFFLOAD_UPDATE_CFG, reason);
13758 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013759 sme_release_global_lock(&mac_ctx->sme);
13760 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013761
13762 return status;
13763}
13764
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013765/**
13766 * sme_update_tgt_services() - update the target services config.
13767 * @hal: HAL pointer.
13768 * @cfg: wma_tgt_services parameters.
13769 *
13770 * update the target services config.
13771 *
13772 * Return: None.
13773 */
13774void sme_update_tgt_services(tHalHandle hal, struct wma_tgt_services *cfg)
13775{
13776 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13777
Krunal Sonie6a1cda2017-09-27 15:23:02 -070013778 mac_ctx->lteCoexAntShare = cfg->lte_coex_ant_share;
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013779 mac_ctx->beacon_offload = cfg->beacon_offload;
mukul sharma72c8b222015-09-04 17:02:01 +053013780 mac_ctx->pmf_offload = cfg->pmf_offload;
Abhishek Singhe4a1f882017-08-10 17:59:44 +053013781 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
mukul sharma72c8b222015-09-04 17:02:01 +053013782 FL("mac_ctx->pmf_offload: %d"), mac_ctx->pmf_offload);
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053013783 mac_ctx->is_fils_roaming_supported =
13784 cfg->is_fils_roaming_supported;
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +053013785 mac_ctx->is_11k_offload_supported =
13786 cfg->is_11k_offload_supported;
13787 sme_debug("pmf_offload: %d fils_roam support %d 11k_offload %d",
13788 mac_ctx->pmf_offload, mac_ctx->is_fils_roaming_supported,
13789 mac_ctx->is_11k_offload_supported);
Krishna Kumaar Natarajan052c6e62015-09-28 15:32:55 -070013790}
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013791
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013792/**
13793 * sme_is_session_id_valid() - Check if the session id is valid
13794 * @hal: Pointer to HAL
13795 * @session_id: Session id
13796 *
13797 * Checks if the session id is valid or not
13798 *
13799 * Return: True is the session id is valid, false otherwise
13800 */
13801bool sme_is_session_id_valid(tHalHandle hal, uint32_t session_id)
13802{
13803 tpAniSirGlobal mac = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013804
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013805 if (!mac) {
Chandrasekaran, Manishekard3cb4772016-02-22 22:21:10 +053013806 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13807 "%s: null mac pointer", __func__);
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013808 return false;
13809 }
13810
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013811 if (CSR_IS_SESSION_VALID(mac, session_id))
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013812 return true;
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053013813
13814 return false;
Chandrasekaran, Manishekar2859de42016-02-11 16:17:38 +053013815}
13816
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013817#ifdef FEATURE_WLAN_TDLS
13818
13819/**
13820 * sme_get_opclass() - determine operating class
13821 * @hal: Pointer to HAL
13822 * @channel: channel id
13823 * @bw_offset: bandwidth offset
13824 * @opclass: pointer to operating class
13825 *
13826 * Function will determine operating class from regdm_get_opclass_from_channel
13827 *
13828 * Return: none
13829 */
13830void sme_get_opclass(tHalHandle hal, uint8_t channel, uint8_t bw_offset,
13831 uint8_t *opclass)
13832{
13833 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13834
13835 /* redgm opclass table contains opclass for 40MHz low primary,
13836 * 40MHz high primary and 20MHz. No support for 80MHz yet. So
13837 * first we will check if bit for 40MHz is set and if so find
13838 * matching opclass either with low primary or high primary
13839 * (a channel would never be in both) and then search for opclass
13840 * matching 20MHz, else for any BW.
13841 */
13842 if (bw_offset & (1 << BW_40_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013843 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013844 mac_ctx->scan.countryCodeCurrent,
13845 channel, BW40_LOW_PRIMARY);
13846 if (!(*opclass)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013847 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013848 mac_ctx->scan.countryCodeCurrent,
13849 channel, BW40_HIGH_PRIMARY);
13850 }
13851 } else if (bw_offset & (1 << BW_20_OFFSET_BIT)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013852 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013853 mac_ctx->scan.countryCodeCurrent,
13854 channel, BW20);
13855 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013856 *opclass = wlan_reg_dmn_get_opclass_from_channel(
Masti, Narayanraddic4a7ab82015-11-25 15:41:10 +053013857 mac_ctx->scan.countryCodeCurrent,
13858 channel, BWALL);
13859 }
13860}
13861#endif
Ryan Hsu3c8f79f2015-12-02 16:45:09 -080013862
Sandeep Puligillae0875662016-02-12 16:09:21 -080013863/**
Anurag Chouhanbf5e0e22016-09-12 12:54:09 +053013864 * sme_set_fw_test() - set fw test
13865 * @fw_test: fw test param
13866 *
13867 * Return: Return QDF_STATUS, otherwise appropriate failure code
13868 */
13869QDF_STATUS sme_set_fw_test(struct set_fwtest_params *fw_test)
13870{
13871 void *wma_handle;
13872
13873 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13874 if (!wma_handle) {
13875 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13876 "wma handle is NULL");
13877 return QDF_STATUS_E_FAILURE;
13878 }
13879 wma_process_fw_test_cmd(wma_handle, fw_test);
13880 return QDF_STATUS_SUCCESS;
13881}
13882
13883/**
Sandeep Puligillae0875662016-02-12 16:09:21 -080013884 * sme_ht40_stop_obss_scan() - ht40 obss stop scan
13885 * @hal: mac handel
13886 * @vdev_id: vdev identifier
13887 *
13888 * Return: Return QDF_STATUS, otherwise appropriate failure code
13889 */
13890QDF_STATUS sme_ht40_stop_obss_scan(tHalHandle hal, uint32_t vdev_id)
13891{
13892 void *wma_handle;
13893
13894 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
13895 if (!wma_handle) {
13896 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13897 "wma handle is NULL");
13898 return QDF_STATUS_E_FAILURE;
13899 }
13900 wma_ht40_stop_obss_scan(wma_handle, vdev_id);
13901 return QDF_STATUS_SUCCESS;
13902}
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013903
13904/**
13905 * sme_update_mimo_power_save() - Update MIMO power save
13906 * configuration
13907 * @hal: The handle returned by macOpen
13908 * @is_ht_smps_enabled: enable/disable ht smps
13909 * @ht_smps_mode: smps mode disabled/static/dynamic
Archana Ramachandranfec24812016-02-16 16:31:56 -080013910 * @send_smps_action: flag to send smps force mode command
13911 * to FW
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013912 *
13913 * Return: QDF_STATUS if SME update mimo power save
Jeff Johnson698eacd2018-05-12 17:00:03 -070013914 * configuration success else failure status
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013915 */
13916QDF_STATUS sme_update_mimo_power_save(tHalHandle hal,
13917 uint8_t is_ht_smps_enabled,
Archana Ramachandranfec24812016-02-16 16:31:56 -080013918 uint8_t ht_smps_mode,
13919 bool send_smps_action)
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013920{
13921 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Archana Ramachandranfec24812016-02-16 16:31:56 -080013922
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013923 sme_debug("SMPS enable: %d mode: %d send action: %d",
Archana Ramachandranfec24812016-02-16 16:31:56 -080013924 is_ht_smps_enabled, ht_smps_mode,
13925 send_smps_action);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013926 mac_ctx->roam.configParam.enableHtSmps =
13927 is_ht_smps_enabled;
13928 mac_ctx->roam.configParam.htSmps = ht_smps_mode;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013929 mac_ctx->roam.configParam.send_smps_action =
13930 send_smps_action;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013931
13932 return QDF_STATUS_SUCCESS;
13933}
13934
13935/**
13936 * sme_is_sta_smps_allowed() - check if the supported nss for
13937 * the session is greater than 1x1 to enable sta SMPS
13938 * @hal: The handle returned by macOpen
13939 * @session_id: session id
13940 *
13941 * Return: bool returns true if supported nss is greater than
13942 * 1x1 else false
13943 */
13944bool sme_is_sta_smps_allowed(tHalHandle hal, uint8_t session_id)
13945{
13946 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013947 struct csr_roam_session *csr_session;
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013948
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013949 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
13950 if (NULL == csr_session) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013951 sme_err("SME session not valid: %d", session_id);
Sreelakshmi Konamki58697e12016-05-25 17:30:18 +053013952 return false;
13953 }
13954
13955 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013956 sme_err("CSR session not valid: %d", session_id);
Archana Ramachandran20d2e232016-02-11 16:58:40 -080013957 return false;
13958 }
13959
13960 return (csr_session->supported_nss_1x1 == true) ? false : true;
13961}
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013962
13963/**
13964 * sme_add_beacon_filter() - set the beacon filter configuration
13965 * @hal: The handle returned by macOpen
13966 * @session_id: session id
13967 * @ie_map: bitwise array of IEs
13968 *
13969 * Return: Return QDF_STATUS, otherwise appropriate failure code
13970 */
13971QDF_STATUS sme_add_beacon_filter(tHalHandle hal,
13972 uint32_t session_id,
13973 uint32_t *ie_map)
13974{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070013975 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013976 QDF_STATUS qdf_status;
13977 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
13978 struct beacon_filter_param *filter_param;
13979
13980 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070013981 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070013982 return QDF_STATUS_E_FAILURE;
13983 }
13984
13985 filter_param = qdf_mem_malloc(sizeof(*filter_param));
13986 if (NULL == filter_param) {
13987 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
13988 "%s: fail to alloc filter_param", __func__);
13989 return QDF_STATUS_E_FAILURE;
13990 }
13991
13992 filter_param->vdev_id = session_id;
13993
13994 qdf_mem_copy(filter_param->ie_map, ie_map,
13995 BCN_FLT_MAX_ELEMS_IE_LIST * sizeof(uint32_t));
13996
13997 message.type = WMA_ADD_BCN_FILTER_CMDID;
13998 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080013999 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014000 &message);
14001 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14002 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14003 "%s: Not able to post msg to WDA!",
14004 __func__);
14005
14006 qdf_mem_free(filter_param);
14007 }
14008 return qdf_status;
14009}
14010
14011/**
14012 * sme_remove_beacon_filter() - set the beacon filter configuration
14013 * @hal: The handle returned by macOpen
14014 * @session_id: session id
14015 *
14016 * Return: Return QDF_STATUS, otherwise appropriate failure code
14017 */
14018QDF_STATUS sme_remove_beacon_filter(tHalHandle hal, uint32_t session_id)
14019{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014020 struct scheduler_msg message = {0};
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014021 QDF_STATUS qdf_status;
14022 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14023 struct beacon_filter_param *filter_param;
14024
14025 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014026 sme_err("CSR session not valid: %d", session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014027 return QDF_STATUS_E_FAILURE;
14028 }
14029
14030 filter_param = qdf_mem_malloc(sizeof(*filter_param));
14031 if (NULL == filter_param) {
14032 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14033 "%s: fail to alloc filter_param", __func__);
14034 return QDF_STATUS_E_FAILURE;
14035 }
14036
14037 filter_param->vdev_id = session_id;
14038
14039 message.type = WMA_REMOVE_BCN_FILTER_CMDID;
14040 message.bodyptr = filter_param;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014041 qdf_status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -070014042 &message);
14043 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
14044 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14045 "%s: Not able to post msg to WDA!",
14046 __func__);
14047
14048 qdf_mem_free(filter_param);
14049 }
14050 return qdf_status;
14051}
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014052
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014053/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014054 * sme_send_disassoc_req_frame - send disassoc req
14055 * @hal: handler to hal
14056 * @session_id: session id
14057 * @peer_mac: peer mac address
14058 * @reason: reason for disassociation
14059 * wait_for_ack: wait for acknowledgment
14060 *
14061 * function to send disassoc request to lim
14062 *
14063 * return: none
14064 */
14065void sme_send_disassoc_req_frame(tHalHandle hal, uint8_t session_id,
14066 uint8_t *peer_mac, uint16_t reason, uint8_t wait_for_ack)
14067{
14068 struct sme_send_disassoc_frm_req *msg;
14069 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
14070 A_UINT8 *buf;
14071 A_UINT16 tmp;
14072
14073 msg = qdf_mem_malloc(sizeof(struct sme_send_disassoc_frm_req));
14074
14075 if (NULL == msg)
14076 qdf_status = QDF_STATUS_E_FAILURE;
14077 else
14078 qdf_status = QDF_STATUS_SUCCESS;
14079
14080 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
14081 return;
14082
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014083 msg->msg_type = (uint16_t) eWNI_SME_SEND_DISASSOC_FRAME;
14084
14085 msg->length = (uint16_t) sizeof(struct sme_send_disassoc_frm_req);
14086
14087 buf = &msg->session_id;
14088
14089 /* session id */
14090 *buf = (A_UINT8) session_id;
14091 buf += sizeof(A_UINT8);
14092
14093 /* transaction id */
14094 *buf = 0;
14095 *(buf + 1) = 0;
14096 buf += sizeof(A_UINT16);
14097
14098 /* Set the peer MAC address before sending the message to LIM */
14099 qdf_mem_copy(buf, peer_mac, QDF_MAC_ADDR_SIZE);
14100
14101 buf += QDF_MAC_ADDR_SIZE;
14102
14103 /* reasoncode */
14104 tmp = (uint16_t) reason;
14105 qdf_mem_copy(buf, &tmp, sizeof(uint16_t));
14106 buf += sizeof(uint16_t);
14107
14108 *buf = wait_for_ack;
14109 buf += sizeof(uint8_t);
14110
Rajeev Kumard138ac52017-01-30 18:38:37 -080014111 qdf_status = umac_send_mb_message_to_mac(msg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053014112
14113 if (qdf_status != QDF_STATUS_SUCCESS)
14114 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14115 FL("cds_send_mb_message Failed"));
14116}
14117
Nachiket Kukadee547a482018-05-22 16:43:30 +053014118QDF_STATUS sme_get_apf_offload_capabilities(tHalHandle hal,
14119 apf_get_offload_cb callback,
Jeff Johnsona867e0c2017-01-26 13:43:51 -080014120 void *context)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014121{
14122 QDF_STATUS status = QDF_STATUS_SUCCESS;
14123 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014124 struct scheduler_msg cds_msg = {0};
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014125
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014126 SME_ENTER();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014127
14128 status = sme_acquire_global_lock(&mac_ctx->sme);
14129 if (QDF_STATUS_SUCCESS == status) {
14130 /* Serialize the req through MC thread */
Nachiket Kukadee547a482018-05-22 16:43:30 +053014131 mac_ctx->sme.apf_get_offload_cb = callback;
14132 mac_ctx->sme.apf_get_offload_context = context;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014133 cds_msg.bodyptr = NULL;
Nachiket Kukadee547a482018-05-22 16:43:30 +053014134 cds_msg.type = WDA_APF_GET_CAPABILITIES_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014135 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014136 if (!QDF_IS_STATUS_SUCCESS(status)) {
14137 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053014138 FL("Post apf get offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014139 status = QDF_STATUS_E_FAILURE;
14140 }
14141 sme_release_global_lock(&mac_ctx->sme);
14142 } else {
14143 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14144 FL("sme_acquire_global_lock error"));
14145 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014146 SME_EXIT();
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014147 return status;
14148}
14149
14150
14151/**
Nachiket Kukadee547a482018-05-22 16:43:30 +053014152 * sme_set_apf_instructions() - Set APF apf filter instructions.
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014153 * @hal: HAL handle
Nachiket Kukadee547a482018-05-22 16:43:30 +053014154 * @apf_set_offload: struct to set apf filter instructions.
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014155 *
14156 * Return: QDF_STATUS enumeration.
14157 */
Nachiket Kukadee547a482018-05-22 16:43:30 +053014158QDF_STATUS sme_set_apf_instructions(tHalHandle hal,
14159 struct sir_apf_set_offload *req)
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014160{
14161 QDF_STATUS status = QDF_STATUS_SUCCESS;
14162 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014163 struct scheduler_msg cds_msg = {0};
Nachiket Kukadee547a482018-05-22 16:43:30 +053014164 struct sir_apf_set_offload *set_offload;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014165
Arun Khandavallica198b52016-04-26 20:53:35 +053014166 set_offload = qdf_mem_malloc(sizeof(*set_offload) +
14167 req->current_length);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014168
14169 if (NULL == set_offload) {
14170 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14171 FL("Failed to alloc set_offload"));
14172 return QDF_STATUS_E_NOMEM;
14173 }
14174
14175 set_offload->session_id = req->session_id;
14176 set_offload->filter_id = req->filter_id;
14177 set_offload->current_offset = req->current_offset;
14178 set_offload->total_length = req->total_length;
Rajeev Kumare5a16822016-07-27 13:11:42 -070014179 set_offload->current_length = req->current_length;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014180 if (set_offload->total_length) {
Arun Khandavallica198b52016-04-26 20:53:35 +053014181 set_offload->program = ((uint8_t *)set_offload) +
14182 sizeof(*set_offload);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014183 qdf_mem_copy(set_offload->program, req->program,
14184 set_offload->current_length);
14185 }
14186 status = sme_acquire_global_lock(&mac_ctx->sme);
14187 if (QDF_STATUS_SUCCESS == status) {
14188 /* Serialize the req through MC thread */
14189 cds_msg.bodyptr = set_offload;
Nachiket Kukadee547a482018-05-22 16:43:30 +053014190 cds_msg.type = WDA_APF_SET_INSTRUCTIONS_REQ;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014191 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &cds_msg);
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014192
14193 if (!QDF_IS_STATUS_SUCCESS(status)) {
14194 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nachiket Kukadee547a482018-05-22 16:43:30 +053014195 FL("Post APF set offload msg fail"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014196 status = QDF_STATUS_E_FAILURE;
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014197 qdf_mem_free(set_offload);
14198 }
14199 sme_release_global_lock(&mac_ctx->sme);
14200 } else {
14201 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14202 FL("sme_acquire_global_lock failed"));
Arun Khandavalli2476ef52016-04-26 20:19:43 +053014203 qdf_mem_free(set_offload);
14204 }
14205 return status;
14206}
14207
14208/**
Abhishek Singh1c676222016-05-09 14:20:28 +053014209 * sme_get_wni_dot11_mode() - return configured wni dot11mode
14210 * @hal: hal pointer
14211 *
14212 * Return: wni dot11 mode.
14213 */
14214uint32_t sme_get_wni_dot11_mode(tHalHandle hal)
14215{
14216 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14217
14218 return csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14219 mac_ctx->roam.configParam.uCfgDot11Mode);
14220}
14221
14222/**
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014223 * sme_create_mon_session() - post message to create PE session for monitormode
14224 * operation
14225 * @hal_handle: Handle to the HAL
14226 * @bssid: pointer to bssid
14227 *
14228 * Return: QDF_STATUS_SUCCESS on success, non-zero error code on failure.
14229 */
14230QDF_STATUS sme_create_mon_session(tHalHandle hal_handle, tSirMacAddr bss_id)
14231{
14232 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14233 struct sir_create_session *msg;
14234
14235 msg = qdf_mem_malloc(sizeof(*msg));
14236 if (NULL != msg) {
14237 msg->type = eWNI_SME_MON_INIT_SESSION;
14238 msg->msg_len = sizeof(*msg);
14239 qdf_mem_copy(msg->bss_id.bytes, bss_id, QDF_MAC_ADDR_SIZE);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014240 status = umac_send_mb_message_to_mac(msg);
Manjunathappa Prakash59f861d2016-04-21 10:33:31 -070014241 }
14242 return status;
14243}
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014244
Kapil Gupta4f0c0c12017-02-07 15:21:15 +053014245void sme_set_chan_info_callback(tHalHandle hal_handle,
14246 void (*callback)(struct scan_chan_info *chan_info))
14247{
14248 tpAniSirGlobal mac;
14249
14250 if (hal_handle == NULL) {
14251 QDF_ASSERT(0);
14252 return;
14253 }
14254 mac = PMAC_STRUCT(hal_handle);
14255 mac->chan_info_cb = callback;
14256}
14257
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014258/**
14259 * sme_set_adaptive_dwelltime_config() - Update Adaptive dwelltime configuration
14260 * @hal: The handle returned by macOpen
14261 * @params: adaptive_dwelltime_params config
14262 *
14263 * Return: QDF_STATUS if adaptive dwell time update
Jeff Johnson698eacd2018-05-12 17:00:03 -070014264 * configuration success else failure status
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014265 */
14266QDF_STATUS sme_set_adaptive_dwelltime_config(tHalHandle hal,
14267 struct adaptive_dwelltime_params *params)
14268{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014269 struct scheduler_msg message = {0};
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014270 QDF_STATUS status;
14271 struct adaptive_dwelltime_params *dwelltime_params;
14272
14273 dwelltime_params = qdf_mem_malloc(sizeof(*dwelltime_params));
14274 if (NULL == dwelltime_params) {
14275 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14276 "%s: fail to alloc dwelltime_params", __func__);
14277 return QDF_STATUS_E_NOMEM;
14278 }
14279
14280 dwelltime_params->is_enabled = params->is_enabled;
14281 dwelltime_params->dwelltime_mode = params->dwelltime_mode;
14282 dwelltime_params->lpf_weight = params->lpf_weight;
14283 dwelltime_params->passive_mon_intval = params->passive_mon_intval;
14284 dwelltime_params->wifi_act_threshold = params->wifi_act_threshold;
14285
14286 message.type = WMA_SET_ADAPT_DWELLTIME_CONF_PARAMS;
14287 message.bodyptr = dwelltime_params;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014288 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053014289 if (!QDF_IS_STATUS_SUCCESS(status)) {
14290 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14291 "%s: Not able to post msg to WMA!", __func__);
14292
14293 qdf_mem_free(dwelltime_params);
14294 }
14295 return status;
14296}
Naveen Rawata410c5a2016-09-19 14:22:33 -070014297
14298/**
14299 * sme_set_vdev_ies_per_band() - sends the per band IEs to vdev
14300 * @hal: Pointer to HAL
14301 * @vdev_id: vdev_id for which IE is targeted
14302 *
14303 * Return: None
14304 */
14305void sme_set_vdev_ies_per_band(tHalHandle hal, uint8_t vdev_id)
14306{
Naveen Rawata410c5a2016-09-19 14:22:33 -070014307 struct sir_set_vdev_ies_per_band *p_msg;
14308 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14309
14310 p_msg = qdf_mem_malloc(sizeof(*p_msg));
14311 if (NULL == p_msg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014312 sme_err("mem alloc failed for sme msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014313 return;
14314 }
14315
14316 p_msg->vdev_id = vdev_id;
14317 p_msg->msg_type = eWNI_SME_SET_VDEV_IES_PER_BAND;
14318 p_msg->len = sizeof(*p_msg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014319 sme_debug("sending eWNI_SME_SET_VDEV_IES_PER_BAND: vdev_id: %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -070014320 vdev_id);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014321 status = umac_send_mb_message_to_mac(p_msg);
Naveen Rawata410c5a2016-09-19 14:22:33 -070014322 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014323 sme_err("Send eWNI_SME_SET_VDEV_IES_PER_BAND fail");
Naveen Rawata410c5a2016-09-19 14:22:33 -070014324}
14325
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014326/**
14327 * sme_set_pdev_ht_vht_ies() - sends the set pdev IE req
14328 * @hal: Pointer to HAL
14329 * @enable2x2: 1x1 or 2x2 mode.
14330 *
14331 * Sends the set pdev IE req with Nss value.
14332 *
14333 * Return: None
14334 */
14335void sme_set_pdev_ht_vht_ies(tHalHandle hal, bool enable2x2)
14336{
14337 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14338 struct sir_set_ht_vht_cfg *ht_vht_cfg;
14339 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14340
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014341 if (!((mac_ctx->roam.configParam.uCfgDot11Mode ==
14342 eCSR_CFG_DOT11_MODE_AUTO) ||
14343 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14344 eCSR_CFG_DOT11_MODE_11N) ||
14345 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14346 eCSR_CFG_DOT11_MODE_11N_ONLY) ||
14347 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14348 eCSR_CFG_DOT11_MODE_11AC) ||
14349 (mac_ctx->roam.configParam.uCfgDot11Mode ==
14350 eCSR_CFG_DOT11_MODE_11AC_ONLY)))
14351 return;
14352
14353 status = sme_acquire_global_lock(&mac_ctx->sme);
14354 if (QDF_STATUS_SUCCESS == status) {
14355 ht_vht_cfg = qdf_mem_malloc(sizeof(*ht_vht_cfg));
14356 if (NULL == ht_vht_cfg) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014357 sme_err("mem alloc failed for ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014358 sme_release_global_lock(&mac_ctx->sme);
14359 return;
14360 }
14361
14362 ht_vht_cfg->pdev_id = 0;
14363 if (enable2x2)
14364 ht_vht_cfg->nss = 2;
14365 else
14366 ht_vht_cfg->nss = 1;
14367 ht_vht_cfg->dot11mode =
14368 (uint8_t)csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
14369 mac_ctx->roam.configParam.uCfgDot11Mode);
14370
14371 ht_vht_cfg->msg_type = eWNI_SME_PDEV_SET_HT_VHT_IE;
14372 ht_vht_cfg->len = sizeof(*ht_vht_cfg);
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014373 sme_debug("SET_HT_VHT_IE with nss: %d, dot11mode: %d",
14374 ht_vht_cfg->nss,
14375 ht_vht_cfg->dot11mode);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014376 status = umac_send_mb_message_to_mac(ht_vht_cfg);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014377 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014378 sme_err("Send SME_PDEV_SET_HT_VHT_IE fail");
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014379
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014380 sme_release_global_lock(&mac_ctx->sme);
14381 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014382}
14383
14384/**
14385 * sme_update_vdev_type_nss() - sets the nss per vdev type
14386 * @hal: Pointer to HAL
14387 * @max_supp_nss: max_supported Nss
14388 * @band: 5G or 2.4G band
14389 *
14390 * Sets the per band Nss for each vdev type based on INI and configured
14391 * chain mask value.
14392 *
14393 * Return: None
14394 */
14395void sme_update_vdev_type_nss(tHalHandle hal, uint8_t max_supp_nss,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014396 uint32_t vdev_type_nss, enum band_info band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014397{
14398 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14399 struct vdev_type_nss *vdev_nss;
14400
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014401 if (BAND_5G == band)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070014402 vdev_nss = &mac_ctx->vdev_type_nss_5g;
14403 else
14404 vdev_nss = &mac_ctx->vdev_type_nss_2g;
14405
14406 vdev_nss->sta = QDF_MIN(max_supp_nss, CFG_STA_NSS(vdev_type_nss));
14407 vdev_nss->sap = QDF_MIN(max_supp_nss, CFG_SAP_NSS(vdev_type_nss));
14408 vdev_nss->p2p_go = QDF_MIN(max_supp_nss,
14409 CFG_P2P_GO_NSS(vdev_type_nss));
14410 vdev_nss->p2p_cli = QDF_MIN(max_supp_nss,
14411 CFG_P2P_CLI_NSS(vdev_type_nss));
14412 vdev_nss->p2p_dev = QDF_MIN(max_supp_nss,
14413 CFG_P2P_DEV_NSS(vdev_type_nss));
14414 vdev_nss->ibss = QDF_MIN(max_supp_nss, CFG_IBSS_NSS(vdev_type_nss));
14415 vdev_nss->tdls = QDF_MIN(max_supp_nss, CFG_TDLS_NSS(vdev_type_nss));
14416 vdev_nss->ocb = QDF_MIN(max_supp_nss, CFG_OCB_NSS(vdev_type_nss));
14417
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014418 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 -070014419 band, vdev_nss->sta, vdev_nss->sap, vdev_nss->p2p_cli,
14420 vdev_nss->p2p_go, vdev_nss->p2p_dev, vdev_nss->ibss,
14421 vdev_nss->tdls, vdev_nss->ocb);
14422}
Peng Xu8fdaa492016-06-22 10:20:47 -070014423
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -070014424#ifdef WLAN_FEATURE_11AX_BSS_COLOR
14425#define MAX_BSS_COLOR_VAL 63
14426#define MIN_BSS_COLOR_VAL 1
14427
14428QDF_STATUS sme_set_he_bss_color(tHalHandle hal, uint8_t session_id,
14429 uint8_t bss_color)
14430
14431{
14432 struct sir_set_he_bss_color *bss_color_msg;
14433 uint8_t len;
14434
14435 if (!hal) {
14436 sme_err("Invalid hal pointer");
14437 return QDF_STATUS_E_FAULT;
14438 }
14439
14440 sme_debug("Set HE bss_color %d", bss_color);
14441
14442 if (bss_color < MIN_BSS_COLOR_VAL || bss_color > MAX_BSS_COLOR_VAL) {
14443 sme_debug("Invalid HE bss_color %d", bss_color);
14444 return QDF_STATUS_E_INVAL;
14445 }
14446 len = sizeof(*bss_color_msg);
14447 bss_color_msg = qdf_mem_malloc(len);
14448 if (!bss_color_msg) {
14449 sme_err("mem alloc failed");
14450 return QDF_STATUS_E_NOMEM;
14451 }
14452 bss_color_msg->message_type = eWNI_SME_SET_HE_BSS_COLOR;
14453 bss_color_msg->length = len;
14454 bss_color_msg->session_id = session_id;
14455 bss_color_msg->bss_color = bss_color;
14456 return umac_send_mb_message_to_mac(bss_color_msg);
14457}
14458#endif
14459
Peng Xu8fdaa492016-06-22 10:20:47 -070014460/**
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014461 * sme_update_hw_dbs_capable() - sets the HW DBS capability
14462 * @hal: Pointer to HAL
14463 * @hw_dbs_capable: HW DBS capability
14464 *
14465 * Sets HW DBS capability based on INI and fw capability.
14466 *
14467 * Return: None
14468 */
14469void sme_update_hw_dbs_capable(tHalHandle hal, uint8_t hw_dbs_capable)
14470{
14471 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014472
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +053014473 mac_ctx->hw_dbs_capable = hw_dbs_capable;
14474}
14475
14476/**
Peng Xu8fdaa492016-06-22 10:20:47 -070014477 * sme_register_p2p_lo_event() - Register for the p2p lo event
14478 * @hHal: reference to the HAL
14479 * @context: the context of the call
14480 * @callback: the callback to hdd
14481 *
14482 * This function registers the callback function for P2P listen
14483 * offload stop event.
14484 *
14485 * Return: none
14486 */
14487void sme_register_p2p_lo_event(tHalHandle hHal, void *context,
14488 p2p_lo_callback callback)
14489{
14490 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
14491 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14492
14493 status = sme_acquire_global_lock(&pMac->sme);
14494 pMac->sme.p2p_lo_event_callback = callback;
14495 pMac->sme.p2p_lo_event_context = context;
14496 sme_release_global_lock(&pMac->sme);
14497}
Manjeet Singhf82ed072016-07-08 11:40:00 +053014498
14499/**
14500 * sme_process_mac_pwr_dbg_cmd() - enable mac pwr debugging
14501 * @hal: The handle returned by macOpen
14502 * @session_id: session id
14503 * @dbg_args: args for mac pwr debug command
14504 * Return: Return QDF_STATUS, otherwise appropriate failure code
14505 */
14506QDF_STATUS sme_process_mac_pwr_dbg_cmd(tHalHandle hal, uint32_t session_id,
14507 struct sir_mac_pwr_dbg_cmd*
14508 dbg_args)
14509{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014510 struct scheduler_msg message = {0};
Manjeet Singhf82ed072016-07-08 11:40:00 +053014511 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14512 struct sir_mac_pwr_dbg_cmd *req;
14513 int i;
14514
14515 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014516 sme_err("CSR session not valid: %d", session_id);
Manjeet Singhf82ed072016-07-08 11:40:00 +053014517 return QDF_STATUS_E_FAILURE;
14518 }
14519
14520 req = qdf_mem_malloc(sizeof(*req));
14521 if (NULL == req) {
14522 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14523 "%s: fail to alloc mac_pwr_dbg_args", __func__);
14524 return QDF_STATUS_E_FAILURE;
14525 }
14526 req->module_id = dbg_args->module_id;
14527 req->pdev_id = dbg_args->pdev_id;
14528 req->num_args = dbg_args->num_args;
14529 for (i = 0; i < req->num_args; i++)
14530 req->args[i] = dbg_args->args[i];
14531
14532 message.type = SIR_HAL_POWER_DBG_CMD;
14533 message.bodyptr = req;
14534
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014535 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg
Manjeet Singhf82ed072016-07-08 11:40:00 +053014536 (QDF_MODULE_ID_WMA, &message))) {
14537 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14538 "%s: Not able to post msg to WDA!",
14539 __func__);
14540 qdf_mem_free(req);
14541 }
14542 return QDF_STATUS_SUCCESS;
14543}
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014544/**
14545 * sme_get_vdev_type_nss() - gets the nss per vdev type
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014546 * @dev_mode: connection type.
14547 * @nss2g: Pointer to the 2G Nss parameter.
14548 * @nss5g: Pointer to the 5G Nss parameter.
14549 *
14550 * Fills the 2G and 5G Nss values based on connection type.
14551 *
14552 * Return: None
14553 */
Jeff Johnsonc1e62782017-11-09 09:50:17 -080014554void sme_get_vdev_type_nss(enum QDF_OPMODE dev_mode,
14555 uint8_t *nss_2g, uint8_t *nss_5g)
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014556{
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014557 tpAniSirGlobal mac_ctx = sme_get_mac_context();
14558
14559 if (NULL == mac_ctx) {
14560 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14561 FL("Invalid MAC context"));
14562 return;
14563 }
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -070014564 csr_get_vdev_type_nss(mac_ctx, dev_mode, nss_2g, nss_5g);
14565}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014566
14567/**
14568 * sme_update_sta_roam_policy() - update sta roam policy for
14569 * unsafe and DFS channels.
14570 * @hal_handle: hal handle for getting global mac struct
14571 * @dfs_mode: dfs mode which tell if dfs channel needs to be
14572 * skipped or not
14573 * @skip_unsafe_channels: Param to tell if driver needs to
14574 * skip unsafe channels or not.
14575 * @param session_id: sme_session_id
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014576 * @sap_operating_band: Band on which SAP is operating
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014577 *
14578 * sme_update_sta_roam_policy update sta rome policies to csr
14579 * this function will call csrUpdateChannelList as well
14580 * to include/exclude DFS channels and unsafe channels.
14581 *
14582 * Return: eHAL_STATUS_SUCCESS or non-zero on failure.
14583 */
14584QDF_STATUS sme_update_sta_roam_policy(tHalHandle hal_handle,
14585 enum sta_roam_policy_dfs_mode dfs_mode,
14586 bool skip_unsafe_channels,
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014587 uint8_t session_id, uint8_t sap_operating_band)
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014588{
14589 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14590 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014591 tSmeConfigParams *sme_config;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014592
14593 if (!mac_ctx) {
14594 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
14595 "%s: mac_ctx is null", __func__);
14596 return QDF_STATUS_E_FAILURE;
14597 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014598
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014599 sme_config = qdf_mem_malloc(sizeof(*sme_config));
14600 if (!sme_config) {
14601 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14602 FL("failed to allocate memory for sme_config"));
14603 return QDF_STATUS_E_FAILURE;
14604 }
14605 qdf_mem_zero(sme_config, sizeof(*sme_config));
14606 sme_get_config_param(hal_handle, sme_config);
14607
14608 sme_config->csrConfig.sta_roam_policy_params.dfs_mode =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014609 dfs_mode;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014610 sme_config->csrConfig.sta_roam_policy_params.skip_unsafe_channels =
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014611 skip_unsafe_channels;
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014612 sme_config->csrConfig.sta_roam_policy_params.sap_operating_band =
Agrawal, Ashish9f84c402016-11-30 16:19:44 +053014613 sap_operating_band;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014614
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014615 sme_update_config(hal_handle, sme_config);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014616
14617 status = csr_update_channel_list(mac_ctx);
14618 if (QDF_STATUS_SUCCESS != status) {
14619 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14620 FL("failed to update the supported channel list"));
14621 }
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014622
14623 if (mac_ctx->roam.configParam.isRoamOffloadScanEnabled) {
14624 status = sme_acquire_global_lock(&mac_ctx->sme);
14625 if (QDF_IS_STATUS_SUCCESS(status)) {
14626 csr_roam_offload_scan(mac_ctx, session_id,
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014627 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14628 REASON_ROAM_SCAN_STA_ROAM_POLICY_CHANGED);
Vignesh Viswanathan4e65e8e2018-05-01 12:04:16 +053014629 sme_release_global_lock(&mac_ctx->sme);
14630 } else {
14631 sme_err("Failed to acquire SME lock");
14632 }
14633 }
Sridhar Selvaraj48c47092017-07-31 18:18:14 +053014634 qdf_mem_free(sme_config);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014635 return status;
14636}
14637
14638/**
14639 * sme_enable_disable_chanavoidind_event - configure ca event ind
14640 * @hal: handler to hal
14641 * @set_value: enable/disable
14642 *
14643 * function to enable/disable chan avoidance indication
14644 *
14645 * Return: QDF_STATUS
14646 */
14647QDF_STATUS sme_enable_disable_chanavoidind_event(tHalHandle hal,
14648 uint8_t set_value)
14649{
14650 QDF_STATUS status;
14651 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014652 struct scheduler_msg msg = {0};
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014653
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014654 sme_debug("set_value: %d", set_value);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014655 status = sme_acquire_global_lock(&mac_ctx->sme);
14656 if (QDF_STATUS_SUCCESS == status) {
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014657 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014658 msg.type = WMA_SEND_FREQ_RANGE_CONTROL_IND;
14659 msg.bodyval = set_value;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014660 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Selvaraj, Sridharebda0f22016-08-29 16:05:23 +053014661 sme_release_global_lock(&mac_ctx->sme);
14662 return status;
14663 }
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014664 return status;
14665}
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014666
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014667/*
14668 * sme_set_default_scan_ie() - API to send default scan IE to LIM
14669 * @hal: reference to the HAL
14670 * @session_id: current session ID
14671 * @ie_data: Pointer to Scan IE data
14672 * @ie_len: Length of @ie_data
14673 *
14674 * Return: QDF_STATUS
14675 */
14676QDF_STATUS sme_set_default_scan_ie(tHalHandle hal, uint16_t session_id,
14677 uint8_t *ie_data, uint16_t ie_len)
14678{
14679 QDF_STATUS status;
14680 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14681 struct hdd_default_scan_ie *set_ie_params;
14682
Rajeev Kumar5d17dd52017-12-19 16:17:42 -080014683 if (!ie_data)
14684 return QDF_STATUS_E_INVAL;
14685
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014686 status = sme_acquire_global_lock(&mac_ctx->sme);
14687 if (QDF_IS_STATUS_SUCCESS(status)) {
14688 set_ie_params = qdf_mem_malloc(sizeof(*set_ie_params));
14689 if (!set_ie_params)
14690 status = QDF_STATUS_E_NOMEM;
14691 else {
14692 set_ie_params->message_type = eWNI_SME_DEFAULT_SCAN_IE;
14693 set_ie_params->length = sizeof(*set_ie_params);
14694 set_ie_params->session_id = session_id;
14695 set_ie_params->ie_len = ie_len;
14696 qdf_mem_copy(set_ie_params->ie_data, ie_data, ie_len);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014697 status = umac_send_mb_message_to_mac(set_ie_params);
Deepak Dhamdhereb106ae52016-08-10 20:55:30 +053014698 }
14699 sme_release_global_lock(&mac_ctx->sme);
14700 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053014701 return status;
14702}
Padma, Santhosh Kumard7cc0792016-06-28 18:54:12 +053014703
Jeff Johnsonf0e54b02017-12-18 15:22:25 -080014704QDF_STATUS sme_get_sar_power_limits(tHalHandle hal,
14705 wma_sar_cb callback, void *context)
14706{
14707 void *wma_handle;
14708
14709 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14710 if (!wma_handle) {
14711 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14712 "wma handle is NULL");
14713 return QDF_STATUS_E_FAILURE;
14714 }
14715
14716 return wma_get_sar_limit(wma_handle, callback, context);
14717}
14718
Kabilan Kannan3c0a7352016-12-02 18:49:38 -080014719QDF_STATUS sme_set_sar_power_limits(tHalHandle hal,
14720 struct sar_limit_cmd_params *sar_limit_cmd)
14721{
14722 void *wma_handle;
14723
14724 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14725 if (!wma_handle) {
14726 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14727 "wma handle is NULL");
14728 return QDF_STATUS_E_FAILURE;
14729 }
14730
14731 return wma_set_sar_limit(wma_handle, sar_limit_cmd);
14732}
14733
Jeff Johnson6136fb92017-03-30 15:21:49 -070014734#ifdef WLAN_FEATURE_FIPS
14735QDF_STATUS sme_fips_request(tHalHandle hal, struct fips_params *param,
14736 wma_fips_cb callback, void *context)
14737{
14738 void *wma_handle;
14739
14740 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14741 if (!wma_handle) {
14742 sme_err("wma handle is NULL");
14743 return QDF_STATUS_E_FAILURE;
14744 }
14745
14746 return wma_fips_request(wma_handle, param, callback, context);
14747}
14748#endif
14749
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014750QDF_STATUS sme_set_cts2self_for_p2p_go(tHalHandle hal_handle)
14751{
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014752 void *wma_handle;
14753
14754 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
14755 if (!wma_handle) {
14756 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14757 "wma_handle is NULL");
14758 return QDF_STATUS_E_FAILURE;
14759 }
Agrawal Ashishb2d1a452016-05-05 12:23:58 +053014760 if (QDF_STATUS_SUCCESS !=
14761 wma_set_cts2self_for_p2p_go(wma_handle, true)) {
14762 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14763 "%s: Failed to set cts2self for p2p GO to firmware",
14764 __func__);
14765 return QDF_STATUS_E_FAILURE;
14766 }
14767 return QDF_STATUS_SUCCESS;
14768}
Yingying Tang95409972016-10-20 15:16:15 +080014769
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014770/**
14771 * sme_update_tx_fail_cnt_threshold() - update tx fail count Threshold
14772 * @hal: Handle returned by mac_open
14773 * @session_id: Session ID on which tx fail count needs to be updated to FW
14774 * @tx_fail_count: Count for tx fail threshold after which FW will disconnect
14775 *
14776 * This function is used to set tx fail count threshold to firmware.
14777 * firmware will issue disocnnect with peer device once this threshold is
14778 * reached.
14779 *
14780 * Return: Return QDF_STATUS, otherwise appropriate failure code
14781 */
14782QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle,
14783 uint8_t session_id, uint32_t tx_fail_count)
14784{
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014785 QDF_STATUS status = QDF_STATUS_E_FAILURE;
14786 struct sme_tx_fail_cnt_threshold *tx_fail_cnt;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014787 struct scheduler_msg msg = {0};
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014788
14789 tx_fail_cnt = qdf_mem_malloc(sizeof(*tx_fail_cnt));
14790 if (NULL == tx_fail_cnt) {
14791 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14792 "%s: fail to alloc filter_param", __func__);
14793 return QDF_STATUS_E_FAILURE;
14794 }
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070014795 sme_debug("session_id: %d tx_fail_count: %d",
14796 session_id, tx_fail_count);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014797 tx_fail_cnt->session_id = session_id;
14798 tx_fail_cnt->tx_fail_cnt_threshold = tx_fail_count;
14799
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014800 qdf_mem_zero(&msg, sizeof(struct scheduler_msg));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014801 msg.type = SIR_HAL_UPDATE_TX_FAIL_CNT_TH;
14802 msg.reserved = 0;
14803 msg.bodyptr = tx_fail_cnt;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014804 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014805
14806 if (!QDF_IS_STATUS_SUCCESS(status)) {
14807 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014808 FL("Not able to post Tx fail count message to WDA"));
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014809 qdf_mem_free(tx_fail_cnt);
14810 }
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014811 return status;
14812}
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014813
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014814QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal,
14815 void (*cb)(void *, struct sir_lost_link_info *))
14816{
14817 QDF_STATUS status = QDF_STATUS_SUCCESS;
14818 tpAniSirGlobal mac = PMAC_STRUCT(hal);
14819
14820 status = sme_acquire_global_lock(&mac->sme);
14821 if (QDF_IS_STATUS_SUCCESS(status)) {
14822 mac->sme.lost_link_info_cb = cb;
14823 sme_release_global_lock(&mac->sme);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014824 } else {
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014825 sme_err("sme_acquire_global_lock error status: %d", status);
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +053014826 }
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014827
Agrawal, Ashish35b251d2016-09-08 19:21:03 +053014828 return status;
14829}
Yingying Tang95409972016-10-20 15:16:15 +080014830
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014831#ifdef FEATURE_WLAN_ESE
Jeff Johnson172237b2017-11-07 15:32:59 -080014832bool sme_roam_is_ese_assoc(struct csr_roam_info *roam_info)
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014833{
14834 return roam_info->isESEAssoc;
14835}
Manjeet Singh2f785062017-03-08 18:14:18 +053014836#endif
Manjeet Singha9cae432017-02-28 11:58:22 +053014837/**
Manjeet Singh2f785062017-03-08 18:14:18 +053014838 * sme_set_5g_band_pref(): If 5G preference is enabled,set boost/drop
Manjeet Singha9cae432017-02-28 11:58:22 +053014839 * params from ini.
14840 * @hal_handle: Handle returned by mac_open
14841 * @5g_pref_params: pref params from ini.
14842 *
14843 * Returns: None
14844 */
14845void sme_set_5g_band_pref(tHalHandle hal_handle,
14846 struct sme_5g_band_pref_params *pref_params)
14847{
14848
14849 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_handle);
14850 struct roam_ext_params *roam_params;
14851 QDF_STATUS status = QDF_STATUS_SUCCESS;
14852
14853 if (!pref_params) {
14854 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14855 "Invalid 5G pref params!");
14856 return;
14857 }
14858 status = sme_acquire_global_lock(&mac_ctx->sme);
14859 if (QDF_STATUS_SUCCESS == status) {
14860 roam_params = &mac_ctx->roam.configParam.roam_params;
14861 roam_params->raise_rssi_thresh_5g =
14862 pref_params->rssi_boost_threshold_5g;
14863 roam_params->raise_factor_5g =
14864 pref_params->rssi_boost_factor_5g;
14865 roam_params->max_raise_rssi_5g =
14866 pref_params->max_rssi_boost_5g;
14867 roam_params->drop_rssi_thresh_5g =
14868 pref_params->rssi_penalize_threshold_5g;
14869 roam_params->drop_factor_5g =
14870 pref_params->rssi_penalize_factor_5g;
14871 roam_params->max_drop_rssi_5g =
14872 pref_params->max_rssi_penalize_5g;
14873
14874 sme_release_global_lock(&mac_ctx->sme);
14875 } else
14876 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14877 "Unable to acquire global sme lock");
14878}
14879
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014880
14881bool sme_neighbor_roam_is11r_assoc(tHalHandle hal_ctx, uint8_t session_id)
14882{
14883 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
Yeshwanth Sriram Guntuka04b0bb22017-09-26 11:38:08 +053014884
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +053014885 return csr_neighbor_roam_is11r_assoc(mac_ctx, session_id);
14886}
Yingying Tang95409972016-10-20 15:16:15 +080014887
14888#ifdef WLAN_FEATURE_WOW_PULSE
14889/**
14890 * sme_set_wow_pulse() - set wow pulse info
14891 * @wow_pulse_set_info: wow_pulse_mode structure pointer
14892 *
14893 * Return: QDF_STATUS
14894 */
14895QDF_STATUS sme_set_wow_pulse(struct wow_pulse_mode *wow_pulse_set_info)
14896{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070014897 struct scheduler_msg message = {0};
Yingying Tang95409972016-10-20 15:16:15 +080014898 QDF_STATUS status;
14899 struct wow_pulse_mode *wow_pulse_set_cmd;
14900
14901 if (!wow_pulse_set_info) {
14902 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14903 "%s: invalid wow_pulse_set_info pointer", __func__);
14904 return QDF_STATUS_E_FAILURE;
14905 }
14906
14907 wow_pulse_set_cmd = qdf_mem_malloc(sizeof(*wow_pulse_set_cmd));
14908 if (NULL == wow_pulse_set_cmd) {
14909 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14910 "%s: fail to alloc wow_pulse_set_cmd", __func__);
14911 return QDF_STATUS_E_NOMEM;
14912 }
14913
14914 *wow_pulse_set_cmd = *wow_pulse_set_info;
14915
14916 message.type = WMA_SET_WOW_PULSE_CMD;
14917 message.bodyptr = wow_pulse_set_cmd;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080014918 status = scheduler_post_msg(QDF_MODULE_ID_WMA,
Yingying Tang95409972016-10-20 15:16:15 +080014919 &message);
14920 if (!QDF_IS_STATUS_SUCCESS(status)) {
14921 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14922 "%s: Not able to post msg to WDA!",
14923 __func__);
14924 qdf_mem_free(wow_pulse_set_cmd);
14925 status = QDF_STATUS_E_FAILURE;
14926 }
14927
14928 return status;
14929}
14930#endif
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014931
14932/**
14933 * sme_prepare_beacon_from_bss_descp() - prepares beacon frame by populating
14934 * different fields and IEs from bss descriptor.
14935 * @frame_buf: frame buffer to populate
14936 * @bss_descp: bss descriptor
14937 * @bssid: bssid of the beacon frame to populate
14938 * @ie_len: length of IE fields
14939 *
14940 * Return: None
14941 */
14942static void sme_prepare_beacon_from_bss_descp(uint8_t *frame_buf,
14943 tSirBssDescription *bss_descp,
14944 const tSirMacAddr bssid,
Naveen Rawat6dabf4e2017-02-08 15:55:49 -080014945 uint32_t ie_len)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080014946{
14947 tDot11fBeacon1 *bcn_fixed;
14948 tpSirMacMgmtHdr mac_hdr = (tpSirMacMgmtHdr)frame_buf;
14949
14950 /* populate mac header first to indicate beacon */
14951 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
14952 mac_hdr->fc.type = SIR_MAC_MGMT_FRAME;
14953 mac_hdr->fc.subType = SIR_MAC_MGMT_BEACON;
14954 qdf_mem_copy((uint8_t *) mac_hdr->da,
14955 (uint8_t *) "\xFF\xFF\xFF\xFF\xFF\xFF",
14956 sizeof(struct qdf_mac_addr));
14957 qdf_mem_copy((uint8_t *) mac_hdr->sa, bssid,
14958 sizeof(struct qdf_mac_addr));
14959 qdf_mem_copy((uint8_t *) mac_hdr->bssId, bssid,
14960 sizeof(struct qdf_mac_addr));
14961
14962 /* now populate fixed params */
14963 bcn_fixed = (tDot11fBeacon1 *)(frame_buf + SIR_MAC_HDR_LEN_3A);
14964 /* populate timestamp */
14965 qdf_mem_copy(&bcn_fixed->TimeStamp.timestamp, &bss_descp->timeStamp,
14966 sizeof(bss_descp->timeStamp));
14967 /* populate beacon interval */
14968 bcn_fixed->BeaconInterval.interval = bss_descp->beaconInterval;
14969 /* populate capability */
14970 qdf_mem_copy(&bcn_fixed->Capabilities, &bss_descp->capabilityInfo,
14971 sizeof(bss_descp->capabilityInfo));
14972
14973 /* copy IEs now */
14974 qdf_mem_copy(frame_buf + SIR_MAC_HDR_LEN_3A
14975 + SIR_MAC_B_PR_SSID_OFFSET,
14976 &bss_descp->ieFields, ie_len);
14977}
14978
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014979QDF_STATUS sme_get_rssi_snr_by_bssid(tHalHandle hal,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014980 struct csr_roam_profile *profile,
Hanumanth Reddy Pothula90051782017-05-04 22:14:43 +053014981 const uint8_t *bssid,
14982 int8_t *rssi, int8_t *snr)
14983{
14984 tSirBssDescription *bss_descp;
14985 tCsrScanResultFilter *scan_filter;
14986 struct scan_result_list *bss_list;
14987 tScanResultHandle result_handle = NULL;
14988 QDF_STATUS status = QDF_STATUS_SUCCESS;
14989 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
14990
14991 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
14992 if (NULL == scan_filter) {
14993 sme_err("memory allocation failed");
14994 status = QDF_STATUS_E_NOMEM;
14995 goto free_scan_flter;
14996 }
14997
14998 status = csr_roam_prepare_filter_from_profile(mac_ctx,
14999 profile, scan_filter);
15000 if (QDF_STATUS_SUCCESS != status) {
15001 sme_err("prepare_filter failed");
15002 goto free_scan_flter;
15003 }
15004
15005 /* update filter to get scan result with just target BSSID */
15006 if (NULL == scan_filter->BSSIDs.bssid) {
15007 scan_filter->BSSIDs.bssid =
15008 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15009 if (scan_filter->BSSIDs.bssid == NULL) {
15010 sme_err("malloc failed");
15011 status = QDF_STATUS_E_NOMEM;
15012 goto free_scan_flter;
15013 }
15014 }
15015
15016 scan_filter->BSSIDs.numOfBSSIDs = 1;
15017 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15018 bssid, sizeof(struct qdf_mac_addr));
15019
15020 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15021 if (QDF_STATUS_SUCCESS != status) {
15022 sme_err("parse_scan_result failed");
15023 goto free_scan_flter;
15024 }
15025
15026 bss_list = (struct scan_result_list *)result_handle;
15027 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
15028 if (!bss_descp) {
15029 sme_err("unable to fetch bss descriptor");
15030 status = QDF_STATUS_E_FAULT;
15031 goto free_scan_flter;
15032 }
15033
15034 sme_debug("snr: %d, rssi: %d, raw_rssi: %d",
15035 bss_descp->sinr, bss_descp->rssi, bss_descp->rssi_raw);
15036
15037 if (rssi)
15038 *rssi = bss_descp->rssi;
15039 if (snr)
15040 *snr = bss_descp->sinr;
15041
15042free_scan_flter:
15043 /* free scan filter and exit */
15044 if (scan_filter) {
15045 csr_free_scan_filter(mac_ctx, scan_filter);
15046 qdf_mem_free(scan_filter);
15047 }
15048
15049 if (result_handle)
15050 csr_scan_result_purge(mac_ctx, result_handle);
15051
15052 return status;
15053}
15054
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015055QDF_STATUS sme_get_beacon_frm(tHalHandle hal, struct csr_roam_profile *profile,
15056 const tSirMacAddr bssid,
15057 uint8_t **frame_buf, uint32_t *frame_len,
15058 int *channel)
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015059{
15060 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat56b4de82017-02-17 14:38:49 -080015061 tScanResultHandle result_handle = NULL;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015062 tCsrScanResultFilter *scan_filter;
15063 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15064 tSirBssDescription *bss_descp;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015065 struct scan_result_list *bss_list;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015066 uint32_t ie_len;
15067
15068 scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
15069 if (NULL == scan_filter) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015070 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015071 status = QDF_STATUS_E_NOMEM;
15072 goto free_scan_flter;
15073 }
15074 status = csr_roam_prepare_filter_from_profile(mac_ctx,
15075 profile, scan_filter);
15076 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015077 sme_err("prepare_filter failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015078 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015079 goto free_scan_flter;
15080 }
15081
15082 /* update filter to get scan result with just target BSSID */
15083 if (NULL == scan_filter->BSSIDs.bssid) {
15084 scan_filter->BSSIDs.bssid =
15085 qdf_mem_malloc(sizeof(struct qdf_mac_addr));
15086 if (scan_filter->BSSIDs.bssid == NULL) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015087 sme_err("malloc failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015088 status = QDF_STATUS_E_NOMEM;
15089 goto free_scan_flter;
15090 }
15091 }
15092 scan_filter->BSSIDs.numOfBSSIDs = 1;
15093 qdf_mem_copy(scan_filter->BSSIDs.bssid[0].bytes,
15094 bssid, sizeof(struct qdf_mac_addr));
15095
15096 status = csr_scan_get_result(mac_ctx, scan_filter, &result_handle);
15097 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015098 sme_err("parse_scan_result failed");
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015099 status = QDF_STATUS_E_FAULT;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015100 goto free_scan_flter;
15101 }
15102
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053015103 bss_list = (struct scan_result_list *)result_handle;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015104 bss_descp = csr_get_fst_bssdescr_ptr(bss_list);
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015105 if (!bss_descp) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015106 sme_err("unable to fetch bss descriptor");
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015107 status = QDF_STATUS_E_FAULT;
15108 goto free_scan_flter;
15109 }
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015110
Naveen Rawat81f058c2017-06-02 16:02:39 -070015111 /**
15112 * Length of BSS descriptor is without length of
15113 * length itself and length of pointer that holds ieFields.
15114 *
15115 * tSirBssDescription
15116 * +--------+---------------------------------+---------------+
15117 * | length | other fields | pointer to IEs|
15118 * +--------+---------------------------------+---------------+
15119 * ^
15120 * ieFields
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015121 */
Naveen Rawat81f058c2017-06-02 16:02:39 -070015122 ie_len = bss_descp->length + sizeof(bss_descp->length)
15123 - (uint16_t)(offsetof(tSirBssDescription, ieFields[0]));
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015124 sme_debug("found bss_descriptor ie_len: %d channel %d",
15125 ie_len, bss_descp->channelId);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015126
15127 /* include mac header and fixed params along with IEs in frame */
15128 *frame_len = SIR_MAC_HDR_LEN_3A + SIR_MAC_B_PR_SSID_OFFSET + ie_len;
15129 *frame_buf = qdf_mem_malloc(*frame_len);
15130 if (NULL == *frame_buf) {
Srinivas Girigowda2da81e22017-03-16 21:22:19 -070015131 sme_err("memory allocation failed");
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015132 status = QDF_STATUS_E_NOMEM;
15133 goto free_scan_flter;
15134 }
15135
15136 sme_prepare_beacon_from_bss_descp(*frame_buf, bss_descp, bssid, ie_len);
15137
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015138 if (!*channel)
15139 *channel = bss_descp->channelId;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015140free_scan_flter:
15141 /* free scan filter and exit */
15142 if (scan_filter) {
15143 csr_free_scan_filter(mac_ctx, scan_filter);
15144 qdf_mem_free(scan_filter);
15145 }
Arif Hussainfdb25e22017-02-05 17:38:16 -080015146 if (result_handle)
15147 csr_scan_result_purge(mac_ctx, result_handle);
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015148
Naveen Rawatae0aaa82017-02-17 14:41:19 -080015149 return status;
Naveen Rawat664a7cb2017-01-19 17:58:14 -080015150}
15151
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015152#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015153QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile,
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015154 const tSirMacAddr bssid, int channel,
Krunal Soni332f4af2017-06-01 14:36:17 -070015155 uint8_t vdev_id, const tSirMacAddr connected_bssid)
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015156{
15157 QDF_STATUS status;
15158 struct wma_roam_invoke_cmd *fastreassoc;
15159 struct scheduler_msg msg = {0};
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015160 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015161
15162 fastreassoc = qdf_mem_malloc(sizeof(*fastreassoc));
15163 if (NULL == fastreassoc) {
15164 sme_err("qdf_mem_malloc failed for fastreassoc");
15165 return QDF_STATUS_E_NOMEM;
15166 }
Krunal Soni332f4af2017-06-01 14:36:17 -070015167 /* if both are same then set the flag */
15168 if (!qdf_mem_cmp(connected_bssid, bssid, ETH_ALEN)) {
15169 fastreassoc->is_same_bssid = true;
15170 sme_debug("bssid same, bssid[%pM]", bssid);
15171 }
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015172 fastreassoc->vdev_id = vdev_id;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015173 fastreassoc->bssid[0] = bssid[0];
15174 fastreassoc->bssid[1] = bssid[1];
15175 fastreassoc->bssid[2] = bssid[2];
15176 fastreassoc->bssid[3] = bssid[3];
15177 fastreassoc->bssid[4] = bssid[4];
15178 fastreassoc->bssid[5] = bssid[5];
15179
15180 status = sme_get_beacon_frm(hal, profile, bssid,
15181 &fastreassoc->frame_buf,
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015182 &fastreassoc->frame_len,
15183 &channel);
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015184
Selvaraj, Sridhar64b0a9c2017-05-11 16:50:15 +053015185 if (!channel) {
15186 sme_err("channel retrieval from BSS desc fails!");
15187 qdf_mem_free(fastreassoc);
15188 return QDF_STATUS_E_FAULT;
15189 }
15190
15191 fastreassoc->channel = channel;
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015192 if (QDF_STATUS_SUCCESS != status) {
15193 sme_warn("sme_get_beacon_frm failed");
15194 fastreassoc->frame_buf = NULL;
15195 fastreassoc->frame_len = 0;
15196 }
15197
Padma, Santhosh Kumar5bc0c242017-11-29 15:44:27 +053015198 if (csr_is_auth_type_ese(mac_ctx->roam.roamSession[vdev_id].
15199 connectedProfile.AuthType)) {
15200 sme_debug("Beacon is not required for ESE");
15201 if (fastreassoc->frame_len) {
15202 qdf_mem_free(fastreassoc->frame_buf);
15203 fastreassoc->frame_buf = NULL;
15204 fastreassoc->frame_len = 0;
15205 }
15206 }
15207
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015208 msg.type = SIR_HAL_ROAM_INVOKE;
15209 msg.reserved = 0;
15210 msg.bodyptr = fastreassoc;
15211 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15212 if (QDF_STATUS_SUCCESS != status) {
15213 sme_err("Not able to post ROAM_INVOKE_CMD message to WMA");
15214 qdf_mem_free(fastreassoc);
15215 }
15216
15217 return status;
15218}
Paul Zhangc3fc0a82018-01-09 16:38:20 +080015219#endif
Naveen Rawat4195c5e2017-05-22 17:07:45 -070015220
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015221QDF_STATUS sme_set_del_pmkid_cache(tHalHandle hal, uint8_t session_id,
15222 tPmkidCacheInfo *pmk_cache_info,
15223 bool is_add)
15224{
15225 struct wmi_unified_pmk_cache *pmk_cache;
15226 struct scheduler_msg msg;
15227
15228 pmk_cache = qdf_mem_malloc(sizeof(*pmk_cache));
15229 if (!pmk_cache) {
15230 sme_err("Memory allocation failure");
15231 return QDF_STATUS_E_NOMEM;
15232 }
15233
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015234 qdf_mem_set(pmk_cache, sizeof(*pmk_cache), 0);
15235
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015236 pmk_cache->session_id = session_id;
15237
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015238 if (!pmk_cache_info)
15239 goto send_flush_cmd;
15240
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015241 if (!pmk_cache_info->ssid_len) {
15242 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_BSSID;
15243 WMI_CHAR_ARRAY_TO_MAC_ADDR(pmk_cache_info->BSSID.bytes,
15244 &pmk_cache->bssid);
15245 } else {
15246 pmk_cache->cat_flag = WMI_PMK_CACHE_CAT_FLAG_SSID_CACHE_ID;
15247 pmk_cache->ssid.length = pmk_cache_info->ssid_len;
15248 qdf_mem_copy(pmk_cache->ssid.mac_ssid,
15249 pmk_cache_info->ssid,
15250 pmk_cache->ssid.length);
15251 }
15252 pmk_cache->cache_id = (uint32_t) (pmk_cache_info->cache_id[0] << 8 |
15253 pmk_cache_info->cache_id[1]);
15254
15255 if (is_add)
15256 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_ADD_ENTRY;
15257 else
15258 pmk_cache->action_flag = WMI_PMK_CACHE_ACTION_FLAG_DEL_ENTRY;
15259
15260 pmk_cache->pmkid_len = CSR_RSN_PMKID_SIZE;
15261 qdf_mem_copy(pmk_cache->pmkid, pmk_cache_info->PMKID,
15262 CSR_RSN_PMKID_SIZE);
15263
15264 pmk_cache->pmk_len = pmk_cache_info->pmk_len;
15265 qdf_mem_copy(pmk_cache->pmk, pmk_cache_info->pmk,
15266 pmk_cache->pmk_len);
15267
Vignesh Viswanathane8a26b22017-10-11 20:38:47 +053015268send_flush_cmd:
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053015269 msg.type = SIR_HAL_SET_DEL_PMKID_CACHE;
15270 msg.reserved = 0;
15271 msg.bodyptr = pmk_cache;
15272 if (QDF_STATUS_SUCCESS !=
15273 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15274 sme_err("Not able to post message to WDA");
15275 qdf_mem_free(pmk_cache);
15276 return QDF_STATUS_E_FAILURE;
15277 }
15278
15279 return QDF_STATUS_SUCCESS;
15280}
15281
Anurag Chouhan3920c0f2017-09-11 17:10:56 +053015282/* ARP DEBUG STATS */
15283
15284/**
15285 * sme_set_nud_debug_stats() - sme api to set nud debug stats
15286 * @hal: handle to hal
15287 * @set_stats_param: pointer to set stats param
15288 *
15289 * Return: Return QDF_STATUS.
15290 */
15291QDF_STATUS sme_set_nud_debug_stats(tHalHandle hal,
15292 struct set_arp_stats_params
15293 *set_stats_param)
15294{
15295 struct set_arp_stats_params *arp_set_param;
15296 struct scheduler_msg msg;
15297
15298 arp_set_param = qdf_mem_malloc(sizeof(*arp_set_param));
15299 if (arp_set_param == NULL) {
15300 sme_err("Memory allocation failure");
15301 return QDF_STATUS_E_NOMEM;
15302 }
15303
15304 qdf_mem_copy(arp_set_param, set_stats_param, sizeof(*arp_set_param));
15305
15306 msg.type = WMA_SET_ARP_STATS_REQ;
15307 msg.reserved = 0;
15308 msg.bodyptr = arp_set_param;
15309
15310 if (QDF_STATUS_SUCCESS !=
15311 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15312 sme_err("Not able to post message to WDA");
15313 qdf_mem_free(arp_set_param);
15314 return QDF_STATUS_E_FAILURE;
15315 }
15316
15317 return QDF_STATUS_SUCCESS;
15318}
15319
15320/**
15321 * sme_get_nud_debug_stats() - sme api to get nud debug stats
15322 * @hal: handle to hal
15323 * @get_stats_param: pointer to set stats param
15324 *
15325 * Return: Return QDF_STATUS.
15326 */
15327QDF_STATUS sme_get_nud_debug_stats(tHalHandle hal,
15328 struct get_arp_stats_params
15329 *get_stats_param)
15330{
15331 struct get_arp_stats_params *arp_get_param;
15332 struct scheduler_msg msg;
15333
15334 arp_get_param = qdf_mem_malloc(sizeof(*arp_get_param));
15335 if (arp_get_param == NULL) {
15336 sme_err("Memory allocation failure");
15337 return QDF_STATUS_E_NOMEM;
15338 }
15339
15340 qdf_mem_copy(arp_get_param, get_stats_param, sizeof(*arp_get_param));
15341
15342 msg.type = WMA_GET_ARP_STATS_REQ;
15343 msg.reserved = 0;
15344 msg.bodyptr = arp_get_param;
15345
15346 if (QDF_STATUS_SUCCESS !=
15347 scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
15348 sme_err("Not able to post message to WDA");
15349 qdf_mem_free(arp_get_param);
15350 return QDF_STATUS_E_FAILURE;
15351 }
15352
15353 return QDF_STATUS_SUCCESS;
15354}
15355
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015356QDF_STATUS sme_set_peer_param(uint8_t *peer_addr, uint32_t param_id,
15357 uint32_t param_value, uint32_t vdev_id)
15358{
15359 void *wma_handle;
15360
15361 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15362 if (!wma_handle) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015363 sme_err("wma handle is NULL");
Krishna Kumaar Natarajanf1581df2017-02-21 13:42:08 -080015364 return QDF_STATUS_E_FAILURE;
15365 }
15366
15367 return wma_set_peer_param(wma_handle, peer_addr, param_id,
15368 param_value, vdev_id);
15369}
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015370
15371QDF_STATUS sme_register_set_connection_info_cb(tHalHandle hHal,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015372 bool (*set_connection_info_cb)(bool),
15373 bool (*get_connection_info_cb)(uint8_t *session_id,
15374 enum scan_reject_states *reason))
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015375{
15376 QDF_STATUS status = QDF_STATUS_SUCCESS;
15377 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
15378
15379 status = sme_acquire_global_lock(&pMac->sme);
15380 if (QDF_IS_STATUS_SUCCESS(status)) {
15381 pMac->sme.set_connection_info_cb = set_connection_info_cb;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015382 pMac->sme.get_connection_info_cb = get_connection_info_cb;
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080015383 sme_release_global_lock(&pMac->sme);
15384 }
15385 return status;
15386}
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015387
15388QDF_STATUS sme_rso_cmd_status_cb(tHalHandle hal,
15389 void (*cb)(void *, struct rso_cmd_status *))
15390{
15391 QDF_STATUS status = QDF_STATUS_SUCCESS;
15392 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15393
15394 mac->sme.rso_cmd_status_cb = cb;
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015395 sme_debug("Registered RSO command status callback");
Sreelakshmi Konamki88a2a412017-04-14 15:11:55 +053015396 return status;
15397}
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015398
Nitesh Shahf9a09ff2017-05-22 15:46:25 +053015399QDF_STATUS sme_set_dbs_scan_selection_config(tHalHandle hal,
15400 struct wmi_dbs_scan_sel_params *params)
15401{
15402 struct scheduler_msg message = {0};
15403 QDF_STATUS status;
15404 struct wmi_dbs_scan_sel_params *dbs_scan_params;
15405 uint32_t i;
15406
15407 if (0 == params->num_clients) {
15408 sme_err("Num of clients is 0");
15409 return QDF_STATUS_E_FAILURE;
15410 }
15411
15412 dbs_scan_params = qdf_mem_malloc(sizeof(*dbs_scan_params));
15413 if (!dbs_scan_params) {
15414 sme_err("fail to alloc dbs_scan_params");
15415 return QDF_STATUS_E_NOMEM;
15416 }
15417
15418 dbs_scan_params->num_clients = params->num_clients;
15419 dbs_scan_params->pdev_id = params->pdev_id;
15420 for (i = 0; i < params->num_clients; i++) {
15421 dbs_scan_params->module_id[i] = params->module_id[i];
15422 dbs_scan_params->num_dbs_scans[i] = params->num_dbs_scans[i];
15423 dbs_scan_params->num_non_dbs_scans[i] =
15424 params->num_non_dbs_scans[i];
15425 }
15426 message.type = WMA_SET_DBS_SCAN_SEL_CONF_PARAMS;
15427 message.bodyptr = dbs_scan_params;
15428 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
15429 if (!QDF_IS_STATUS_SUCCESS(status)) {
15430 sme_err("Not able to post msg to WMA!");
15431 qdf_mem_free(dbs_scan_params);
15432 }
15433
15434 return status;
15435}
15436
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015437QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi)
15438{
15439 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15440 tpAniSirGlobal pMac = PMAC_STRUCT(hal);
Naveen Rawatb7be1ed2017-11-16 16:52:08 -080015441 struct scheduler_msg msg = {0};
Rajeev Kumar Sirasanagandla996e5292016-11-22 21:20:33 +053015442 struct sme_rcpi_req *rcpi_req;
15443
15444 rcpi_req = qdf_mem_malloc(sizeof(*rcpi_req));
15445 if (rcpi_req == NULL) {
15446 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15447 "%s: Not able to allocate memory for rcpi req",
15448 __func__);
15449 return QDF_STATUS_E_NOMEM;
15450 }
15451 qdf_mem_copy(rcpi_req, rcpi, sizeof(*rcpi_req));
15452
15453 status = sme_acquire_global_lock(&pMac->sme);
15454 if (QDF_IS_STATUS_SUCCESS(status)) {
15455 msg.bodyptr = rcpi_req;
15456 msg.type = WMA_GET_RCPI_REQ;
15457 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
15458 sme_release_global_lock(&pMac->sme);
15459 if (!QDF_IS_STATUS_SUCCESS(status)) {
15460 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15461 FL("post get rcpi req failed"));
15462 status = QDF_STATUS_E_FAILURE;
15463 qdf_mem_free(rcpi_req);
15464 }
15465 } else {
15466 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15467 FL("sme_acquire_global_lock failed"));
15468 qdf_mem_free(rcpi_req);
15469 }
15470
15471 return status;
15472}
15473
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015474void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev)
15475{
15476 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15477 void *wma_handle;
15478 QDF_STATUS status;
15479
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015480 status = wlan_objmgr_pdev_try_get_ref(pdev, WLAN_LEGACY_MAC_ID);
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015481 if (QDF_STATUS_SUCCESS != status) {
15482 mac_ctx->pdev = NULL;
15483 return;
15484 }
15485 mac_ctx->pdev = pdev;
15486 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15487 if (!wma_handle) {
15488 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Kiran Kumar Lokeref089a3a2017-04-20 21:39:26 -070015489 FL("wma handle is NULL"));
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015490 return;
15491 }
15492 wma_store_pdev(wma_handle, pdev);
15493}
15494
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015495QDF_STATUS sme_congestion_register_callback(tHalHandle hal,
15496 void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id))
15497{
15498 QDF_STATUS status;
15499 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15500
15501 status = sme_acquire_global_lock(&mac->sme);
15502 if (QDF_IS_STATUS_SUCCESS(status)) {
15503 mac->sme.congestion_cb = congestion_cb;
15504 sme_release_global_lock(&mac->sme);
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015505 sme_debug("congestion callback set");
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015506 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070015507 sme_err("Aquiring lock failed %d", status);
Padma, Santhosh Kumar16dacfb2017-03-21 19:05:40 +053015508 }
15509
15510 return status;
15511}
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015512
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -080015513QDF_STATUS sme_register_tx_queue_cb(tHalHandle hal,
15514 void (*tx_queue_cb)(void *,
15515 uint32_t vdev_id,
15516 enum netif_action_type action,
15517 enum netif_reason_type reason))
15518{
15519 QDF_STATUS status;
15520 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15521
15522 status = sme_acquire_global_lock(&mac->sme);
15523 if (QDF_IS_STATUS_SUCCESS(status)) {
15524 mac->sme.tx_queue_cb = tx_queue_cb;
15525 sme_release_global_lock(&mac->sme);
15526 sme_debug("Tx queue callback set");
15527 } else {
15528 sme_err("Aquiring lock failed %d", status);
15529 }
15530
15531 return status;
15532}
15533
15534QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal)
15535{
15536 return sme_register_tx_queue_cb(hal, NULL);
15537}
15538
Varun Reddy Yeturud33033f2018-06-11 10:58:30 -070015539#ifdef WLAN_SUPPORT_TWT
Varun Reddy Yeturu3c9f89c2018-04-18 19:10:34 -070015540QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal,
15541 void (*twt_enable_cb)(void *hdd_ctx,
15542 struct wmi_twt_enable_complete_event_param *params))
15543{
15544 QDF_STATUS status;
15545 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15546
15547 status = sme_acquire_global_lock(&mac->sme);
15548 if (QDF_IS_STATUS_SUCCESS(status)) {
15549 mac->sme.twt_enable_cb = twt_enable_cb;
15550 sme_release_global_lock(&mac->sme);
15551 sme_debug("TWT: enable callback set");
15552 } else {
15553 sme_err("Aquiring lock failed %d", status);
15554 }
15555
15556 return status;
15557}
15558
15559QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal,
15560 void (*twt_disable_cb)(void *hdd_ctx))
15561{
15562 QDF_STATUS status;
15563 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15564
15565 status = sme_acquire_global_lock(&mac->sme);
15566 if (QDF_IS_STATUS_SUCCESS(status)) {
15567 mac->sme.twt_disable_cb = twt_disable_cb;
15568 sme_release_global_lock(&mac->sme);
15569 sme_debug("TWT: disable callback set");
15570 } else {
15571 sme_err("Aquiring lock failed %d", status);
15572 }
15573
15574 return status;
15575}
15576
15577QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal)
15578{
15579 return sme_register_twt_enable_complete_cb(hal, NULL);
15580}
15581
15582QDF_STATUS sme_deregister_twt_disable_complete_cb(tHalHandle hal)
15583{
15584 return sme_register_twt_disable_complete_cb(hal, NULL);
15585}
15586#endif
15587
Ashish Kumar Dhanotiyab28338c2017-07-21 20:12:34 +053015588QDF_STATUS sme_set_smps_cfg(uint32_t vdev_id, uint32_t param_id,
15589 uint32_t param_val)
15590{
15591 return wma_configure_smps_params(vdev_id, param_id, param_val);
15592}
15593
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015594QDF_STATUS sme_ipa_uc_stat_request(tHalHandle hal, uint32_t vdev_id,
15595 uint32_t param_id, uint32_t param_val, uint32_t req_cat)
15596{
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015597 wma_cli_set_cmd_t *iwcmd;
15598 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015599
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015600 iwcmd = qdf_mem_malloc(sizeof(*iwcmd));
15601 if (!iwcmd) {
15602 sme_err("Failed alloc memory for iwcmd");
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015603 return QDF_STATUS_E_NOMEM;
15604 }
Sandeep Puligillae64099d2017-05-11 16:38:27 -070015605
15606 qdf_mem_zero(iwcmd, sizeof(*iwcmd));
15607 iwcmd->param_sec_value = 0;
15608 iwcmd->param_vdev_id = vdev_id;
15609 iwcmd->param_id = param_id;
15610 iwcmd->param_vp_dev = req_cat;
15611 iwcmd->param_value = param_val;
15612 wma_ipa_uc_stat_request(iwcmd);
15613 qdf_mem_free(iwcmd);
Sandeep Puligillaf587adf2017-04-27 19:53:21 -070015614
15615 return status;
15616}
lifeng66831662017-05-19 16:01:35 +080015617
15618QDF_STATUS sme_set_reorder_timeout(tHalHandle hal,
15619 struct sir_set_rx_reorder_timeout_val *req)
15620{
15621 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015622 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015623
Zhang Qian1e7649e2018-06-04 13:07:18 +080015624 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15625 status = wma_set_rx_reorder_timeout_val(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015626
15627 return status;
15628}
15629
15630QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
15631 struct sir_peer_set_rx_blocksize *req)
15632{
15633 QDF_STATUS status;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015634 tp_wma_handle wma_handle;
lifeng66831662017-05-19 16:01:35 +080015635
Zhang Qian1e7649e2018-06-04 13:07:18 +080015636 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15637 status = wma_set_rx_blocksize(wma_handle, req);
lifeng66831662017-05-19 16:01:35 +080015638
15639 return status;
15640}
Naveen Rawat247a8682017-06-05 15:00:31 -070015641
15642int sme_cli_set_command(int vdev_id, int param_id, int sval, int vpdev)
15643{
15644 return wma_cli_set_command(vdev_id, param_id, sval, vpdev);
15645}
Vidyullatha Kanchanapallybe0ebb32017-03-23 14:36:21 +053015646
15647QDF_STATUS sme_set_bt_activity_info_cb(tHalHandle hal,
15648 void (*cb)(void *, uint32_t bt_activity))
15649{
15650 QDF_STATUS status;
15651 tpAniSirGlobal mac = PMAC_STRUCT(hal);
15652
15653 status = sme_acquire_global_lock(&mac->sme);
15654 if (QDF_IS_STATUS_SUCCESS(status)) {
15655 mac->sme.bt_activity_info_cb = cb;
15656 sme_release_global_lock(&mac->sme);
15657 sme_debug("bt activity info callback set");
15658 } else {
15659 sme_debug("sme_acquire_global_lock failed %d", status);
15660 }
15661
15662 return status;
15663}
lifengd217d192017-05-09 19:44:16 +080015664
15665QDF_STATUS sme_get_chain_rssi(tHalHandle hal,
15666 struct get_chain_rssi_req_params *input,
15667 get_chain_rssi_callback callback,
15668 void *context)
15669{
15670 QDF_STATUS status = QDF_STATUS_SUCCESS;
15671 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
Zhang Qian1e7649e2018-06-04 13:07:18 +080015672 tp_wma_handle wma_handle;
lifengd217d192017-05-09 19:44:16 +080015673
15674 SME_ENTER();
15675
15676 if (NULL == input) {
15677 sme_err("Invalid req params");
15678 return QDF_STATUS_E_INVAL;
15679 }
15680
15681 mac_ctx->sme.get_chain_rssi_cb = callback;
15682 mac_ctx->sme.get_chain_rssi_context = context;
Zhang Qian1e7649e2018-06-04 13:07:18 +080015683 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15684 wma_get_chain_rssi(wma_handle, input);
lifengd217d192017-05-09 19:44:16 +080015685
15686 SME_EXIT();
15687 return status;
15688}
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015689
Sandeep Puligilla1426d612017-04-12 18:22:06 -070015690QDF_STATUS sme_process_msg_callback(tHalHandle hal,
15691 struct scheduler_msg *msg)
15692{
15693 QDF_STATUS status = QDF_STATUS_E_FAILURE;
15694
15695 if (msg == NULL) {
15696 sme_err("Empty message for SME Msg callback");
15697 return status;
15698 }
15699 status = sme_process_msg(hal, msg);
15700 return status;
15701}
15702
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053015703void sme_display_disconnect_stats(tHalHandle hal, uint8_t session_id)
15704{
15705 struct csr_roam_session *session;
15706 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15707
15708 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
15709 sme_err("%s Invalid session id: %d", __func__, session_id);
15710 return;
15711 }
15712
15713 session = CSR_GET_SESSION(mac_ctx, session_id);
15714 if (!session) {
15715 sme_err("%s Failed to get session for id: %d",
15716 __func__, session_id);
15717 return;
15718 }
15719
15720 sme_debug("Total No. of Disconnections: %d",
15721 session->disconnect_stats.disconnection_cnt);
15722
15723 sme_debug("No. of Diconnects Triggered by Application: %d",
15724 session->disconnect_stats.disconnection_by_app);
15725
15726 sme_debug("No. of Disassoc Sent by Peer: %d",
15727 session->disconnect_stats.disassoc_by_peer);
15728
15729 sme_debug("No. of Deauth Sent by Peer: %d",
15730 session->disconnect_stats.deauth_by_peer);
15731
15732 sme_debug("No. of Disconnections due to Beacon Miss: %d",
15733 session->disconnect_stats.bmiss);
15734
15735 sme_debug("No. of Disconnections due to Peer Kickout: %d",
15736 session->disconnect_stats.peer_kickout);
15737}
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015738
Nachiket Kukade8983cf62017-10-12 18:14:48 +053015739 /**
15740 * sme_set_vc_mode_config() - Set voltage corner config to FW
15741 * @bitmap: Bitmap that referes to voltage corner config with
15742 * different phymode and bw configuration
15743 *
15744 * Return: QDF_STATUS
15745 */
15746QDF_STATUS sme_set_vc_mode_config(uint32_t vc_bitmap)
15747{
15748 void *wma_handle;
15749
15750 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
15751 if (!wma_handle) {
15752 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15753 "wma_handle is NULL");
15754 return QDF_STATUS_E_FAILURE;
15755 }
15756 if (QDF_STATUS_SUCCESS !=
15757 wma_set_vc_mode_config(wma_handle, vc_bitmap)) {
15758 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15759 "%s: Failed to set Voltage Control config to FW",
15760 __func__);
15761 return QDF_STATUS_E_FAILURE;
15762 }
15763 return QDF_STATUS_SUCCESS;
15764}
15765
Nachiket Kukadeaaf8a712017-07-27 19:15:36 +053015766/**
15767 * sme_set_bmiss_bcnt() - set bmiss config parameters
15768 * @vdev_id: virtual device for the command
15769 * @first_cnt: bmiss first value
15770 * @final_cnt: bmiss final value
15771 *
15772 * Return: QDF_STATUS_SUCCESS or non-zero on failure
15773 */
15774QDF_STATUS sme_set_bmiss_bcnt(uint32_t vdev_id, uint32_t first_cnt,
15775 uint32_t final_cnt)
15776{
15777 return wma_config_bmiss_bcnt_params(vdev_id, first_cnt, final_cnt);
15778}
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +053015779
15780QDF_STATUS sme_send_limit_off_channel_params(tHalHandle hal, uint8_t vdev_id,
15781 bool is_tos_active, uint32_t max_off_chan_time,
15782 uint32_t rest_time, bool skip_dfs_chan)
15783{
15784 struct sir_limit_off_chan *cmd;
15785 struct scheduler_msg msg = {0};
15786
15787 cmd = qdf_mem_malloc(sizeof(*cmd));
15788 if (!cmd) {
15789 sme_err("qdf_mem_malloc failed for limit off channel");
15790 return QDF_STATUS_E_NOMEM;
15791 }
15792
15793 cmd->vdev_id = vdev_id;
15794 cmd->is_tos_active = is_tos_active;
15795 cmd->max_off_chan_time = max_off_chan_time;
15796 cmd->rest_time = rest_time;
15797 cmd->skip_dfs_chans = skip_dfs_chan;
15798
15799 msg.type = WMA_SET_LIMIT_OFF_CHAN;
15800 msg.reserved = 0;
15801 msg.bodyptr = cmd;
15802
15803 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
15804 &msg))) {
15805 sme_err("Not able to post WMA_SET_LIMIT_OFF_CHAN to WMA");
15806 qdf_mem_free(cmd);
15807 return QDF_STATUS_E_FAILURE;
15808 }
15809
15810 return QDF_STATUS_SUCCESS;
15811}
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015812
15813/**
15814 * sme_get_status_for_candidate() - Get bss transition status for candidate
15815 * @hal: Handle for HAL
15816 * @conn_bss_desc: connected bss descriptor
15817 * @bss_desc: candidate bss descriptor
15818 * @info: candiadate bss information
15819 * @trans_reason: transition reason code
15820 * @is_bt_in_progress: bt activity indicator
15821 *
15822 * Return : true if candidate is rejected and reject reason is filled
15823 * @info->status. Otherwise returns false.
15824 */
Jeff Johnson22256fe2018-06-04 20:25:53 -070015825static bool sme_get_status_for_candidate(tHalHandle hal,
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015826 tSirBssDescription *conn_bss_desc,
15827 tSirBssDescription *bss_desc,
15828 struct bss_candidate_info *info,
15829 uint8_t trans_reason,
15830 bool is_bt_in_progress)
15831{
15832 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15833
15834 /*
15835 * Low RSSI based rejection
15836 * If candidate rssi is less than mbo_candidate_rssi_thres and connected
15837 * bss rssi is greater than mbo_current_rssi_thres, then reject the
15838 * candidate with MBO reason code 4.
15839 */
15840 if ((bss_desc->rssi < mac_ctx->roam.configParam.mbo_thresholds.
15841 mbo_candidate_rssi_thres) &&
15842 (conn_bss_desc->rssi > mac_ctx->roam.configParam.mbo_thresholds.
15843 mbo_current_rssi_thres)) {
15844 sme_err("Candidate BSS "MAC_ADDRESS_STR" has LOW RSSI(%d), hence reject",
15845 MAC_ADDR_ARRAY(bss_desc->bssId), bss_desc->rssi);
15846 info->status = QCA_STATUS_REJECT_LOW_RSSI;
15847 return true;
15848 }
15849
15850 if (trans_reason == MBO_TRANSITION_REASON_LOAD_BALANCING ||
15851 trans_reason == MBO_TRANSITION_REASON_TRANSITIONING_TO_PREMIUM_AP) {
15852 /*
15853 * MCC rejection
15854 * If moving to candidate's channel will result in MCC scenario
15855 * and the rssi of connected bss is greater than
15856 * mbo_current_rssi_mss_thres, then reject the candidate with
15857 * MBO reason code 3.
15858 */
15859 if ((conn_bss_desc->rssi >
15860 mac_ctx->roam.configParam.mbo_thresholds.
15861 mbo_current_rssi_mcc_thres) &&
15862 csr_is_mcc_channel(hal, bss_desc->channelId)) {
15863 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes MCC, hence reject",
15864 MAC_ADDR_ARRAY(bss_desc->bssId));
15865 info->status =
15866 QCA_STATUS_REJECT_INSUFFICIENT_QOS_CAPACITY;
15867 return true;
15868 }
15869
15870 /*
15871 * BT coex rejection
15872 * If AP is trying to move the client from 5G to 2.4G and moving
15873 * to 2.4G will result in BT coex and candidate channel rssi is
15874 * less than mbo_candidate_rssi_btc_thres, then reject the
15875 * candidate with MBO reason code 2.
15876 */
15877 if (WLAN_REG_IS_5GHZ_CH(conn_bss_desc->channelId) &&
15878 WLAN_REG_IS_24GHZ_CH(bss_desc->channelId) &&
15879 is_bt_in_progress &&
15880 (bss_desc->rssi <
15881 mac_ctx->roam.configParam.mbo_thresholds.
15882 mbo_candidate_rssi_btc_thres)) {
15883 sme_err("Candidate BSS "MAC_ADDRESS_STR" causes BT coex, hence reject",
15884 MAC_ADDR_ARRAY(bss_desc->bssId));
15885 info->status =
15886 QCA_STATUS_REJECT_EXCESSIVE_DELAY_EXPECTED;
15887 return true;
15888 }
15889
15890 /*
15891 * LTE coex rejection
15892 * If moving to candidate's channel can cause LTE coex, then
15893 * reject the candidate with MBO reason code 5.
15894 */
15895 if (policy_mgr_is_safe_channel(mac_ctx->psoc,
15896 conn_bss_desc->channelId) &&
15897 !(policy_mgr_is_safe_channel(mac_ctx->psoc,
15898 bss_desc->channelId))) {
15899 sme_err("High interference expected if transitioned to BSS "
15900 MAC_ADDRESS_STR" hence reject",
15901 MAC_ADDR_ARRAY(bss_desc->bssId));
15902 info->status =
15903 QCA_STATUS_REJECT_HIGH_INTERFERENCE;
15904 return true;
15905 }
15906 }
15907
15908 return false;
15909}
15910
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015911uint32_t sme_unpack_rsn_ie(tHalHandle hal, uint8_t *buf,
15912 uint8_t buf_len, tDot11fIERSN *rsn_ie,
15913 bool append_ie)
15914{
15915 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
15916
Abhishek Singh3f13a812018-01-16 14:24:44 +053015917 return dot11f_unpack_ie_rsn(mac_ctx, buf, buf_len, rsn_ie, append_ie);
Abhishek Singh7dcb85b2017-12-27 15:15:01 +053015918}
15919
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +053015920/**
15921 * wlan_hdd_get_bss_transition_status() - get bss transition status all cadidates
15922 * @adapter : Pointer to adapter
15923 * @transition_reason : Transition reason
15924 * @info : bss candidate information
15925 * @n_candidates : number of candidates
15926 *
15927 * Return : 0 on success otherwise errno
15928 */
15929int sme_get_bss_transition_status(tHalHandle hal,
15930 uint8_t transition_reason,
15931 struct qdf_mac_addr *bssid,
15932 struct bss_candidate_info *info,
15933 uint16_t n_candidates,
15934 bool is_bt_in_progress)
15935{
15936 QDF_STATUS status = QDF_STATUS_SUCCESS;
15937 tSirBssDescription *bss_desc, *conn_bss_desc;
15938 tCsrScanResultInfo *res, *conn_res;
15939 uint16_t i;
15940
15941 if (!n_candidates || !info) {
15942 sme_err("No candidate info available");
15943 return QDF_STATUS_E_INVAL;
15944 }
15945
15946 conn_res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15947 if (!conn_res) {
15948 sme_err("Failed to allocate memory for conn_res");
15949 return QDF_STATUS_E_NOMEM;
15950 }
15951
15952 res = qdf_mem_malloc(sizeof(tCsrScanResultInfo));
15953 if (!res) {
15954 sme_err("Failed to allocate memory for conn_res");
15955 status = QDF_STATUS_E_NOMEM;
15956 goto free;
15957 }
15958
15959 /* Get the connected BSS descriptor */
15960 status = sme_scan_get_result_for_bssid(hal, bssid, conn_res);
15961 if (!QDF_IS_STATUS_SUCCESS(status)) {
15962 sme_err("Failed to find connected BSS in scan list");
15963 goto free;
15964 }
15965 conn_bss_desc = &conn_res->BssDescriptor;
15966
15967 for (i = 0; i < n_candidates; i++) {
15968 /* Get candidate BSS descriptors */
15969 status = sme_scan_get_result_for_bssid(hal, &info[i].bssid,
15970 res);
15971 if (!QDF_IS_STATUS_SUCCESS(status)) {
15972 sme_err("BSS "MAC_ADDRESS_STR" not present in scan list",
15973 MAC_ADDR_ARRAY(info[i].bssid.bytes));
15974 info[i].status = QCA_STATUS_REJECT_UNKNOWN;
15975 continue;
15976 }
15977
15978 bss_desc = &res->BssDescriptor;
15979 if (!sme_get_status_for_candidate(hal, conn_bss_desc, bss_desc,
15980 &info[i], transition_reason, is_bt_in_progress)) {
15981 /*
15982 * If status is not over written, it means it is a
15983 * candidate for accept.
15984 */
15985 info[i].status = QCA_STATUS_ACCEPT;
15986 }
15987 }
15988
15989 /* success */
15990 status = QDF_STATUS_SUCCESS;
15991
15992free:
15993 /* free allocated memory */
15994 if (conn_res)
15995 qdf_mem_free(conn_res);
15996 if (res)
15997 qdf_mem_free(res);
15998
15999 return status;
16000}
16001
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016002void sme_enable_roaming_on_connected_sta(tHalHandle hal)
16003{
16004 uint8_t session_id;
16005 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16006 QDF_STATUS status;
16007
16008 session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
16009 if (session_id != CSR_SESSION_ID_INVALID)
16010 return;
16011
16012 session_id = csr_get_connected_infra(mac_ctx);
16013 if (session_id == CSR_SESSION_ID_INVALID) {
16014 sme_debug("No STA in conencted state");
16015 return;
16016 }
16017
16018 sme_debug("Roaming not enabled on any STA, enable roaming on session %d",
16019 session_id);
16020 status = sme_acquire_global_lock(&mac_ctx->sme);
16021 if (QDF_IS_STATUS_SUCCESS(status)) {
16022 csr_roam_offload_scan(mac_ctx, session_id,
16023 ROAM_SCAN_OFFLOAD_START,
16024 REASON_CTX_INIT);
16025 sme_release_global_lock(&mac_ctx->sme);
16026 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016027}
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016028
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016029int16_t sme_get_oper_chan_freq(struct wlan_objmgr_vdev *vdev)
16030{
16031 uint8_t vdev_id, chan;
16032 struct csr_roam_session *session;
16033 tpAniSirGlobal mac_ctx;
16034 tHalHandle h_hal;
16035 int16_t freq = 0;
16036
16037 if (vdev == NULL) {
16038 sme_err("Invalid vdev id is passed");
16039 return 0;
16040 }
16041
16042 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016043 if (!h_hal) {
16044 sme_err("h_hal is null");
16045 return 0;
16046 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016047 mac_ctx = PMAC_STRUCT(h_hal);
16048 vdev_id = wlan_vdev_get_id(vdev);
16049 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16050 sme_err("Invalid vdev id is passed");
16051 return 0;
16052 }
16053
16054 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16055 chan = csr_get_infra_operation_channel(mac_ctx, vdev_id);
16056 if (chan)
16057 freq = cds_chan_to_freq(chan);
16058
16059 return freq;
16060}
16061
16062enum phy_ch_width sme_get_oper_ch_width(struct wlan_objmgr_vdev *vdev)
16063{
16064 uint8_t vdev_id;
16065 struct csr_roam_session *session;
16066 tpAniSirGlobal mac_ctx;
16067 tHalHandle h_hal;
16068 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
16069
16070 if (vdev == NULL) {
16071 sme_err("Invalid vdev id is passed");
16072 return CH_WIDTH_INVALID;
16073 }
16074
16075 h_hal = cds_get_context(QDF_MODULE_ID_SME);
Arif Hussaind15902c2018-03-02 00:08:29 -080016076 if (!h_hal) {
16077 sme_err("h_hal is null");
16078 return CH_WIDTH_INVALID;
16079 }
Sandeep Puligilla063a4342018-01-10 02:50:14 -080016080 mac_ctx = PMAC_STRUCT(h_hal);
16081 vdev_id = wlan_vdev_get_id(vdev);
16082 if (!CSR_IS_SESSION_VALID(mac_ctx, vdev_id)) {
16083 sme_err("Invalid vdev id is passed");
16084 return CH_WIDTH_INVALID;
16085 }
16086
16087 session = CSR_GET_SESSION(mac_ctx, vdev_id);
16088
16089 if (csr_is_conn_state_connected(mac_ctx, vdev_id))
16090 ch_width = session->connectedProfile.vht_channel_width;
16091
16092 return ch_width;
16093}
16094
16095int sme_get_sec20chan_freq_mhz(struct wlan_objmgr_vdev *vdev,
16096 uint16_t *sec20chan_freq)
16097{
16098 uint8_t vdev_id;
16099
16100 vdev_id = wlan_vdev_get_id(vdev);
16101 /* Need to extend */
16102 return 0;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053016103}
16104
Padma, Santhosh Kumardd3f4852018-01-16 18:51:51 +053016105#ifdef WLAN_FEATURE_SAE
16106QDF_STATUS sme_handle_sae_msg(tHalHandle hal, uint8_t session_id,
16107 uint8_t sae_status)
16108{
16109 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
16110 tpAniSirGlobal mac = PMAC_STRUCT(hal);
16111 struct sir_sae_msg *sae_msg;
16112 struct scheduler_msg sch_msg = {0};
16113
16114 qdf_status = sme_acquire_global_lock(&mac->sme);
16115 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
16116 sae_msg = qdf_mem_malloc(sizeof(*sae_msg));
16117 if (!sae_msg) {
16118 qdf_status = QDF_STATUS_E_NOMEM;
16119 sme_err("SAE: memory allocation failed");
16120 } else {
16121 sae_msg->message_type = eWNI_SME_SEND_SAE_MSG;
16122 sae_msg->length = sizeof(*sae_msg);
16123 sae_msg->session_id = session_id;
16124 sae_msg->sae_status = sae_status;
16125 sme_debug("SAE: sae_status %d session_id %d",
16126 sae_msg->sae_status,
16127 sae_msg->session_id);
16128
16129 sch_msg.type = eWNI_SME_SEND_SAE_MSG;
16130 sch_msg.bodyptr = sae_msg;
16131
16132 qdf_status =
16133 scheduler_post_msg(QDF_MODULE_ID_PE, &sch_msg);
16134 }
16135 sme_release_global_lock(&mac->sme);
16136 }
16137
16138 return qdf_status;
16139}
16140#endif
Vignesh Viswanathan0a569292018-02-14 15:34:47 +053016141
16142bool sme_is_sta_key_exchange_in_progress(tHalHandle hal, uint8_t session_id)
16143{
16144 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16145
16146 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
16147 sme_err("Invalid session id: %d", session_id);
16148 return false;
16149 }
16150
16151 return CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id);
16152}
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016153
16154bool sme_validate_channel_list(tHalHandle hal,
16155 uint8_t *chan_list,
16156 uint8_t num_channels)
16157{
16158 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16159 uint8_t i = 0;
16160 uint8_t j;
16161 bool found;
16162 struct csr_channel *ch_lst_info = &mac_ctx->scan.base_channels;
16163
16164 if (!chan_list || !num_channels) {
16165 sme_err("Chan list empty %pK or num_channels is 0", chan_list);
16166 return false;
16167 }
16168
16169 while (i < num_channels) {
16170 found = false;
16171 for (j = 0; j < ch_lst_info->numChannels; j++) {
16172 if (ch_lst_info->channelList[j] == chan_list[i]) {
16173 found = true;
16174 break;
16175 }
16176 }
16177
16178 if (!found) {
16179 sme_debug("Invalid channel %d", chan_list[i]);
16180 return false;
16181 }
16182
16183 i++;
16184 }
Arif Hussain0e246802018-05-01 18:13:44 -070016185
Vignesh Viswanathana2f5ce582018-05-09 20:38:39 +053016186 return true;
16187}
Arif Hussain0e246802018-05-01 18:13:44 -070016188
16189void sme_set_amsdu(tHalHandle hal, bool enable)
16190{
16191 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal);
16192 mac_ctx->is_usr_cfg_amsdu_enabled = enable;
16193}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070016194
16195uint8_t sme_get_mcs_idx(uint16_t max_rate, uint8_t rate_flags,
16196 uint8_t nss, uint8_t *mcs_rate_flags)
16197{
16198 return wma_get_mcs_idx(max_rate, rate_flags, nss, mcs_rate_flags);
16199}