blob: d1b1937ff75f4154ebd5efac1f97677d41c56ef3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * 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/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "sap_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053055#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070056#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/*
59 * This overhead is time for sending NOA start to host in case of GO/sending
60 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
61 * with init scan req/rsp plus in case of concurrency, taking care of sending
62 * null data and receiving ACK to/from AP/Also SetChannel with calibration
63 * is taking around 7ms .
64 */
65#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
66#define JOIN_NOA_DURATION 2000 /* in msecs */
67#define OEM_DATA_NOA_DURATION 60 /* in msecs */
68#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
69
70#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
71
Paul Zhangd2315472017-02-22 10:02:50 +080072#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
73#define STA_BURST_SCAN_DURATION 120 /* in msecs */
74
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* SME REQ processing function templates */
76static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080077static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
78 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
80static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
81static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
82static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080085static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
86 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053087static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
88 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
90 uint32_t *pMsg);
91static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
92static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
93static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
94static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95
96static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
97 uint8_t **pDstData_buff,
98 uint16_t *pDstDataLen,
99 uint8_t *pSrcData_buff,
100 uint16_t srcDataLen);
101
102static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800106static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Abhishek Singh518323d2015-10-19 17:42:01 +0530114static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
115 uint32_t *msg);
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
118 * lim_process_set_hw_mode() - Send set HW mode command to WMA
119 * @mac: Globacl MAC pointer
120 * @msg: Message containing the hw mode index
121 *
122 * Send the set HW mode command to WMA
123 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530124 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530126static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700129 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800130 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 uint32_t len;
132 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700133 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 struct sir_set_hw_mode_resp *param;
135
136 buf = (struct s_sir_set_hw_mode *) msg;
137 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700138 pe_err("Set HW mode param is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530139 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 /* To free the active command list */
141 goto fail;
142 }
143
144 len = sizeof(*req_msg);
145
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530146 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530147 if (!req_msg) {
148 pe_debug("failed to allocate memory");
149 status = QDF_STATUS_E_NOMEM;
150 goto fail;
151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530154 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Other parameters are not needed for WMA */
156
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800157 message.bodyptr = req_msg;
158 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700160 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530161 status = scheduler_post_message(QDF_MODULE_ID_PE,
162 QDF_MODULE_ID_WMA,
163 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530164 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700165 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 goto fail;
169 }
170 return status;
171fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530172 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700173 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 param->status = SET_HW_MODE_STATUS_ECANCELED;
176 param->cfgd_hw_mode_index = 0;
177 param->num_vdev_mac_entries = 0;
178 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
179 resp_msg.bodyptr = param;
180 resp_msg.bodyval = 0;
181 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530182 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183}
184
185/**
186 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
187 * @mac: Global MAC pointer
188 * @msg: Message containing the dual mac config parameter
189 *
190 * Send the set dual mac config command to WMA
191 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195 uint32_t *msg)
196{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530197 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700198 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800199 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 uint32_t len;
201 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 struct sir_dual_mac_config_resp *param;
204
205 buf = (struct sir_set_dual_mac_cfg *) msg;
206 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700207 pe_err("Set Dual mac config is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530208 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /* To free the active command list */
210 goto fail;
211 }
212
213 len = sizeof(*req_msg);
214
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530215 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530216 if (!req_msg) {
217 pe_debug("failed to allocate memory");
218 status = QDF_STATUS_E_NOMEM;
219 goto fail;
220 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 req_msg->scan_config = buf->set_dual_mac.scan_config;
223 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
224 /* Other parameters are not needed for WMA */
225
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800226 message.bodyptr = req_msg;
227 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700229 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530231 status = scheduler_post_message(QDF_MODULE_ID_PE,
232 QDF_MODULE_ID_WMA,
233 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700235 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530237 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 goto fail;
239 }
240 return status;
241fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530242 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700243 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 param->status = SET_HW_MODE_STATUS_ECANCELED;
246 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
247 resp_msg.bodyptr = param;
248 resp_msg.bodyval = 0;
249 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530250 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251}
252
253/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800254 * lim_process_set_antenna_mode_req() - Set antenna mode command
255 * to WMA
256 * @mac: Global MAC pointer
257 * @msg: Message containing the antenna mode parameter
258 *
259 * Send the set antenna mode command to WMA
260 *
261 * Return: QDF_STATUS_SUCCESS if message posting is successful
262 */
263static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
264 uint32_t *msg)
265{
266 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700267 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 struct sir_antenna_mode_param *req_msg;
269 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700270 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800271 struct sir_antenna_mode_resp *param;
272
273 buf = (struct sir_set_antenna_mode *) msg;
274 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700275 pe_err("Set antenna mode is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530276 status = QDF_STATUS_E_INVAL;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 /* To free the active command list */
278 goto fail;
279 }
280
281 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530282 if (!req_msg) {
283 pe_debug("failed to allocate memory");
284 status = QDF_STATUS_E_NOMEM;
285 goto fail;
286 }
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800287
288 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
289 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
290
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800291 message.bodyptr = req_msg;
292 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800293
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700294 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800295 req_msg->num_rx_chains,
296 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530297 status = scheduler_post_message(QDF_MODULE_ID_PE,
298 QDF_MODULE_ID_WMA,
299 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800300 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700301 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800302 status);
303 qdf_mem_free(req_msg);
304 goto fail;
305 }
306 return status;
307fail:
308 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700309 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
312 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
313 resp_msg.bodyptr = param;
314 resp_msg.bodyval = 0;
315 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530316 return status;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800317}
318
319/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 * __lim_is_sme_assoc_cnf_valid()
321 *
322 ***FUNCTION:
323 * This function is called by __lim_process_sme_assoc_cnf_new() upon
324 * receiving SME_ASSOC_CNF.
325 *
326 ***LOGIC:
327 * Message validity checks are performed in this function
328 *
329 ***ASSUMPTIONS:
330 *
331 ***NOTE:
332 *
333 * @param pMeasReq Pointer to Received ASSOC_CNF message
334 * @return true When received SME_ASSOC_CNF is formatted
335 * correctly
336 * false otherwise
337 */
338
339static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
340{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530341 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 return false;
343 else
344 return true;
345} /*** end __lim_is_sme_assoc_cnf_valid() ***/
346
347/**
348 * __lim_get_sme_join_req_size_for_alloc()
349 *
350 ***FUNCTION:
351 * This function is called in various places to get IE length
352 * from tSirBssDescription structure
353 * number being scanned.
354 *
355 ***PARAMS:
356 *
357 ***LOGIC:
358 *
359 ***ASSUMPTIONS:
360 * NA
361 *
362 ***NOTE:
363 * NA
364 *
365 * @param pBssDescr
366 * @return Total IE length
367 */
368
369static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
370{
371 uint16_t len = 0;
372
373 if (!pBuf)
374 return len;
375
376 pBuf += sizeof(uint16_t);
377 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700378 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379}
380
381/**
382 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
383 * @pMac: Global MAC context
384 * @pMsg: Pointer to message posted from SME to LIM.
385 *
386 * Has role only if 11h is enabled. Not used on STA side.
387 * Defers the message if SME is in learn state and brings
388 * the LIM back to normal mode.
389 *
390 * Return: true - If defered false - Otherwise
391 */
392
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800393static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
394 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395{
396 if (lim_is_system_in_scan_state(pMac)) {
397 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700398 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 return false;
400 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 pMsg->type);
403 return true;
404 }
405 return false;
406}
407
408/**
409 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
410 * @mac_ctx: Pointer to Global MAC structure
411 * @message: Pointer to message posted from SME to LIM.
412 *
413 * Has role only if 11h is enabled. Not used on STA side.
414 * Defers the message if radar is detected.
415 *
416 * Return: true, if defered otherwise return false.
417 */
418static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800419__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
420 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421{
422 /*
423 * fRadarDetCurOperChan will be set only if we
424 * detect radar in current operating channel and
425 * System Role == AP ROLE
426 *
427 * TODO: Need to take care radar detection.
428 *
429 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
430 */
431 if (0) {
432 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700433 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 return false;
435 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 message->type);
438 return true;
439 }
440 return false;
441}
442
443/**
444 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
445 * @pMac: Global MAC context
446 * @pMsgBuf: Message from WMA
447 *
448 * handles the notification from HDD. PE just forwards this message to HAL.
449 *
450 * Return: true-Posting to HAL failed, so PE will consume the buffer.
451 * false-Posting to HAL successful, so HAL will consume the buffer.
452 */
453
454static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
455{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700456 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
458
459 msg.type = WMA_SYS_READY_IND;
460 msg.reserved = 0;
461 msg.bodyptr = pMsgBuf;
462 msg.bodyval = 0;
463
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700464 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800465 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530466 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700467 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700468 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530469 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700471
472 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
474
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700475 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700476 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 return true;
478 }
479 return false;
480}
481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482/**
483 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
484 *@mac_ctx: Pointer to Global MAC structure
485 *@session: A pointer to session entry
486 *@sme_start_bss_req: Start BSS Request from upper layers.
487 *
488 * This function is used to configure the start bss parameters
489 * in to the session.
490 *
491 * Return: None.
492 */
493static void
494lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
495 tpSirSmeStartBssReq sme_start_bss_req)
496{
497 session->limSystemRole = eLIM_AP_ROLE;
498 session->privacy = sme_start_bss_req->privacy;
499 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
500 session->authType = sme_start_bss_req->authType;
501 /* Store the DTIM period */
502 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
503 /* Enable/disable UAPSD */
504 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530505 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 session->proxyProbeRspEn = 0;
507 } else {
508 /*
509 * To detect PBC overlap in SAP WPS mode,
510 * Host handles Probe Requests.
511 */
512 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
513 session->proxyProbeRspEn = 1;
514 else
515 session->proxyProbeRspEn = 0;
516 }
517 session->ssidHidden = sme_start_bss_req->ssidHidden;
518 session->wps_state = sme_start_bss_req->wps_state;
519 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530520 session->vendor_vht_sap =
521 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
523 &session->shortSlotTimeSupported);
524 session->isCoalesingInIBSSAllowed =
525 sme_start_bss_req->isCoalesingInIBSSAllowed;
526
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800527 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529}
530
531/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530532 * lim_send_start_vdev_req() - send vdev start request
533 *@session: pe session
534 *@mlm_start_req: vdev start req
535 *
536 * Return: QDF_STATUS
537 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530538#ifdef CONFIG_VDEV_SM
539static QDF_STATUS
540lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
541{
542 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
543 WLAN_VDEV_SM_EV_START,
544 sizeof(*mlm_start_req),
545 mlm_start_req);
546}
547#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530548static QDF_STATUS
549lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
550{
551 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
552
553 return QDF_STATUS_SUCCESS;
554}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530555#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530556
557/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
559 *@mac_ctx: Pointer to Global MAC structure
560 *@msg_buf: A pointer to the SME message buffer
561 *
562 * This function is called to process SME_START_BSS_REQ message
563 * from HDD or upper layer application.
564 *
565 * Return: None
566 */
567static void
568__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
569{
570 uint16_t size;
571 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700572 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 tSirMacChanNum channel_number;
574 tLimMlmStartReq *mlm_start_req = NULL;
575 tpSirSmeStartBssReq sme_start_bss_req = NULL;
576 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
577 /* Flag Used in case of IBSS to Auto generate BSSID. */
578 uint32_t auto_gen_bssid = false;
579 uint8_t session_id;
580 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800581 uint8_t sme_session_id = 0xFF;
582 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700584 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530585 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586
587/* FEATURE_WLAN_DIAG_SUPPORT */
588#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
589 /*
590 * Since the session is not created yet, sending NULL.
591 * The response should have the correct state.
592 */
593 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
594 NULL, 0, 0);
595#endif /* FEATURE_WLAN_DIAG_SUPPORT */
596
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700597 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800598 size = sizeof(tSirSmeStartBssReq);
599 sme_start_bss_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700600 if (!sme_start_bss_req) {
Krunal Sonib37bb352016-12-20 14:12:21 -0800601 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
602 goto free;
603 }
604 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
605 sme_session_id = sme_start_bss_req->sessionId;
606 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
609 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
611 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700612 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 ret_code = eSIR_SME_INVALID_PARAMETERS;
614 goto free;
615 }
616
617 /*
618 * This is the place where PE is going to create a session.
619 * If session is not existed, then create a new session
620 */
621 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800622 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700624 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
626 session = NULL;
627 goto free;
628 } else {
629 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800630 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530632 sme_start_bss_req->bssType,
633 sme_start_bss_req->sessionId);
634 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700635 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
637 goto free;
638 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530639
640 /* Update the beacon/probe filter in mac_ctx */
641 lim_set_bcn_probe_filter(mac_ctx, session,
642 &sme_start_bss_req->ssId,
643 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 }
645
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700646 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
647 /* Probe resp add ie */
648 lim_start_bss_update_add_ie_buffer(mac_ctx,
649 &session->addIeParams.probeRespData_buff,
650 &session->addIeParams.probeRespDataLen,
651 sme_start_bss_req->addIeParams.
652 probeRespData_buff,
653 sme_start_bss_req->addIeParams.
654 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700656 /* Probe Beacon add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespBCNData_buff,
659 &session->addIeParams.probeRespBCNDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Assoc resp IE */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.assocRespData_buff,
668 &session->addIeParams.assocRespDataLen,
669 sme_start_bss_req->addIeParams.
670 assocRespData_buff,
671 sme_start_bss_req->addIeParams.
672 assocRespDataLen);
673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 /* Store the session related params in newly created session */
675 session->pLimStartBssReq = sme_start_bss_req;
676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 session->transactionId = sme_start_bss_req->transactionId;
678
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 &(sme_start_bss_req->htConfig),
681 sizeof(session->htConfig));
682
Sandeep Puligilla98917432016-06-10 13:50:28 -0700683 qdf_mem_copy(&(session->vht_config),
684 &(sme_start_bss_req->vht_config),
685 sizeof(session->vht_config));
686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800688 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689
690 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 (uint8_t *) &sme_start_bss_req->ssId,
693 (sme_start_bss_req->ssId.length + 1));
694
695 session->bssType = sme_start_bss_req->bssType;
696
697 session->nwType = sme_start_bss_req->nwType;
698
699 session->beaconParams.beaconInterval =
700 sme_start_bss_req->beaconInterval;
701
702 /* Store the channel number in session Table */
703 session->currentOperChannel =
704 sme_start_bss_req->channelId;
705
706 /* Store Persona */
707 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530708 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 FL("PE PERSONA=%d"), session->pePersona);
710
711 /* Update the phymode */
712 session->gLimPhyMode = sme_start_bss_req->nwType;
713
714 session->maxTxPower =
715 cfg_get_regulatory_max_transmit_power(mac_ctx,
716 session->currentOperChannel);
717 /* Store the dot 11 mode in to the session Table */
718 session->dot11mode = sme_start_bss_req->dot11mode;
719#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
720 session->cc_switch_mode =
721 sme_start_bss_req->cc_switch_mode;
722#endif
723 session->htCapability =
724 IS_DOT11_MODE_HT(session->dot11mode);
725 session->vhtCapability =
726 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800727
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700728 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800729 session->htCapability, session->vhtCapability);
730
731 if (IS_DOT11_MODE_HE(session->dot11mode)) {
732 lim_update_session_he_capable(mac_ctx, session);
733 lim_copy_bss_he_cap(session, sme_start_bss_req);
734 }
735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 session->txLdpcIniFeatureEnabled =
737 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738#ifdef WLAN_FEATURE_11W
739 session->limRmfEnabled =
740 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700741 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742#endif
743
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530744 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 (void *)&sme_start_bss_req->operationalRateSet,
746 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (void *)&sme_start_bss_req->extendedRateSet,
749 sizeof(tSirMacRateSet));
750
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700751 if (IS_5G_CH(session->currentOperChannel))
752 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
753 else
754 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 switch (sme_start_bss_req->bssType) {
757 case eSIR_INFRA_AP_MODE:
758 lim_configure_ap_start_bss_session(mac_ctx, session,
759 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700760 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700761 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700762 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700763 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 break;
765 case eSIR_IBSS_MODE:
766 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
767 lim_get_short_slot_from_phy_mode(mac_ctx, session,
768 session->gLimPhyMode,
769 &session->shortSlotTimeSupported);
770
771 /*
772 * initialize to "OPEN".
773 * will be updated upon key installation
774 */
775 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700776 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
778 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700779 case eSIR_NDI_MODE:
780 session->limSystemRole = eLIM_NDI_ROLE;
781 break;
782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 /*
785 * There is one more mode called auto mode.
786 * which is used no where
787 */
788
789 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
790
791 default:
792 /* not used anywhere...used in scan function */
793 break;
794 }
795
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700796 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700797 session->pePersona, session->vdev_nss);
798 session->nss = session->vdev_nss;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530799 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700800 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700802 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 * parsed (Re)Assoc request structure
804 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700805 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700808 size * sizeof(tpSirAssocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700809 if (!session->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
811 goto free;
812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700815 if (!sme_start_bss_req->channelId &&
816 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700817 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 ret_code = eSIR_SME_INVALID_PARAMETERS;
819 goto free;
820 }
821 channel_number = sme_start_bss_req->channelId;
822#ifdef QCA_HT_2040_COEX
823 if (sme_start_bss_req->obssEnabled)
824 session->htSupportedChannelWidthSet =
825 session->htCapability;
826 else
827#endif
828 session->htSupportedChannelWidthSet =
829 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
830 session->htSecondaryChannelOffset =
831 sme_start_bss_req->sec_ch_offset;
832 session->htRecommendedTxWidthSet =
833 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530834 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800836 if (lim_is_session_he_capable(session) ||
837 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700839 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800840 sme_start_bss_req->vht_channel_width,
841 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->ch_width = chanwidth;
843 if (session->htSupportedChannelWidthSet) {
844 session->ch_center_freq_seg0 =
845 sme_start_bss_req->center_freq_seg0;
846 session->ch_center_freq_seg1 =
847 sme_start_bss_req->center_freq_seg1;
848 } else {
849 session->ch_center_freq_seg0 = 0;
850 session->ch_center_freq_seg1 = 0;
851 }
852 }
Gaurank Kathpalia511634b2018-10-23 03:41:16 -0700853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800855 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700860 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Delete pre-auth list if any */
863 lim_delete_pre_auth_list(mac_ctx);
864
865 /*
866 * keep the RSN/WPA IE information in PE Session Entry
867 * later will be using this to check when received (Re)Assoc req
868 */
869 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
870 &sme_start_bss_req->rsnIE, session);
871
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700872 if (LIM_IS_AP_ROLE(session) ||
873 LIM_IS_IBSS_ROLE(session) ||
874 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 session->gLimProtectionControl =
876 sme_start_bss_req->protEnabled;
877 /*
878 * each byte will have the following info
879 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
880 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
881 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530882 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 (void *)&sme_start_bss_req->ht_capab,
884 sizeof(uint16_t));
885 /* Initialize WPS PBC session link list */
886 session->pAPWPSPBCSession = NULL;
887 }
888 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700890 if (!mlm_start_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
892 goto free;
893 }
894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 (uint8_t *) &sme_start_bss_req->ssId,
898 sme_start_bss_req->ssId.length + 1);
899 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
900 mlm_start_req->obssProtEnabled =
901 sme_start_bss_req->obssProtEnabled;
902
903 mlm_start_req->bssType = session->bssType;
904
905 /* Fill PE session Id from the session Table */
906 mlm_start_req->sessionId = session->peSessionId;
907
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700908 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
909 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 /*
911 * Copy the BSSId from sessionTable to
912 * mlmStartReq struct
913 */
914 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
915 } else {
916 /* ibss mode */
917 mac_ctx->lim.gLimIbssCoalescingHappened = false;
918
919 ret_status = wlan_cfg_get_int(mac_ctx,
920 WNI_CFG_IBSS_AUTO_BSSID,
921 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700922 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700923 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530925 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 goto free;
927 }
928
929 if (!auto_gen_bssid) {
930 /*
931 * We're not auto generating BSSID.
932 * Instead, get it from session entry
933 */
934 sir_copy_mac_addr(mlm_start_req->bssId,
935 session->bssId);
936 /*
937 * Start IBSS group BSSID
938 * Auto Generating BSSID.
939 */
940 auto_gen_bssid = ((mlm_start_req->bssId[0] &
941 0x01) ? true : false);
942 }
943
944 if (auto_gen_bssid) {
945 /*
946 * if BSSID is not any uc id.
947 * then use locally generated BSSID.
948 * Autogenerate the BSSID
949 */
950 lim_get_random_bssid(mac_ctx,
951 mlm_start_req->bssId);
952 mlm_start_req->bssId[0] = 0x02;
953
954 /*
955 * Copy randomly generated BSSID
956 * to the session Table
957 */
958 sir_copy_mac_addr(session->bssId,
959 mlm_start_req->bssId);
960 }
961 }
962 /* store the channel num in mlmstart req structure */
963 mlm_start_req->channelNumber = session->currentOperChannel;
964 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
965 mlm_start_req->beaconPeriod =
966 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700967 mlm_start_req->cac_duration_ms =
968 sme_start_bss_req->cac_duration_ms;
969 mlm_start_req->dfs_regdomain =
970 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (LIM_IS_AP_ROLE(session)) {
972 mlm_start_req->dtimPeriod = session->dtimPeriod;
973 mlm_start_req->wps_state = session->wps_state;
974
975 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530976 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 mlm_start_req->dtimPeriod = (uint8_t) val;
978 }
979
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530980 mlm_start_req->cfParamSet.cfpPeriod =
981 mac_ctx->mlme_cfg->rates.cfp_period;
982 mlm_start_req->cfParamSet.cfpMaxDuration =
983 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 /*
986 * this may not be needed anymore now,
987 * as rateSet is now included in the
988 * session entry and MLM has session context.
989 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 (void *)&session->rateSet,
992 sizeof(tSirMacRateSet));
993
994 /* Now populate the 11n related parameters */
995 mlm_start_req->nwType = session->nwType;
996 mlm_start_req->htCapable = session->htCapability;
997
998 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
999 /* Unused */
1000 mlm_start_req->dualCTSProtection =
1001 mac_ctx->lim.gHTDualCTSProtection;
1002 mlm_start_req->txChannelWidthSet =
1003 session->htRecommendedTxWidthSet;
1004
1005 session->limRFBand = lim_get_rf_band(channel_number);
1006
1007 /* Initialize 11h Enable Flag */
1008 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001009 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1010 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001011 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001013 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001014 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 else
1016 session->lim11hEnable = val;
1017
1018 if (session->lim11hEnable &&
1019 (eSIR_INFRA_AP_MODE ==
1020 mlm_start_req->bssType)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001021 session->lim11hEnable =
1022 mac_ctx->mlme_cfg->
1023 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 }
1026
1027 if (!session->lim11hEnable) {
1028 if (cfg_set_int(mac_ctx,
1029 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001030 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 /*
1032 * Failed to set the CFG param
1033 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1034 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 }
1037
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001038 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 session->limPrevSmeState = session->limSmeState;
1041 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1042 MTRACE(mac_trace
1043 (mac_ctx, TRACE_CODE_SME_STATE,
1044 session->peSessionId,
1045 session->limSmeState));
1046
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301047 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1048 if (QDF_IS_STATUS_ERROR(qdf_status))
1049 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301050 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 return;
1052 } else {
1053
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001054 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mac_ctx->lim.gLimSmeState);
1056 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001057 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1059
1060free:
1061 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001062 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 session->pLimStartBssReq = NULL;
1064 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001065 if (NULL != sme_start_bss_req)
1066 qdf_mem_free(sme_start_bss_req);
1067 if (NULL != mlm_start_req)
1068 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 if (NULL != session) {
1070 pe_delete_session(mac_ctx, session);
1071 session = NULL;
1072 }
1073 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1074 session, sme_session_id, sme_transaction_id);
1075}
1076
1077/**
1078 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1079 *
1080 * @pMac: Global MAC context
1081 * @pMsg: Message pointer
1082 *
1083 * Wrapper for the function __lim_handle_sme_start_bss_request
1084 * This message will be defered until softmac come out of
1085 * scan mode or if we have detected radar on the current
1086 * operating channel.
1087 *
1088 * return true - If we consumed the buffer
1089 * false - If have defered the message.
1090 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001091static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1092 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093{
1094 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1095 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1096 /**
1097 * If message defered, buffer is not consumed yet.
1098 * So return false
1099 */
1100 return false;
1101 }
1102
1103 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1104 return true;
1105}
1106
1107/**
1108 * lim_get_random_bssid()
1109 *
1110 * FUNCTION:This function is called to process generate the random number for bssid
1111 * This function is called to process SME_SCAN_REQ message
1112 * from HDD or upper layer application.
1113 *
1114 * LOGIC:
1115 *
1116 * ASSUMPTIONS:
1117 *
1118 * NOTE:
1119 * 1. geneartes the unique random number for bssid in ibss
1120 *
1121 * @param pMac Pointer to Global MAC structure
1122 * @param *data Pointer to bssid buffer
1123 * @return None
1124 */
1125void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1126{
1127 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 random[0] = tx_time_get();
1130 random[0] |= (random[0] << 15);
1131 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301132 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133}
1134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135/**
1136 * __lim_process_clear_dfs_channel_list()
1137 *
1138 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001139 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 .*This message is sent from SME.
1141 *
1142 ***LOGIC:
1143 *
1144 ***ASSUMPTIONS:
1145 *
1146 ***NOTE:
1147 *
1148 * @param pMac Pointer to Global MAC structure
1149 * @param *pMsgBuf A pointer to the SME message buffer
1150 * @return None
1151 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001152static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1153 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156}
1157
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301158#ifdef WLAN_FEATURE_SAE
1159
1160/**
1161 * lim_update_sae_config()- This API update SAE session info to csr config
1162 * from join request.
1163 * @session: PE session
1164 * @sme_join_req: pointer to join request
1165 *
1166 * Return: None
1167 */
1168static void lim_update_sae_config(tpPESession session,
1169 tpSirSmeJoinReq sme_join_req)
1170{
1171 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1172
1173 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1174 session->sae_pmk_cached,
1175 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1176}
1177#else
1178static inline void lim_update_sae_config(tpPESession session,
1179 tpSirSmeJoinReq sme_join_req)
1180{}
1181#endif
1182
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001183/**
Jianmin Zhu09236602018-10-15 15:36:10 +08001184 * lim_send_join_req() - send vdev start request for assoc
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001185 *@session: pe session
1186 *@mlm_join_req: join req
1187 *
1188 * Return: QDF_STATUS
1189 */
1190
1191#ifdef CONFIG_VDEV_SM
1192static QDF_STATUS lim_send_join_req(tpPESession session,
1193 tLimMlmJoinReq *mlm_join_req)
1194{
Abhishek Singh254d5512018-10-30 12:17:05 +05301195 QDF_STATUS status;
1196
1197 status = mlme_set_assoc_type(session->vdev, VDEV_ASSOC);
1198 if (QDF_IS_STATUS_ERROR(status))
1199 return status;
1200
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001201 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1202 WLAN_VDEV_SM_EV_START,
1203 sizeof(*mlm_join_req),
1204 mlm_join_req);
1205}
1206#else
1207static QDF_STATUS lim_send_join_req(tpPESession session,
1208 tLimMlmJoinReq *mlm_join_req)
1209{
1210 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1211
1212 return QDF_STATUS_SUCCESS;
1213}
1214#endif
1215
Jianmin Zhu09236602018-10-15 15:36:10 +08001216/**
1217 * lim_send_reassoc_req() - send vdev start request for reassoc
1218 *@session: pe session
1219 *@mlm_join_req: join req
1220 *
1221 * Return: QDF_STATUS
1222 */
1223
1224#ifdef CONFIG_VDEV_SM
1225static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1226 tLimMlmReassocReq *reassoc_req)
1227{
Abhishek Singh254d5512018-10-30 12:17:05 +05301228 QDF_STATUS status;
1229
1230 status = mlme_set_assoc_type(session->vdev, VDEV_REASSOC);
1231 if (QDF_IS_STATUS_ERROR(status))
1232 return status;
1233
Jianmin Zhu09236602018-10-15 15:36:10 +08001234 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1235 WLAN_VDEV_SM_EV_START,
1236 sizeof(*reassoc_req),
1237 reassoc_req);
1238}
1239#else
1240static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1241 tLimMlmReassocReq *reassoc_req)
1242{
1243 lim_process_mlm_reassoc_req(session->mac_ctx, reassoc_req);
1244
1245 return QDF_STATUS_SUCCESS;
1246}
1247#endif
1248
1249/**
1250 * lim_send_ft_reassoc_req() - send vdev start request for ft_reassoc
1251 *@session: pe session
1252 *@mlm_join_req: join req
1253 *
1254 * Return: QDF_STATUS
1255 */
1256
1257#ifdef CONFIG_VDEV_SM
Abhishek Singh254d5512018-10-30 12:17:05 +05301258static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session,
1259 tLimMlmReassocReq *reassoc_req)
Jianmin Zhu09236602018-10-15 15:36:10 +08001260{
Abhishek Singh254d5512018-10-30 12:17:05 +05301261 QDF_STATUS status;
1262
1263 status = mlme_set_assoc_type(session->vdev, VDEV_FT_REASSOC);
1264 if (QDF_IS_STATUS_ERROR(status))
1265 return status;
1266
Jianmin Zhu09236602018-10-15 15:36:10 +08001267 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1268 WLAN_VDEV_SM_EV_START,
Abhishek Singh254d5512018-10-30 12:17:05 +05301269 sizeof(*reassoc_req),
1270 reassoc_req);
Jianmin Zhu09236602018-10-15 15:36:10 +08001271}
1272#else
Abhishek Singh254d5512018-10-30 12:17:05 +05301273static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session,
1274 tLimMlmReassocReq *reassoc_req)
Jianmin Zhu09236602018-10-15 15:36:10 +08001275{
Abhishek Singh254d5512018-10-30 12:17:05 +05301276 lim_process_mlm_ft_reassoc_req(session->mac_ctx, reassoc_req);
Jianmin Zhu09236602018-10-15 15:36:10 +08001277
1278 return QDF_STATUS_SUCCESS;
1279}
1280#endif
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282/**
1283 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1284 * @mac_ctx: Pointer to Global MAC structure
1285 * @msg_buf: A pointer to the SME message buffer
1286 *
1287 * This function is called to process SME_JOIN_REQ message
1288 * from HDD or upper layer application.
1289 *
1290 * Return: None
1291 */
1292static void
1293__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1294{
1295 tpSirSmeJoinReq sme_join_req = NULL;
1296 tLimMlmJoinReq *mlm_join_req;
1297 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1298 uint32_t val = 0;
1299 uint16_t n_size;
1300 uint8_t session_id;
1301 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301302 uint8_t sme_session_id = 0;
1303 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001304 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001306 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001307 tSirBssDescription *bss_desc;
Abhishek Singh254d5512018-10-30 12:17:05 +05301308 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309
Arif Hussain995fcaf2016-07-18 11:28:22 -07001310 if (!mac_ctx || !msg_buf) {
1311 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1312 FL("JOIN REQ with invalid data"));
1313 return;
1314 }
1315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316/* FEATURE_WLAN_DIAG_SUPPORT */
1317#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1318 /*
1319 * Not sending any session, since it is not created yet.
1320 * The response whould have correct state.
1321 */
1322 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1323#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 /*
1326 * Expect Join request in idle state.
1327 * Reassociate request is expected in link established state.
1328 */
1329
1330 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1331 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1332 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1333 msg_buf);
1334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 sme_join_req = qdf_mem_malloc(n_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001336 if (!sme_join_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301338 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301340 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 n_size);
1342
1343 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1344 /* Received invalid eWNI_SME_JOIN_REQ */
1345 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001346 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 sme_join_req->sessionId);
1348 ret_code = eSIR_SME_INVALID_PARAMETERS;
1349 goto end;
1350 }
1351
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001352 /*
1353 * Update the capability here itself as this is used in
1354 * lim_extract_ap_capability() below. If not updated issues
1355 * like not honoring power constraint on 1st association after
1356 * driver loading might occur.
1357 */
1358 lim_update_rrm_capability(mac_ctx, sme_join_req);
1359
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001360 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001362 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 &session_id);
1364
1365 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001366 pe_err("Session(%d) Already exists for BSSID: "
1367 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001369 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 session->limSmeState);
1371
1372 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1373 session->smeSessionId == sme_join_req->sessionId) {
1374 /*
1375 * Received eWNI_SME_JOIN_REQ for same
1376 * BSS as currently associated.
1377 * Log the event and send success
1378 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001379 pe_warn("SessionId: %d", session_id);
1380 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 /* Send Join success response to host */
1382 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1383 session = NULL;
1384 goto end;
1385 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001386 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 ret_code = eSIR_SME_REFUSED;
1388 session = NULL;
1389 goto end;
1390 }
1391 } else {
1392 /*
1393 * Session Entry does not exist for given BSSId
1394 * Try to Create a new session
1395 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001396 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301398 eSIR_INFRASTRUCTURE_MODE,
1399 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001401 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1403 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301404 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001405 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301407 }
1408
1409 /* Update the beacon/probe filter in mac_ctx */
1410 lim_set_bcn_probe_filter(mac_ctx, session,
1411 &sme_join_req->ssId,
1412 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001414 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001415 session->enable_session_twt_support =
1416 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 /*
1418 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420
1421 /* store the smejoin req handle in session table */
1422 session->pLimJoinReq = sme_join_req;
1423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 /* Store SME transaction Id in session Table */
1425 session->transactionId = sme_join_req->transactionId;
1426
1427 /* Store beaconInterval */
1428 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001429 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301431 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 sizeof(session->htConfig));
1433
Sandeep Puligilla98917432016-06-10 13:50:28 -07001434 qdf_mem_copy(&(session->vht_config),
1435 &(sme_join_req->vht_config),
1436 sizeof(session->vht_config));
1437
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 /* Copying of bssId is already done, while creating session */
1439 sir_copy_mac_addr(session->selfMacAddr,
1440 sme_join_req->selfMacAddr);
1441 session->bssType = sme_join_req->bsstype;
1442
1443 session->statypeForBss = STA_ENTRY_PEER;
1444 session->limWmeEnabled = sme_join_req->isWMEenabled;
1445 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301446 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001447 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301449 session->enable_bcast_probe_rsp =
1450 sme_join_req->enable_bcast_probe_rsp;
1451
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001452 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001453 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1455
Naveen Rawat08db88f2017-09-08 15:07:48 -07001456 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001458 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459
1460 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001461 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 session->isCiscoVendorAP = true;
1463 } else {
1464 session->isCiscoVendorAP = false;
1465 }
1466
1467 /* Copy the dot 11 mode in to the session table */
1468
1469 session->dot11mode = sme_join_req->dot11mode;
1470#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1471 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1472#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001473 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1475 session->enableHtSmps = sme_join_req->enableHtSmps;
1476 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001477 session->send_smps_action =
1478 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001479 /*
1480 * By default supported NSS 1x1 is set to true
1481 * and later on updated while determining session
1482 * supported rates which is the intersection of
1483 * self and peer rates
1484 */
1485 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301486 /*Store Persona */
1487 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001488 pe_debug("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001489 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001490 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001491 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301492 session->supported_nss_1x1,
1493 session->pePersona,
1494 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001495
1496 /*Store Persona */
1497 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301498 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301499 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001500 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301501 session->nwType, session->dot11mode,
1502 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001503
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001504 /* Copy The channel Id to the session Table */
1505 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 session->vhtCapability =
1508 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301510 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001511 session->vht_config.su_beam_formee =
1512 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001514 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 session->enableVhtpAid =
1517 sme_join_req->enableVhtpAid;
1518 session->enableVhtGid =
1519 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001520 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001521 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 }
Krunal Soni53993f72016-07-08 18:20:03 -07001523
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001524 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301525 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001526 session->vht_config.su_beam_formee,
1527 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001528 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001530 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301532 session->force_24ghz_in_ht20 =
1533 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 /* cbMode is already merged value of peer and self -
1535 * done by csr in csr_get_cb_mode_from_ies */
1536 session->htSupportedChannelWidthSet =
1537 (sme_join_req->cbMode) ? 1 : 0;
1538 session->htRecommendedTxWidthSet =
1539 session->htSupportedChannelWidthSet;
1540 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1541
1542 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1543 session->ch_center_freq_seg0 =
1544 session->currentOperChannel - 2;
1545 session->ch_width = CH_WIDTH_40MHZ;
1546 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1547 sme_join_req->cbMode) {
1548 session->ch_center_freq_seg0 =
1549 session->currentOperChannel + 2;
1550 session->ch_width = CH_WIDTH_40MHZ;
1551 } else {
1552 session->ch_center_freq_seg0 = 0;
1553 session->ch_width = CH_WIDTH_20MHZ;
1554 }
1555
Naveen Rawataeca1b92017-10-16 16:55:31 -07001556 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1557 lim_update_session_he_capable(mac_ctx, session);
1558 lim_copy_join_req_he_cap(session, sme_join_req);
1559 }
1560
1561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 /* Record if management frames need to be protected */
1563#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301564 if ((eSIR_ED_AES_128_CMAC ==
1565 sme_join_req->MgmtEncryptionType) ||
1566 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1567 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001569 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571#endif
1572
1573#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001574 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575#endif
1576
1577 /* Copy the SSID from smejoinreq to session entry */
1578 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301579 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 session->ssId.length);
1581
1582 /*
1583 * Determin 11r or ESE connection based on input from SME
1584 * which inturn is dependent on the profile the user wants
1585 * to connect to, So input is coming from supplicant
1586 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588#ifdef FEATURE_WLAN_ESE
1589 session->isESEconnection = sme_join_req->isESEconnection;
1590#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 session->isFastTransitionEnabled =
1592 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 session->isFastRoamIniFeatureEnabled =
1595 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 session->txLdpcIniFeatureEnabled =
1597 sme_join_req->txLdpcIniFeatureEnabled;
1598
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301599 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301600 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1602 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 } else {
1604 /*
1605 * Throw an error and return and make
1606 * sure to delete the session.
1607 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001608 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 session->bssType);
1610 ret_code = eSIR_SME_INVALID_PARAMETERS;
1611 goto end;
1612 }
1613
1614 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301615 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 &sme_join_req->addIEScan, sizeof(tSirAddie));
1617
1618 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301619 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1621
1622 val = sizeof(tLimMlmJoinReq) +
1623 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301624 mlm_join_req = qdf_mem_malloc(val);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001625 if (!mlm_join_req) {
Nitesh Shah0102cac2016-07-13 14:38:30 +05301626 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1627 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
1630 /* PE SessionId is stored as a part of JoinReq */
1631 mlm_join_req->sessionId = session->peSessionId;
1632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301634 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 (void *)&sme_join_req->operationalRateSet,
1636 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301637 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 (void *)&sme_join_req->extendedRateSet,
1639 sizeof(tSirMacRateSet));
1640 /*
1641 * this may not be needed anymore now, as rateSet is now
1642 * included in the session entry and MLM has session context.
1643 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301644 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 (void *)&session->rateSet,
1646 sizeof(tSirMacRateSet));
1647
1648 session->encryptType = sme_join_req->UCEncryptionType;
1649
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301650 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1651 session->vdev_nss = sme_join_req->vdev_nss;
1652 session->nss = sme_join_req->nss;
1653 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1654
1655 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1656 session->nss,
1657 session->vdev_nss,
1658 session->supported_nss_1x1);
1659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 mlm_join_req->bssDescription.length =
1661 session->pLimJoinReq->bssDescription.length;
1662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301663 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 (uint8_t *)
1665 &session->pLimJoinReq->bssDescription.bssId,
1666 session->pLimJoinReq->bssDescription.length + 2);
1667
1668 session->limCurrentBssCaps =
1669 session->pLimJoinReq->bssDescription.capabilityInfo;
1670
1671 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1672 session->currentOperChannel);
1673 local_power_constraint = reg_max;
1674
1675 lim_extract_ap_capability(mac_ctx,
1676 (uint8_t *)
1677 session->pLimJoinReq->bssDescription.ieFields,
1678 lim_get_ielen_from_bss_description(
1679 &session->pLimJoinReq->bssDescription),
1680 &session->limCurrentBssQosCaps,
1681 &session->limCurrentBssPropCap,
1682 &session->gLimCurrentBssUapsd,
1683 &local_power_constraint, session);
1684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 session->maxTxPower = lim_get_max_tx_power(reg_max,
1686 local_power_constraint,
1687 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301688 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301689
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001690 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301691 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301693 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1694 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1695 pe_debug("Update MaxTxPower in join Req to %d",
1696 sme_join_req->powerCap.maxTxPower);
1697 }
1698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 if (session->gLimCurrentBssUapsd) {
1700 session->gUapsdPerAcBitmask =
1701 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001702 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 session->gUapsdPerAcBitmask);
1704
1705 /* resetting the dynamic uapsd mask */
1706 session->gUapsdPerAcDeliveryEnableMask = 0;
1707 session->gUapsdPerAcTriggerEnableMask = 0;
1708 }
1709
1710 session->limRFBand =
1711 lim_get_rf_band(session->currentOperChannel);
1712
1713 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001714 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001716 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001717 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 session->lim11hEnable =
1719 WNI_CFG_11H_ENABLED_STADEF;
1720 } else {
1721 session->lim11hEnable = val;
1722 }
1723 } else {
1724 session->lim11hEnable = 0;
1725 }
1726
1727 /*
1728 * To care of the scenario when STA transitions from
1729 * IBSS to Infrastructure mode.
1730 */
1731 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1732
1733 session->limPrevSmeState = session->limSmeState;
1734 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1735 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1736 session->peSessionId,
1737 session->limSmeState));
1738
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /* Indicate whether spectrum management is enabled */
1740 session->spectrumMgtEnabled =
1741 sme_join_req->spectrumMgtIndicator;
1742
1743 /* Enable the spectrum management if this is a DFS channel */
1744 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001745 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 session->currentOperChannel))
1747 session->spectrumMgtEnabled = true;
1748
1749 session->isOSENConnection = sme_join_req->isOSENConnection;
1750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 /* Issue LIM_MLM_JOIN_REQ to MLM */
Abhishek Singh254d5512018-10-30 12:17:05 +05301752 status = lim_send_join_req(session, mlm_join_req);
1753 if (QDF_IS_STATUS_ERROR(status)) {
1754 qdf_mem_free(mlm_join_req);
1755 ret_code = eSIR_SME_REFUSED;
1756 goto end;
1757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 return;
1759
1760 } else {
1761 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001762 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 mac_ctx->lim.gLimSmeState);
1764 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1765 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1766 session = NULL;
1767 goto end;
1768 }
1769
1770end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301771 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1772 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773
1774 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301775 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 sme_join_req = NULL;
1777 if (NULL != session)
1778 session->pLimJoinReq = NULL;
1779 }
1780 if (ret_code != eSIR_SME_SUCCESS) {
1781 if (NULL != session) {
1782 pe_delete_session(mac_ctx, session);
1783 session = NULL;
1784 }
1785 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001786 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 sme_session_id, ret_code);
1788 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1789 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1790 sme_transaction_id);
1791}
1792
Amar Singhala297bfa2015-10-15 15:07:29 -07001793uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 uint8_t iniTxPower)
1795{
1796 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301797 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001798
Anurag Chouhan6d760662016-02-20 16:05:43 +05301799 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1801 maxTxPower = txPower;
1802 else if (txPower < MIN_TX_PWR_CAP)
1803 maxTxPower = MIN_TX_PWR_CAP;
1804 else
1805 maxTxPower = MAX_TX_PWR_CAP;
1806
1807 return maxTxPower;
1808}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
1810/**
1811 * __lim_process_sme_reassoc_req() - process reassoc req
1812 *
1813 * @mac_ctx: Pointer to Global MAC structure
1814 * @msg_buf: pointer to the SME message buffer
1815 *
1816 * This function is called to process SME_REASSOC_REQ message
1817 * from HDD or upper layer application.
1818 *
1819 * Return: None
1820 */
1821
1822static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1823 uint32_t *msg_buf)
1824{
1825 uint16_t caps;
1826 uint32_t val;
1827 tpSirSmeJoinReq reassoc_req = NULL;
1828 tLimMlmReassocReq *mlm_reassoc_req;
1829 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1830 tpPESession session_entry = NULL;
1831 uint8_t session_id;
1832 uint8_t sme_session_id;
1833 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001834 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 uint32_t tele_bcn_en = 0;
1836 uint16_t size;
Abhishek Singh254d5512018-10-30 12:17:05 +05301837 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301840 reassoc_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001841 if (!reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1843 goto end;
1844 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301845 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846
1847 if (!lim_is_sme_join_req_valid(mac_ctx,
1848 (tpSirSmeJoinReq)reassoc_req)) {
1849 /*
1850 * Received invalid eWNI_SME_REASSOC_REQ
1851 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001852 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853
1854 ret_code = eSIR_SME_INVALID_PARAMETERS;
1855 goto end;
1856 }
Jianmin Zhu09236602018-10-15 15:36:10 +08001857 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1858 &sme_session_id, &transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859
1860 session_entry = pe_find_session_by_bssid(mac_ctx,
1861 reassoc_req->bssDescription.bssId,
1862 &session_id);
1863 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001864 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001865 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1866 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001868 session_entry =
1869 pe_find_session_by_sme_session_id(mac_ctx,
1870 sme_session_id);
1871 if (session_entry != NULL)
1872 lim_handle_sme_join_result(mac_ctx,
1873 eSIR_SME_INVALID_PARAMETERS,
1874 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1875 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 goto end;
1877 }
1878#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1879 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001880 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1882 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1883
1884 /* Store the reassoc handle in the session Table */
1885 session_entry->pLimReAssocReq = reassoc_req;
1886
1887 session_entry->dot11mode = reassoc_req->dot11mode;
1888 session_entry->vhtCapability =
1889 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001890
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301891 if (session_entry->vhtCapability) {
1892 if (session_entry->pePersona == QDF_STA_MODE) {
1893 session_entry->vht_config.su_beam_formee =
1894 reassoc_req->vht_config.su_beam_formee;
1895 } else {
1896 reassoc_req->vht_config.su_beam_formee = 0;
1897 }
1898 session_entry->enableVhtpAid =
1899 reassoc_req->enableVhtpAid;
1900 session_entry->enableVhtGid =
1901 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001902 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301903 }
1904
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301905 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1906 session_entry->vdev_nss = reassoc_req->vdev_nss;
1907 session_entry->nss = reassoc_req->nss;
1908 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001910 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301911 session_entry->vhtCapability,
1912 session_entry->vht_config.su_beam_formee,
1913 session_entry->vht_config.su_beam_former);
1914
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001915 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1916 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001917 session_entry->send_smps_action =
1918 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001919 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001920 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001921 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001922 session_entry->send_smps_action,
1923 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 /*
1925 * Reassociate request is expected
1926 * in link established state only.
1927 */
1928
1929 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1931 /*
1932 * May be from 11r FT pre-auth. So lets check it
1933 * before we bail out
1934 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001935 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 session_entry->peSessionId);
1937
1938 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301939 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 session_entry->limReAssocbssId,
1941 6)) {
1942 lim_print_mac_addr(mac_ctx,
1943 reassoc_req->bssDescription.
1944 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001945 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 ret_code = eSIR_SME_INVALID_PARAMETERS;
1947 goto end;
1948 }
1949
Jianmin Zhu09236602018-10-15 15:36:10 +08001950 session_entry->smeSessionId = sme_session_id;
1951 session_entry->transactionId = transaction_id;
Abhishek Singh254d5512018-10-30 12:17:05 +05301952 mlm_reassoc_req =
1953 qdf_mem_malloc(sizeof(*mlm_reassoc_req));
1954 if (!mlm_reassoc_req) {
1955 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1956 goto end;
1957 }
1958
1959 /* Update PE sessionId */
1960 mlm_reassoc_req->sessionId = session_entry->peSessionId;
1961 status = lim_send_ft_reassoc_req(session_entry,
1962 mlm_reassoc_req);
1963 if (QDF_IS_STATUS_ERROR(status)) {
1964 qdf_mem_free(mlm_reassoc_req);
1965 ret_code = eSIR_SME_REFUSED;
1966 goto end;
1967 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 return;
1969 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 /*
1971 * Should not have received eWNI_SME_REASSOC_REQ
1972 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001973 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 session_entry->limSmeState);
1975 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1976
1977 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1978 goto end;
1979 }
1980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301981 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 session_entry->pLimReAssocReq->bssDescription.bssId,
1983 sizeof(tSirMacAddr));
1984
1985 session_entry->limReassocChannelId =
1986 session_entry->pLimReAssocReq->bssDescription.channelId;
1987
1988 session_entry->reAssocHtSupportedChannelWidthSet =
1989 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1990 session_entry->reAssocHtRecommendedTxWidthSet =
1991 session_entry->reAssocHtSupportedChannelWidthSet;
1992 session_entry->reAssocHtSecondaryChannelOffset =
1993 session_entry->pLimReAssocReq->cbMode;
1994
1995 session_entry->limReassocBssCaps =
1996 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1997 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1998 session_entry->currentOperChannel);
1999 local_pwr_constraint = reg_max;
2000
2001 lim_extract_ap_capability(mac_ctx,
2002 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2003 lim_get_ielen_from_bss_description(
2004 &session_entry->pLimReAssocReq->bssDescription),
2005 &session_entry->limReassocBssQosCaps,
2006 &session_entry->limReassocBssPropCap,
2007 &session_entry->gLimCurrentBssUapsd,
2008 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302009 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002010 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302011 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 /* Copy the SSID from session entry to local variable */
2013 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302014 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 reassoc_req->ssId.ssId,
2016 session_entry->limReassocSSID.length);
2017 if (session_entry->gLimCurrentBssUapsd) {
2018 session_entry->gUapsdPerAcBitmask =
2019 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002020 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 session_entry->gUapsdPerAcBitmask);
2022 }
2023
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002025 if (!mlm_reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2027 goto end;
2028 }
2029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002034 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002035 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302036
2037 lim_update_caps_info_for_bss(mac_ctx, &caps,
2038 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002039 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 mlm_reassoc_req->capabilityInfo = caps;
2042
2043 /* Update PE session_id */
2044 mlm_reassoc_req->sessionId = session_id;
2045
2046 /*
2047 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302048 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302051 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302053 if (tele_bcn_en)
2054 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2055 else
2056 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057
2058 mlm_reassoc_req->listenInterval = (uint16_t) val;
2059
2060 /* Indicate whether spectrum management is enabled */
2061 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2062
2063 /* Enable the spectrum management if this is a DFS channel */
2064 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002065 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 session_entry->currentOperChannel))
2067 session_entry->spectrumMgtEnabled = true;
2068
2069 session_entry->limPrevSmeState = session_entry->limSmeState;
2070 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2071
2072 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2073 session_entry->peSessionId,
2074 session_entry->limSmeState));
2075
Abhishek Singh254d5512018-10-30 12:17:05 +05302076 status = lim_send_reassoc_req(session_entry, mlm_reassoc_req);
2077 if (QDF_IS_STATUS_ERROR(status)) {
2078 qdf_mem_free(mlm_reassoc_req);
2079 ret_code = eSIR_SME_REFUSED;
2080 goto end;
2081 }
Jianmin Zhu09236602018-10-15 15:36:10 +08002082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 return;
2084end:
2085 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302086 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 if (session_entry)
2088 session_entry->pLimReAssocReq = NULL;
2089 }
2090
2091 if (session_entry) {
2092 /*
2093 * error occurred after we determined the session so extract
2094 * session and transaction info from there
2095 */
2096 sme_session_id = session_entry->smeSessionId;
2097 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002098 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 /*
2100 * error occurred before or during the time we determined
2101 * the session so extract the session and transaction info
2102 * from the message
2103 */
2104 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2105 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002106 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 /*
2108 * Send Reassoc failure response to host
2109 * (note session_entry may be NULL, but that's OK)
2110 */
2111 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2112 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2113 session_entry, sme_session_id,
2114 transaction_id);
2115}
2116
2117bool send_disassoc_frame = 1;
2118/**
2119 * __lim_process_sme_disassoc_req()
2120 *
2121 ***FUNCTION:
2122 * This function is called to process SME_DISASSOC_REQ message
2123 * from HDD or upper layer application.
2124 *
2125 ***LOGIC:
2126 *
2127 ***ASSUMPTIONS:
2128 *
2129 ***NOTE:
2130 *
2131 * @param pMac Pointer to Global MAC structure
2132 * @param *pMsgBuf A pointer to the SME message buffer
2133 * @return None
2134 */
2135
2136static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2137{
2138 uint16_t disassocTrigger, reasonCode;
2139 tLimMlmDisassocReq *pMlmDisassocReq;
2140 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2141 tSirSmeDisassocReq smeDisassocReq;
2142 tpPESession psessionEntry = NULL;
2143 uint8_t sessionId;
2144 uint8_t smesessionId;
2145 uint16_t smetransactionId;
2146
2147 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 return;
2150 }
2151
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302152 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 smesessionId = smeDisassocReq.sessionId;
2154 smetransactionId = smeDisassocReq.transactionId;
2155 if (!lim_is_sme_disassoc_req_valid(pMac,
2156 &smeDisassocReq,
2157 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002158 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 if (pMac->lim.gLimRspReqd) {
2160 pMac->lim.gLimRspReqd = false;
2161
2162 retCode = eSIR_SME_INVALID_PARAMETERS;
2163 disassocTrigger = eLIM_HOST_DISASSOC;
2164 goto sendDisassoc;
2165 }
2166
2167 return;
2168 }
2169
2170 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002171 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 &sessionId);
2173 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002174 pe_err("session does not exist for given bssId "
2175 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002176 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 retCode = eSIR_SME_INVALID_PARAMETERS;
2178 disassocTrigger = eLIM_HOST_DISASSOC;
2179 goto sendDisassoc;
2180 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002181 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2182 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2184 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002185 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186
2187#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2188 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2189 0, smeDisassocReq.reasonCode);
2190#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2191
2192 /* Update SME session Id and SME transaction ID */
2193
2194 psessionEntry->smeSessionId = smesessionId;
2195 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002196 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002197 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198
2199 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2200 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 switch (psessionEntry->limSmeState) {
2202 case eLIM_SME_ASSOCIATED_STATE:
2203 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002204 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002205 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 psessionEntry->limPrevSmeState =
2207 psessionEntry->limSmeState;
2208 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209 /* Delete all TDLS peers connected before leaving BSS */
2210 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002211 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2212 psessionEntry->peSessionId,
2213 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 break;
2215
2216 case eLIM_SME_WT_DEAUTH_STATE:
2217 /* PE shall still process the DISASSOC_REQ and proceed with
2218 * link tear down even if it had already sent a DEAUTH_IND to
2219 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2220 * its been set when PE entered WT_DEAUTH_STATE.
2221 */
2222 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2223 MTRACE(mac_trace
2224 (pMac, TRACE_CODE_SME_STATE,
2225 psessionEntry->peSessionId,
2226 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002227 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 break;
2229
2230 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002231 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2233 * PE can continue processing DISASSOC_REQ and send the response instead
2234 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2235 * for disassoc frame.
2236 *
2237 * It will send a disassoc, which is ok. However, we can use the global flag
2238 * sendDisassoc to not send disassoc frame.
2239 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002240 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 break;
2242
2243 case eLIM_SME_JOIN_FAILURE_STATE: {
2244 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 if (pMac->lim.gLimRspReqd) {
2247 retCode = eSIR_SME_SUCCESS;
2248 disassocTrigger = eLIM_HOST_DISASSOC;
2249 goto sendDisassoc;
2250 }
2251 }
2252 break;
2253 default:
2254 /**
2255 * STA is not currently associated.
2256 * Log error and send response to host
2257 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002258 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 psessionEntry->limSmeState);
2260 lim_print_sme_state(pMac, LOGE,
2261 psessionEntry->limSmeState);
2262
2263 if (pMac->lim.gLimRspReqd) {
2264 if (psessionEntry->limSmeState !=
2265 eLIM_SME_WT_ASSOC_STATE)
2266 pMac->lim.gLimRspReqd = false;
2267
2268 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2269 disassocTrigger = eLIM_HOST_DISASSOC;
2270 goto sendDisassoc;
2271 }
2272
2273 return;
2274 }
2275
2276 break;
2277
2278 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 /* Fall through */
2280 break;
2281
2282 case eLIM_STA_IN_IBSS_ROLE:
2283 default:
2284 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002285 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 GET_LIM_SYSTEM_ROLE(psessionEntry));
2287
2288 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2289 disassocTrigger = eLIM_HOST_DISASSOC;
2290 goto sendDisassoc;
2291 } /* end switch (pMac->lim.gLimSystemRole) */
2292
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302293 disassocTrigger = eLIM_HOST_DISASSOC;
2294 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295
2296 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002297 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 send_disassoc_frame = 0;
2299 }
2300 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002301 pe_debug("Sending Disasscoc with disassoc Trigger"
2302 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 disassocTrigger, reasonCode);
2304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302305 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002306 if (!pMlmDisassocReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308
Anurag Chouhanc5548422016-02-24 18:33:27 +05302309 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002310 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311
2312 pMlmDisassocReq->reasonCode = reasonCode;
2313 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2314
2315 /* Update PE session ID */
2316 pMlmDisassocReq->sessionId = sessionId;
2317
2318 lim_post_mlm_message(pMac,
2319 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2320 return;
2321
2322sendDisassoc:
2323 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002324 lim_send_sme_disassoc_ntf(pMac,
2325 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 retCode,
2327 disassocTrigger,
2328 1, smesessionId, smetransactionId,
2329 psessionEntry);
2330 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002331 lim_send_sme_disassoc_ntf(pMac,
2332 smeDisassocReq.peer_macaddr.bytes,
2333 retCode, disassocTrigger, 1,
2334 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335
2336} /*** end __lim_process_sme_disassoc_req() ***/
2337
2338/** -----------------------------------------------------------------
2339 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2340
2341 This function is called to process SME_DISASSOC_CNF message
2342 from HDD or upper layer application.
2343
2344 \param pMac - global mac structure
2345 \param pStaDs - station dph hash node
2346 \return none
2347 \sa
2348 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002349void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350{
2351 tSirSmeDisassocCnf smeDisassocCnf;
2352 uint16_t aid;
2353 tpDphHashNode pStaDs;
2354 tpPESession psessionEntry;
2355 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302356 uint32_t *msg = NULL;
2357 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302359 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 sizeof(struct sSirSmeDisassocCnf));
2361
2362 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002363 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 &sessionId);
2365 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002366 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302367 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302368 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302369 eSIR_SME_INVALID_SESSION,
2370 NULL);
2371 if (QDF_IS_STATUS_SUCCESS(status))
2372 lim_send_sme_disassoc_deauth_ntf(pMac,
2373 QDF_STATUS_SUCCESS,
2374 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 return;
2376 }
2377
2378 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002379 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302380 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2381 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302382 eSIR_SME_INVALID_PARAMETERS,
2383 &smeDisassocCnf.bssid.bytes[0]);
2384 if (QDF_IS_STATUS_SUCCESS(status))
2385 lim_send_sme_disassoc_deauth_ntf(pMac,
2386 QDF_STATUS_SUCCESS,
2387 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 return;
2389 }
2390#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2391 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2392 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2393 psessionEntry,
2394 (uint16_t) smeDisassocCnf.statusCode, 0);
2395 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2396 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2397 psessionEntry,
2398 (uint16_t) smeDisassocCnf.statusCode, 0);
2399#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2400
2401 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2402 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2404 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2405 && (psessionEntry->limSmeState !=
2406 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002407 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 psessionEntry->limSmeState);
2409 lim_print_sme_state(pMac, LOGE,
2410 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302411 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302412 psessionEntry->smeSessionId,
2413 eSIR_SME_INVALID_STATE,
2414 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302415 if (QDF_IS_STATUS_SUCCESS(status))
2416 lim_send_sme_disassoc_deauth_ntf(pMac,
2417 QDF_STATUS_SUCCESS,
2418 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 return;
2420 }
2421 break;
2422
2423 case eLIM_AP_ROLE:
2424 /* Fall through */
2425 break;
2426
2427 case eLIM_STA_IN_IBSS_ROLE:
2428 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002429 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302431 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2432 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302433 eSIR_SME_INVALID_STATE,
2434 &smeDisassocCnf.bssid.bytes[0]);
2435 if (QDF_IS_STATUS_SUCCESS(status))
2436 lim_send_sme_disassoc_deauth_ntf(pMac,
2437 QDF_STATUS_SUCCESS,
2438 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 return;
2440 }
2441
2442 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2443 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2444 LIM_IS_AP_ROLE(psessionEntry)) {
2445 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002446 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 &psessionEntry->dph.dphHashTable);
2448 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002449 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2450 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002451 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302452 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302453 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302454 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302455 &smeDisassocCnf.bssid.bytes[0]);
2456 if (QDF_IS_STATUS_SUCCESS(status))
2457 lim_send_sme_disassoc_deauth_ntf(pMac,
2458 QDF_STATUS_SUCCESS,
2459 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 return;
2461 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302462
2463 if ((pStaDs->mlmStaContext.mlmState ==
2464 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2465 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002466 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002467 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002468 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302469 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302470 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302471 psessionEntry->smeSessionId,
2472 eSIR_SME_SUCCESS,
2473 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302474 if (QDF_IS_STATUS_SUCCESS(status))
2475 lim_send_sme_disassoc_deauth_ntf(pMac,
2476 QDF_STATUS_SUCCESS,
2477 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302478 return;
2479 }
2480
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 /* Delete FT session if there exists one */
2482 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2484
2485 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002486 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 }
2488
2489 return;
2490}
2491
2492/**
2493 * __lim_process_sme_deauth_req() - process sme deauth req
2494 * @mac_ctx: Pointer to Global MAC structure
2495 * @msg_buf: pointer to the SME message buffer
2496 *
2497 * This function is called to process SME_DEAUTH_REQ message
2498 * from HDD or upper layer application.
2499 *
2500 * Return: None
2501 */
2502
2503static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2504 uint32_t *msg_buf)
2505{
2506 uint16_t deauth_trigger, reason_code;
2507 tLimMlmDeauthReq *mlm_deauth_req;
2508 tSirSmeDeauthReq sme_deauth_req;
2509 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2510 tpPESession session_entry;
2511 uint8_t session_id; /* PE sessionId */
2512 uint8_t sme_session_id;
2513 uint16_t sme_transaction_id;
2514
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302515 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 sme_session_id = sme_deauth_req.sessionId;
2517 sme_transaction_id = sme_deauth_req.transactionId;
2518
2519 /*
2520 * We need to get a session first but we don't even know
2521 * if the message is correct.
2522 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002523 session_entry = pe_find_session_by_bssid(mac_ctx,
2524 sme_deauth_req.bssid.bytes,
2525 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002527 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 ret_code = eSIR_SME_INVALID_PARAMETERS;
2529 deauth_trigger = eLIM_HOST_DEAUTH;
2530 goto send_deauth;
2531 }
2532
2533 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2534 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002535 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 mac_ctx->lim.gLimRspReqd = false;
2537
2538 ret_code = eSIR_SME_INVALID_PARAMETERS;
2539 deauth_trigger = eLIM_HOST_DEAUTH;
2540 goto send_deauth;
2541 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002542 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2543 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2545 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002546 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2548 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2549 session_entry, 0, sme_deauth_req.reasonCode);
2550#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2551
2552 /* Update SME session ID and Transaction ID */
2553 session_entry->smeSessionId = sme_session_id;
2554 session_entry->transactionId = sme_transaction_id;
2555
2556 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2557 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 switch (session_entry->limSmeState) {
2559 case eLIM_SME_ASSOCIATED_STATE:
2560 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302561 /* Delete all TDLS peers connected before leaving BSS */
2562 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302563 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 case eLIM_SME_WT_ASSOC_STATE:
2565 case eLIM_SME_JOIN_FAILURE_STATE:
2566 case eLIM_SME_IDLE_STATE:
2567 session_entry->limPrevSmeState =
2568 session_entry->limSmeState;
2569 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2570 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2571 session_entry->peSessionId,
2572 session_entry->limSmeState));
2573 /* Send Deauthentication request to MLM below */
2574 break;
2575 case eLIM_SME_WT_DEAUTH_STATE:
2576 case eLIM_SME_WT_DISASSOC_STATE:
2577 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002578 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2580 * Which means host is also trying to disconnect.
2581 * PE can continue processing DEAUTH_REQ and send
2582 * the response instead of failing the request.
2583 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2584 * was sent for deauth/disassoc frame.
2585 */
2586 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002587 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 break;
2589 default:
2590 /*
2591 * STA is not in a state to deauthenticate with
2592 * peer. Log error and send response to host.
2593 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002594 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 session_entry->limSmeState);
2596 lim_print_sme_state(mac_ctx, LOGE,
2597 session_entry->limSmeState);
2598
2599 if (mac_ctx->lim.gLimRspReqd) {
2600 mac_ctx->lim.gLimRspReqd = false;
2601
2602 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2603 deauth_trigger = eLIM_HOST_DEAUTH;
2604
wadesong42968e92017-06-08 14:11:21 +08002605 /*
2606 * here we received deauth request from AP so
2607 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2608 * have ISSUED delSta then mlm state should be
2609 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2610 * delBSS rsp then mlm state should be
2611 * eLIM_MLM_IDLE_STATE so the below condition
2612 * captures the state where delSta not done
2613 * and firmware still in connected state.
2614 */
2615 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 eLIM_SME_WT_DEAUTH_STATE &&
2617 session_entry->limMlmState !=
2618 eLIM_MLM_IDLE_STATE &&
2619 session_entry->limMlmState !=
2620 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002621 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 goto send_deauth;
2623 }
2624 return;
2625 }
2626 break;
2627
2628 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002629 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 if (mac_ctx->lim.gLimRspReqd) {
2631 mac_ctx->lim.gLimRspReqd = false;
2632 ret_code = eSIR_SME_INVALID_PARAMETERS;
2633 deauth_trigger = eLIM_HOST_DEAUTH;
2634 goto send_deauth;
2635 }
2636 return;
2637 case eLIM_AP_ROLE:
2638 break;
2639 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002640 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 GET_LIM_SYSTEM_ROLE(session_entry));
2642 if (mac_ctx->lim.gLimRspReqd) {
2643 mac_ctx->lim.gLimRspReqd = false;
2644 ret_code = eSIR_SME_INVALID_PARAMETERS;
2645 deauth_trigger = eLIM_HOST_DEAUTH;
2646 goto send_deauth;
2647 }
2648 return;
2649 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2650
Yu Ouyang57c25532018-09-07 17:14:01 +08002651 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2652 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002654 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2656 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2657 } else {
2658 deauth_trigger = eLIM_HOST_DEAUTH;
2659 reason_code = sme_deauth_req.reasonCode;
2660 }
2661
2662 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002664 if (!mlm_deauth_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 if (mac_ctx->lim.gLimRspReqd) {
2666 mac_ctx->lim.gLimRspReqd = false;
2667 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2668 deauth_trigger = eLIM_HOST_DEAUTH;
2669 goto send_deauth;
2670 }
2671 return;
2672 }
2673
Anurag Chouhanc5548422016-02-24 18:33:27 +05302674 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002675 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676
2677 mlm_deauth_req->reasonCode = reason_code;
2678 mlm_deauth_req->deauthTrigger = deauth_trigger;
2679
2680 /* Update PE session Id */
2681 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002682 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 return;
2685
2686send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002687 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2688 ret_code, deauth_trigger, 1,
2689 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690}
2691
2692/**
2693 * __lim_process_sme_set_context_req()
2694 *
2695 * @mac_ctx: Pointer to Global MAC structure
2696 * @msg_buf: pointer to the SME message buffer
2697 *
2698 * This function is called to process SME_SETCONTEXT_REQ message
2699 * from HDD or upper layer application.
2700 *
2701 * Return: None
2702 */
2703
2704static void
2705__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2706{
2707 tpSirSmeSetContextReq set_context_req;
2708 tLimMlmSetKeysReq *mlm_set_key_req;
2709 tpPESession session_entry;
2710 uint8_t session_id; /* PE sessionID */
2711 uint8_t sme_session_id;
2712 uint16_t sme_transaction_id;
2713
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002715 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002716 return;
2717 }
2718
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302719 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002720 if (!set_context_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302722 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 sizeof(struct sSirSmeSetContextReq));
2724 sme_session_id = set_context_req->sessionId;
2725 sme_transaction_id = set_context_req->transactionId;
2726
2727 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002728 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 goto end;
2730 }
2731
2732 if (set_context_req->keyMaterial.numKeys >
2733 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002734 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 set_context_req->keyMaterial.numKeys);
2736 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002737 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 eSIR_SME_INVALID_PARAMETERS, NULL,
2739 sme_session_id, sme_transaction_id);
2740 goto end;
2741 }
2742
2743 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002744 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002746 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002748 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 eSIR_SME_INVALID_PARAMETERS, NULL,
2750 sme_session_id, sme_transaction_id);
2751 goto end;
2752 }
2753#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2754 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2755 session_entry, 0, 0);
2756#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2757
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002758 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2760 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002761 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2763 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302764 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002765 if (!mlm_set_key_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2768 mlm_set_key_req->numKeys =
2769 set_context_req->keyMaterial.numKeys;
2770 if (mlm_set_key_req->numKeys >
2771 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002772 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002773 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 goto end;
2775 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302776 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002777 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302779 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 (uint8_t *) &set_context_req->keyMaterial.key,
2781 sizeof(tSirKeys) *
2782 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2783 numKeys : 1));
2784
2785 mlm_set_key_req->sessionId = session_id;
2786 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002787 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789
2790 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2791 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2792 LIM_IS_AP_ROLE(session_entry)) {
2793 if (set_context_req->keyMaterial.key[0].keyLength) {
2794 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 key_id =
2797 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302798 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 &session_entry->WEPKeyMaterial[key_id],
2800 (uint8_t *) &set_context_req->keyMaterial,
2801 sizeof(tSirKeyMaterial));
2802 } else {
2803 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002804
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2806 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 &mlm_set_key_req->key[i],
2809 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2810 sizeof(tSirKeys));
2811 }
2812 }
2813 }
2814 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2815 (uint32_t *) mlm_set_key_req);
2816 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002817 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 GET_LIM_SYSTEM_ROLE(session_entry),
2819 session_entry->limSmeState);
2820 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2821
2822 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002823 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2825 session_entry, sme_session_id,
2826 sme_transaction_id);
2827 }
2828end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 return;
2831}
2832
2833/**
2834 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2835 *
2836 * @mac_ctx: Pointer to Global MAC structure
2837 * @msg_buf: pointer to the SME message buffer
2838 *
2839 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2840 * from HDD or upper layer application.
2841 *
2842 * Return: None
2843 */
2844
Jeff Johnson801f1532016-10-07 07:54:50 -07002845static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2846 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847{
2848 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2849 tpDphHashNode sta_ds = NULL;
2850 tpPESession session_entry = NULL;
2851 tSap_Event sap_event;
2852 tpWLAN_SAPEventCB sap_event_cb = NULL;
2853 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2854 uint8_t session_id = CSR_SESSION_ID_INVALID;
2855 uint8_t assoc_id = 0;
2856 uint8_t sta_cnt = 0;
2857
2858 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002859 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 return;
2861 }
2862
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302863 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 sizeof(struct sSirSmeGetAssocSTAsReq));
2865 /*
2866 * Get Associated stations from PE.
2867 * Find PE session Entry
2868 */
2869 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002870 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871 &session_id);
2872 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002873 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 goto lim_assoc_sta_end;
2875 }
2876
2877 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002878 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 session_entry->limSmeState,
2880 GET_LIM_SYSTEM_ROLE(session_entry));
2881 goto lim_assoc_sta_end;
2882 }
2883 /* Retrieve values obtained in the request message */
2884 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2885 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2886
2887 if (NULL == assoc_sta_tmp)
2888 goto lim_assoc_sta_end;
2889 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2890 assoc_id++) {
2891 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2892 &session_entry->dph.dphHashTable);
2893 if (NULL == sta_ds)
2894 continue;
2895 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302896 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302898 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2900 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2901
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302902 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 (uint8_t *)&sta_ds->supportedRates,
2904 sizeof(tSirSupportedRates));
2905 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2906 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2907 assoc_sta_tmp->Support40Mhz =
2908 sta_ds->htDsssCckRate40MHzSupport;
2909
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002910 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002912 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002914 pe_debug("Association Id: %d Station Index: %d",
2915 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 assoc_sta_tmp++;
2917 sta_cnt++;
2918 }
2919 }
2920lim_assoc_sta_end:
2921 /*
2922 * Call hdd callback with sap event to send the list of
2923 * associated stations from PE
2924 */
2925 if (sap_event_cb != NULL) {
2926 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2927 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302928 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2930 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2931 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2932 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2933 }
2934}
2935
2936/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 * __lim_counter_measures()
2938 *
2939 * FUNCTION:
2940 * This function is called to "implement" MIC counter measure
2941 * and is *temporary* only
2942 *
2943 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2944 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002945 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 *
2947 ***ASSUMPTIONS:
2948 *
2949 ***NOTE:
2950 *
2951 * @param pMac Pointer to Global MAC structure
2952 * @return None
2953 */
2954
2955static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2956{
Jeff Johnson2b511902018-11-20 09:40:23 -08002957 tSirMacAddr mac_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002958
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002959 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
Jeff Johnson2b511902018-11-20 09:40:23 -08002961 mac_addr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962};
2963
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302964void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2965 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302966{
2967 session->limSmeState = session->limPrevSmeState;
2968
2969 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2970 session->limSmeState));
2971
2972 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2973 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2974 session->transactionId);
2975}
2976
2977void lim_delete_all_peers(tpPESession session)
2978{
2979 uint8_t i = 0;
2980 tpAniSirGlobal mac_ctx = session->mac_ctx;
2981 tpDphHashNode sta_ds = NULL;
2982 QDF_STATUS status;
2983
2984 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2985 sta_ds = dph_get_hash_entry(mac_ctx, i,
2986 &session->dph.dphHashTable);
2987 if (!sta_ds)
2988 continue;
2989 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2990 if (QDF_STATUS_SUCCESS == status) {
2991 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2992 sta_ds->assocId, session);
2993 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2994 } else {
2995 pe_err("lim_del_sta failed with Status: %d", status);
2996 QDF_ASSERT(0);
2997 }
2998 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302999
3000#ifdef CONFIG_VDEV_SM
3001 status =
3002 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3003 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
3004 sizeof(*session), session);
3005 if (QDF_IS_STATUS_ERROR(status)) {
3006 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
3007 session->smeSessionId);
3008 lim_send_stop_bss_failure_resp(mac_ctx, session);
3009 }
3010#endif
3011
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303012}
3013
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07003014QDF_STATUS lim_sta_send_del_bss(tpPESession session)
3015{
3016 tpAniSirGlobal mac_ctx = session->mac_ctx;
3017 QDF_STATUS status = QDF_STATUS_E_FAILURE;
3018 tpDphHashNode sta_ds = NULL;
3019
3020 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3021 &session->dph.dphHashTable);
3022 if (!sta_ds) {
3023 pe_err("DPH Entry for STA is missing, failed to send delbss");
3024 goto end;
3025 }
3026
3027 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
3028 if (QDF_IS_STATUS_ERROR(status))
3029 pe_err("delBss failed for bss %d", session->bssIdx);
3030
3031end:
3032 return status;
3033}
3034
Abhishek Singhcaa61852018-09-12 15:50:04 +05303035QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303036{
3037 tpAniSirGlobal mac_ctx = session->mac_ctx;
3038 QDF_STATUS status;
3039
3040 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
3041
3042 if (QDF_IS_STATUS_ERROR(status)) {
3043 pe_err("delBss failed for bss %d", session->bssIdx);
3044 lim_send_stop_bss_failure_resp(mac_ctx, session);
3045 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05303046
3047 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303048}
3049
3050/**
3051 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
3052 * @session: session pointer
3053 *
3054 * Return None
3055 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303056#ifdef CONFIG_VDEV_SM
3057static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3058{
3059 tpAniSirGlobal mac_ctx = session->mac_ctx;
3060 QDF_STATUS status;
3061
Abhishek Singhc5a54082018-09-12 16:08:03 +05303062 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3063 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3064 status =
3065 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3066 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303067 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303068 else
3069 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3070 WLAN_VDEV_SM_EV_DOWN,
3071 sizeof(*session),
3072 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303073 if (QDF_IS_STATUS_ERROR(status)) {
3074 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3075 session->smeSessionId);
3076 lim_send_stop_bss_failure_resp(mac_ctx, session);
3077 }
3078}
3079#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303080static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3081{
3082 lim_delete_all_peers(session);
3083 /* send a delBss to HAL and wait for a response */
3084 lim_send_vdev_stop(session);
3085}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303086#endif
3087
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088static void
3089__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3090{
3091 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 tLimSmeStates prevState;
3093 tpPESession psessionEntry;
3094 uint8_t smesessionId;
3095 uint8_t sessionId;
3096 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303098 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 smesessionId = stopBssReq.sessionId;
3100 smetransactionId = stopBssReq.transactionId;
3101
3102 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003103 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 /* Send Stop BSS response to host */
3105 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3106 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3107 smetransactionId);
3108 return;
3109 }
3110
3111 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003112 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 &sessionId);
3114 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003115 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3117 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3118 smetransactionId);
3119 return;
3120 }
3121#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3122 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3123 0, 0);
3124#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3125
3126 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3127 LIM_IS_STA_ROLE(psessionEntry)) {
3128 /**
3129 * Should not have received STOP_BSS_REQ in states
3130 * other than 'normal' state or on STA in Infrastructure
3131 * mode. Log error and return response to host.
3132 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003133 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 psessionEntry->limSmeState,
3135 GET_LIM_SYSTEM_ROLE(psessionEntry));
3136 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3137 /* / Send Stop BSS response to host */
3138 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3139 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3140 smetransactionId);
3141 return;
3142 }
3143
3144 if (LIM_IS_AP_ROLE(psessionEntry))
3145 lim_wpspbc_close(pMac, psessionEntry);
3146
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003147 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 stopBssReq.reasonCode);
3149
3150 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303151 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152
3153 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3154 MTRACE(mac_trace
3155 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3156 psessionEntry->limSmeState));
3157
3158 /* Update SME session Id and Transaction Id */
3159 psessionEntry->smeSessionId = smesessionId;
3160 psessionEntry->transactionId = smetransactionId;
3161
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003162 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3163 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3164 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3168 /* Send disassoc all stations associated thru TKIP */
3169 __lim_counter_measures(pMac, psessionEntry);
3170 else
3171 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003172 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3173 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
3175
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003176 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3177 /* Free the buffer allocated in START_BSS_REQ */
3178 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3179 psessionEntry->addIeParams.probeRespDataLen = 0;
3180 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003182 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3183 psessionEntry->addIeParams.assocRespDataLen = 0;
3184 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003186 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3187 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3188 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003190 /*
3191 * lim_del_bss is also called as part of coalescing,
3192 * when we send DEL BSS followed by Add Bss msg.
3193 */
3194 pMac->lim.gLimIbssCoalescingHappened = false;
3195 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303197 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199}
3200
3201/**
3202 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3203 * @pMac: Global MAC context
3204 * @pMsg: Message from SME
3205 *
3206 * Wrapper for the function __lim_handle_sme_stop_bss_request
3207 * This message will be defered until softmac come out of
3208 * scan mode. Message should be handled even if we have
3209 * detected radar in the current operating channel.
3210 *
3211 * Return: true - If we consumed the buffer
3212 * false - If have defered the message.
3213 */
3214
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003215static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3216 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217{
3218 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3219 /**
3220 * If message defered, buffer is not consumed yet.
3221 * So return false
3222 */
3223 return false;
3224 }
3225 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3226 return true;
3227} /*** end __lim_process_sme_stop_bss_req() ***/
3228
3229void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3230 uint32_t body, tpPESession psessionEntry)
3231{
3232
3233 (void)body;
3234 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3235 lim_ibss_delete(pMac, psessionEntry);
3236 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3237 lim_delete_pre_auth_list(pMac);
3238 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3239 psessionEntry->smeSessionId,
3240 psessionEntry->transactionId);
3241 return;
3242}
3243
3244/**
3245 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3246 *
3247 * @mac_ctx: pointer to mac context
3248 * @msg_type: message type
3249 * @msg_buf: pointer to the SME message buffer
3250 *
3251 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3252 * in BTAMP AP.
3253 *
3254 * Return: None
3255 */
3256
3257void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3258 uint32_t *msg_buf)
3259{
3260 tSirSmeAssocCnf assoc_cnf;
3261 tpDphHashNode sta_ds = NULL;
3262 tpPESession session_entry = NULL;
3263 uint8_t session_id;
3264 tpSirAssocReq assoc_req;
3265
3266 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 goto end;
3269 }
3270
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303271 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003273 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 goto end;
3275 }
3276
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003277 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 &session_id);
3279 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 goto end;
3282 }
3283
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003284 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3286 (session_entry->limSmeState !=
3287 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003288 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 msg_type, session_entry->limSmeState,
3290 GET_LIM_SYSTEM_ROLE(session_entry));
3291 goto end;
3292 }
3293 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3294 &session_entry->dph.dphHashTable);
3295 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003296 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303298 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299
3300 /*
3301 * send a DISASSOC_IND message to WSM to make sure
3302 * the state in WSM and LIM is the same
3303 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003304 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 eSIR_SME_STA_NOT_ASSOCIATED,
3306 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3307 session_entry->smeSessionId,
3308 session_entry->transactionId,
3309 session_entry);
3310 goto end;
3311 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303312 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003313 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303314 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003315 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303317 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 goto end;
3319 }
3320
3321 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3322 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3323 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3324 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3325 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003326 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3327 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303329 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 goto end;
3331 }
3332 /*
3333 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3334 * has been received
3335 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003336 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3338 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3339
3340 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3341 /*
3342 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3343 * when it had received Assoc Request frame. Now, PE just needs
3344 * to send association rsp frame to the requesting BTAMP-STA.
3345 */
3346 sta_ds->mlmStaContext.mlmState =
3347 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003348 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003350 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 sta_ds->assocId, sta_ds->staAddr,
3352 sta_ds->mlmStaContext.subType, sta_ds,
3353 session_entry);
3354 goto end;
3355 } else {
3356 /*
3357 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3358 * to be associated since the HAL sta entry is created for
3359 * denied STA we need to remove this HAL entry.
3360 * So to do that set updateContext to 1
3361 */
3362 if (!sta_ds->mlmStaContext.updateContext)
3363 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003364 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 assoc_cnf.statusCode, sta_ds->assocId);
3366 lim_reject_association(mac_ctx, sta_ds->staAddr,
3367 sta_ds->mlmStaContext.subType,
3368 true, sta_ds->mlmStaContext.authType,
3369 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003370 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 session_entry);
3372 }
3373end:
3374 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3375 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3376 assoc_req = (tpSirAssocReq)
3377 session_entry->parsedAssocReq[sta_ds->assocId];
3378 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303379 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 assoc_req->assocReqFrame = NULL;
3381 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303382 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3384 }
3385}
3386
3387static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3388{
3389 tpDphHashNode pStaDs;
3390 tSirMacAddr peerMac;
3391 tpSirAddtsReq pSirAddts;
3392 uint32_t timeout;
3393 tpPESession psessionEntry;
3394 uint8_t sessionId; /* PE sessionId */
3395 uint8_t smesessionId;
3396 uint16_t smetransactionId;
3397
3398 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003399 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 return;
3401 }
3402
3403 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3404 &smetransactionId);
3405
3406 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3407
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003408 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3409 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003411 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003412 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303413 NULL, pSirAddts->req.tspec,
3414 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 return;
3416 }
3417#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3418 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3419 0);
3420#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3421
3422 /* if sta
3423 * - verify assoc state
3424 * - send addts request to ap
3425 * - wait for addts response from ap
3426 * if ap, just ignore with error log
3427 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003428 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3429 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3430 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003432 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303434 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436
3437 pStaDs =
3438 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3439 &psessionEntry->dph.dphHashTable);
3440
3441 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003442 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303443 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 }
3445
3446 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3447 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003448 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303449 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 }
3451
3452 pSirAddts->req.wsmTspecPresent = 0;
3453 pSirAddts->req.wmeTspecPresent = 0;
3454 pSirAddts->req.lleTspecPresent = 0;
3455
3456 if ((pStaDs->wsmEnabled) &&
3457 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3458 SIR_MAC_ACCESSPOLICY_EDCA))
3459 pSirAddts->req.wsmTspecPresent = 1;
3460 else if (pStaDs->wmeEnabled)
3461 pSirAddts->req.wmeTspecPresent = 1;
3462 else if (pStaDs->lleEnabled)
3463 pSirAddts->req.lleTspecPresent = 1;
3464 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303466 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 }
3468
3469 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3470 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003471 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303473 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 }
3475
3476 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003477 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 pMac->lim.gLimAddtsReq.req.dialogToken,
3479 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3480 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3481 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303482 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 }
3484
3485 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3486
3487 /* save the addts request */
3488 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303489 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3491
3492 /* ship out the message now */
3493 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3494 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303495 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 /* start a timer to wait for the response */
3497 if (pSirAddts->timeout)
3498 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003499 else
3500 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501
3502 timeout = SYS_MS_TO_TICKS(timeout);
3503 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3504 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003505 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303506 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 }
3508 pMac->lim.gLimAddtsRspTimerCount++;
3509 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3510 pMac->lim.gLimAddtsRspTimerCount) !=
3511 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003512 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303513 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 }
3515 MTRACE(mac_trace
3516 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3517 eLIM_ADDTS_RSP_TIMER));
3518
3519 /* add the sessionId to the timer object */
3520 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3521 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3522 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003523 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303524 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 }
3526 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303527
3528send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003529 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303530 psessionEntry, pSirAddts->req.tspec,
3531 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532}
3533
3534static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3535{
3536 tSirMacAddr peerMacAddr;
3537 uint8_t ac;
3538 tSirMacTSInfo *pTsinfo;
3539 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3540 tpDphHashNode pStaDs = NULL;
3541 tpPESession psessionEntry;
3542 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003543 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 uint8_t smesessionId;
3545 uint16_t smetransactionId;
3546
3547 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3548 &smetransactionId);
3549
3550 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003551 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 &sessionId);
3553 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003554 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003555 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 goto end;
3557 }
3558#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3559 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3560 0);
3561#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3562
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003563 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003565 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003566 status = QDF_STATUS_E_FAILURE;
3567 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 smesessionId, smetransactionId);
3569 return;
3570 }
3571
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003572 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3573 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3575
3576 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3577 pDeltsReq->req.wmeTspecPresent,
3578 &pDeltsReq->req.tsinfo,
3579 &pDeltsReq->req.tspec, psessionEntry);
3580
3581 pTsinfo =
3582 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3583 tsinfo : &pDeltsReq->req.tsinfo;
3584
3585 /* We've successfully send DELTS frame to AP. Update the
3586 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3587 * is no longer trigger enabled or delivery enabled
3588 */
3589 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3590 pTsinfo, CLEAR_UAPSD_MASK);
3591
3592 /* We're deleting the TSPEC, so this particular AC is no longer
3593 * admitted. PE needs to downgrade the EDCA
3594 * parameters(for the AC for which TS is being deleted) to the
3595 * next best AC for which ACM is not enabled, and send the
3596 * updated values to HAL.
3597 */
3598 ac = upToAc(pTsinfo->traffic.userPrio);
3599
3600 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3601 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3602 ~(1 << ac);
3603 } else if (pTsinfo->traffic.direction ==
3604 SIR_MAC_DIRECTION_DNLINK) {
3605 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3606 ~(1 << ac);
3607 } else if (pTsinfo->traffic.direction ==
3608 SIR_MAC_DIRECTION_BIDIR) {
3609 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3610 ~(1 << ac);
3611 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3612 ~(1 << ac);
3613 }
3614
3615 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3616 psessionEntry);
3617
3618 pStaDs =
3619 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3620 &psessionEntry->dph.dphHashTable);
3621 if (pStaDs != NULL) {
3622 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003623 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003624 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003626 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003627 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631#endif
3632
3633 /* send an sme response back */
3634end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003635 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 smesessionId, smetransactionId);
3637}
3638
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303639void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640{
3641 /* fetch the sessionEntry based on the sessionId */
3642 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 psessionEntry = pe_find_session_by_session_id(pMac,
3645 pMac->lim.limTimers.gLimAddtsRspTimer.
3646 sessionId);
3647 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003648 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 return;
3650 }
3651
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003652 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003653 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 GET_LIM_SYSTEM_ROLE(psessionEntry));
3655 pMac->lim.gLimAddtsSent = false;
3656 return;
3657 }
3658
3659 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003660 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 return;
3662 }
3663
3664 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003665 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 pMac->lim.gLimAddtsRspTimerCount);
3667 return;
3668 }
3669 /* this a real response timeout */
3670 pMac->lim.gLimAddtsSent = false;
3671 pMac->lim.gLimAddtsRspTimerCount++;
3672
3673 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3674 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3675 psessionEntry->smeSessionId,
3676 psessionEntry->transactionId);
3677}
3678
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003679#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680/**
3681 * __lim_process_sme_get_statistics_request()
3682 *
3683 ***FUNCTION:
3684 *
3685 *
3686 ***NOTE:
3687 *
3688 * @param pMac Pointer to Global MAC structure
3689 * @param *pMsgBuf A pointer to the SME message buffer
3690 * @return None
3691 */
3692static void
3693__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3694{
3695 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003696 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697
3698 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3699
3700 msgQ.type = WMA_GET_STATISTICS_REQ;
3701
3702 msgQ.reserved = 0;
3703 msgQ.bodyptr = pMsgBuf;
3704 msgQ.bodyval = 0;
3705 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3706
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003707 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303708 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003710 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 return;
3712 }
3713
3714 return;
3715}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003716#else
3717static void __lim_process_sme_get_statistics_request(
Jeff Johnson009c40f2018-11-05 09:54:37 -08003718 struct mac_context *mac_ctx, uint32_t *pMsgBuf) {}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003719#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003721#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003723 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003725 * @pMac: Pointer to Global MAC structure
3726 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003728 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 */
3730static void
3731__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3732{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003733 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734
3735 msgQ.type = WMA_TSM_STATS_REQ;
3736 msgQ.reserved = 0;
3737 msgQ.bodyptr = pMsgBuf;
3738 msgQ.bodyval = 0;
3739 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3740
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003741 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303742 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003744 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 return;
3746 }
3747}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003748#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003750static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3751 struct sme_addba_accept *msg)
3752{
3753 if (!msg) {
3754 pe_err("Msg Buffer is NULL");
3755 return;
3756 }
3757 if (!msg->addba_accept)
3758 mac_ctx->reject_addba_req = 1;
3759 else
3760 mac_ctx->reject_addba_req = 0;
3761}
3762
Arif Hussaineb8ba362018-03-07 19:15:13 -08003763static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3764 uint32_t sme_session_id)
3765{
3766 tpPESession pe_session;
3767 tpDphHashNode sta_ds_ptr;
3768
3769 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3770 if (!pe_session) {
3771 pe_err("Session does not exist: sme_id %d", sme_session_id);
3772 return;
3773 }
3774 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3775 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3776 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3777 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3778 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3779 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3780 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3781 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3782 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3783 &pe_session->dph.dphHashTable);
3784 if (sta_ds_ptr)
3785 lim_send_edca_params(mac_ctx,
3786 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003787 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003788 else
3789 pe_err("Self entry missing in Hash Table");
3790}
3791
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003792static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3793 uint32_t sme_session_id)
3794{
3795 tpPESession pe_session;
3796 tpDphHashNode sta_ds_ptr;
3797
3798 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3799 if (!pe_session) {
3800 pe_err("Session does not exist: sme_id %d", sme_session_id);
3801 return;
3802 }
3803 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3804 &pe_session->dph.dphHashTable);
3805 if (sta_ds_ptr)
3806 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3807 sta_ds_ptr->bssId, true);
3808 else
3809 pe_err("Self entry missing in Hash Table");
3810}
3811
Naveen Rawat8029a402017-06-01 10:54:19 -07003812static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3813 struct update_config *msg)
3814{
3815 tpPESession pe_session;
3816
3817 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3818 if (msg == NULL) {
3819 pe_err("Buffer is Pointing to NULL");
3820 return;
3821 }
3822
3823 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3824 msg->sme_session_id);
3825 if (pe_session == NULL) {
3826 pe_warn("Session does not exist for given BSSID");
3827 return;
3828 }
3829
3830 switch (msg->capab) {
3831 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3832 pe_session->htConfig.ht_rx_ldpc = msg->value;
3833 break;
3834 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3835 pe_session->htConfig.ht_tx_stbc = msg->value;
3836 break;
3837 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3838 pe_session->htConfig.ht_rx_stbc = msg->value;
3839 break;
3840 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3841 pe_session->htConfig.ht_sgi20 = msg->value;
3842 break;
3843 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3844 pe_session->htConfig.ht_sgi40 = msg->value;
3845 break;
3846 }
3847
3848 if (LIM_IS_AP_ROLE(pe_session)) {
3849 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
Abhishek Singhfc740be2018-10-12 11:34:26 +05303850 lim_send_beacon_ind(mac_ctx, pe_session, REASON_CONFIG_UPDATE);
Naveen Rawat8029a402017-06-01 10:54:19 -07003851 }
3852}
3853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854void
3855lim_send_vdev_restart(tpAniSirGlobal pMac,
3856 tpPESession psessionEntry, uint8_t sessionId)
3857{
3858 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003859 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003860 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861
3862 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003863 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003864 return;
3865 }
3866
3867 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303868 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003869 if (!pHalHiddenSsidVdevRestart)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871
3872 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3873 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003874 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875
3876 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3877 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3878 msgQ.bodyval = 0;
3879
3880 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003881 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003882 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303883 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 }
3885}
3886
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303887/**
3888 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3889 * @mac_ctx: Pointer to Global MAC structure
3890 * @msg_buf: Pointer to SME message buffer
3891 *
3892 * Return: None
3893 */
3894static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3895 uint32_t *msg_buf)
3896{
3897 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003898 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003899 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303900 tSirRoamOffloadScanReq *req_buffer;
3901 uint16_t local_ie_len;
3902 uint8_t *local_ie_buf;
3903
3904 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3905 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3906 req_buffer->sessionId);
3907
3908 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3909 if (!local_ie_buf) {
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303910 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303911 return;
3912 }
3913
3914 local_ie_len = req_buffer->assoc_ie.length;
3915 /* Update ext cap IE if present */
3916 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003917 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3918 local_ie_buf, &local_ie_len)) {
3919 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003920 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3921 req_buffer->assoc_ie.length = local_ie_len;
3922 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3923 local_ie_buf, local_ie_len);
3924 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303925 }
3926 qdf_mem_free(local_ie_buf);
3927
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303928 if (pe_session)
3929 lim_update_fils_rik(pe_session, req_buffer);
3930
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303931 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3932 wma_msg.bodyptr = req_buffer;
3933
3934 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003935 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003936 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303937 qdf_mem_free(req_buffer);
3938 }
3939}
3940
Paul Zhang624f88d2018-11-07 15:29:45 +08003941#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3942/**
3943 * lim_process_roam_invoke() - process the Roam Invoke req
3944 * @mac_ctx: Pointer to Global MAC structure
3945 * @msg_buf: Pointer to the SME message buffer
3946 *
3947 * This function is called by limProcessMessageQueue(). This function sends the
3948 * ROAM_INVOKE command to WMA.
3949 *
3950 * Return: None
3951 */
3952static void lim_process_roam_invoke(tpAniSirGlobal mac_ctx,
3953 uint32_t *msg_buf)
3954{
3955 struct scheduler_msg msg = {0};
3956 QDF_STATUS status;
3957
3958 msg.type = SIR_HAL_ROAM_INVOKE;
3959 msg.bodyptr = msg_buf;
3960 msg.reserved = 0;
3961
3962 status = wma_post_ctrl_msg(mac_ctx, &msg);
3963 if (QDF_STATUS_SUCCESS != status)
3964 pe_err("Not able to post SIR_HAL_ROAM_INVOKE to WMA");
3965}
3966#else
3967static void lim_process_roam_invoke(tpAniSirGlobal mac_ctx,
3968 uint32_t *msg_buf)
3969{
3970 qdf_mem_free(msg_buf);
3971}
3972#endif
3973
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303974/*
3975 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3976 * @mac_ctx: Pointer to global mac context
3977 * @session: Pointer to PE session
3978 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3979 * 1 - Disable broadcast SSID
3980 *
3981 * Return: None
3982 */
3983static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3984 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003986 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003987 session->ssidHidden, ssid_hidden);
3988
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003989 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303990 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003991 } else {
3992 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303993 return;
3994 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995
Abhishek Singh6c681f42018-09-12 15:52:36 +05303996#ifdef CONFIG_VDEV_SM
3997 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3998 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3999 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
4000 sizeof(*session), session);
4001#else
4002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304004 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05304005#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304008}
4009
4010/**
4011 * __lim_process_sme_session_update - process SME session update msg
4012 *
4013 * @mac_ctx: Pointer to global mac context
4014 * @msg_buf: Pointer to the received message buffer
4015 *
4016 * Return: None
4017 */
4018static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4019 uint32_t *msg_buf)
4020{
4021 struct sir_update_session_param *msg;
4022 tpPESession session;
4023
4024 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004025 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304026 return;
4027 }
4028
4029 msg = (struct sir_update_session_param *) msg_buf;
4030
4031 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4032 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004033 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304034 msg->session_id);
4035 return;
4036 }
4037
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004038 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304039 msg->param_type, msg->param_val);
4040 switch (msg->param_type) {
4041 case SIR_PARAM_SSID_HIDDEN:
4042 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4043 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304044 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4045 session->ignore_assoc_disallowed = msg->param_val;
4046 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304047 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004048 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304049 break;
4050 }
4051}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053/*
4054 Update the beacon Interval dynamically if beaconInterval is different in MCC
4055 */
4056static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4057{
4058 tpSirChangeBIParams pChangeBIParams;
4059 tpPESession psessionEntry;
4060 uint8_t sessionId = 0;
4061 tUpdateBeaconParams beaconParams;
4062
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004063 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064
4065 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004066 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 return;
4068 }
4069
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304070 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4072
4073 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004074 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 &sessionId);
4076 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004077 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 return;
4079 }
4080
4081 /*Update sessionEntry Beacon Interval */
4082 if (psessionEntry->beaconParams.beaconInterval !=
4083 pChangeBIParams->beaconInterval) {
4084 psessionEntry->beaconParams.beaconInterval =
4085 pChangeBIParams->beaconInterval;
4086 }
4087
4088 /*Update sch beaconInterval */
4089 if (pMac->sch.schObject.gSchBeaconInterval !=
4090 pChangeBIParams->beaconInterval) {
4091 pMac->sch.schObject.gSchBeaconInterval =
4092 pChangeBIParams->beaconInterval;
4093
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004094 pe_debug("LIM send update BeaconInterval Indication: %d",
4095 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096
4097 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4098 /* Update beacon */
4099 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4100
4101 beaconParams.bssIdx = psessionEntry->bssIdx;
4102 /* Set change in beacon Interval */
4103 beaconParams.beaconInterval =
4104 pChangeBIParams->beaconInterval;
4105 beaconParams.paramChangeBitmap =
4106 PARAM_BCN_INTERVAL_CHANGED;
4107 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4108 }
4109 }
4110
4111 return;
4112} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4113
4114#ifdef QCA_HT_2040_COEX
4115static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4116 uint32_t *pMsgBuf)
4117{
4118 tpSirSetHT2040Mode pSetHT2040Mode;
4119 tpPESession psessionEntry;
4120 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004121 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 tUpdateVHTOpMode *pHtOpMode = NULL;
4123 uint16_t staId = 0;
4124 tpDphHashNode pStaDs = NULL;
4125
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004126 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004128 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 return;
4130 }
4131
4132 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4133
4134 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004135 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 &sessionId);
4137 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004138 pe_debug("Session does not exist for given BSSID");
4139 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 return;
4141 }
4142
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004143 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 pSetHT2040Mode->cbMode);
4145 /*Update sessionEntry HT related fields */
4146 switch (pSetHT2040Mode->cbMode) {
4147 case PHY_SINGLE_CHANNEL_CENTERED:
4148 psessionEntry->htSecondaryChannelOffset =
4149 PHY_SINGLE_CHANNEL_CENTERED;
4150 psessionEntry->htRecommendedTxWidthSet = 0;
4151 if (pSetHT2040Mode->obssEnabled)
4152 psessionEntry->htSupportedChannelWidthSet
4153 = eHT_CHANNEL_WIDTH_40MHZ;
4154 else
4155 psessionEntry->htSupportedChannelWidthSet
4156 = eHT_CHANNEL_WIDTH_20MHZ;
4157 break;
4158 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4159 psessionEntry->htSecondaryChannelOffset =
4160 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4161 psessionEntry->htRecommendedTxWidthSet = 1;
4162 break;
4163 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4164 psessionEntry->htSecondaryChannelOffset =
4165 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4166 psessionEntry->htRecommendedTxWidthSet = 1;
4167 break;
4168 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004169 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170 return;
4171 }
4172
4173 /* Update beacon */
4174 sch_set_fixed_beacon_fields(pMac, psessionEntry);
Abhishek Singhfc740be2018-10-12 11:34:26 +05304175 lim_send_beacon_ind(pMac, psessionEntry, REASON_SET_HT2040);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004176
4177 /* update OP Mode for each associated peer */
4178 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4179 pStaDs = dph_get_hash_entry(pMac, staId,
4180 &psessionEntry->dph.dphHashTable);
4181 if (NULL == pStaDs)
4182 continue;
4183
4184 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304185 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004186 if (!pHtOpMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 pHtOpMode->opMode =
4189 (psessionEntry->htSecondaryChannelOffset ==
4190 PHY_SINGLE_CHANNEL_CENTERED) ?
4191 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4192 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304193 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 sizeof(tSirMacAddr));
4195 pHtOpMode->smesessionId = sessionId;
4196
4197 msg.type = WMA_UPDATE_OP_MODE;
4198 msg.reserved = 0;
4199 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004200 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304201 (scheduler_post_message(QDF_MODULE_ID_PE,
4202 QDF_MODULE_ID_WMA,
4203 QDF_MODULE_ID_WMA,
4204 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004205 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304206 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 return;
4208 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004209 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004210 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
4212 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004213 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 }
4215
4216 return;
4217}
4218#endif
4219
4220/* -------------------------------------------------------------------- */
4221/**
4222 * __lim_process_report_message
4223 *
4224 * FUNCTION: Processes the next received Radio Resource Management message
4225 *
4226 * LOGIC:
4227 *
4228 * ASSUMPTIONS:
4229 *
4230 * NOTE:
4231 *
4232 * @param None
4233 * @return None
4234 */
4235
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004236static void __lim_process_report_message(tpAniSirGlobal pMac,
4237 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 switch (pMsg->type) {
4240 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4241 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4242 break;
4243 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004245 break;
4246 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004247 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004248 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249}
4250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251/* -------------------------------------------------------------------- */
4252/**
4253 * lim_send_set_max_tx_power_req
4254 *
4255 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4256 *
4257 * LOGIC:
4258 *
4259 * ASSUMPTIONS:
4260 *
4261 * NOTE:
4262 *
4263 * @param txPower txPower to be set.
4264 * @param pSessionEntry session entry.
4265 * @return None
4266 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004267QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004268lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 tpPESession pSessionEntry)
4270{
4271 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004272 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004273 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274
4275 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004276 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004277 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 }
4279
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304280 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004281 if (!pMaxTxParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004282 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304284 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304285 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004287 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304288 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289
4290 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4291 msgQ.bodyptr = pMaxTxParams;
4292 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004293 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4295 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004297 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304298 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 }
4300 return retCode;
4301}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302
4303/**
4304 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4305 *
4306 * @mac_ctx: Pointer to Global MAC structure
4307 * @msg_buf: pointer to the SME message buffer
4308 *
4309 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4310 * from SME. It Register this information within PE.
4311 *
4312 * Return: None
4313 */
4314static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4315 uint32_t *msg_buf)
4316{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304317 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4319 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4320 struct mgmt_frm_reg_info *next = NULL;
4321 bool match = false;
4322
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004323 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 sme_req->registerFrame, sme_req->frameType,
4325 sme_req->matchLen);
4326 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304327 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304328 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4329 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304330 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331
4332 while (lim_mgmt_regn != NULL) {
4333 if (lim_mgmt_regn->frameType != sme_req->frameType)
4334 goto skip_match;
4335 if (sme_req->matchLen) {
4336 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304337 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 sme_req->matchData,
4339 lim_mgmt_regn->matchLen))) {
4340 /* found match! */
4341 match = true;
4342 break;
4343 }
4344 } else {
4345 /* found match! */
4346 match = true;
4347 break;
4348 }
4349skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304350 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304351 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304353 (qdf_list_node_t *)lim_mgmt_regn,
4354 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304355 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 lim_mgmt_regn = next;
4357 next = NULL;
4358 }
4359 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304360 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004361 if (QDF_STATUS_SUCCESS ==
4362 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004364 (qdf_list_node_t *)lim_mgmt_regn))
4365 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304366 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 }
4368
4369 if (sme_req->registerFrame) {
4370 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304371 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 sme_req->matchLen);
4373 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 lim_mgmt_regn->frameType = sme_req->frameType;
4375 lim_mgmt_regn->matchLen = sme_req->matchLen;
4376 lim_mgmt_regn->sessionId = sme_req->sessionId;
4377 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304378 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 sme_req->matchData,
4380 sme_req->matchLen);
4381 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304382 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304384 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385 gLimMgmtFrameRegistratinQueue,
4386 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304387 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 &mac_ctx->lim.lim_frame_register_lock);
4389 }
4390 }
4391 return;
4392}
4393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394static void
4395__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4396{
4397 tpSirResetAPCapsChange pResetCapsChange;
4398 tpPESession psessionEntry;
4399 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004402 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 return;
4404 }
4405
4406 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4407 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004408 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4409 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004411 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 return;
4413 }
4414
4415 psessionEntry->limSentCapsChangeNtf = false;
4416 return;
4417}
4418
4419/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304420 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4421 * indication callback in PE.
4422 * @mac_ptr: Mac pointer
4423 * @msg_buf: Msg pointer containing the callback
4424 *
4425 * This function is used save the Management frame
4426 * indication callback in PE.
4427 *
4428 * Return: None
4429 */
4430static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4431 uint32_t *msg_buf)
4432{
4433 struct sir_sme_mgmt_frame_cb_req *sme_req =
4434 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4435
4436 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004437 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304438 return;
4439 }
4440 if (sme_req->callback)
4441 mac_ctx->mgmt_frame_ind_cb =
4442 (sir_mgmt_frame_ind_callback)sme_req->callback;
4443 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004444 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304445}
4446
4447/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304448 *__lim_process_send_disassoc_frame: function processes disassoc frame
4449 * @mac_ctx: pointer to mac context
4450 * @msg_buf: message buffer
4451 *
4452 * function processes disassoc request received from SME
4453 *
4454 * return: none
4455 */
4456static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4457 uint32_t *msg_buf)
4458{
4459 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004460 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304461 tpPESession session_entry = NULL;
4462 uint8_t sme_session_id;
4463 uint16_t sme_trans_id;
4464
4465 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004466 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304467 return;
4468 }
4469
4470 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4471 &sme_trans_id);
4472
4473 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4474 &sme_send_disassoc_frame_req,
4475 (uint8_t *)msg_buf);
4476
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004477 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304478 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4479 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004480 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304481 return;
4482 }
4483
4484 session_entry = pe_find_session_by_sme_session_id(
4485 mac_ctx, sme_session_id);
4486 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004487 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304488 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4489 return;
4490 }
4491
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004492 pe_debug("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d",
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304493 sme_send_disassoc_frame_req.msg_type,
4494 sme_send_disassoc_frame_req.length,
4495 sme_send_disassoc_frame_req.session_id,
4496 sme_send_disassoc_frame_req.trans_id,
4497 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4498 sme_send_disassoc_frame_req.reason,
4499 sme_send_disassoc_frame_req.wait_for_ack);
4500
4501 lim_send_disassoc_mgmt_frame(mac_ctx,
4502 sme_send_disassoc_frame_req.reason,
4503 sme_send_disassoc_frame_req.peer_mac,
4504 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4505}
4506
4507/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004508 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4509 * @mac_ctx: Pointer to Global MAC structure
4510 * @pdev_id: pdev id to set the IE.
4511 * @nss: Nss values to prepare the HT IE.
4512 *
4513 * Prepares the HT IE with self capabilities for different
4514 * Nss values and sends the set HT IE req to FW.
4515 *
4516 * Return: None
4517 */
4518static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4519 uint8_t nss)
4520{
4521 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004522 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004523 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004524 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004525 tHtCaps *p_ht_cap;
4526 int i;
4527
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004528 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004529 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004530 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004531 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004532 ie_params->nss = i;
4533 ie_params->pdev_id = pdev_id;
4534 ie_params->ie_type = DOT11_HT_IE;
4535 /* 2 for IE len and EID */
4536 ie_params->ie_len = 2 + sizeof(tHtCaps);
4537 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004538 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004539 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004540 return;
4541 }
4542 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4543 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4544 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4545 ie_params->ie_len);
4546
4547 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004548 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4549 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004550 if (NULL == p_ie) {
4551 qdf_mem_free(ie_params->ie_ptr);
4552 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004553 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004554 return;
4555 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004556 p_ht_cap = (tHtCaps *)&p_ie[2];
4557 p_ht_cap->supportedMCSSet[1] = 0;
4558 p_ht_cap->txSTBC = 0;
4559 }
4560
4561 msg.type = WMA_SET_PDEV_IE_REQ;
4562 msg.bodyptr = ie_params;
4563 msg.bodyval = 0;
4564
4565 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004566 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004567 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004568 qdf_mem_free(ie_params->ie_ptr);
4569 qdf_mem_free(ie_params);
4570 return;
4571 }
4572 }
4573}
4574
4575/**
4576 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4577 * @mac_ctx: Pointer to Global MAC structure
4578 * @pdev_id: pdev id to set the IE.
4579 * @nss: Nss values to prepare the VHT IE.
4580 *
4581 * Prepares the VHT IE with self capabilities for different
4582 * Nss values and sends the set VHT IE req to FW.
4583 *
4584 * Return: None
4585 */
4586static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4587 uint8_t nss)
4588{
4589 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004590 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004591 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004592 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004593 tSirMacVHTCapabilityInfo *vht_cap;
4594 int i;
4595 tSirVhtMcsInfo *vht_mcs;
4596
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004597 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004598 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004599 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004600 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004601 ie_params->nss = i;
4602 ie_params->pdev_id = pdev_id;
4603 ie_params->ie_type = DOT11_VHT_IE;
4604 /* 2 for IE len and EID */
4605 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4606 sizeof(tSirVhtMcsInfo);
4607 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004608 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004609 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004610 return;
4611 }
4612 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4613 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4614 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4615 ie_params->ie_len);
4616
4617 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004618 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4619 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004620 if (NULL == p_ie) {
4621 qdf_mem_free(ie_params->ie_ptr);
4622 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004623 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004624 return;
4625 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004626 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4627 vht_cap->txSTBC = 0;
4628 vht_mcs =
4629 (tSirVhtMcsInfo *)&p_ie[2 +
4630 sizeof(tSirMacVHTCapabilityInfo)];
4631 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4632 vht_mcs->rxHighest =
4633 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4634 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4635 vht_mcs->txHighest =
4636 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4637 }
4638 msg.type = WMA_SET_PDEV_IE_REQ;
4639 msg.bodyptr = ie_params;
4640 msg.bodyval = 0;
4641
4642 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004643 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004644 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004645 qdf_mem_free(ie_params->ie_ptr);
4646 qdf_mem_free(ie_params);
4647 return;
4648 }
4649 }
4650}
4651
4652/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004653 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4654 * @mac_ctx: Pointer to Global MAC structure
4655 * @msg_buf: Pointer to the SME message buffer
4656 *
4657 * This function is called by limProcessMessageQueue(). This function sets the
4658 * VDEV IEs to the FW.
4659 *
4660 * Return: None
4661 */
4662static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4663 uint32_t *msg_buf)
4664{
4665 struct sir_set_vdev_ies_per_band *p_msg =
4666 (struct sir_set_vdev_ies_per_band *)msg_buf;
4667
4668 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004669 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004670 return;
4671 }
4672
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004673 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004674 p_msg->vdev_id);
4675 /* intentionally using NULL here so that self capabilty are sent */
4676 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4677 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004678 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004679}
4680
4681/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004682 * lim_process_set_pdev_IEs() - process the set pdev IE req
4683 * @mac_ctx: Pointer to Global MAC structure
4684 * @msg_buf: Pointer to the SME message buffer
4685 *
4686 * This function is called by limProcessMessageQueue(). This
4687 * function sets the PDEV IEs to the FW.
4688 *
4689 * Return: None
4690 */
4691static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4692{
4693 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4694
4695 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4696
4697 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004698 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004699 return;
4700 }
4701
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004702 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004703 ht_vht_cfg->nss);
4704 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4705
4706 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4707 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4708 ht_vht_cfg->nss);
4709}
4710
4711/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304712 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4713 *
4714 * access policy
4715 * @mac_ctx: pointer to mac context
4716 * @msg: message buffer
4717 *
4718 * function processes vendor IE and access policy from SME and updates PE
4719 *
4720 * session entry
4721 *
4722 * return: none
4723*/
4724static void lim_process_sme_update_access_policy_vendor_ie(
4725 tpAniSirGlobal mac_ctx,
4726 uint32_t *msg)
4727{
4728 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
Jeff Johnson0f99bd82018-11-18 18:42:12 -08004729 struct pe_session *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304730 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304731
4732 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004733 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304734 return;
4735 }
4736 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4737 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4738 update_vendor_ie->sme_session_id);
4739
4740 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004741 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304742 update_vendor_ie->sme_session_id);
4743 return;
4744 }
4745 if (pe_session_entry->access_policy_vendor_ie)
4746 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4747
4748 num_bytes = update_vendor_ie->ie[1] + 2;
4749 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004750 if (!pe_session_entry->access_policy_vendor_ie)
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304751 return;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304752 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4753 &update_vendor_ie->ie[0], num_bytes);
4754
4755 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4756}
4757
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004758#ifdef CONFIG_VDEV_SM
4759QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4760 uint16_t data_len, void *data)
4761{
4762 tpAniSirGlobal mac_ctx;
4763 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4764
4765 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4766 if (!mac_ctx) {
4767 pe_err("mac_ctx is NULL");
4768 if (data)
4769 qdf_mem_free(data);
4770 return QDF_STATUS_E_INVAL;
4771 }
4772 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4773
4774 switch (msg->type) {
4775 case eWNI_SME_DEAUTH_REQ:
4776 __lim_process_sme_deauth_req(mac_ctx,
4777 (uint32_t *)msg->bodyptr);
4778 break;
4779 case eWNI_SME_DISASSOC_CNF:
4780 case eWNI_SME_DEAUTH_CNF:
4781 __lim_process_sme_disassoc_cnf(mac_ctx,
4782 (uint32_t *)msg->bodyptr);
4783 break;
4784 case eWNI_SME_DISASSOC_REQ:
4785 __lim_process_sme_disassoc_req(mac_ctx,
4786 (uint32_t *)msg->bodyptr);
4787 break;
4788 default:
4789 pe_debug("Wrong message type received %d", msg->type);
4790 }
4791 return QDF_STATUS_SUCCESS;
4792}
4793#endif
4794
4795static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4796 struct scheduler_msg *msg)
4797{
4798#ifdef CONFIG_VDEV_SM
4799 tSirSmeDisassocCnf sme_disassoc_cnf;
4800 tpPESession session;
4801 uint8_t session_id;
4802 QDF_STATUS status;
4803
4804 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4805 sizeof(struct sSirSmeDisassocCnf));
4806
4807 session = pe_find_session_by_bssid(mac_ctx,
4808 sme_disassoc_cnf.bssid.bytes,
4809 &session_id);
4810
4811 if (LIM_IS_STA_ROLE(session)) {
4812 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4813 WLAN_VDEV_SM_EV_DOWN,
4814 sizeof(*msg),
4815 msg);
4816 } else {
4817 __lim_process_sme_disassoc_cnf(mac_ctx,
4818 (uint32_t *)msg->bodyptr);
4819 }
4820#else
4821 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4822#endif
4823}
4824
4825static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4826 struct scheduler_msg *msg)
4827{
4828#ifdef CONFIG_VDEV_SM
4829 tSirSmeDisassocReq disassoc_req;
4830 tpPESession session;
4831 uint8_t session_id;
4832 QDF_STATUS status;
4833
4834 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4835
4836 session = pe_find_session_by_bssid(mac_ctx,
4837 disassoc_req.bssid.bytes,
4838 &session_id);
4839 if (LIM_IS_STA_ROLE(session)) {
4840 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4841 WLAN_VDEV_SM_EV_DOWN,
4842 sizeof(*msg),
4843 msg);
4844 } else {
4845 __lim_process_sme_disassoc_req(mac_ctx,
4846 (uint32_t *)msg->bodyptr);
4847 }
4848#else
4849 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4850#endif
4851}
4852
4853static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4854 struct scheduler_msg *msg)
4855{
4856#ifdef CONFIG_VDEV_SM
4857 tSirSmeDeauthReq sme_deauth_req;
4858 tpPESession session;
4859 uint8_t session_id;
4860 QDF_STATUS status;
4861
4862 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4863
4864 session = pe_find_session_by_bssid(mac_ctx,
4865 sme_deauth_req.bssid.bytes,
4866 &session_id);
4867 if (LIM_IS_STA_ROLE(session)) {
4868 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4869 WLAN_VDEV_SM_EV_DOWN,
4870 sizeof(*msg),
4871 msg);
4872 } else {
4873 __lim_process_sme_deauth_req(mac_ctx,
4874 (uint32_t *)msg->bodyptr);
4875 }
4876#else
4877 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4878#endif
4879}
4880
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304881/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 * lim_process_sme_req_messages()
4883 *
4884 ***FUNCTION:
4885 * This function is called by limProcessMessageQueue(). This
4886 * function processes SME request messages from HDD or upper layer
4887 * application.
4888 *
4889 ***LOGIC:
4890 *
4891 ***ASSUMPTIONS:
4892 *
4893 ***NOTE:
4894 *
4895 * @param pMac Pointer to Global MAC structure
4896 * @param msgType Indicates the SME message type
4897 * @param *pMsgBuf A pointer to the SME message buffer
4898 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4899 * false - if pMsgBuf is not to be freed.
4900 */
4901
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004902bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4903 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904{
Jeff Johnson33142e62018-05-06 17:58:36 -07004905 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesn't want pMsgBuf to be freed. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004907
4908 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 lim_msg_str(pMsg->type), pMsg->type,
4910 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4911 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913 /* If no insert NOA required then execute the code below */
4914
4915 switch (pMsg->type) {
4916 case eWNI_SME_SYS_READY_IND:
4917 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4918 break;
4919
4920 case eWNI_SME_START_BSS_REQ:
4921 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4922 break;
4923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4925 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4926 break;
4927 case eWNI_SME_JOIN_REQ:
4928 __lim_process_sme_join_req(pMac, pMsgBuf);
4929 break;
4930
4931 case eWNI_SME_REASSOC_REQ:
4932 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4933 break;
4934
4935 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004936 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 break;
4938
4939 case eWNI_SME_DISASSOC_CNF:
4940 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004941 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 break;
4943
4944 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004945 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 break;
4947
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304948 case eWNI_SME_SEND_DISASSOC_FRAME:
4949 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4950 break;
4951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 case eWNI_SME_SETCONTEXT_REQ:
4953 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4954 break;
4955
4956 case eWNI_SME_STOP_BSS_REQ:
4957 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4958 break;
4959
4960 case eWNI_SME_ASSOC_CNF:
4961 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004962 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004963 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4964 pMsgBuf);
4965 break;
4966
4967 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004968 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004969 __lim_process_sme_addts_req(pMac, pMsgBuf);
4970 break;
4971
4972 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004973 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 __lim_process_sme_delts_req(pMac, pMsgBuf);
4975 break;
4976
4977 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004978 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4980 break;
4981
4982 case eWNI_SME_GET_STATISTICS_REQ:
4983 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4984 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4985 bufConsumed = false;
4986 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004987#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 case eWNI_SME_GET_TSM_STATS_REQ:
4989 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4990 bufConsumed = false;
4991 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004992#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 case eWNI_SME_GET_ASSOC_STAS_REQ:
4994 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4995 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304996 case eWNI_SME_SESSION_UPDATE_PARAM:
4997 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304999 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5000 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5001 bufConsumed = false;
5002 break;
Paul Zhang624f88d2018-11-07 15:29:45 +08005003 case eWNI_SME_ROAM_INVOKE:
5004 lim_process_roam_invoke(pMac, pMsgBuf);
5005 bufConsumed = false;
5006 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005007 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5008 /* Update the beaconInterval */
5009 __lim_process_sme_change_bi(pMac, pMsgBuf);
5010 break;
5011
5012#ifdef QCA_HT_2040_COEX
5013 case eWNI_SME_SET_HT_2040_MODE:
5014 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5015 break;
5016#endif
5017
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5019 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5020 __lim_process_report_message(pMac, pMsg);
5021 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023 case eWNI_SME_FT_PRE_AUTH_REQ:
5024 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5025 break;
5026 case eWNI_SME_FT_UPDATE_KEY:
5027 lim_process_ft_update_key(pMac, pMsgBuf);
5028 break;
5029
5030 case eWNI_SME_FT_AGGR_QOS_REQ:
5031 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5032 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033
5034 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5035 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5036 break;
5037#ifdef FEATURE_WLAN_TDLS
5038 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5039 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5040 break;
5041 case eWNI_SME_TDLS_ADD_STA_REQ:
5042 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5043 break;
5044 case eWNI_SME_TDLS_DEL_STA_REQ:
5045 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5046 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005047#endif
5048 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5049 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5050 break;
5051
5052 case eWNI_SME_CHANNEL_CHANGE_REQ:
5053 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5054 break;
5055
5056 case eWNI_SME_START_BEACON_REQ:
5057 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5058 break;
5059
5060 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5061 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5062 break;
5063
5064 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5065 lim_process_update_add_ies(pMac, pMsgBuf);
5066 break;
5067
5068 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5069 lim_process_modify_add_ies(pMac, pMsgBuf);
5070 break;
5071 case eWNI_SME_SET_HW_MODE_REQ:
5072 lim_process_set_hw_mode(pMac, pMsgBuf);
5073 break;
5074 case eWNI_SME_NSS_UPDATE_REQ:
5075 lim_process_nss_update_request(pMac, pMsgBuf);
5076 break;
5077 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5078 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5079 break;
5080 case eWNI_SME_SET_IE_REQ:
5081 lim_process_set_ie_req(pMac, pMsgBuf);
5082 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305083 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5084 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5085 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305086 case eWNI_SME_EXT_CHANGE_CHANNEL:
5087 lim_process_ext_change_channel(pMac, pMsgBuf);
5088 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005089 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5090 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5091 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005092 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5093 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005094 break;
5095 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5096 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5097 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305098 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5099 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5100 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005101 case eWNI_SME_UPDATE_CONFIG:
5102 lim_process_sme_update_config(pMac,
5103 (struct update_config *)pMsgBuf);
5104 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005105 case eWNI_SME_SET_ADDBA_ACCEPT:
5106 lim_process_sme_set_addba_accept(pMac,
5107 (struct sme_addba_accept *)pMsgBuf);
5108 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005109 case eWNI_SME_UPDATE_EDCA_PROFILE:
5110 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5111 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005112 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5113 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5114 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305116 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 pMsg->bodyptr = NULL;
5118 break;
5119 } /* switch (msgType) */
5120
5121 return bufConsumed;
5122} /*** end lim_process_sme_req_messages() ***/
5123
5124/**
5125 * lim_process_sme_start_beacon_req()
5126 *
5127 ***FUNCTION:
5128 * This function is called by limProcessMessageQueue(). This
5129 * function processes SME request messages from HDD or upper layer
5130 * application.
5131 *
5132 ***LOGIC:
5133 *
5134 ***ASSUMPTIONS:
5135 *
5136 ***NOTE:
5137 *
5138 * @param pMac Pointer to Global MAC structure
5139 * @param msgType Indicates the SME message type
5140 * @param *pMsgBuf A pointer to the SME message buffer
5141 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5142 * false - if pMsgBuf is not to be freed.
5143 */
5144static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5145{
5146 tpSirStartBeaconIndication pBeaconStartInd;
5147 tpPESession psessionEntry;
5148 uint8_t sessionId; /* PE sessionID */
5149
5150 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005151 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152 return;
5153 }
5154
5155 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5156 psessionEntry = pe_find_session_by_bssid(pMac,
5157 pBeaconStartInd->bssid,
5158 &sessionId);
5159 if (psessionEntry == NULL) {
5160 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005161 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 return;
5163 }
5164
5165 if (pBeaconStartInd->beaconStartStatus == true) {
5166 /*
5167 * Currently this Indication comes from SAP
5168 * to start Beacon Tx on a DFS channel
5169 * since beaconing has to be done on DFS
5170 * channel only after CAC WAIT is completed.
5171 * On a DFS Channel LIM does not start beacon
5172 * Tx right after the WMA_ADD_BSS_RSP.
5173 */
5174 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305175 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 FL("Start Beacon with ssid %s Ch %d"),
5177 psessionEntry->ssId.ssId,
5178 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305179 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005180 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005181 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5182 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005184 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185 return;
5186 }
5187}
5188
5189/**
5190 * lim_process_sme_channel_change_request() - process sme ch change req
5191 *
5192 * @mac_ctx: Pointer to Global MAC structure
5193 * @msg_buf: pointer to the SME message buffer
5194 *
5195 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5196 *
5197 * Return: None
5198 */
5199static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5200 uint32_t *msg_buf)
5201{
5202 tpSirChanChangeRequest ch_change_req;
5203 tpPESession session_entry;
5204 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005205 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 uint32_t val = 0;
5207
5208 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005209 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 return;
5211 }
5212 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5213
5214 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5215 ch_change_req->targetChannel);
5216
5217 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5218 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005219 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005220 return;
5221 }
5222
5223 session_entry = pe_find_session_by_bssid(mac_ctx,
5224 ch_change_req->bssid, &session_id);
5225 if (session_entry == NULL) {
5226 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005227 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228 return;
5229 }
5230
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005231 if ((session_entry->currentOperChannel ==
5232 ch_change_req->targetChannel) &&
5233 (session_entry->ch_width == ch_change_req->ch_width)) {
5234 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5235 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 return;
5237 }
5238
5239 if (LIM_IS_AP_ROLE(session_entry))
5240 session_entry->channelChangeReasonCode =
5241 LIM_SWITCH_CHANNEL_SAP_DFS;
5242 else
5243 session_entry->channelChangeReasonCode =
5244 LIM_SWITCH_CHANNEL_OPERATION;
5245
Bala Venkateshb39ed152017-12-26 19:35:27 +05305246 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5247 session_entry->currentOperChannel,
5248 ch_change_req->targetChannel,
5249 ch_change_req->ch_width,
5250 ch_change_req->nw_type,
5251 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252
5253 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005254 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 session_entry->ch_center_freq_seg0 =
5256 ch_change_req->center_freq_seg_0;
5257 session_entry->ch_center_freq_seg1 =
5258 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005259 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005261 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 session_entry->htRecommendedTxWidthSet =
5263 session_entry->htSupportedChannelWidthSet;
5264 session_entry->currentOperChannel =
5265 ch_change_req->targetChannel;
5266 session_entry->limRFBand =
5267 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305268 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5269 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5270 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305271
5272 /* Update the global beacon filter */
5273 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5274
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005276 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005277 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005279 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005280 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 }
5282
5283 session_entry->lim11hEnable = val;
5284 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305285 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305286 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005287 &ch_change_req->operational_rateset,
5288 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305289 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 &ch_change_req->extended_rateset,
5291 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305292
5293#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305294 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305295 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5296 WLAN_VDEV_S_DFS_CAC_WAIT)
5297 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5298 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5299 sizeof(*session_entry),
5300 session_entry);
5301 else
5302 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5303 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5304 sizeof(*session_entry),
5305 session_entry);
5306
5307
5308#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5310 session_entry->ch_center_freq_seg0,
5311 session_entry->ch_center_freq_seg1,
5312 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005313 max_tx_pwr, session_entry->peSessionId,
5314 ch_change_req->cac_duration_ms,
5315 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305316#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317}
5318
5319/******************************************************************************
5320* lim_start_bss_update_add_ie_buffer()
5321*
5322***FUNCTION:
5323* This function checks the src buffer and its length and then malloc for
5324* dst buffer update the same
5325*
5326***LOGIC:
5327*
5328***ASSUMPTIONS:
5329*
5330***NOTE:
5331*
5332* @param pMac Pointer to Global MAC structure
5333* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5334* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5335* @param *pSrcData_buff A pointer of uint8_t src buffer
5336* @param srcDataLen src buffer length
5337******************************************************************************/
5338
5339static void
5340lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5341 uint8_t **pDstData_buff,
5342 uint16_t *pDstDataLen,
5343 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5344{
5345
5346 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5347 *pDstDataLen = srcDataLen;
5348
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305349 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005350 if (!*pDstData_buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305352 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 } else {
5354 *pDstData_buff = NULL;
5355 *pDstDataLen = 0;
5356 }
5357}
5358
5359/******************************************************************************
5360* lim_update_add_ie_buffer()
5361*
5362***FUNCTION:
5363* This function checks the src buffer and length if src buffer length more
5364* than dst buffer length then free the dst buffer and malloc for the new src
5365* length, and update the dst buffer and length. But if dst buffer is bigger
5366* than src buffer length then it just update the dst buffer and length
5367*
5368***LOGIC:
5369*
5370***ASSUMPTIONS:
5371*
5372***NOTE:
5373*
5374* @param pMac Pointer to Global MAC structure
5375* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5376* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5377* @param *pSrcData_buff A pointer of uint8_t src buffer
5378* @param srcDataLen src buffer length
5379******************************************************************************/
5380
5381static void
5382lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5383 uint8_t **pDstData_buff,
5384 uint16_t *pDstDataLen,
5385 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5386{
5387
5388 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005389 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 return;
5391 }
5392
5393 if (srcDataLen > *pDstDataLen) {
5394 *pDstDataLen = srcDataLen;
5395 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305396 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305398 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005399 if (!*pDstData_buff) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400 *pDstDataLen = 0;
5401 return;
5402 }
5403 }
5404
5405 /* copy the content of buffer into dst buffer
5406 */
5407 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305408 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409
5410}
5411
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005412/**
5413 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5414 * @pMac : Pointer to Global MAC structure
5415 * @pDstData_buff : A pointer to pointer of dst buffer
5416 * @pDstDataLen : A pointer to pointer of dst buffer length
5417 * @pModifyIE : A pointer to tSirModifyIE
5418 *
5419 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5420 *
5421 * Return:
5422 * True or false depending upon whether IE is updated or not
5423 */
5424static bool
5425lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5426 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5427{
Hong Shi1553d692016-09-28 12:16:19 +08005428 int32_t oui_length;
5429 uint8_t *ibss_ie = NULL;
5430 uint8_t *vendor_ie;
5431#define MAC_VENDOR_OUI "\x00\x16\x32"
5432#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005433
5434 ibss_ie = pModifyIE->pIEBuffer;
5435 oui_length = pModifyIE->oui_length;
5436
5437 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005438 pe_err("Invalid set IBSS vendor IE command length %d",
5439 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005440 return false;
5441 }
5442
Hong Shi1553d692016-09-28 12:16:19 +08005443 /*
5444 * Why replace only beacon OUI data here:
5445 * 1. other ie (such as wpa) shall not be overwritten here.
5446 * 2. per spec, beacon oui ie might be set twice and original one
5447 * shall be updated.
5448 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005449 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005450 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5451 if (vendor_ie) {
5452 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5453 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5454 pModifyIE->ieBufferlength);
5455 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005456 uint16_t new_length;
5457 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005458
Naveen Rawat668dee32017-09-29 14:39:40 -07005459 /*
5460 * check for uint16 overflow before using sum of two numbers as
5461 * length of size to malloc
5462 */
5463 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5464 pe_err("U16 overflow due to %d + %d",
5465 pModifyIE->ieBufferlength, *pDstDataLen);
5466 return false;
5467 }
5468
5469 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5470 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005471 if (!new_ptr)
Hong Shi1553d692016-09-28 12:16:19 +08005472 return false;
Hong Shi1553d692016-09-28 12:16:19 +08005473 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5474 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5475 pModifyIE->ieBufferlength);
5476 qdf_mem_free(*pDstData_buff);
5477 *pDstDataLen = new_length;
5478 *pDstData_buff = new_ptr;
5479 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005480 return true;
5481}
5482
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483/*
5484* lim_process_modify_add_ies() - process modify additional IE req.
5485*
5486* @mac_ctx: Pointer to Global MAC structure
5487* @msg_buf: pointer to the SME message buffer
5488*
5489* This function update the PE buffers for additional IEs.
5490*
5491* Return: None
5492*/
5493static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5494 uint32_t *msg_buf)
5495{
5496 tpSirModifyIEsInd modify_add_ies;
5497 tpPESession session_entry;
5498 uint8_t session_id;
5499 bool ret = false;
5500 tSirAddIeParams *add_ie_params;
5501
5502 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005503 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 return;
5505 }
5506
5507 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5508 /* Incoming message has smeSession, use BSSID to find PE session */
5509 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005510 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511
5512 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005513 pe_err("Session not found for given bssid"
5514 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005515 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 goto end;
5517 }
5518 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5519 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5520 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005521 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 modify_add_ies->modifyIE.pIEBuffer,
5523 modify_add_ies->modifyIE.ieBufferlength,
5524 modify_add_ies->modifyIE.ieID,
5525 modify_add_ies->modifyIE.ieIDLen,
5526 modify_add_ies->updateType);
5527 goto end;
5528 }
5529 add_ie_params = &session_entry->addIeParams;
5530 switch (modify_add_ies->updateType) {
5531 case eUPDATE_IE_PROBE_RESP:
5532 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005533 if (LIM_IS_IBSS_ROLE(session_entry)) {
5534 lim_update_ibss_prop_add_ies(mac_ctx,
5535 &add_ie_params->probeRespData_buff,
5536 &add_ie_params->probeRespDataLen,
5537 &modify_add_ies->modifyIE);
5538 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 break;
5540 case eUPDATE_IE_ASSOC_RESP:
5541 /* assoc resp IE */
5542 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305543 QDF_TRACE(QDF_MODULE_ID_PE,
5544 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 "assoc resp add ie not present %d"),
5546 add_ie_params->assocRespDataLen);
5547 }
5548 /* search through the buffer and modify the IE */
5549 break;
5550 case eUPDATE_IE_PROBE_BCN:
5551 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005552 if (LIM_IS_IBSS_ROLE(session_entry)) {
5553 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5554 &add_ie_params->probeRespBCNData_buff,
5555 &add_ie_params->probeRespBCNDataLen,
5556 &modify_add_ies->modifyIE);
5557 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 if (ret == true && modify_add_ies->modifyIE.notify) {
5559 lim_handle_param_update(mac_ctx,
5560 modify_add_ies->updateType);
5561 }
5562 break;
5563 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005564 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 modify_add_ies->updateType);
5566 break;
5567 }
5568end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305569 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 modify_add_ies->modifyIE.pIEBuffer = NULL;
5571}
5572
5573/*
5574* lim_process_update_add_ies() - process additional IE update req
5575*
5576* @mac_ctx: Pointer to Global MAC structure
5577* @msg_buf: pointer to the SME message buffer
5578*
5579* This function update the PE buffers for additional IEs.
5580*
5581* Return: None
5582*/
5583static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5584 uint32_t *msg_buf)
5585{
5586 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5587 uint8_t session_id;
5588 tpPESession session_entry;
5589 tSirAddIeParams *addn_ie;
5590 uint16_t new_length = 0;
5591 uint8_t *new_ptr = NULL;
5592 tSirUpdateIE *update_ie;
5593
5594 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005595 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 return;
5597 }
5598 update_ie = &update_add_ies->updateIE;
5599 /* incoming message has smeSession, use BSSID to find PE session */
5600 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005601 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602
5603 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305604 pe_debug("Session not found for given bssid"
5605 MAC_ADDRESS_STR,
5606 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 goto end;
5608 }
5609 addn_ie = &session_entry->addIeParams;
5610 /* if len is 0, upper layer requested freeing of buffer */
5611 if (0 == update_ie->ieBufferlength) {
5612 switch (update_add_ies->updateType) {
5613 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305614 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 addn_ie->probeRespData_buff = NULL;
5616 addn_ie->probeRespDataLen = 0;
5617 break;
5618 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305619 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 addn_ie->assocRespData_buff = NULL;
5621 addn_ie->assocRespDataLen = 0;
5622 break;
5623 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305624 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 addn_ie->probeRespBCNData_buff = NULL;
5626 addn_ie->probeRespBCNDataLen = 0;
5627
5628 if (update_ie->notify)
5629 lim_handle_param_update(mac_ctx,
5630 update_add_ies->updateType);
5631 break;
5632 default:
5633 break;
5634 }
5635 return;
5636 }
5637 switch (update_add_ies->updateType) {
5638 case eUPDATE_IE_PROBE_RESP:
5639 if (update_ie->append) {
5640 /*
5641 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005642 * with combined length.
5643 * Multiple back to back append commands
5644 * can lead to a huge length.So, check
5645 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005647 if (addn_ie->probeRespDataLen >
5648 (USHRT_MAX - update_ie->ieBufferlength)) {
5649 pe_err("IE Length overflow, curr:%d, new:%d",
5650 addn_ie->probeRespDataLen,
5651 update_ie->ieBufferlength);
5652 goto end;
5653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 new_length = update_ie->ieBufferlength +
5655 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305656 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005657 if (!new_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305660 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305662 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 update_ie->pAdditionIEBuffer,
5664 update_ie->ieBufferlength);
5665 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305666 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 /* adjust length accordingly */
5668 addn_ie->probeRespDataLen = new_length;
5669 /* save refernece of local buffer in PE session */
5670 addn_ie->probeRespData_buff = new_ptr;
5671 goto end;
5672 }
5673 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5674 &addn_ie->probeRespDataLen,
5675 update_ie->pAdditionIEBuffer,
5676 update_ie->ieBufferlength);
5677 break;
5678 case eUPDATE_IE_ASSOC_RESP:
5679 /* assoc resp IE */
5680 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5681 &addn_ie->assocRespDataLen,
5682 update_ie->pAdditionIEBuffer,
5683 update_ie->ieBufferlength);
5684 break;
5685 case eUPDATE_IE_PROBE_BCN:
5686 /* probe resp Bcn IE */
5687 lim_update_add_ie_buffer(mac_ctx,
5688 &addn_ie->probeRespBCNData_buff,
5689 &addn_ie->probeRespBCNDataLen,
5690 update_ie->pAdditionIEBuffer,
5691 update_ie->ieBufferlength);
5692 if (update_ie->notify)
5693 lim_handle_param_update(mac_ctx,
5694 update_add_ies->updateType);
5695 break;
5696 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005697 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 break;
5699 }
5700end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305701 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005702 update_ie->pAdditionIEBuffer = NULL;
5703}
5704
5705/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305706 * send_extended_chan_switch_action_frame()- function to send ECSA
5707 * action frame for each sta connected to SAP/GO and AP in case of
5708 * STA .
5709 * @mac_ctx: pointer to global mac structure
5710 * @new_channel: new channel to switch to.
5711 * @ch_bandwidth: BW of channel to calculate op_class
5712 * @session_entry: pe session
5713 *
5714 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5715 *
5716 * Return: void
5717 */
5718
5719static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5720 uint16_t new_channel, uint8_t ch_bandwidth,
5721 tpPESession session_entry)
5722{
5723 uint16_t op_class;
5724 uint8_t switch_mode = 0, i;
5725 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005726 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305727
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005728 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305729 mac_ctx->scan.countryCodeCurrent,
5730 new_channel,
5731 ch_bandwidth);
5732
5733 if (LIM_IS_AP_ROLE(session_entry) &&
5734 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005735 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305736
gaoleze2920bd2017-03-21 17:38:42 +08005737 switch_count = session_entry->gLimChannelSwitch.switchCount;
5738
Abhishek Singh518323d2015-10-19 17:42:01 +05305739 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005740 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305741 psta =
5742 session_entry->dph.dphHashTable.pDphNodeArray + i;
5743 if (psta && psta->added)
5744 lim_send_extended_chan_switch_action_frame(
5745 mac_ctx,
5746 psta->staAddr,
5747 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005748 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305749 }
5750 } else if (LIM_IS_STA_ROLE(session_entry)) {
5751 lim_send_extended_chan_switch_action_frame(mac_ctx,
5752 session_entry->bssId,
5753 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005754 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305755 }
5756
5757}
5758
gaolez76d2a162017-03-21 19:23:58 +08005759void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5760 uint16_t new_channel,
5761 uint8_t ch_bandwidth,
5762 tpPESession session_entry)
5763{
5764 uint16_t op_class;
5765 uint8_t switch_mode = 0, i;
5766 uint8_t switch_count;
5767 tpDphHashNode psta;
5768 tpDphHashNode dph_node_array_ptr;
5769
5770 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5771
5772 op_class = wlan_reg_dmn_get_opclass_from_channel(
5773 mac_ctx->scan.countryCodeCurrent,
5774 new_channel, ch_bandwidth);
5775
5776 if (LIM_IS_AP_ROLE(session_entry) &&
5777 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5778 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5779
5780 switch_count = session_entry->gLimChannelSwitch.switchCount;
5781
5782 if (LIM_IS_AP_ROLE(session_entry)) {
5783 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5784 psta = dph_node_array_ptr + i;
5785 if (!(psta && psta->added))
5786 continue;
5787 if (session_entry->lim_non_ecsa_cap_num == 0)
5788 lim_send_extended_chan_switch_action_frame
5789 (mac_ctx, psta->staAddr, switch_mode,
5790 op_class, new_channel, switch_count,
5791 session_entry);
5792 else
5793 lim_send_channel_switch_mgmt_frame
5794 (mac_ctx, psta->staAddr, switch_mode,
5795 new_channel, switch_count,
5796 session_entry);
5797 }
5798 } else if (LIM_IS_STA_ROLE(session_entry)) {
5799 lim_send_extended_chan_switch_action_frame
5800 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5801 new_channel, switch_count, session_entry);
5802 }
5803}
5804
5805/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5807 *
5808 * @mac_ctx: Pointer to Global MAC structure
5809 * @msg_buf: pointer to the SME message buffer
5810 *
5811 * This function processes SME request messages from HDD or upper layer
5812 * application.
5813 *
5814 * Return: None
5815 */
5816static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5817 uint32_t *msg_buf)
5818{
5819 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5820 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 uint8_t session_id;
5822 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005823 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824
5825 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005826 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 return;
5828 }
5829
5830 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5831 session_entry = pe_find_session_by_bssid(mac_ctx,
5832 dfs_csa_ie_req->bssid, &session_id);
5833 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005834 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5836 return;
5837 }
5838
5839 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005840 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 GET_LIM_SYSTEM_ROLE(session_entry));
5842 return;
5843 }
5844
5845 /* target channel */
5846 session_entry->gLimChannelSwitch.primaryChannel =
5847 dfs_csa_ie_req->targetChannel;
5848
5849 /* Channel switch announcement needs to be included in beacon */
5850 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005851 session_entry->gLimChannelSwitch.switchCount =
5852 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005854 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305855 session_entry->gLimChannelSwitch.sec_ch_offset =
5856 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005858 session_entry->gLimChannelSwitch.switchMode =
5859 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005860
5861 /*
5862 * Validate if SAP is operating HT or VHT mode and set the Channel
5863 * Switch Wrapper element with the Wide Band Switch subelement.
5864 */
5865 if (true != session_entry->vhtCapability)
5866 goto skip_vht;
5867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 /* Now encode the Wider Ch BW element depending on the ch width */
5869 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005870 switch (dfs_csa_ie_req->ch_params.ch_width) {
5871 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872 /*
5873 * Wide channel BW sublement in channel wrapper element is not
5874 * required in case of 20 Mhz operation. Currently It is set
5875 * only set in case of 40/80 Mhz Operation.
5876 */
5877 session_entry->dfsIncludeChanWrapperIe = false;
5878 wider_bw_ch_switch->newChanWidth =
5879 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5880 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005881 case CH_WIDTH_40MHZ:
5882 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005883 wider_bw_ch_switch->newChanWidth =
5884 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5885 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005886 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887 session_entry->dfsIncludeChanWrapperIe = true;
5888 wider_bw_ch_switch->newChanWidth =
5889 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5890 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005891 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005892 session_entry->dfsIncludeChanWrapperIe = true;
5893 wider_bw_ch_switch->newChanWidth =
5894 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5895 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005896 case CH_WIDTH_80P80MHZ:
5897 session_entry->dfsIncludeChanWrapperIe = true;
5898 wider_bw_ch_switch->newChanWidth =
5899 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005900 /*
5901 * This is not applicable for 20/40/80 Mhz.
5902 * Only used when we support 80+80 Mhz operation.
5903 * In case of 80+80 Mhz, this parameter indicates
5904 * center channel frequency index of 80 Mhz channel of
5905 * frequency segment 1.
5906 */
5907 wider_bw_ch_switch->newCenterChanFreq1 =
5908 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005909 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005910 default:
5911 session_entry->dfsIncludeChanWrapperIe = false;
5912 /*
5913 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5914 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5915 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005916 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 break;
5918 }
5919 /* Fetch the center channel based on the channel width */
5920 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005921 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005922skip_vht:
5923 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305924 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305925
5926 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5927 ch_offset = BW80;
5928 else
5929 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5930
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005931 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305932 session_entry->gLimChannelSwitch.switchCount,
5933 session_entry->gLimChannelSwitch.primaryChannel,
5934 session_entry->gLimChannelSwitch.ch_width,
5935 session_entry->dfsIncludeChanWrapperIe,
5936 ch_offset);
5937
gaolez76d2a162017-03-21 19:23:58 +08005938 /* Send ECSA/CSA Action frame after updating the beacon */
5939 if (CHAN_HOP_ALL_BANDS_ENABLE)
5940 lim_send_chan_switch_action_frame(mac_ctx,
5941 session_entry->gLimChannelSwitch.primaryChannel,
5942 ch_offset, session_entry);
5943 else
5944 send_extended_chan_switch_action_frame(mac_ctx,
5945 session_entry->gLimChannelSwitch.primaryChannel,
5946 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005947}
5948
5949/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305950 * lim_process_ext_change_channel()- function to send ECSA
5951 * action frame for STA/CLI .
5952 * @mac_ctx: pointer to global mac structure
5953 * @msg: params from sme for new channel.
5954 *
5955 * This function is called to send ECSA frame for STA/CLI.
5956 *
5957 * Return: void
5958 */
5959
5960static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5961 uint32_t *msg)
5962{
5963 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5964 (struct sir_sme_ext_cng_chan_req *) msg;
5965 tpPESession session_entry = NULL;
5966
5967 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005968 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305969 return;
5970 }
5971 session_entry =
5972 pe_find_session_by_sme_session_id(mac_ctx,
5973 ext_chng_channel->session_id);
5974 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005975 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305976 ext_chng_channel->session_id);
5977 return;
5978 }
5979 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005980 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305981 return;
5982 }
5983 send_extended_chan_switch_action_frame(mac_ctx,
5984 ext_chng_channel->new_channel,
5985 0, session_entry);
5986}
5987
5988/**
Abhishek Singhfc740be2018-10-12 11:34:26 +05305989 * lim_nss_update_rsp() - send NSS update response to SME
5990 * @mac_ctx Pointer to Global MAC structure
5991 * @vdev_id: vdev id
5992 * @status: nss update status
5993 *
5994 * Return: None
5995 */
5996static void lim_nss_update_rsp(tpAniSirGlobal mac_ctx,
5997 uint8_t vdev_id, QDF_STATUS status)
5998{
5999 struct scheduler_msg msg = {0};
6000 struct sir_bcn_update_rsp *nss_rsp;
6001 QDF_STATUS qdf_status;
6002
6003 nss_rsp = qdf_mem_malloc(sizeof(*nss_rsp));
6004 if (!nss_rsp) {
6005 pe_err("AllocateMemory failed for nss_rsp");
6006 return;
6007 }
6008
6009 nss_rsp->vdev_id = vdev_id;
6010 nss_rsp->status = status;
6011 nss_rsp->reason = REASON_NSS_UPDATE;
6012
6013 msg.type = eWNI_SME_NSS_UPDATE_RSP;
6014 msg.bodyptr = nss_rsp;
6015 msg.bodyval = 0;
6016 qdf_status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_SME,
6017 QDF_MODULE_ID_SME, &msg);
6018 if (QDF_IS_STATUS_ERROR(qdf_status)) {
6019 pe_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
6020 qdf_mem_free(nss_rsp);
6021 }
6022}
6023
6024void lim_send_bcn_rsp(tpAniSirGlobal mac_ctx, tpSendbeaconParams rsp)
6025{
6026 if (!rsp) {
6027 pe_err("rsp is NULL");
6028 return;
6029 }
6030
6031 pe_debug("Send beacon resp status %d for reason %d",
6032 rsp->status, rsp->reason);
6033
6034 if (rsp->reason == REASON_NSS_UPDATE)
6035 lim_nss_update_rsp(mac_ctx, rsp->vdev_id, rsp->status);
6036}
6037
6038/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006039 * lim_process_nss_update_request() - process sme nss update req
6040 *
6041 * @mac_ctx: Pointer to Global MAC structure
6042 * @msg_buf: pointer to the SME message buffer
6043 *
6044 * This function processes SME request messages from HDD or upper layer
6045 * application.
6046 *
6047 * Return: None
6048 */
6049static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6050 uint32_t *msg_buf)
6051{
6052 struct sir_nss_update_request *nss_update_req_ptr;
6053 tpPESession session_entry = NULL;
Abhishek Singhfc740be2018-10-12 11:34:26 +05306054 QDF_STATUS status = QDF_STATUS_E_FAILURE;
6055 uint8_t vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056
Abhishek Singhfc740be2018-10-12 11:34:26 +05306057 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006058 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 return;
6060 }
6061
6062 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Abhishek Singhfc740be2018-10-12 11:34:26 +05306063 vdev_id = nss_update_req_ptr->vdev_id;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306064 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006065 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05306066 if (!session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006067 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006068 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05306069 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 }
6071
6072 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006073 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 GET_LIM_SYSTEM_ROLE(session_entry));
Abhishek Singhfc740be2018-10-12 11:34:26 +05306075 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 }
6077
6078 /* populate nss field in the beacon */
6079 session_entry->gLimOperatingMode.present = 1;
6080 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306081 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6082
6083 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6084 (session_entry->ch_width > CH_WIDTH_80MHZ))
6085 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6086
Abhishek Singhfc740be2018-10-12 11:34:26 +05306087 pe_debug("ch width %d Rx NSS %d",
6088 session_entry->gLimOperatingMode.chanWidth,
6089 session_entry->gLimOperatingMode.rxNSS);
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 /* Send nss update request from here */
Abhishek Singhfc740be2018-10-12 11:34:26 +05306092 status = sch_set_fixed_beacon_fields(mac_ctx, session_entry);
6093 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006094 pe_err("Unable to set op mode IE in beacon");
Abhishek Singhfc740be2018-10-12 11:34:26 +05306095 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 }
6097
Abhishek Singhfc740be2018-10-12 11:34:26 +05306098 status = lim_send_beacon_ind(mac_ctx, session_entry, REASON_NSS_UPDATE);
6099 if (QDF_IS_STATUS_SUCCESS(status))
6100 return;
6101
6102 pe_err("Unable to send beacon");
6103end:
6104 /*
6105 * send resp only in case of failure,
6106 * success case response will be from wma.
6107 */
6108 lim_nss_update_rsp(mac_ctx, vdev_id, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109}
6110
6111/**
6112 * lim_process_set_ie_req() - process sme set IE request
6113 *
6114 * @mac_ctx: Pointer to Global MAC structure
6115 * @msg_buf: pointer to the SME message buffer
6116 *
6117 * This function processes SME request messages from HDD or upper layer
6118 * application.
6119 *
6120 * Return: None
6121 */
6122static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6123{
6124 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306125 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126
6127 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006128 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129 return;
6130 }
6131
6132 msg = (struct send_extcap_ie *)msg_buf;
6133 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306134 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006135 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006136
6137}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006138
6139#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006140
6141/**
6142 * obss_color_collision_process_color_disable() - Disable bss color
6143 * @mac_ctx: Pointer to Global MAC structure
6144 * @session: pointer to session
6145 *
6146 * This function will disbale bss color.
6147 *
6148 * Return: None
6149 */
6150static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6151 tpPESession session)
6152{
6153 tUpdateBeaconParams beacon_params;
6154
6155 if (!session) {
6156 pe_err("Invalid session");
6157 return;
6158 }
6159
6160 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6161 pe_err("Invalid SystemRole %d",
6162 GET_LIM_SYSTEM_ROLE(session));
6163 return;
6164 }
6165
6166 if (session->bss_color_changing == 1) {
6167 pe_warn("%d: color change in progress", session->smeSessionId);
6168 /* Continue color collision detection */
6169 lim_send_obss_color_collision_cfg(mac_ctx, session,
6170 OBSS_COLOR_COLLISION_DETECTION);
6171 return;
6172 }
6173
6174 if (session->he_op.bss_col_disabled == 1) {
6175 pe_warn("%d: bss color already disabled",
6176 session->smeSessionId);
6177 /* Continue free color detection */
6178 lim_send_obss_color_collision_cfg(mac_ctx, session,
6179 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6180 return;
6181 }
6182
6183 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6184 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6185 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006186 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006187 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006188
6189 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006190 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006191 pe_err("Unable to set op mode IE in beacon");
6192 return;
6193 }
6194
6195 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6196 lim_send_obss_color_collision_cfg(mac_ctx, session,
6197 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6198}
6199
6200/**
6201 * obss_color_collision_process_color_change() - Process bss color change
6202 * @mac_ctx: Pointer to Global MAC structure
6203 * @session: pointer to session
6204 * @obss_color_info: obss color collision/free slot indication info
6205 *
6206 * This function selects new color ib case of bss color collision.
6207 *
6208 * Return: None
6209 */
6210static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6211 tpPESession session,
6212 struct wmi_obss_color_collision_info *obss_color_info)
6213{
6214 int i, num_bss_color = 0;
6215 uint32_t bss_color_bitmap;
6216 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6217 uint32_t rand_byte = 0;
6218 struct sir_set_he_bss_color he_bss_color;
6219 bool is_color_collision = false;
6220
6221
6222 if (session->bss_color_changing == 1) {
6223 pe_err("%d: color change in progress", session->smeSessionId);
6224 return;
6225 }
6226
6227 if (!session->he_op.bss_col_disabled) {
6228 if (session->he_op.bss_color < 32)
6229 is_color_collision = (obss_color_info->
6230 obss_color_bitmap_bit0to31 >>
6231 session->he_op.bss_color) & 0x01;
6232 else
6233 is_color_collision = (obss_color_info->
6234 obss_color_bitmap_bit32to63 >>
6235 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006236 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006237 if (!is_color_collision) {
6238 pe_err("%d: color collision not found, curr_color: %d",
6239 session->smeSessionId,
6240 session->he_op.bss_color);
6241 return;
6242 }
6243 }
6244
6245 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6246
6247 /* Skip color zero */
6248 bss_color_bitmap = bss_color_bitmap >> 1;
6249 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6250 if (!(bss_color_bitmap & 0x01)) {
6251 bss_color_index_array[num_bss_color] = i + 1;
6252 num_bss_color++;
6253 }
6254 bss_color_bitmap = bss_color_bitmap >> 1;
6255 }
6256
6257 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6258 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6259 if (!(bss_color_bitmap & 0x01)) {
6260 bss_color_index_array[num_bss_color] = i + 32;
6261 num_bss_color++;
6262 }
6263 bss_color_bitmap = bss_color_bitmap >> 1;
6264 }
6265
6266 if (num_bss_color) {
6267 qdf_get_random_bytes((void *) &rand_byte, 1);
6268 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6269 num_bss_color;
6270 pe_debug("New bss color = %d", bss_color_index_array[i]);
6271 he_bss_color.session_id = obss_color_info->vdev_id;
6272 he_bss_color.bss_color = bss_color_index_array[i];
6273 lim_process_set_he_bss_color(mac_ctx,
6274 (uint32_t *)&he_bss_color);
6275 } else {
6276 pe_err("Unable to find bss color from bitmasp");
6277 if (obss_color_info->evt_type ==
6278 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6279 session->obss_color_collision_dec_evt ==
6280 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6281 /* In dot11BSSColorCollisionAPPeriod and
6282 * timer expired, time to disable bss color.
6283 */
6284 obss_color_collision_process_color_disable(mac_ctx,
6285 session);
6286 else
6287 /*
6288 * Enter dot11BSSColorCollisionAPPeriod period.
6289 */
6290 lim_send_obss_color_collision_cfg(mac_ctx, session,
6291 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6292 }
6293}
6294
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006295void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6296{
6297 struct sir_set_he_bss_color *bss_color;
6298 tpPESession session_entry = NULL;
6299 tUpdateBeaconParams beacon_params;
6300
6301 if (!msg_buf) {
6302 pe_err("Buffer is Pointing to NULL");
6303 return;
6304 }
6305
6306 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6307 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6308 bss_color->session_id);
6309 if (!session_entry) {
6310 pe_err("Session not found for given session_id %d",
6311 bss_color->session_id);
6312 return;
6313 }
6314
6315 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6316 pe_err("Invalid SystemRole %d",
6317 GET_LIM_SYSTEM_ROLE(session_entry));
6318 return;
6319 }
6320
6321 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6322 pe_err("No change in BSS color, current BSS color %d",
6323 bss_color->bss_color);
6324 return;
6325 }
6326 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6327 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6328 session_entry->he_op.bss_col_disabled = 1;
6329 session_entry->he_bss_color_change.countdown =
6330 BSS_COLOR_SWITCH_COUNTDOWN;
6331 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006332 beacon_params.bss_color_disabled = 1;
6333 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006334 session_entry->bss_color_changing = 1;
6335
6336 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006337 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006338 pe_err("Unable to set op mode IE in beacon");
6339 return;
6340 }
6341
6342 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006343 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6344 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6345}
6346
6347void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6348 tpPESession session,
6349 enum wmi_obss_color_collision_evt_type
6350 event_type)
6351{
6352 struct wmi_obss_color_collision_cfg_param *cfg_param;
6353 struct scheduler_msg msg = {0};
6354
6355 if (!session) {
6356 pe_err("Invalid session");
6357 return;
6358 }
6359
6360 if (!session->he_capable ||
6361 !session->is_session_obss_color_collision_det_enabled) {
6362 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6363 session->smeSessionId, session->he_capable,
6364 session->is_session_obss_color_collision_det_enabled,
6365 mac_ctx->lim.global_obss_color_collision_det_offload);
6366 return;
6367 }
6368
6369 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006370 if (!cfg_param)
Arif Hussain05fb4872018-01-03 16:02:55 -08006371 return;
Arif Hussain05fb4872018-01-03 16:02:55 -08006372
6373 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6374 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6375 cfg_param->vdev_id = session->smeSessionId;
6376 cfg_param->evt_type = event_type;
6377 if (LIM_IS_AP_ROLE(session))
6378 cfg_param->detection_period_ms =
6379 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6380 else
6381 cfg_param->detection_period_ms =
6382 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6383
6384 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6385 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6386 cfg_param->free_slot_expiry_time_ms =
6387 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6388
6389 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6390 msg.bodyptr = cfg_param;
6391 msg.reserved = 0;
6392
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306393 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6394 QDF_MODULE_ID_WMA,
6395 QDF_MODULE_ID_WMA,
6396 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006397 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6398 qdf_mem_free(cfg_param);
6399 } else {
6400 session->obss_color_collision_dec_evt = event_type;
6401 }
6402}
6403
6404void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6405 uint32_t *msg_buf)
6406{
6407 struct wmi_obss_color_collision_info *obss_color_info;
6408 tpPESession session;
6409
6410 if (!msg_buf) {
6411 pe_err("Buffer is Pointing to NULL");
6412 return;
6413 }
6414
6415 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6416 session = pe_find_session_by_sme_session_id(mac_ctx,
6417 obss_color_info->vdev_id);
6418 if (!session) {
6419 pe_err("Session not found for given session_id %d",
6420 obss_color_info->vdev_id);
6421 return;
6422 }
6423
6424 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6425 obss_color_info->vdev_id,
6426 obss_color_info->evt_type,
6427 session->obss_color_collision_dec_evt,
6428 obss_color_info->obss_color_bitmap_bit0to31,
6429 obss_color_info->obss_color_bitmap_bit32to63,
6430 session->he_capable,
6431 session->is_session_obss_color_collision_det_enabled,
6432 mac_ctx->lim.global_obss_color_collision_det_offload);
6433
6434 if (!session->he_capable ||
6435 !session->is_session_obss_color_collision_det_enabled) {
6436 return;
6437 }
6438
6439 switch (obss_color_info->evt_type) {
6440 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6441 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6442 session->smeSessionId, session->he_capable,
6443 session->is_session_obss_color_collision_det_enabled,
6444 mac_ctx->lim.global_obss_color_collision_det_offload);
6445 session->is_session_obss_color_collision_det_enabled = false;
6446 return;
6447 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6448 case OBSS_COLOR_COLLISION_DETECTION:
6449 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6450 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6451 pe_debug("Invalid System Role %d",
6452 GET_LIM_SYSTEM_ROLE(session));
6453 return;
6454 }
6455
6456 if (session->obss_color_collision_dec_evt !=
6457 obss_color_info->evt_type) {
6458 pe_debug("%d: Wrong event: %d, skiping",
6459 obss_color_info->vdev_id,
6460 obss_color_info->evt_type);
6461 return;
6462 }
6463 obss_color_collision_process_color_change(mac_ctx, session,
6464 obss_color_info);
6465 break;
6466 default:
6467 pe_err("%d: Invalid event type %d",
6468 obss_color_info->vdev_id, obss_color_info->evt_type);
6469 return;
6470 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006471}
6472#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306473
6474#ifdef CONFIG_VDEV_SM
6475void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6476{
6477 tpPESession session;
6478
6479 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6480
6481 if (!session) {
6482 pe_err("session not found for vdev id %d", vdev_id);
6483 return;
6484 }
6485
6486 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6487 WLAN_VDEV_SM_EV_CSA_RESTART,
6488 sizeof(*session), session);
6489}
6490#endif