blob: c7db4086aef089bdd7f776596058d4cf0eb2eb38 [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");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 /* To free the active command list */
140 goto fail;
141 }
142
143 len = sizeof(*req_msg);
144
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530145 req_msg = qdf_mem_malloc(len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700146 if (!req_msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530147 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530150 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* Other parameters are not needed for WMA */
152
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800153 message.bodyptr = req_msg;
154 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700156 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530157 status = scheduler_post_message(QDF_MODULE_ID_PE,
158 QDF_MODULE_ID_WMA,
159 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530160 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700161 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530163 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 goto fail;
165 }
166 return status;
167fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530168 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700169 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530170 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 param->status = SET_HW_MODE_STATUS_ECANCELED;
172 param->cfgd_hw_mode_index = 0;
173 param->num_vdev_mac_entries = 0;
174 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
175 resp_msg.bodyptr = param;
176 resp_msg.bodyval = 0;
177 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530178 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179}
180
181/**
182 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
183 * @mac: Global MAC pointer
184 * @msg: Message containing the dual mac config parameter
185 *
186 * Send the set dual mac config command to WMA
187 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530188 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530190static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 uint32_t *msg)
192{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700194 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800195 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 uint32_t len;
197 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700198 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 struct sir_dual_mac_config_resp *param;
200
201 buf = (struct sir_set_dual_mac_cfg *) msg;
202 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700203 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 /* To free the active command list */
205 goto fail;
206 }
207
208 len = sizeof(*req_msg);
209
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530210 req_msg = qdf_mem_malloc(len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700211 if (!req_msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530212 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 req_msg->scan_config = buf->set_dual_mac.scan_config;
215 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
216 /* Other parameters are not needed for WMA */
217
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800218 message.bodyptr = req_msg;
219 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700221 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530223 status = scheduler_post_message(QDF_MODULE_ID_PE,
224 QDF_MODULE_ID_WMA,
225 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530226 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700227 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530229 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 goto fail;
231 }
232 return status;
233fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700235 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530236 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 param->status = SET_HW_MODE_STATUS_ECANCELED;
238 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
239 resp_msg.bodyptr = param;
240 resp_msg.bodyval = 0;
241 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530242 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243}
244
245/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800246 * lim_process_set_antenna_mode_req() - Set antenna mode command
247 * to WMA
248 * @mac: Global MAC pointer
249 * @msg: Message containing the antenna mode parameter
250 *
251 * Send the set antenna mode command to WMA
252 *
253 * Return: QDF_STATUS_SUCCESS if message posting is successful
254 */
255static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
256 uint32_t *msg)
257{
258 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700259 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800260 struct sir_antenna_mode_param *req_msg;
261 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700262 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800263 struct sir_antenna_mode_resp *param;
264
265 buf = (struct sir_set_antenna_mode *) msg;
266 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700267 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 /* To free the active command list */
269 goto fail;
270 }
271
272 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700273 if (!req_msg)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800274 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800275
276 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
277 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
278
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800279 message.bodyptr = req_msg;
280 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700282 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800283 req_msg->num_rx_chains,
284 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530285 status = scheduler_post_message(QDF_MODULE_ID_PE,
286 QDF_MODULE_ID_WMA,
287 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700289 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800290 status);
291 qdf_mem_free(req_msg);
292 goto fail;
293 }
294 return status;
295fail:
296 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700297 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800299 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
300 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
301 resp_msg.bodyptr = param;
302 resp_msg.bodyval = 0;
303 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
304 return QDF_STATUS_SUCCESS;
305}
306
307/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 * __lim_is_sme_assoc_cnf_valid()
309 *
310 ***FUNCTION:
311 * This function is called by __lim_process_sme_assoc_cnf_new() upon
312 * receiving SME_ASSOC_CNF.
313 *
314 ***LOGIC:
315 * Message validity checks are performed in this function
316 *
317 ***ASSUMPTIONS:
318 *
319 ***NOTE:
320 *
321 * @param pMeasReq Pointer to Received ASSOC_CNF message
322 * @return true When received SME_ASSOC_CNF is formatted
323 * correctly
324 * false otherwise
325 */
326
327static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
328{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530329 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 return false;
331 else
332 return true;
333} /*** end __lim_is_sme_assoc_cnf_valid() ***/
334
335/**
336 * __lim_get_sme_join_req_size_for_alloc()
337 *
338 ***FUNCTION:
339 * This function is called in various places to get IE length
340 * from tSirBssDescription structure
341 * number being scanned.
342 *
343 ***PARAMS:
344 *
345 ***LOGIC:
346 *
347 ***ASSUMPTIONS:
348 * NA
349 *
350 ***NOTE:
351 * NA
352 *
353 * @param pBssDescr
354 * @return Total IE length
355 */
356
357static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
358{
359 uint16_t len = 0;
360
361 if (!pBuf)
362 return len;
363
364 pBuf += sizeof(uint16_t);
365 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700366 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367}
368
369/**
370 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
371 * @pMac: Global MAC context
372 * @pMsg: Pointer to message posted from SME to LIM.
373 *
374 * Has role only if 11h is enabled. Not used on STA side.
375 * Defers the message if SME is in learn state and brings
376 * the LIM back to normal mode.
377 *
378 * Return: true - If defered false - Otherwise
379 */
380
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800381static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
382 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383{
384 if (lim_is_system_in_scan_state(pMac)) {
385 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700386 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 return false;
388 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700389 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 pMsg->type);
391 return true;
392 }
393 return false;
394}
395
396/**
397 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
398 * @mac_ctx: Pointer to Global MAC structure
399 * @message: Pointer to message posted from SME to LIM.
400 *
401 * Has role only if 11h is enabled. Not used on STA side.
402 * Defers the message if radar is detected.
403 *
404 * Return: true, if defered otherwise return false.
405 */
406static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800407__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
408 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409{
410 /*
411 * fRadarDetCurOperChan will be set only if we
412 * detect radar in current operating channel and
413 * System Role == AP ROLE
414 *
415 * TODO: Need to take care radar detection.
416 *
417 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
418 */
419 if (0) {
420 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700421 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 return false;
423 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700424 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 message->type);
426 return true;
427 }
428 return false;
429}
430
431/**
432 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
433 * @pMac: Global MAC context
434 * @pMsgBuf: Message from WMA
435 *
436 * handles the notification from HDD. PE just forwards this message to HAL.
437 *
438 * Return: true-Posting to HAL failed, so PE will consume the buffer.
439 * false-Posting to HAL successful, so HAL will consume the buffer.
440 */
441
442static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
443{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700444 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
446
447 msg.type = WMA_SYS_READY_IND;
448 msg.reserved = 0;
449 msg.bodyptr = pMsgBuf;
450 msg.bodyval = 0;
451
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700452 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800453 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530454 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700455 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700456 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530457 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700459
460 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
462
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700463 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700464 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 return true;
466 }
467 return false;
468}
469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470/**
471 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
472 *@mac_ctx: Pointer to Global MAC structure
473 *@session: A pointer to session entry
474 *@sme_start_bss_req: Start BSS Request from upper layers.
475 *
476 * This function is used to configure the start bss parameters
477 * in to the session.
478 *
479 * Return: None.
480 */
481static void
482lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
483 tpSirSmeStartBssReq sme_start_bss_req)
484{
485 session->limSystemRole = eLIM_AP_ROLE;
486 session->privacy = sme_start_bss_req->privacy;
487 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
488 session->authType = sme_start_bss_req->authType;
489 /* Store the DTIM period */
490 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
491 /* Enable/disable UAPSD */
492 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530493 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 session->proxyProbeRspEn = 0;
495 } else {
496 /*
497 * To detect PBC overlap in SAP WPS mode,
498 * Host handles Probe Requests.
499 */
500 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
501 session->proxyProbeRspEn = 1;
502 else
503 session->proxyProbeRspEn = 0;
504 }
505 session->ssidHidden = sme_start_bss_req->ssidHidden;
506 session->wps_state = sme_start_bss_req->wps_state;
507 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530508 session->vendor_vht_sap =
509 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
511 &session->shortSlotTimeSupported);
512 session->isCoalesingInIBSSAllowed =
513 sme_start_bss_req->isCoalesingInIBSSAllowed;
514
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800515 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517}
518
519/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530520 * lim_send_start_vdev_req() - send vdev start request
521 *@session: pe session
522 *@mlm_start_req: vdev start req
523 *
524 * Return: QDF_STATUS
525 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530526#ifdef CONFIG_VDEV_SM
527static QDF_STATUS
528lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
529{
530 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
531 WLAN_VDEV_SM_EV_START,
532 sizeof(*mlm_start_req),
533 mlm_start_req);
534}
535#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530536static QDF_STATUS
537lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
538{
539 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
540
541 return QDF_STATUS_SUCCESS;
542}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530543#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530544
545/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
547 *@mac_ctx: Pointer to Global MAC structure
548 *@msg_buf: A pointer to the SME message buffer
549 *
550 * This function is called to process SME_START_BSS_REQ message
551 * from HDD or upper layer application.
552 *
553 * Return: None
554 */
555static void
556__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
557{
558 uint16_t size;
559 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700560 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 tSirMacChanNum channel_number;
562 tLimMlmStartReq *mlm_start_req = NULL;
563 tpSirSmeStartBssReq sme_start_bss_req = NULL;
564 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
565 /* Flag Used in case of IBSS to Auto generate BSSID. */
566 uint32_t auto_gen_bssid = false;
567 uint8_t session_id;
568 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800569 uint8_t sme_session_id = 0xFF;
570 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700572 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574
575/* FEATURE_WLAN_DIAG_SUPPORT */
576#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
577 /*
578 * Since the session is not created yet, sending NULL.
579 * The response should have the correct state.
580 */
581 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
582 NULL, 0, 0);
583#endif /* FEATURE_WLAN_DIAG_SUPPORT */
584
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700585 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800586 size = sizeof(tSirSmeStartBssReq);
587 sme_start_bss_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700588 if (!sme_start_bss_req) {
Krunal Sonib37bb352016-12-20 14:12:21 -0800589 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
590 goto free;
591 }
592 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
593 sme_session_id = sme_start_bss_req->sessionId;
594 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
597 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
599 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700600 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 ret_code = eSIR_SME_INVALID_PARAMETERS;
602 goto free;
603 }
604
605 /*
606 * This is the place where PE is going to create a session.
607 * If session is not existed, then create a new session
608 */
609 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800610 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700612 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
614 session = NULL;
615 goto free;
616 } else {
617 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800618 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530620 sme_start_bss_req->bssType,
621 sme_start_bss_req->sessionId);
622 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700623 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
625 goto free;
626 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530627
628 /* Update the beacon/probe filter in mac_ctx */
629 lim_set_bcn_probe_filter(mac_ctx, session,
630 &sme_start_bss_req->ssId,
631 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 }
633
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700634 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
635 /* Probe resp add ie */
636 lim_start_bss_update_add_ie_buffer(mac_ctx,
637 &session->addIeParams.probeRespData_buff,
638 &session->addIeParams.probeRespDataLen,
639 sme_start_bss_req->addIeParams.
640 probeRespData_buff,
641 sme_start_bss_req->addIeParams.
642 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700644 /* Probe Beacon add ie */
645 lim_start_bss_update_add_ie_buffer(mac_ctx,
646 &session->addIeParams.probeRespBCNData_buff,
647 &session->addIeParams.probeRespBCNDataLen,
648 sme_start_bss_req->addIeParams.
649 probeRespBCNData_buff,
650 sme_start_bss_req->addIeParams.
651 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700653 /* Assoc resp IE */
654 lim_start_bss_update_add_ie_buffer(mac_ctx,
655 &session->addIeParams.assocRespData_buff,
656 &session->addIeParams.assocRespDataLen,
657 sme_start_bss_req->addIeParams.
658 assocRespData_buff,
659 sme_start_bss_req->addIeParams.
660 assocRespDataLen);
661 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 /* Store the session related params in newly created session */
663 session->pLimStartBssReq = sme_start_bss_req;
664
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 session->transactionId = sme_start_bss_req->transactionId;
666
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530667 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 &(sme_start_bss_req->htConfig),
669 sizeof(session->htConfig));
670
Sandeep Puligilla98917432016-06-10 13:50:28 -0700671 qdf_mem_copy(&(session->vht_config),
672 &(sme_start_bss_req->vht_config),
673 sizeof(session->vht_config));
674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800676 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677
678 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 (uint8_t *) &sme_start_bss_req->ssId,
681 (sme_start_bss_req->ssId.length + 1));
682
683 session->bssType = sme_start_bss_req->bssType;
684
685 session->nwType = sme_start_bss_req->nwType;
686
687 session->beaconParams.beaconInterval =
688 sme_start_bss_req->beaconInterval;
689
690 /* Store the channel number in session Table */
691 session->currentOperChannel =
692 sme_start_bss_req->channelId;
693
694 /* Store Persona */
695 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530696 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 FL("PE PERSONA=%d"), session->pePersona);
698
699 /* Update the phymode */
700 session->gLimPhyMode = sme_start_bss_req->nwType;
701
702 session->maxTxPower =
703 cfg_get_regulatory_max_transmit_power(mac_ctx,
704 session->currentOperChannel);
705 /* Store the dot 11 mode in to the session Table */
706 session->dot11mode = sme_start_bss_req->dot11mode;
707#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
708 session->cc_switch_mode =
709 sme_start_bss_req->cc_switch_mode;
710#endif
711 session->htCapability =
712 IS_DOT11_MODE_HT(session->dot11mode);
713 session->vhtCapability =
714 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800715
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700716 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800717 session->htCapability, session->vhtCapability);
718
719 if (IS_DOT11_MODE_HE(session->dot11mode)) {
720 lim_update_session_he_capable(mac_ctx, session);
721 lim_copy_bss_he_cap(session, sme_start_bss_req);
722 }
723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 session->txLdpcIniFeatureEnabled =
725 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726#ifdef WLAN_FEATURE_11W
727 session->limRmfEnabled =
728 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700729 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730#endif
731
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530732 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 (void *)&sme_start_bss_req->operationalRateSet,
734 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530735 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 (void *)&sme_start_bss_req->extendedRateSet,
737 sizeof(tSirMacRateSet));
738
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700739 if (IS_5G_CH(session->currentOperChannel))
740 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
741 else
742 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
743
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 switch (sme_start_bss_req->bssType) {
745 case eSIR_INFRA_AP_MODE:
746 lim_configure_ap_start_bss_session(mac_ctx, session,
747 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700748 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700749 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700750 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700751 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 break;
753 case eSIR_IBSS_MODE:
754 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
755 lim_get_short_slot_from_phy_mode(mac_ctx, session,
756 session->gLimPhyMode,
757 &session->shortSlotTimeSupported);
758
759 /*
760 * initialize to "OPEN".
761 * will be updated upon key installation
762 */
763 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700764 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765
766 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700767 case eSIR_NDI_MODE:
768 session->limSystemRole = eLIM_NDI_ROLE;
769 break;
770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 /*
773 * There is one more mode called auto mode.
774 * which is used no where
775 */
776
777 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
778
779 default:
780 /* not used anywhere...used in scan function */
781 break;
782 }
783
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700784 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700785 session->pePersona, session->vdev_nss);
786 session->nss = session->vdev_nss;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530787 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700788 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700790 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 * parsed (Re)Assoc request structure
792 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700793 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530795 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700796 size * sizeof(tpSirAssocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700797 if (!session->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
799 goto free;
800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 }
802
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700803 if (!sme_start_bss_req->channelId &&
804 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700805 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 ret_code = eSIR_SME_INVALID_PARAMETERS;
807 goto free;
808 }
809 channel_number = sme_start_bss_req->channelId;
810#ifdef QCA_HT_2040_COEX
811 if (sme_start_bss_req->obssEnabled)
812 session->htSupportedChannelWidthSet =
813 session->htCapability;
814 else
815#endif
816 session->htSupportedChannelWidthSet =
817 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
818 session->htSecondaryChannelOffset =
819 sme_start_bss_req->sec_ch_offset;
820 session->htRecommendedTxWidthSet =
821 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530822 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800824 if (lim_is_session_he_capable(session) ||
825 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700827 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800828 sme_start_bss_req->vht_channel_width,
829 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 session->ch_width = chanwidth;
831 if (session->htSupportedChannelWidthSet) {
832 session->ch_center_freq_seg0 =
833 sme_start_bss_req->center_freq_seg0;
834 session->ch_center_freq_seg1 =
835 sme_start_bss_req->center_freq_seg1;
836 } else {
837 session->ch_center_freq_seg0 = 0;
838 session->ch_center_freq_seg1 = 0;
839 }
840 }
Gaurank Kathpalia511634b2018-10-23 03:41:16 -0700841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800843 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700845 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700847 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700848 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849
850 /* Delete pre-auth list if any */
851 lim_delete_pre_auth_list(mac_ctx);
852
853 /*
854 * keep the RSN/WPA IE information in PE Session Entry
855 * later will be using this to check when received (Re)Assoc req
856 */
857 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
858 &sme_start_bss_req->rsnIE, session);
859
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700860 if (LIM_IS_AP_ROLE(session) ||
861 LIM_IS_IBSS_ROLE(session) ||
862 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 session->gLimProtectionControl =
864 sme_start_bss_req->protEnabled;
865 /*
866 * each byte will have the following info
867 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
868 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
869 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 (void *)&sme_start_bss_req->ht_capab,
872 sizeof(uint16_t));
873 /* Initialize WPS PBC session link list */
874 session->pAPWPSPBCSession = NULL;
875 }
876 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700878 if (!mlm_start_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
880 goto free;
881 }
882
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530884 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 (uint8_t *) &sme_start_bss_req->ssId,
886 sme_start_bss_req->ssId.length + 1);
887 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
888 mlm_start_req->obssProtEnabled =
889 sme_start_bss_req->obssProtEnabled;
890
891 mlm_start_req->bssType = session->bssType;
892
893 /* Fill PE session Id from the session Table */
894 mlm_start_req->sessionId = session->peSessionId;
895
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700896 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
897 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 /*
899 * Copy the BSSId from sessionTable to
900 * mlmStartReq struct
901 */
902 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
903 } else {
904 /* ibss mode */
905 mac_ctx->lim.gLimIbssCoalescingHappened = false;
906
907 ret_status = wlan_cfg_get_int(mac_ctx,
908 WNI_CFG_IBSS_AUTO_BSSID,
909 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700910 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700911 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530913 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 goto free;
915 }
916
917 if (!auto_gen_bssid) {
918 /*
919 * We're not auto generating BSSID.
920 * Instead, get it from session entry
921 */
922 sir_copy_mac_addr(mlm_start_req->bssId,
923 session->bssId);
924 /*
925 * Start IBSS group BSSID
926 * Auto Generating BSSID.
927 */
928 auto_gen_bssid = ((mlm_start_req->bssId[0] &
929 0x01) ? true : false);
930 }
931
932 if (auto_gen_bssid) {
933 /*
934 * if BSSID is not any uc id.
935 * then use locally generated BSSID.
936 * Autogenerate the BSSID
937 */
938 lim_get_random_bssid(mac_ctx,
939 mlm_start_req->bssId);
940 mlm_start_req->bssId[0] = 0x02;
941
942 /*
943 * Copy randomly generated BSSID
944 * to the session Table
945 */
946 sir_copy_mac_addr(session->bssId,
947 mlm_start_req->bssId);
948 }
949 }
950 /* store the channel num in mlmstart req structure */
951 mlm_start_req->channelNumber = session->currentOperChannel;
952 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
953 mlm_start_req->beaconPeriod =
954 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700955 mlm_start_req->cac_duration_ms =
956 sme_start_bss_req->cac_duration_ms;
957 mlm_start_req->dfs_regdomain =
958 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 if (LIM_IS_AP_ROLE(session)) {
960 mlm_start_req->dtimPeriod = session->dtimPeriod;
961 mlm_start_req->wps_state = session->wps_state;
962
963 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530964 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 mlm_start_req->dtimPeriod = (uint8_t) val;
966 }
967
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530968 mlm_start_req->cfParamSet.cfpPeriod =
969 mac_ctx->mlme_cfg->rates.cfp_period;
970 mlm_start_req->cfParamSet.cfpMaxDuration =
971 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972
973 /*
974 * this may not be needed anymore now,
975 * as rateSet is now included in the
976 * session entry and MLM has session context.
977 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530978 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 (void *)&session->rateSet,
980 sizeof(tSirMacRateSet));
981
982 /* Now populate the 11n related parameters */
983 mlm_start_req->nwType = session->nwType;
984 mlm_start_req->htCapable = session->htCapability;
985
986 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
987 /* Unused */
988 mlm_start_req->dualCTSProtection =
989 mac_ctx->lim.gHTDualCTSProtection;
990 mlm_start_req->txChannelWidthSet =
991 session->htRecommendedTxWidthSet;
992
993 session->limRFBand = lim_get_rf_band(channel_number);
994
995 /* Initialize 11h Enable Flag */
996 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +0800997 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
998 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800999 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001001 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001002 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 else
1004 session->lim11hEnable = val;
1005
1006 if (session->lim11hEnable &&
1007 (eSIR_INFRA_AP_MODE ==
1008 mlm_start_req->bssType)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001009 session->lim11hEnable =
1010 mac_ctx->mlme_cfg->
1011 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 }
1014
1015 if (!session->lim11hEnable) {
1016 if (cfg_set_int(mac_ctx,
1017 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001018 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 /*
1020 * Failed to set the CFG param
1021 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1022 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001023 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 }
1025
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001026 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 session->limPrevSmeState = session->limSmeState;
1029 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1030 MTRACE(mac_trace
1031 (mac_ctx, TRACE_CODE_SME_STATE,
1032 session->peSessionId,
1033 session->limSmeState));
1034
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301035 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1036 if (QDF_IS_STATUS_ERROR(qdf_status))
1037 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301038 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 return;
1040 } else {
1041
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001042 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 mac_ctx->lim.gLimSmeState);
1044 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001045 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1047
1048free:
1049 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001050 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 session->pLimStartBssReq = NULL;
1052 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001053 if (NULL != sme_start_bss_req)
1054 qdf_mem_free(sme_start_bss_req);
1055 if (NULL != mlm_start_req)
1056 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 if (NULL != session) {
1058 pe_delete_session(mac_ctx, session);
1059 session = NULL;
1060 }
1061 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1062 session, sme_session_id, sme_transaction_id);
1063}
1064
1065/**
1066 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1067 *
1068 * @pMac: Global MAC context
1069 * @pMsg: Message pointer
1070 *
1071 * Wrapper for the function __lim_handle_sme_start_bss_request
1072 * This message will be defered until softmac come out of
1073 * scan mode or if we have detected radar on the current
1074 * operating channel.
1075 *
1076 * return true - If we consumed the buffer
1077 * false - If have defered the message.
1078 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001079static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1080 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081{
1082 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1083 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1084 /**
1085 * If message defered, buffer is not consumed yet.
1086 * So return false
1087 */
1088 return false;
1089 }
1090
1091 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1092 return true;
1093}
1094
1095/**
1096 * lim_get_random_bssid()
1097 *
1098 * FUNCTION:This function is called to process generate the random number for bssid
1099 * This function is called to process SME_SCAN_REQ message
1100 * from HDD or upper layer application.
1101 *
1102 * LOGIC:
1103 *
1104 * ASSUMPTIONS:
1105 *
1106 * NOTE:
1107 * 1. geneartes the unique random number for bssid in ibss
1108 *
1109 * @param pMac Pointer to Global MAC structure
1110 * @param *data Pointer to bssid buffer
1111 * @return None
1112 */
1113void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1114{
1115 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 random[0] = tx_time_get();
1118 random[0] |= (random[0] << 15);
1119 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301120 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121}
1122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123/**
1124 * __lim_process_clear_dfs_channel_list()
1125 *
1126 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001127 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 .*This message is sent from SME.
1129 *
1130 ***LOGIC:
1131 *
1132 ***ASSUMPTIONS:
1133 *
1134 ***NOTE:
1135 *
1136 * @param pMac Pointer to Global MAC structure
1137 * @param *pMsgBuf A pointer to the SME message buffer
1138 * @return None
1139 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001140static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1141 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301143 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144}
1145
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301146#ifdef WLAN_FEATURE_SAE
1147
1148/**
1149 * lim_update_sae_config()- This API update SAE session info to csr config
1150 * from join request.
1151 * @session: PE session
1152 * @sme_join_req: pointer to join request
1153 *
1154 * Return: None
1155 */
1156static void lim_update_sae_config(tpPESession session,
1157 tpSirSmeJoinReq sme_join_req)
1158{
1159 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1160
1161 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1162 session->sae_pmk_cached,
1163 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1164}
1165#else
1166static inline void lim_update_sae_config(tpPESession session,
1167 tpSirSmeJoinReq sme_join_req)
1168{}
1169#endif
1170
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001171/**
Jianmin Zhu09236602018-10-15 15:36:10 +08001172 * lim_send_join_req() - send vdev start request for assoc
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001173 *@session: pe session
1174 *@mlm_join_req: join req
1175 *
1176 * Return: QDF_STATUS
1177 */
1178
1179#ifdef CONFIG_VDEV_SM
1180static QDF_STATUS lim_send_join_req(tpPESession session,
1181 tLimMlmJoinReq *mlm_join_req)
1182{
Jianmin Zhu09236602018-10-15 15:36:10 +08001183 mlme_set_assoc_type(session->vdev, VDEV_ASSOC);
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001184 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1185 WLAN_VDEV_SM_EV_START,
1186 sizeof(*mlm_join_req),
1187 mlm_join_req);
1188}
1189#else
1190static QDF_STATUS lim_send_join_req(tpPESession session,
1191 tLimMlmJoinReq *mlm_join_req)
1192{
1193 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1194
1195 return QDF_STATUS_SUCCESS;
1196}
1197#endif
1198
Jianmin Zhu09236602018-10-15 15:36:10 +08001199/**
1200 * lim_send_reassoc_req() - send vdev start request for reassoc
1201 *@session: pe session
1202 *@mlm_join_req: join req
1203 *
1204 * Return: QDF_STATUS
1205 */
1206
1207#ifdef CONFIG_VDEV_SM
1208static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1209 tLimMlmReassocReq *reassoc_req)
1210{
1211 mlme_set_assoc_type(session->vdev, VDEV_REASSOC);
1212 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1213 WLAN_VDEV_SM_EV_START,
1214 sizeof(*reassoc_req),
1215 reassoc_req);
1216}
1217#else
1218static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1219 tLimMlmReassocReq *reassoc_req)
1220{
1221 lim_process_mlm_reassoc_req(session->mac_ctx, reassoc_req);
1222
1223 return QDF_STATUS_SUCCESS;
1224}
1225#endif
1226
1227/**
1228 * lim_send_ft_reassoc_req() - send vdev start request for ft_reassoc
1229 *@session: pe session
1230 *@mlm_join_req: join req
1231 *
1232 * Return: QDF_STATUS
1233 */
1234
1235#ifdef CONFIG_VDEV_SM
1236static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1237{
1238 mlme_set_assoc_type(session->vdev, VDEV_FT_REASSOC);
1239 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1240 WLAN_VDEV_SM_EV_START,
1241 sizeof(*session),
1242 session);
1243}
1244#else
1245static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1246{
1247 lim_process_mlm_ft_reassoc_req(session->mac_ctx, session);
1248
1249 return QDF_STATUS_SUCCESS;
1250}
1251#endif
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253/**
1254 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1255 * @mac_ctx: Pointer to Global MAC structure
1256 * @msg_buf: A pointer to the SME message buffer
1257 *
1258 * This function is called to process SME_JOIN_REQ message
1259 * from HDD or upper layer application.
1260 *
1261 * Return: None
1262 */
1263static void
1264__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1265{
1266 tpSirSmeJoinReq sme_join_req = NULL;
1267 tLimMlmJoinReq *mlm_join_req;
1268 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1269 uint32_t val = 0;
1270 uint16_t n_size;
1271 uint8_t session_id;
1272 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301273 uint8_t sme_session_id = 0;
1274 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001275 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001277 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001278 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001279
Arif Hussain995fcaf2016-07-18 11:28:22 -07001280 if (!mac_ctx || !msg_buf) {
1281 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1282 FL("JOIN REQ with invalid data"));
1283 return;
1284 }
1285
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286/* FEATURE_WLAN_DIAG_SUPPORT */
1287#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1288 /*
1289 * Not sending any session, since it is not created yet.
1290 * The response whould have correct state.
1291 */
1292 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1293#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 /*
1296 * Expect Join request in idle state.
1297 * Reassociate request is expected in link established state.
1298 */
1299
1300 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1301 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1302 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1303 msg_buf);
1304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301305 sme_join_req = qdf_mem_malloc(n_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001306 if (!sme_join_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301308 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301310 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 n_size);
1312
1313 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1314 /* Received invalid eWNI_SME_JOIN_REQ */
1315 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001316 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 sme_join_req->sessionId);
1318 ret_code = eSIR_SME_INVALID_PARAMETERS;
1319 goto end;
1320 }
1321
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001322 /*
1323 * Update the capability here itself as this is used in
1324 * lim_extract_ap_capability() below. If not updated issues
1325 * like not honoring power constraint on 1st association after
1326 * driver loading might occur.
1327 */
1328 lim_update_rrm_capability(mac_ctx, sme_join_req);
1329
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001330 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001332 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 &session_id);
1334
1335 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001336 pe_err("Session(%d) Already exists for BSSID: "
1337 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001339 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 session->limSmeState);
1341
1342 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1343 session->smeSessionId == sme_join_req->sessionId) {
1344 /*
1345 * Received eWNI_SME_JOIN_REQ for same
1346 * BSS as currently associated.
1347 * Log the event and send success
1348 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001349 pe_warn("SessionId: %d", session_id);
1350 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 /* Send Join success response to host */
1352 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1353 session = NULL;
1354 goto end;
1355 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001356 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 ret_code = eSIR_SME_REFUSED;
1358 session = NULL;
1359 goto end;
1360 }
1361 } else {
1362 /*
1363 * Session Entry does not exist for given BSSId
1364 * Try to Create a new session
1365 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001366 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301368 eSIR_INFRASTRUCTURE_MODE,
1369 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001371 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1373 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301374 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001375 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301377 }
1378
1379 /* Update the beacon/probe filter in mac_ctx */
1380 lim_set_bcn_probe_filter(mac_ctx, session,
1381 &sme_join_req->ssId,
1382 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001384 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001385 session->enable_session_twt_support =
1386 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 /*
1388 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390
1391 /* store the smejoin req handle in session table */
1392 session->pLimJoinReq = sme_join_req;
1393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 /* Store SME transaction Id in session Table */
1395 session->transactionId = sme_join_req->transactionId;
1396
1397 /* Store beaconInterval */
1398 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001399 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301401 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 sizeof(session->htConfig));
1403
Sandeep Puligilla98917432016-06-10 13:50:28 -07001404 qdf_mem_copy(&(session->vht_config),
1405 &(sme_join_req->vht_config),
1406 sizeof(session->vht_config));
1407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 /* Copying of bssId is already done, while creating session */
1409 sir_copy_mac_addr(session->selfMacAddr,
1410 sme_join_req->selfMacAddr);
1411 session->bssType = sme_join_req->bsstype;
1412
1413 session->statypeForBss = STA_ENTRY_PEER;
1414 session->limWmeEnabled = sme_join_req->isWMEenabled;
1415 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301416 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001417 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301419 session->enable_bcast_probe_rsp =
1420 sme_join_req->enable_bcast_probe_rsp;
1421
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001422 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001423 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1425
Naveen Rawat08db88f2017-09-08 15:07:48 -07001426 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001428 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429
1430 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001431 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 session->isCiscoVendorAP = true;
1433 } else {
1434 session->isCiscoVendorAP = false;
1435 }
1436
1437 /* Copy the dot 11 mode in to the session table */
1438
1439 session->dot11mode = sme_join_req->dot11mode;
1440#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1441 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1442#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001443 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1445 session->enableHtSmps = sme_join_req->enableHtSmps;
1446 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001447 session->send_smps_action =
1448 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001449 /*
1450 * By default supported NSS 1x1 is set to true
1451 * and later on updated while determining session
1452 * supported rates which is the intersection of
1453 * self and peer rates
1454 */
1455 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301456 /*Store Persona */
1457 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001458 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 -08001459 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001460 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001461 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301462 session->supported_nss_1x1,
1463 session->pePersona,
1464 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001465
1466 /*Store Persona */
1467 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301468 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301469 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001470 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301471 session->nwType, session->dot11mode,
1472 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001473
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001474 /* Copy The channel Id to the session Table */
1475 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 session->vhtCapability =
1478 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301480 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001481 session->vht_config.su_beam_formee =
1482 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001484 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 session->enableVhtpAid =
1487 sme_join_req->enableVhtpAid;
1488 session->enableVhtGid =
1489 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001490 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001491 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 }
Krunal Soni53993f72016-07-08 18:20:03 -07001493
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001494 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301495 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001496 session->vht_config.su_beam_formee,
1497 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001498 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001500 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301502 session->force_24ghz_in_ht20 =
1503 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 /* cbMode is already merged value of peer and self -
1505 * done by csr in csr_get_cb_mode_from_ies */
1506 session->htSupportedChannelWidthSet =
1507 (sme_join_req->cbMode) ? 1 : 0;
1508 session->htRecommendedTxWidthSet =
1509 session->htSupportedChannelWidthSet;
1510 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1511
1512 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1513 session->ch_center_freq_seg0 =
1514 session->currentOperChannel - 2;
1515 session->ch_width = CH_WIDTH_40MHZ;
1516 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1517 sme_join_req->cbMode) {
1518 session->ch_center_freq_seg0 =
1519 session->currentOperChannel + 2;
1520 session->ch_width = CH_WIDTH_40MHZ;
1521 } else {
1522 session->ch_center_freq_seg0 = 0;
1523 session->ch_width = CH_WIDTH_20MHZ;
1524 }
1525
Naveen Rawataeca1b92017-10-16 16:55:31 -07001526 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1527 lim_update_session_he_capable(mac_ctx, session);
1528 lim_copy_join_req_he_cap(session, sme_join_req);
1529 }
1530
1531
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 /* Record if management frames need to be protected */
1533#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301534 if ((eSIR_ED_AES_128_CMAC ==
1535 sme_join_req->MgmtEncryptionType) ||
1536 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1537 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001539 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541#endif
1542
1543#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001544 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545#endif
1546
1547 /* Copy the SSID from smejoinreq to session entry */
1548 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 session->ssId.length);
1551
1552 /*
1553 * Determin 11r or ESE connection based on input from SME
1554 * which inturn is dependent on the profile the user wants
1555 * to connect to, So input is coming from supplicant
1556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558#ifdef FEATURE_WLAN_ESE
1559 session->isESEconnection = sme_join_req->isESEconnection;
1560#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 session->isFastTransitionEnabled =
1562 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 session->isFastRoamIniFeatureEnabled =
1565 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 session->txLdpcIniFeatureEnabled =
1567 sme_join_req->txLdpcIniFeatureEnabled;
1568
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301569 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301570 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1572 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 } else {
1574 /*
1575 * Throw an error and return and make
1576 * sure to delete the session.
1577 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001578 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 session->bssType);
1580 ret_code = eSIR_SME_INVALID_PARAMETERS;
1581 goto end;
1582 }
1583
1584 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301585 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 &sme_join_req->addIEScan, sizeof(tSirAddie));
1587
1588 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301589 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1591
1592 val = sizeof(tLimMlmJoinReq) +
1593 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301594 mlm_join_req = qdf_mem_malloc(val);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001595 if (!mlm_join_req) {
Nitesh Shah0102cac2016-07-13 14:38:30 +05301596 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1597 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
1600 /* PE SessionId is stored as a part of JoinReq */
1601 mlm_join_req->sessionId = session->peSessionId;
1602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301604 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 (void *)&sme_join_req->operationalRateSet,
1606 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301607 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 (void *)&sme_join_req->extendedRateSet,
1609 sizeof(tSirMacRateSet));
1610 /*
1611 * this may not be needed anymore now, as rateSet is now
1612 * included in the session entry and MLM has session context.
1613 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301614 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 (void *)&session->rateSet,
1616 sizeof(tSirMacRateSet));
1617
1618 session->encryptType = sme_join_req->UCEncryptionType;
1619
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301620 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1621 session->vdev_nss = sme_join_req->vdev_nss;
1622 session->nss = sme_join_req->nss;
1623 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1624
1625 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1626 session->nss,
1627 session->vdev_nss,
1628 session->supported_nss_1x1);
1629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 mlm_join_req->bssDescription.length =
1631 session->pLimJoinReq->bssDescription.length;
1632
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301633 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 (uint8_t *)
1635 &session->pLimJoinReq->bssDescription.bssId,
1636 session->pLimJoinReq->bssDescription.length + 2);
1637
1638 session->limCurrentBssCaps =
1639 session->pLimJoinReq->bssDescription.capabilityInfo;
1640
1641 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1642 session->currentOperChannel);
1643 local_power_constraint = reg_max;
1644
1645 lim_extract_ap_capability(mac_ctx,
1646 (uint8_t *)
1647 session->pLimJoinReq->bssDescription.ieFields,
1648 lim_get_ielen_from_bss_description(
1649 &session->pLimJoinReq->bssDescription),
1650 &session->limCurrentBssQosCaps,
1651 &session->limCurrentBssPropCap,
1652 &session->gLimCurrentBssUapsd,
1653 &local_power_constraint, session);
1654
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 session->maxTxPower = lim_get_max_tx_power(reg_max,
1656 local_power_constraint,
1657 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301658 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301659
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001660 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301661 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301663 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1664 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1665 pe_debug("Update MaxTxPower in join Req to %d",
1666 sme_join_req->powerCap.maxTxPower);
1667 }
1668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 if (session->gLimCurrentBssUapsd) {
1670 session->gUapsdPerAcBitmask =
1671 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001672 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 session->gUapsdPerAcBitmask);
1674
1675 /* resetting the dynamic uapsd mask */
1676 session->gUapsdPerAcDeliveryEnableMask = 0;
1677 session->gUapsdPerAcTriggerEnableMask = 0;
1678 }
1679
1680 session->limRFBand =
1681 lim_get_rf_band(session->currentOperChannel);
1682
1683 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001684 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001686 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001687 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 session->lim11hEnable =
1689 WNI_CFG_11H_ENABLED_STADEF;
1690 } else {
1691 session->lim11hEnable = val;
1692 }
1693 } else {
1694 session->lim11hEnable = 0;
1695 }
1696
1697 /*
1698 * To care of the scenario when STA transitions from
1699 * IBSS to Infrastructure mode.
1700 */
1701 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1702
1703 session->limPrevSmeState = session->limSmeState;
1704 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1705 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1706 session->peSessionId,
1707 session->limSmeState));
1708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 /* Indicate whether spectrum management is enabled */
1710 session->spectrumMgtEnabled =
1711 sme_join_req->spectrumMgtIndicator;
1712
1713 /* Enable the spectrum management if this is a DFS channel */
1714 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001715 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 session->currentOperChannel))
1717 session->spectrumMgtEnabled = true;
1718
1719 session->isOSENConnection = sme_join_req->isOSENConnection;
1720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001722 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 return;
1724
1725 } else {
1726 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001727 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 mac_ctx->lim.gLimSmeState);
1729 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1730 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1731 session = NULL;
1732 goto end;
1733 }
1734
1735end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301736 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1737 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738
1739 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301740 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 sme_join_req = NULL;
1742 if (NULL != session)
1743 session->pLimJoinReq = NULL;
1744 }
1745 if (ret_code != eSIR_SME_SUCCESS) {
1746 if (NULL != session) {
1747 pe_delete_session(mac_ctx, session);
1748 session = NULL;
1749 }
1750 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001751 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752 sme_session_id, ret_code);
1753 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1754 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1755 sme_transaction_id);
1756}
1757
Amar Singhala297bfa2015-10-15 15:07:29 -07001758uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 uint8_t iniTxPower)
1760{
1761 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301762 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001763
Anurag Chouhan6d760662016-02-20 16:05:43 +05301764 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1766 maxTxPower = txPower;
1767 else if (txPower < MIN_TX_PWR_CAP)
1768 maxTxPower = MIN_TX_PWR_CAP;
1769 else
1770 maxTxPower = MAX_TX_PWR_CAP;
1771
1772 return maxTxPower;
1773}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774
1775/**
1776 * __lim_process_sme_reassoc_req() - process reassoc req
1777 *
1778 * @mac_ctx: Pointer to Global MAC structure
1779 * @msg_buf: pointer to the SME message buffer
1780 *
1781 * This function is called to process SME_REASSOC_REQ message
1782 * from HDD or upper layer application.
1783 *
1784 * Return: None
1785 */
1786
1787static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1788 uint32_t *msg_buf)
1789{
1790 uint16_t caps;
1791 uint32_t val;
1792 tpSirSmeJoinReq reassoc_req = NULL;
1793 tLimMlmReassocReq *mlm_reassoc_req;
1794 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1795 tpPESession session_entry = NULL;
1796 uint8_t session_id;
1797 uint8_t sme_session_id;
1798 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001799 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 uint32_t tele_bcn_en = 0;
1801 uint16_t size;
1802
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301804 reassoc_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001805 if (!reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1807 goto end;
1808 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301809 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810
1811 if (!lim_is_sme_join_req_valid(mac_ctx,
1812 (tpSirSmeJoinReq)reassoc_req)) {
1813 /*
1814 * Received invalid eWNI_SME_REASSOC_REQ
1815 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001816 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817
1818 ret_code = eSIR_SME_INVALID_PARAMETERS;
1819 goto end;
1820 }
Jianmin Zhu09236602018-10-15 15:36:10 +08001821 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1822 &sme_session_id, &transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823
1824 session_entry = pe_find_session_by_bssid(mac_ctx,
1825 reassoc_req->bssDescription.bssId,
1826 &session_id);
1827 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001828 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001829 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1830 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001832 session_entry =
1833 pe_find_session_by_sme_session_id(mac_ctx,
1834 sme_session_id);
1835 if (session_entry != NULL)
1836 lim_handle_sme_join_result(mac_ctx,
1837 eSIR_SME_INVALID_PARAMETERS,
1838 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1839 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 goto end;
1841 }
1842#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1843 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001844 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1846 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1847
1848 /* Store the reassoc handle in the session Table */
1849 session_entry->pLimReAssocReq = reassoc_req;
1850
1851 session_entry->dot11mode = reassoc_req->dot11mode;
1852 session_entry->vhtCapability =
1853 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001854
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301855 if (session_entry->vhtCapability) {
1856 if (session_entry->pePersona == QDF_STA_MODE) {
1857 session_entry->vht_config.su_beam_formee =
1858 reassoc_req->vht_config.su_beam_formee;
1859 } else {
1860 reassoc_req->vht_config.su_beam_formee = 0;
1861 }
1862 session_entry->enableVhtpAid =
1863 reassoc_req->enableVhtpAid;
1864 session_entry->enableVhtGid =
1865 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001866 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301867 }
1868
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301869 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1870 session_entry->vdev_nss = reassoc_req->vdev_nss;
1871 session_entry->nss = reassoc_req->nss;
1872 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1873
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001874 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301875 session_entry->vhtCapability,
1876 session_entry->vht_config.su_beam_formee,
1877 session_entry->vht_config.su_beam_former);
1878
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001879 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1880 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001881 session_entry->send_smps_action =
1882 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001883 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001884 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001885 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001886 session_entry->send_smps_action,
1887 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 /*
1889 * Reassociate request is expected
1890 * in link established state only.
1891 */
1892
1893 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1895 /*
1896 * May be from 11r FT pre-auth. So lets check it
1897 * before we bail out
1898 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001899 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session_entry->peSessionId);
1901
1902 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301903 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 session_entry->limReAssocbssId,
1905 6)) {
1906 lim_print_mac_addr(mac_ctx,
1907 reassoc_req->bssDescription.
1908 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001909 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 ret_code = eSIR_SME_INVALID_PARAMETERS;
1911 goto end;
1912 }
1913
Jianmin Zhu09236602018-10-15 15:36:10 +08001914 session_entry->smeSessionId = sme_session_id;
1915 session_entry->transactionId = transaction_id;
1916 lim_send_ft_reassoc_req(session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 return;
1918 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 /*
1920 * Should not have received eWNI_SME_REASSOC_REQ
1921 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001922 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 session_entry->limSmeState);
1924 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1925
1926 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1927 goto end;
1928 }
1929
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301930 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 session_entry->pLimReAssocReq->bssDescription.bssId,
1932 sizeof(tSirMacAddr));
1933
1934 session_entry->limReassocChannelId =
1935 session_entry->pLimReAssocReq->bssDescription.channelId;
1936
1937 session_entry->reAssocHtSupportedChannelWidthSet =
1938 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1939 session_entry->reAssocHtRecommendedTxWidthSet =
1940 session_entry->reAssocHtSupportedChannelWidthSet;
1941 session_entry->reAssocHtSecondaryChannelOffset =
1942 session_entry->pLimReAssocReq->cbMode;
1943
1944 session_entry->limReassocBssCaps =
1945 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1946 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1947 session_entry->currentOperChannel);
1948 local_pwr_constraint = reg_max;
1949
1950 lim_extract_ap_capability(mac_ctx,
1951 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1952 lim_get_ielen_from_bss_description(
1953 &session_entry->pLimReAssocReq->bssDescription),
1954 &session_entry->limReassocBssQosCaps,
1955 &session_entry->limReassocBssPropCap,
1956 &session_entry->gLimCurrentBssUapsd,
1957 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301958 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001959 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301960 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 /* Copy the SSID from session entry to local variable */
1962 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301963 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 reassoc_req->ssId.ssId,
1965 session_entry->limReassocSSID.length);
1966 if (session_entry->gLimCurrentBssUapsd) {
1967 session_entry->gUapsdPerAcBitmask =
1968 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001969 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 session_entry->gUapsdPerAcBitmask);
1971 }
1972
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301973 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001974 if (!mlm_reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1976 goto end;
1977 }
1978
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301979 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1981
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001983 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001984 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301985
1986 lim_update_caps_info_for_bss(mac_ctx, &caps,
1987 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001988 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 mlm_reassoc_req->capabilityInfo = caps;
1991
1992 /* Update PE session_id */
1993 mlm_reassoc_req->sessionId = session_id;
1994
1995 /*
1996 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301997 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302000 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302002 if (tele_bcn_en)
2003 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2004 else
2005 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006
2007 mlm_reassoc_req->listenInterval = (uint16_t) val;
2008
2009 /* Indicate whether spectrum management is enabled */
2010 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2011
2012 /* Enable the spectrum management if this is a DFS channel */
2013 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002014 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 session_entry->currentOperChannel))
2016 session_entry->spectrumMgtEnabled = true;
2017
2018 session_entry->limPrevSmeState = session_entry->limSmeState;
2019 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2020
2021 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2022 session_entry->peSessionId,
2023 session_entry->limSmeState));
2024
Jianmin Zhu09236602018-10-15 15:36:10 +08002025 lim_send_reassoc_req(session_entry, mlm_reassoc_req);
2026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 return;
2028end:
2029 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302030 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 if (session_entry)
2032 session_entry->pLimReAssocReq = NULL;
2033 }
2034
2035 if (session_entry) {
2036 /*
2037 * error occurred after we determined the session so extract
2038 * session and transaction info from there
2039 */
2040 sme_session_id = session_entry->smeSessionId;
2041 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002042 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 /*
2044 * error occurred before or during the time we determined
2045 * the session so extract the session and transaction info
2046 * from the message
2047 */
2048 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2049 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 /*
2052 * Send Reassoc failure response to host
2053 * (note session_entry may be NULL, but that's OK)
2054 */
2055 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2056 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2057 session_entry, sme_session_id,
2058 transaction_id);
2059}
2060
2061bool send_disassoc_frame = 1;
2062/**
2063 * __lim_process_sme_disassoc_req()
2064 *
2065 ***FUNCTION:
2066 * This function is called to process SME_DISASSOC_REQ message
2067 * from HDD or upper layer application.
2068 *
2069 ***LOGIC:
2070 *
2071 ***ASSUMPTIONS:
2072 *
2073 ***NOTE:
2074 *
2075 * @param pMac Pointer to Global MAC structure
2076 * @param *pMsgBuf A pointer to the SME message buffer
2077 * @return None
2078 */
2079
2080static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2081{
2082 uint16_t disassocTrigger, reasonCode;
2083 tLimMlmDisassocReq *pMlmDisassocReq;
2084 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2085 tSirSmeDisassocReq smeDisassocReq;
2086 tpPESession psessionEntry = NULL;
2087 uint8_t sessionId;
2088 uint8_t smesessionId;
2089 uint16_t smetransactionId;
2090
2091 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002092 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 return;
2094 }
2095
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302096 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 smesessionId = smeDisassocReq.sessionId;
2098 smetransactionId = smeDisassocReq.transactionId;
2099 if (!lim_is_sme_disassoc_req_valid(pMac,
2100 &smeDisassocReq,
2101 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002102 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 if (pMac->lim.gLimRspReqd) {
2104 pMac->lim.gLimRspReqd = false;
2105
2106 retCode = eSIR_SME_INVALID_PARAMETERS;
2107 disassocTrigger = eLIM_HOST_DISASSOC;
2108 goto sendDisassoc;
2109 }
2110
2111 return;
2112 }
2113
2114 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002115 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 &sessionId);
2117 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002118 pe_err("session does not exist for given bssId "
2119 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002120 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 retCode = eSIR_SME_INVALID_PARAMETERS;
2122 disassocTrigger = eLIM_HOST_DISASSOC;
2123 goto sendDisassoc;
2124 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002125 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2126 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2128 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002129 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130
2131#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2132 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2133 0, smeDisassocReq.reasonCode);
2134#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2135
2136 /* Update SME session Id and SME transaction ID */
2137
2138 psessionEntry->smeSessionId = smesessionId;
2139 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002140 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002141 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142
2143 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2144 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 switch (psessionEntry->limSmeState) {
2146 case eLIM_SME_ASSOCIATED_STATE:
2147 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002149 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 psessionEntry->limPrevSmeState =
2151 psessionEntry->limSmeState;
2152 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 /* Delete all TDLS peers connected before leaving BSS */
2154 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002155 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2156 psessionEntry->peSessionId,
2157 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 break;
2159
2160 case eLIM_SME_WT_DEAUTH_STATE:
2161 /* PE shall still process the DISASSOC_REQ and proceed with
2162 * link tear down even if it had already sent a DEAUTH_IND to
2163 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2164 * its been set when PE entered WT_DEAUTH_STATE.
2165 */
2166 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2167 MTRACE(mac_trace
2168 (pMac, TRACE_CODE_SME_STATE,
2169 psessionEntry->peSessionId,
2170 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002171 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 break;
2173
2174 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002175 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2177 * PE can continue processing DISASSOC_REQ and send the response instead
2178 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2179 * for disassoc frame.
2180 *
2181 * It will send a disassoc, which is ok. However, we can use the global flag
2182 * sendDisassoc to not send disassoc frame.
2183 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002184 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 break;
2186
2187 case eLIM_SME_JOIN_FAILURE_STATE: {
2188 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002189 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 if (pMac->lim.gLimRspReqd) {
2191 retCode = eSIR_SME_SUCCESS;
2192 disassocTrigger = eLIM_HOST_DISASSOC;
2193 goto sendDisassoc;
2194 }
2195 }
2196 break;
2197 default:
2198 /**
2199 * STA is not currently associated.
2200 * Log error and send response to host
2201 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002202 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 psessionEntry->limSmeState);
2204 lim_print_sme_state(pMac, LOGE,
2205 psessionEntry->limSmeState);
2206
2207 if (pMac->lim.gLimRspReqd) {
2208 if (psessionEntry->limSmeState !=
2209 eLIM_SME_WT_ASSOC_STATE)
2210 pMac->lim.gLimRspReqd = false;
2211
2212 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2213 disassocTrigger = eLIM_HOST_DISASSOC;
2214 goto sendDisassoc;
2215 }
2216
2217 return;
2218 }
2219
2220 break;
2221
2222 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 /* Fall through */
2224 break;
2225
2226 case eLIM_STA_IN_IBSS_ROLE:
2227 default:
2228 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002229 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 GET_LIM_SYSTEM_ROLE(psessionEntry));
2231
2232 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2233 disassocTrigger = eLIM_HOST_DISASSOC;
2234 goto sendDisassoc;
2235 } /* end switch (pMac->lim.gLimSystemRole) */
2236
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302237 disassocTrigger = eLIM_HOST_DISASSOC;
2238 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239
2240 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002241 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 send_disassoc_frame = 0;
2243 }
2244 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_debug("Sending Disasscoc with disassoc Trigger"
2246 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 disassocTrigger, reasonCode);
2248
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302249 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002250 if (!pMlmDisassocReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252
Anurag Chouhanc5548422016-02-24 18:33:27 +05302253 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002254 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255
2256 pMlmDisassocReq->reasonCode = reasonCode;
2257 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2258
2259 /* Update PE session ID */
2260 pMlmDisassocReq->sessionId = sessionId;
2261
2262 lim_post_mlm_message(pMac,
2263 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2264 return;
2265
2266sendDisassoc:
2267 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002268 lim_send_sme_disassoc_ntf(pMac,
2269 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 retCode,
2271 disassocTrigger,
2272 1, smesessionId, smetransactionId,
2273 psessionEntry);
2274 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002275 lim_send_sme_disassoc_ntf(pMac,
2276 smeDisassocReq.peer_macaddr.bytes,
2277 retCode, disassocTrigger, 1,
2278 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279
2280} /*** end __lim_process_sme_disassoc_req() ***/
2281
2282/** -----------------------------------------------------------------
2283 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2284
2285 This function is called to process SME_DISASSOC_CNF message
2286 from HDD or upper layer application.
2287
2288 \param pMac - global mac structure
2289 \param pStaDs - station dph hash node
2290 \return none
2291 \sa
2292 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002293void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294{
2295 tSirSmeDisassocCnf smeDisassocCnf;
2296 uint16_t aid;
2297 tpDphHashNode pStaDs;
2298 tpPESession psessionEntry;
2299 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302300 uint32_t *msg = NULL;
2301 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302303 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 sizeof(struct sSirSmeDisassocCnf));
2305
2306 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002307 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 &sessionId);
2309 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002310 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302311 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302312 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302313 eSIR_SME_INVALID_SESSION,
2314 NULL);
2315 if (QDF_IS_STATUS_SUCCESS(status))
2316 lim_send_sme_disassoc_deauth_ntf(pMac,
2317 QDF_STATUS_SUCCESS,
2318 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 return;
2320 }
2321
2322 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002323 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302324 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2325 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302326 eSIR_SME_INVALID_PARAMETERS,
2327 &smeDisassocCnf.bssid.bytes[0]);
2328 if (QDF_IS_STATUS_SUCCESS(status))
2329 lim_send_sme_disassoc_deauth_ntf(pMac,
2330 QDF_STATUS_SUCCESS,
2331 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 return;
2333 }
2334#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2335 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2336 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2337 psessionEntry,
2338 (uint16_t) smeDisassocCnf.statusCode, 0);
2339 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2340 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2341 psessionEntry,
2342 (uint16_t) smeDisassocCnf.statusCode, 0);
2343#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2344
2345 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2346 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2348 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2349 && (psessionEntry->limSmeState !=
2350 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002351 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 psessionEntry->limSmeState);
2353 lim_print_sme_state(pMac, LOGE,
2354 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302355 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302356 psessionEntry->smeSessionId,
2357 eSIR_SME_INVALID_STATE,
2358 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302359 if (QDF_IS_STATUS_SUCCESS(status))
2360 lim_send_sme_disassoc_deauth_ntf(pMac,
2361 QDF_STATUS_SUCCESS,
2362 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 return;
2364 }
2365 break;
2366
2367 case eLIM_AP_ROLE:
2368 /* Fall through */
2369 break;
2370
2371 case eLIM_STA_IN_IBSS_ROLE:
2372 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002373 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302375 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2376 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302377 eSIR_SME_INVALID_STATE,
2378 &smeDisassocCnf.bssid.bytes[0]);
2379 if (QDF_IS_STATUS_SUCCESS(status))
2380 lim_send_sme_disassoc_deauth_ntf(pMac,
2381 QDF_STATUS_SUCCESS,
2382 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 return;
2384 }
2385
2386 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2387 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2388 LIM_IS_AP_ROLE(psessionEntry)) {
2389 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002390 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 &psessionEntry->dph.dphHashTable);
2392 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002393 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2394 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002395 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302396 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302397 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302398 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302399 &smeDisassocCnf.bssid.bytes[0]);
2400 if (QDF_IS_STATUS_SUCCESS(status))
2401 lim_send_sme_disassoc_deauth_ntf(pMac,
2402 QDF_STATUS_SUCCESS,
2403 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 return;
2405 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302406
2407 if ((pStaDs->mlmStaContext.mlmState ==
2408 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2409 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002410 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002411 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002412 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302413 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302414 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302415 psessionEntry->smeSessionId,
2416 eSIR_SME_SUCCESS,
2417 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302418 if (QDF_IS_STATUS_SUCCESS(status))
2419 lim_send_sme_disassoc_deauth_ntf(pMac,
2420 QDF_STATUS_SUCCESS,
2421 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302422 return;
2423 }
2424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 /* Delete FT session if there exists one */
2426 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2428
2429 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002430 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 }
2432
2433 return;
2434}
2435
2436/**
2437 * __lim_process_sme_deauth_req() - process sme deauth req
2438 * @mac_ctx: Pointer to Global MAC structure
2439 * @msg_buf: pointer to the SME message buffer
2440 *
2441 * This function is called to process SME_DEAUTH_REQ message
2442 * from HDD or upper layer application.
2443 *
2444 * Return: None
2445 */
2446
2447static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2448 uint32_t *msg_buf)
2449{
2450 uint16_t deauth_trigger, reason_code;
2451 tLimMlmDeauthReq *mlm_deauth_req;
2452 tSirSmeDeauthReq sme_deauth_req;
2453 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2454 tpPESession session_entry;
2455 uint8_t session_id; /* PE sessionId */
2456 uint8_t sme_session_id;
2457 uint16_t sme_transaction_id;
2458
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302459 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 sme_session_id = sme_deauth_req.sessionId;
2461 sme_transaction_id = sme_deauth_req.transactionId;
2462
2463 /*
2464 * We need to get a session first but we don't even know
2465 * if the message is correct.
2466 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002467 session_entry = pe_find_session_by_bssid(mac_ctx,
2468 sme_deauth_req.bssid.bytes,
2469 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002471 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 ret_code = eSIR_SME_INVALID_PARAMETERS;
2473 deauth_trigger = eLIM_HOST_DEAUTH;
2474 goto send_deauth;
2475 }
2476
2477 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2478 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002479 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 mac_ctx->lim.gLimRspReqd = false;
2481
2482 ret_code = eSIR_SME_INVALID_PARAMETERS;
2483 deauth_trigger = eLIM_HOST_DEAUTH;
2484 goto send_deauth;
2485 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002486 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2487 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2489 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002490 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2492 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2493 session_entry, 0, sme_deauth_req.reasonCode);
2494#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2495
2496 /* Update SME session ID and Transaction ID */
2497 session_entry->smeSessionId = sme_session_id;
2498 session_entry->transactionId = sme_transaction_id;
2499
2500 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2501 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 switch (session_entry->limSmeState) {
2503 case eLIM_SME_ASSOCIATED_STATE:
2504 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302505 /* Delete all TDLS peers connected before leaving BSS */
2506 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302507 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 case eLIM_SME_WT_ASSOC_STATE:
2509 case eLIM_SME_JOIN_FAILURE_STATE:
2510 case eLIM_SME_IDLE_STATE:
2511 session_entry->limPrevSmeState =
2512 session_entry->limSmeState;
2513 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2514 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2515 session_entry->peSessionId,
2516 session_entry->limSmeState));
2517 /* Send Deauthentication request to MLM below */
2518 break;
2519 case eLIM_SME_WT_DEAUTH_STATE:
2520 case eLIM_SME_WT_DISASSOC_STATE:
2521 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002522 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2524 * Which means host is also trying to disconnect.
2525 * PE can continue processing DEAUTH_REQ and send
2526 * the response instead of failing the request.
2527 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2528 * was sent for deauth/disassoc frame.
2529 */
2530 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002531 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 break;
2533 default:
2534 /*
2535 * STA is not in a state to deauthenticate with
2536 * peer. Log error and send response to host.
2537 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002538 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 session_entry->limSmeState);
2540 lim_print_sme_state(mac_ctx, LOGE,
2541 session_entry->limSmeState);
2542
2543 if (mac_ctx->lim.gLimRspReqd) {
2544 mac_ctx->lim.gLimRspReqd = false;
2545
2546 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2547 deauth_trigger = eLIM_HOST_DEAUTH;
2548
wadesong42968e92017-06-08 14:11:21 +08002549 /*
2550 * here we received deauth request from AP so
2551 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2552 * have ISSUED delSta then mlm state should be
2553 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2554 * delBSS rsp then mlm state should be
2555 * eLIM_MLM_IDLE_STATE so the below condition
2556 * captures the state where delSta not done
2557 * and firmware still in connected state.
2558 */
2559 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 eLIM_SME_WT_DEAUTH_STATE &&
2561 session_entry->limMlmState !=
2562 eLIM_MLM_IDLE_STATE &&
2563 session_entry->limMlmState !=
2564 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002565 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 goto send_deauth;
2567 }
2568 return;
2569 }
2570 break;
2571
2572 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002573 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 if (mac_ctx->lim.gLimRspReqd) {
2575 mac_ctx->lim.gLimRspReqd = false;
2576 ret_code = eSIR_SME_INVALID_PARAMETERS;
2577 deauth_trigger = eLIM_HOST_DEAUTH;
2578 goto send_deauth;
2579 }
2580 return;
2581 case eLIM_AP_ROLE:
2582 break;
2583 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002584 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 GET_LIM_SYSTEM_ROLE(session_entry));
2586 if (mac_ctx->lim.gLimRspReqd) {
2587 mac_ctx->lim.gLimRspReqd = false;
2588 ret_code = eSIR_SME_INVALID_PARAMETERS;
2589 deauth_trigger = eLIM_HOST_DEAUTH;
2590 goto send_deauth;
2591 }
2592 return;
2593 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2594
Yu Ouyang57c25532018-09-07 17:14:01 +08002595 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2596 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002598 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2600 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2601 } else {
2602 deauth_trigger = eLIM_HOST_DEAUTH;
2603 reason_code = sme_deauth_req.reasonCode;
2604 }
2605
2606 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302607 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002608 if (!mlm_deauth_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 if (mac_ctx->lim.gLimRspReqd) {
2610 mac_ctx->lim.gLimRspReqd = false;
2611 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2612 deauth_trigger = eLIM_HOST_DEAUTH;
2613 goto send_deauth;
2614 }
2615 return;
2616 }
2617
Anurag Chouhanc5548422016-02-24 18:33:27 +05302618 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002619 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620
2621 mlm_deauth_req->reasonCode = reason_code;
2622 mlm_deauth_req->deauthTrigger = deauth_trigger;
2623
2624 /* Update PE session Id */
2625 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002626 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 return;
2629
2630send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002631 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2632 ret_code, deauth_trigger, 1,
2633 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634}
2635
2636/**
2637 * __lim_process_sme_set_context_req()
2638 *
2639 * @mac_ctx: Pointer to Global MAC structure
2640 * @msg_buf: pointer to the SME message buffer
2641 *
2642 * This function is called to process SME_SETCONTEXT_REQ message
2643 * from HDD or upper layer application.
2644 *
2645 * Return: None
2646 */
2647
2648static void
2649__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2650{
2651 tpSirSmeSetContextReq set_context_req;
2652 tLimMlmSetKeysReq *mlm_set_key_req;
2653 tpPESession session_entry;
2654 uint8_t session_id; /* PE sessionID */
2655 uint8_t sme_session_id;
2656 uint16_t sme_transaction_id;
2657
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002659 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 return;
2661 }
2662
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002664 if (!set_context_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302666 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 sizeof(struct sSirSmeSetContextReq));
2668 sme_session_id = set_context_req->sessionId;
2669 sme_transaction_id = set_context_req->transactionId;
2670
2671 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002672 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 goto end;
2674 }
2675
2676 if (set_context_req->keyMaterial.numKeys >
2677 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002678 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 set_context_req->keyMaterial.numKeys);
2680 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002681 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 eSIR_SME_INVALID_PARAMETERS, NULL,
2683 sme_session_id, sme_transaction_id);
2684 goto end;
2685 }
2686
2687 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002688 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002690 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002692 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 eSIR_SME_INVALID_PARAMETERS, NULL,
2694 sme_session_id, sme_transaction_id);
2695 goto end;
2696 }
2697#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2698 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2699 session_entry, 0, 0);
2700#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2701
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002702 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2704 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002705 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2707 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302708 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002709 if (!mlm_set_key_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002710 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2712 mlm_set_key_req->numKeys =
2713 set_context_req->keyMaterial.numKeys;
2714 if (mlm_set_key_req->numKeys >
2715 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002716 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002717 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 goto end;
2719 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302720 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002721 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302723 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 (uint8_t *) &set_context_req->keyMaterial.key,
2725 sizeof(tSirKeys) *
2726 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2727 numKeys : 1));
2728
2729 mlm_set_key_req->sessionId = session_id;
2730 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002731 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733
2734 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2735 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2736 LIM_IS_AP_ROLE(session_entry)) {
2737 if (set_context_req->keyMaterial.key[0].keyLength) {
2738 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002739
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 key_id =
2741 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 &session_entry->WEPKeyMaterial[key_id],
2744 (uint8_t *) &set_context_req->keyMaterial,
2745 sizeof(tSirKeyMaterial));
2746 } else {
2747 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2750 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302751 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 &mlm_set_key_req->key[i],
2753 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2754 sizeof(tSirKeys));
2755 }
2756 }
2757 }
2758 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2759 (uint32_t *) mlm_set_key_req);
2760 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002761 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 GET_LIM_SYSTEM_ROLE(session_entry),
2763 session_entry->limSmeState);
2764 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2765
2766 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002767 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2769 session_entry, sme_session_id,
2770 sme_transaction_id);
2771 }
2772end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302773 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 return;
2775}
2776
2777/**
2778 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2779 *
2780 * @mac_ctx: Pointer to Global MAC structure
2781 * @msg_buf: pointer to the SME message buffer
2782 *
2783 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2784 * from HDD or upper layer application.
2785 *
2786 * Return: None
2787 */
2788
Jeff Johnson801f1532016-10-07 07:54:50 -07002789static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2790 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791{
2792 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2793 tpDphHashNode sta_ds = NULL;
2794 tpPESession session_entry = NULL;
2795 tSap_Event sap_event;
2796 tpWLAN_SAPEventCB sap_event_cb = NULL;
2797 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2798 uint8_t session_id = CSR_SESSION_ID_INVALID;
2799 uint8_t assoc_id = 0;
2800 uint8_t sta_cnt = 0;
2801
2802 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002803 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 return;
2805 }
2806
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808 sizeof(struct sSirSmeGetAssocSTAsReq));
2809 /*
2810 * Get Associated stations from PE.
2811 * Find PE session Entry
2812 */
2813 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002814 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 &session_id);
2816 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002817 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 goto lim_assoc_sta_end;
2819 }
2820
2821 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002822 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 session_entry->limSmeState,
2824 GET_LIM_SYSTEM_ROLE(session_entry));
2825 goto lim_assoc_sta_end;
2826 }
2827 /* Retrieve values obtained in the request message */
2828 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2829 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2830
2831 if (NULL == assoc_sta_tmp)
2832 goto lim_assoc_sta_end;
2833 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2834 assoc_id++) {
2835 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2836 &session_entry->dph.dphHashTable);
2837 if (NULL == sta_ds)
2838 continue;
2839 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302840 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302842 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2844 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2845
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302846 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 (uint8_t *)&sta_ds->supportedRates,
2848 sizeof(tSirSupportedRates));
2849 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2850 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2851 assoc_sta_tmp->Support40Mhz =
2852 sta_ds->htDsssCckRate40MHzSupport;
2853
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002854 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002856 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002858 pe_debug("Association Id: %d Station Index: %d",
2859 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 assoc_sta_tmp++;
2861 sta_cnt++;
2862 }
2863 }
2864lim_assoc_sta_end:
2865 /*
2866 * Call hdd callback with sap event to send the list of
2867 * associated stations from PE
2868 */
2869 if (sap_event_cb != NULL) {
2870 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2871 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302872 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2874 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2875 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2876 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2877 }
2878}
2879
2880/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 * __lim_counter_measures()
2882 *
2883 * FUNCTION:
2884 * This function is called to "implement" MIC counter measure
2885 * and is *temporary* only
2886 *
2887 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2888 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002889 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 *
2891 ***ASSUMPTIONS:
2892 *
2893 ***NOTE:
2894 *
2895 * @param pMac Pointer to Global MAC structure
2896 * @return None
2897 */
2898
2899static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2900{
2901 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002902
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002903 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2905 mac, psessionEntry, false);
2906};
2907
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302908void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2909 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302910{
2911 session->limSmeState = session->limPrevSmeState;
2912
2913 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2914 session->limSmeState));
2915
2916 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2917 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2918 session->transactionId);
2919}
2920
2921void lim_delete_all_peers(tpPESession session)
2922{
2923 uint8_t i = 0;
2924 tpAniSirGlobal mac_ctx = session->mac_ctx;
2925 tpDphHashNode sta_ds = NULL;
2926 QDF_STATUS status;
2927
2928 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2929 sta_ds = dph_get_hash_entry(mac_ctx, i,
2930 &session->dph.dphHashTable);
2931 if (!sta_ds)
2932 continue;
2933 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2934 if (QDF_STATUS_SUCCESS == status) {
2935 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2936 sta_ds->assocId, session);
2937 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2938 } else {
2939 pe_err("lim_del_sta failed with Status: %d", status);
2940 QDF_ASSERT(0);
2941 }
2942 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302943
2944#ifdef CONFIG_VDEV_SM
2945 status =
2946 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2947 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2948 sizeof(*session), session);
2949 if (QDF_IS_STATUS_ERROR(status)) {
2950 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2951 session->smeSessionId);
2952 lim_send_stop_bss_failure_resp(mac_ctx, session);
2953 }
2954#endif
2955
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302956}
2957
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002958QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2959{
2960 tpAniSirGlobal mac_ctx = session->mac_ctx;
2961 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2962 tpDphHashNode sta_ds = NULL;
2963
2964 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2965 &session->dph.dphHashTable);
2966 if (!sta_ds) {
2967 pe_err("DPH Entry for STA is missing, failed to send delbss");
2968 goto end;
2969 }
2970
2971 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2972 if (QDF_IS_STATUS_ERROR(status))
2973 pe_err("delBss failed for bss %d", session->bssIdx);
2974
2975end:
2976 return status;
2977}
2978
Abhishek Singhcaa61852018-09-12 15:50:04 +05302979QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302980{
2981 tpAniSirGlobal mac_ctx = session->mac_ctx;
2982 QDF_STATUS status;
2983
2984 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2985
2986 if (QDF_IS_STATUS_ERROR(status)) {
2987 pe_err("delBss failed for bss %d", session->bssIdx);
2988 lim_send_stop_bss_failure_resp(mac_ctx, session);
2989 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302990
2991 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302992}
2993
2994/**
2995 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
2996 * @session: session pointer
2997 *
2998 * Return None
2999 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303000#ifdef CONFIG_VDEV_SM
3001static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3002{
3003 tpAniSirGlobal mac_ctx = session->mac_ctx;
3004 QDF_STATUS status;
3005
Abhishek Singhc5a54082018-09-12 16:08:03 +05303006 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3007 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3008 status =
3009 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3010 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303011 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303012 else
3013 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3014 WLAN_VDEV_SM_EV_DOWN,
3015 sizeof(*session),
3016 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303017 if (QDF_IS_STATUS_ERROR(status)) {
3018 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3019 session->smeSessionId);
3020 lim_send_stop_bss_failure_resp(mac_ctx, session);
3021 }
3022}
3023#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303024static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3025{
3026 lim_delete_all_peers(session);
3027 /* send a delBss to HAL and wait for a response */
3028 lim_send_vdev_stop(session);
3029}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303030#endif
3031
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032static void
3033__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3034{
3035 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 tLimSmeStates prevState;
3037 tpPESession psessionEntry;
3038 uint8_t smesessionId;
3039 uint8_t sessionId;
3040 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303042 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 smesessionId = stopBssReq.sessionId;
3044 smetransactionId = stopBssReq.transactionId;
3045
3046 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003047 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 /* Send Stop BSS response to host */
3049 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3050 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3051 smetransactionId);
3052 return;
3053 }
3054
3055 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003056 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 &sessionId);
3058 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003059 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3061 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3062 smetransactionId);
3063 return;
3064 }
3065#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3066 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3067 0, 0);
3068#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3069
3070 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3071 LIM_IS_STA_ROLE(psessionEntry)) {
3072 /**
3073 * Should not have received STOP_BSS_REQ in states
3074 * other than 'normal' state or on STA in Infrastructure
3075 * mode. Log error and return response to host.
3076 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003077 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 psessionEntry->limSmeState,
3079 GET_LIM_SYSTEM_ROLE(psessionEntry));
3080 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3081 /* / Send Stop BSS response to host */
3082 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3083 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3084 smetransactionId);
3085 return;
3086 }
3087
3088 if (LIM_IS_AP_ROLE(psessionEntry))
3089 lim_wpspbc_close(pMac, psessionEntry);
3090
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003091 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 stopBssReq.reasonCode);
3093
3094 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303095 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096
3097 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3098 MTRACE(mac_trace
3099 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3100 psessionEntry->limSmeState));
3101
3102 /* Update SME session Id and Transaction Id */
3103 psessionEntry->smeSessionId = smesessionId;
3104 psessionEntry->transactionId = smetransactionId;
3105
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003106 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3107 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3108 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3112 /* Send disassoc all stations associated thru TKIP */
3113 __lim_counter_measures(pMac, psessionEntry);
3114 else
3115 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003116 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3117 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 }
3119
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003120 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3121 /* Free the buffer allocated in START_BSS_REQ */
3122 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3123 psessionEntry->addIeParams.probeRespDataLen = 0;
3124 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003126 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3127 psessionEntry->addIeParams.assocRespDataLen = 0;
3128 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003130 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3131 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3132 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003134 /*
3135 * lim_del_bss is also called as part of coalescing,
3136 * when we send DEL BSS followed by Add Bss msg.
3137 */
3138 pMac->lim.gLimIbssCoalescingHappened = false;
3139 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303141 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143}
3144
3145/**
3146 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3147 * @pMac: Global MAC context
3148 * @pMsg: Message from SME
3149 *
3150 * Wrapper for the function __lim_handle_sme_stop_bss_request
3151 * This message will be defered until softmac come out of
3152 * scan mode. Message should be handled even if we have
3153 * detected radar in the current operating channel.
3154 *
3155 * Return: true - If we consumed the buffer
3156 * false - If have defered the message.
3157 */
3158
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003159static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3160 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003161{
3162 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3163 /**
3164 * If message defered, buffer is not consumed yet.
3165 * So return false
3166 */
3167 return false;
3168 }
3169 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3170 return true;
3171} /*** end __lim_process_sme_stop_bss_req() ***/
3172
3173void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3174 uint32_t body, tpPESession psessionEntry)
3175{
3176
3177 (void)body;
3178 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3179 lim_ibss_delete(pMac, psessionEntry);
3180 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3181 lim_delete_pre_auth_list(pMac);
3182 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3183 psessionEntry->smeSessionId,
3184 psessionEntry->transactionId);
3185 return;
3186}
3187
3188/**
3189 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3190 *
3191 * @mac_ctx: pointer to mac context
3192 * @msg_type: message type
3193 * @msg_buf: pointer to the SME message buffer
3194 *
3195 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3196 * in BTAMP AP.
3197 *
3198 * Return: None
3199 */
3200
3201void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3202 uint32_t *msg_buf)
3203{
3204 tSirSmeAssocCnf assoc_cnf;
3205 tpDphHashNode sta_ds = NULL;
3206 tpPESession session_entry = NULL;
3207 uint8_t session_id;
3208 tpSirAssocReq assoc_req;
3209
3210 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003211 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 goto end;
3213 }
3214
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303215 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003217 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 goto end;
3219 }
3220
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003221 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 &session_id);
3223 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003224 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 goto end;
3226 }
3227
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003228 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3230 (session_entry->limSmeState !=
3231 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003232 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 msg_type, session_entry->limSmeState,
3234 GET_LIM_SYSTEM_ROLE(session_entry));
3235 goto end;
3236 }
3237 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3238 &session_entry->dph.dphHashTable);
3239 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303242 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
3244 /*
3245 * send a DISASSOC_IND message to WSM to make sure
3246 * the state in WSM and LIM is the same
3247 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003248 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 eSIR_SME_STA_NOT_ASSOCIATED,
3250 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3251 session_entry->smeSessionId,
3252 session_entry->transactionId,
3253 session_entry);
3254 goto end;
3255 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303256 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003257 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303258 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003259 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303261 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 goto end;
3263 }
3264
3265 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3266 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3267 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3268 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3269 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003270 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3271 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303273 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 goto end;
3275 }
3276 /*
3277 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3278 * has been received
3279 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003280 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3282 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3283
3284 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3285 /*
3286 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3287 * when it had received Assoc Request frame. Now, PE just needs
3288 * to send association rsp frame to the requesting BTAMP-STA.
3289 */
3290 sta_ds->mlmStaContext.mlmState =
3291 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003292 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003294 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 sta_ds->assocId, sta_ds->staAddr,
3296 sta_ds->mlmStaContext.subType, sta_ds,
3297 session_entry);
3298 goto end;
3299 } else {
3300 /*
3301 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3302 * to be associated since the HAL sta entry is created for
3303 * denied STA we need to remove this HAL entry.
3304 * So to do that set updateContext to 1
3305 */
3306 if (!sta_ds->mlmStaContext.updateContext)
3307 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003308 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 assoc_cnf.statusCode, sta_ds->assocId);
3310 lim_reject_association(mac_ctx, sta_ds->staAddr,
3311 sta_ds->mlmStaContext.subType,
3312 true, sta_ds->mlmStaContext.authType,
3313 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003314 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 session_entry);
3316 }
3317end:
3318 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3319 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3320 assoc_req = (tpSirAssocReq)
3321 session_entry->parsedAssocReq[sta_ds->assocId];
3322 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303323 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 assoc_req->assocReqFrame = NULL;
3325 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303326 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3328 }
3329}
3330
3331static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3332{
3333 tpDphHashNode pStaDs;
3334 tSirMacAddr peerMac;
3335 tpSirAddtsReq pSirAddts;
3336 uint32_t timeout;
3337 tpPESession psessionEntry;
3338 uint8_t sessionId; /* PE sessionId */
3339 uint8_t smesessionId;
3340 uint16_t smetransactionId;
3341
3342 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003343 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 return;
3345 }
3346
3347 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3348 &smetransactionId);
3349
3350 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3351
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003352 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3353 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003355 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003356 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303357 NULL, pSirAddts->req.tspec,
3358 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 return;
3360 }
3361#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3362 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3363 0);
3364#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3365
3366 /* if sta
3367 * - verify assoc state
3368 * - send addts request to ap
3369 * - wait for addts response from ap
3370 * if ap, just ignore with error log
3371 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003372 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3373 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3374 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003376 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003377 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303378 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380
3381 pStaDs =
3382 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3383 &psessionEntry->dph.dphHashTable);
3384
3385 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003386 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303387 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 }
3389
3390 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3391 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003392 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303393 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394 }
3395
3396 pSirAddts->req.wsmTspecPresent = 0;
3397 pSirAddts->req.wmeTspecPresent = 0;
3398 pSirAddts->req.lleTspecPresent = 0;
3399
3400 if ((pStaDs->wsmEnabled) &&
3401 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3402 SIR_MAC_ACCESSPOLICY_EDCA))
3403 pSirAddts->req.wsmTspecPresent = 1;
3404 else if (pStaDs->wmeEnabled)
3405 pSirAddts->req.wmeTspecPresent = 1;
3406 else if (pStaDs->lleEnabled)
3407 pSirAddts->req.lleTspecPresent = 1;
3408 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003409 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303410 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 }
3412
3413 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3414 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003415 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303417 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 }
3419
3420 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003421 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 pMac->lim.gLimAddtsReq.req.dialogToken,
3423 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3424 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3425 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303426 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 }
3428
3429 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3430
3431 /* save the addts request */
3432 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303433 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3435
3436 /* ship out the message now */
3437 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3438 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303439 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 /* start a timer to wait for the response */
3441 if (pSirAddts->timeout)
3442 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003443 else
3444 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445
3446 timeout = SYS_MS_TO_TICKS(timeout);
3447 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3448 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003449 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303450 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451 }
3452 pMac->lim.gLimAddtsRspTimerCount++;
3453 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3454 pMac->lim.gLimAddtsRspTimerCount) !=
3455 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003456 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303457 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 }
3459 MTRACE(mac_trace
3460 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3461 eLIM_ADDTS_RSP_TIMER));
3462
3463 /* add the sessionId to the timer object */
3464 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3465 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3466 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003467 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303468 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 }
3470 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303471
3472send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003473 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303474 psessionEntry, pSirAddts->req.tspec,
3475 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476}
3477
3478static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3479{
3480 tSirMacAddr peerMacAddr;
3481 uint8_t ac;
3482 tSirMacTSInfo *pTsinfo;
3483 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3484 tpDphHashNode pStaDs = NULL;
3485 tpPESession psessionEntry;
3486 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003487 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 uint8_t smesessionId;
3489 uint16_t smetransactionId;
3490
3491 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3492 &smetransactionId);
3493
3494 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003495 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 &sessionId);
3497 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003498 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003499 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 goto end;
3501 }
3502#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3503 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3504 0);
3505#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3506
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003507 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003509 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003510 status = QDF_STATUS_E_FAILURE;
3511 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 smesessionId, smetransactionId);
3513 return;
3514 }
3515
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003516 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3517 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3519
3520 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3521 pDeltsReq->req.wmeTspecPresent,
3522 &pDeltsReq->req.tsinfo,
3523 &pDeltsReq->req.tspec, psessionEntry);
3524
3525 pTsinfo =
3526 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3527 tsinfo : &pDeltsReq->req.tsinfo;
3528
3529 /* We've successfully send DELTS frame to AP. Update the
3530 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3531 * is no longer trigger enabled or delivery enabled
3532 */
3533 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3534 pTsinfo, CLEAR_UAPSD_MASK);
3535
3536 /* We're deleting the TSPEC, so this particular AC is no longer
3537 * admitted. PE needs to downgrade the EDCA
3538 * parameters(for the AC for which TS is being deleted) to the
3539 * next best AC for which ACM is not enabled, and send the
3540 * updated values to HAL.
3541 */
3542 ac = upToAc(pTsinfo->traffic.userPrio);
3543
3544 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3545 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3546 ~(1 << ac);
3547 } else if (pTsinfo->traffic.direction ==
3548 SIR_MAC_DIRECTION_DNLINK) {
3549 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3550 ~(1 << ac);
3551 } else if (pTsinfo->traffic.direction ==
3552 SIR_MAC_DIRECTION_BIDIR) {
3553 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3554 ~(1 << ac);
3555 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3556 ~(1 << ac);
3557 }
3558
3559 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3560 psessionEntry);
3561
3562 pStaDs =
3563 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3564 &psessionEntry->dph.dphHashTable);
3565 if (pStaDs != NULL) {
3566 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003567 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003568 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003570 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003571 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 }
3573#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003574 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575#endif
3576
3577 /* send an sme response back */
3578end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003579 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 smesessionId, smetransactionId);
3581}
3582
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303583void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584{
3585 /* fetch the sessionEntry based on the sessionId */
3586 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 psessionEntry = pe_find_session_by_session_id(pMac,
3589 pMac->lim.limTimers.gLimAddtsRspTimer.
3590 sessionId);
3591 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003592 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 return;
3594 }
3595
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003596 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003597 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 GET_LIM_SYSTEM_ROLE(psessionEntry));
3599 pMac->lim.gLimAddtsSent = false;
3600 return;
3601 }
3602
3603 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003604 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 return;
3606 }
3607
3608 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003609 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 pMac->lim.gLimAddtsRspTimerCount);
3611 return;
3612 }
3613 /* this a real response timeout */
3614 pMac->lim.gLimAddtsSent = false;
3615 pMac->lim.gLimAddtsRspTimerCount++;
3616
3617 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3618 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3619 psessionEntry->smeSessionId,
3620 psessionEntry->transactionId);
3621}
3622
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003623#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624/**
3625 * __lim_process_sme_get_statistics_request()
3626 *
3627 ***FUNCTION:
3628 *
3629 *
3630 ***NOTE:
3631 *
3632 * @param pMac Pointer to Global MAC structure
3633 * @param *pMsgBuf A pointer to the SME message buffer
3634 * @return None
3635 */
3636static void
3637__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3638{
3639 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003640 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641
3642 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3643
3644 msgQ.type = WMA_GET_STATISTICS_REQ;
3645
3646 msgQ.reserved = 0;
3647 msgQ.bodyptr = pMsgBuf;
3648 msgQ.bodyval = 0;
3649 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3650
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003651 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303652 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003654 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 return;
3656 }
3657
3658 return;
3659}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003660#else
3661static void __lim_process_sme_get_statistics_request(
3662 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3663#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003665#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003667 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003669 * @pMac: Pointer to Global MAC structure
3670 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003672 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 */
3674static void
3675__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3676{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003677 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678
3679 msgQ.type = WMA_TSM_STATS_REQ;
3680 msgQ.reserved = 0;
3681 msgQ.bodyptr = pMsgBuf;
3682 msgQ.bodyval = 0;
3683 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3684
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003685 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303686 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003688 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 return;
3690 }
3691}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003692#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003693
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003694static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3695 struct sme_addba_accept *msg)
3696{
3697 if (!msg) {
3698 pe_err("Msg Buffer is NULL");
3699 return;
3700 }
3701 if (!msg->addba_accept)
3702 mac_ctx->reject_addba_req = 1;
3703 else
3704 mac_ctx->reject_addba_req = 0;
3705}
3706
Arif Hussaineb8ba362018-03-07 19:15:13 -08003707static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3708 uint32_t sme_session_id)
3709{
3710 tpPESession pe_session;
3711 tpDphHashNode sta_ds_ptr;
3712
3713 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3714 if (!pe_session) {
3715 pe_err("Session does not exist: sme_id %d", sme_session_id);
3716 return;
3717 }
3718 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3719 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3720 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3721 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3722 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3723 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3724 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3725 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3726 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3727 &pe_session->dph.dphHashTable);
3728 if (sta_ds_ptr)
3729 lim_send_edca_params(mac_ctx,
3730 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003731 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003732 else
3733 pe_err("Self entry missing in Hash Table");
3734}
3735
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003736static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3737 uint32_t sme_session_id)
3738{
3739 tpPESession pe_session;
3740 tpDphHashNode sta_ds_ptr;
3741
3742 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3743 if (!pe_session) {
3744 pe_err("Session does not exist: sme_id %d", sme_session_id);
3745 return;
3746 }
3747 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3748 &pe_session->dph.dphHashTable);
3749 if (sta_ds_ptr)
3750 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3751 sta_ds_ptr->bssId, true);
3752 else
3753 pe_err("Self entry missing in Hash Table");
3754}
3755
Naveen Rawat8029a402017-06-01 10:54:19 -07003756static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3757 struct update_config *msg)
3758{
3759 tpPESession pe_session;
3760
3761 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3762 if (msg == NULL) {
3763 pe_err("Buffer is Pointing to NULL");
3764 return;
3765 }
3766
3767 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3768 msg->sme_session_id);
3769 if (pe_session == NULL) {
3770 pe_warn("Session does not exist for given BSSID");
3771 return;
3772 }
3773
3774 switch (msg->capab) {
3775 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3776 pe_session->htConfig.ht_rx_ldpc = msg->value;
3777 break;
3778 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3779 pe_session->htConfig.ht_tx_stbc = msg->value;
3780 break;
3781 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3782 pe_session->htConfig.ht_rx_stbc = msg->value;
3783 break;
3784 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3785 pe_session->htConfig.ht_sgi20 = msg->value;
3786 break;
3787 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3788 pe_session->htConfig.ht_sgi40 = msg->value;
3789 break;
3790 }
3791
3792 if (LIM_IS_AP_ROLE(pe_session)) {
3793 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
Abhishek Singhfc740be2018-10-12 11:34:26 +05303794 lim_send_beacon_ind(mac_ctx, pe_session, REASON_CONFIG_UPDATE);
Naveen Rawat8029a402017-06-01 10:54:19 -07003795 }
3796}
3797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003798void
3799lim_send_vdev_restart(tpAniSirGlobal pMac,
3800 tpPESession psessionEntry, uint8_t sessionId)
3801{
3802 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003803 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003804 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805
3806 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003807 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003808 return;
3809 }
3810
3811 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303812 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003813 if (!pHalHiddenSsidVdevRestart)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815
3816 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3817 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003818 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819
3820 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3821 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3822 msgQ.bodyval = 0;
3823
3824 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003825 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003826 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303827 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 }
3829}
3830
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303831/**
3832 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3833 * @mac_ctx: Pointer to Global MAC structure
3834 * @msg_buf: Pointer to SME message buffer
3835 *
3836 * Return: None
3837 */
3838static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3839 uint32_t *msg_buf)
3840{
3841 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003842 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003843 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303844 tSirRoamOffloadScanReq *req_buffer;
3845 uint16_t local_ie_len;
3846 uint8_t *local_ie_buf;
3847
3848 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3849 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3850 req_buffer->sessionId);
3851
3852 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3853 if (!local_ie_buf) {
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303854 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303855 return;
3856 }
3857
3858 local_ie_len = req_buffer->assoc_ie.length;
3859 /* Update ext cap IE if present */
3860 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003861 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3862 local_ie_buf, &local_ie_len)) {
3863 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003864 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3865 req_buffer->assoc_ie.length = local_ie_len;
3866 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3867 local_ie_buf, local_ie_len);
3868 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303869 }
3870 qdf_mem_free(local_ie_buf);
3871
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303872 if (pe_session)
3873 lim_update_fils_rik(pe_session, req_buffer);
3874
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303875 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3876 wma_msg.bodyptr = req_buffer;
3877
3878 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003879 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003880 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303881 qdf_mem_free(req_buffer);
3882 }
3883}
3884
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303885/*
3886 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3887 * @mac_ctx: Pointer to global mac context
3888 * @session: Pointer to PE session
3889 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3890 * 1 - Disable broadcast SSID
3891 *
3892 * Return: None
3893 */
3894static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3895 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003897 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003898 session->ssidHidden, ssid_hidden);
3899
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003900 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303901 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003902 } else {
3903 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303904 return;
3905 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906
Abhishek Singh6c681f42018-09-12 15:52:36 +05303907#ifdef CONFIG_VDEV_SM
3908 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3909 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3910 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3911 sizeof(*session), session);
3912#else
3913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303915 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303916#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303919}
3920
3921/**
3922 * __lim_process_sme_session_update - process SME session update msg
3923 *
3924 * @mac_ctx: Pointer to global mac context
3925 * @msg_buf: Pointer to the received message buffer
3926 *
3927 * Return: None
3928 */
3929static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3930 uint32_t *msg_buf)
3931{
3932 struct sir_update_session_param *msg;
3933 tpPESession session;
3934
3935 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003936 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303937 return;
3938 }
3939
3940 msg = (struct sir_update_session_param *) msg_buf;
3941
3942 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3943 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003944 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303945 msg->session_id);
3946 return;
3947 }
3948
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003949 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303950 msg->param_type, msg->param_val);
3951 switch (msg->param_type) {
3952 case SIR_PARAM_SSID_HIDDEN:
3953 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3954 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303955 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3956 session->ignore_assoc_disallowed = msg->param_val;
3957 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303958 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003959 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303960 break;
3961 }
3962}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964/*
3965 Update the beacon Interval dynamically if beaconInterval is different in MCC
3966 */
3967static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3968{
3969 tpSirChangeBIParams pChangeBIParams;
3970 tpPESession psessionEntry;
3971 uint8_t sessionId = 0;
3972 tUpdateBeaconParams beaconParams;
3973
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003974 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975
3976 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003977 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 return;
3979 }
3980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303981 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3983
3984 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003985 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 &sessionId);
3987 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003988 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 return;
3990 }
3991
3992 /*Update sessionEntry Beacon Interval */
3993 if (psessionEntry->beaconParams.beaconInterval !=
3994 pChangeBIParams->beaconInterval) {
3995 psessionEntry->beaconParams.beaconInterval =
3996 pChangeBIParams->beaconInterval;
3997 }
3998
3999 /*Update sch beaconInterval */
4000 if (pMac->sch.schObject.gSchBeaconInterval !=
4001 pChangeBIParams->beaconInterval) {
4002 pMac->sch.schObject.gSchBeaconInterval =
4003 pChangeBIParams->beaconInterval;
4004
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004005 pe_debug("LIM send update BeaconInterval Indication: %d",
4006 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004007
4008 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4009 /* Update beacon */
4010 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4011
4012 beaconParams.bssIdx = psessionEntry->bssIdx;
4013 /* Set change in beacon Interval */
4014 beaconParams.beaconInterval =
4015 pChangeBIParams->beaconInterval;
4016 beaconParams.paramChangeBitmap =
4017 PARAM_BCN_INTERVAL_CHANGED;
4018 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4019 }
4020 }
4021
4022 return;
4023} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4024
4025#ifdef QCA_HT_2040_COEX
4026static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4027 uint32_t *pMsgBuf)
4028{
4029 tpSirSetHT2040Mode pSetHT2040Mode;
4030 tpPESession psessionEntry;
4031 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004032 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 tUpdateVHTOpMode *pHtOpMode = NULL;
4034 uint16_t staId = 0;
4035 tpDphHashNode pStaDs = NULL;
4036
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004037 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004039 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 return;
4041 }
4042
4043 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4044
4045 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004046 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 &sessionId);
4048 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004049 pe_debug("Session does not exist for given BSSID");
4050 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 return;
4052 }
4053
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004054 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 pSetHT2040Mode->cbMode);
4056 /*Update sessionEntry HT related fields */
4057 switch (pSetHT2040Mode->cbMode) {
4058 case PHY_SINGLE_CHANNEL_CENTERED:
4059 psessionEntry->htSecondaryChannelOffset =
4060 PHY_SINGLE_CHANNEL_CENTERED;
4061 psessionEntry->htRecommendedTxWidthSet = 0;
4062 if (pSetHT2040Mode->obssEnabled)
4063 psessionEntry->htSupportedChannelWidthSet
4064 = eHT_CHANNEL_WIDTH_40MHZ;
4065 else
4066 psessionEntry->htSupportedChannelWidthSet
4067 = eHT_CHANNEL_WIDTH_20MHZ;
4068 break;
4069 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4070 psessionEntry->htSecondaryChannelOffset =
4071 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4072 psessionEntry->htRecommendedTxWidthSet = 1;
4073 break;
4074 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4075 psessionEntry->htSecondaryChannelOffset =
4076 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4077 psessionEntry->htRecommendedTxWidthSet = 1;
4078 break;
4079 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004080 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 return;
4082 }
4083
4084 /* Update beacon */
4085 sch_set_fixed_beacon_fields(pMac, psessionEntry);
Abhishek Singhfc740be2018-10-12 11:34:26 +05304086 lim_send_beacon_ind(pMac, psessionEntry, REASON_SET_HT2040);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087
4088 /* update OP Mode for each associated peer */
4089 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4090 pStaDs = dph_get_hash_entry(pMac, staId,
4091 &psessionEntry->dph.dphHashTable);
4092 if (NULL == pStaDs)
4093 continue;
4094
4095 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304096 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004097 if (!pHtOpMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 pHtOpMode->opMode =
4100 (psessionEntry->htSecondaryChannelOffset ==
4101 PHY_SINGLE_CHANNEL_CENTERED) ?
4102 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4103 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304104 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105 sizeof(tSirMacAddr));
4106 pHtOpMode->smesessionId = sessionId;
4107
4108 msg.type = WMA_UPDATE_OP_MODE;
4109 msg.reserved = 0;
4110 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004111 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304112 (scheduler_post_message(QDF_MODULE_ID_PE,
4113 QDF_MODULE_ID_WMA,
4114 QDF_MODULE_ID_WMA,
4115 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304117 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 return;
4119 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004120 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004121 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122
4123 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 }
4126
4127 return;
4128}
4129#endif
4130
4131/* -------------------------------------------------------------------- */
4132/**
4133 * __lim_process_report_message
4134 *
4135 * FUNCTION: Processes the next received Radio Resource Management message
4136 *
4137 * LOGIC:
4138 *
4139 * ASSUMPTIONS:
4140 *
4141 * NOTE:
4142 *
4143 * @param None
4144 * @return None
4145 */
4146
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004147static void __lim_process_report_message(tpAniSirGlobal pMac,
4148 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 switch (pMsg->type) {
4151 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4152 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4153 break;
4154 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004156 break;
4157 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004158 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160}
4161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162/* -------------------------------------------------------------------- */
4163/**
4164 * lim_send_set_max_tx_power_req
4165 *
4166 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4167 *
4168 * LOGIC:
4169 *
4170 * ASSUMPTIONS:
4171 *
4172 * NOTE:
4173 *
4174 * @param txPower txPower to be set.
4175 * @param pSessionEntry session entry.
4176 * @return None
4177 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004178QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004179lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 tpPESession pSessionEntry)
4181{
4182 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004183 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004184 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185
4186 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004187 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004188 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 }
4190
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304191 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004192 if (!pMaxTxParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004193 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304195 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304196 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304197 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004198 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304199 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200
4201 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4202 msgQ.bodyptr = pMaxTxParams;
4203 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004204 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4206 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004207 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004208 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304209 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 }
4211 return retCode;
4212}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214/**
4215 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4216 *
4217 * @mac_ctx: Pointer to Global MAC structure
4218 * @msg_buf: pointer to the SME message buffer
4219 *
4220 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4221 * from SME. It Register this information within PE.
4222 *
4223 * Return: None
4224 */
4225static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4226 uint32_t *msg_buf)
4227{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304228 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4230 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4231 struct mgmt_frm_reg_info *next = NULL;
4232 bool match = false;
4233
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004234 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 sme_req->registerFrame, sme_req->frameType,
4236 sme_req->matchLen);
4237 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304238 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304239 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4240 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304241 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242
4243 while (lim_mgmt_regn != NULL) {
4244 if (lim_mgmt_regn->frameType != sme_req->frameType)
4245 goto skip_match;
4246 if (sme_req->matchLen) {
4247 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304248 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 sme_req->matchData,
4250 lim_mgmt_regn->matchLen))) {
4251 /* found match! */
4252 match = true;
4253 break;
4254 }
4255 } else {
4256 /* found match! */
4257 match = true;
4258 break;
4259 }
4260skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304261 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304262 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304264 (qdf_list_node_t *)lim_mgmt_regn,
4265 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304266 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 lim_mgmt_regn = next;
4268 next = NULL;
4269 }
4270 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304271 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004272 if (QDF_STATUS_SUCCESS ==
4273 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004275 (qdf_list_node_t *)lim_mgmt_regn))
4276 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304277 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 }
4279
4280 if (sme_req->registerFrame) {
4281 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304282 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 sme_req->matchLen);
4284 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 lim_mgmt_regn->frameType = sme_req->frameType;
4286 lim_mgmt_regn->matchLen = sme_req->matchLen;
4287 lim_mgmt_regn->sessionId = sme_req->sessionId;
4288 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304289 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 sme_req->matchData,
4291 sme_req->matchLen);
4292 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304293 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304295 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 gLimMgmtFrameRegistratinQueue,
4297 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304298 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 &mac_ctx->lim.lim_frame_register_lock);
4300 }
4301 }
4302 return;
4303}
4304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305static void
4306__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4307{
4308 tpSirResetAPCapsChange pResetCapsChange;
4309 tpPESession psessionEntry;
4310 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004311
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004313 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 return;
4315 }
4316
4317 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4318 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004319 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4320 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004322 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 return;
4324 }
4325
4326 psessionEntry->limSentCapsChangeNtf = false;
4327 return;
4328}
4329
4330/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304331 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4332 * indication callback in PE.
4333 * @mac_ptr: Mac pointer
4334 * @msg_buf: Msg pointer containing the callback
4335 *
4336 * This function is used save the Management frame
4337 * indication callback in PE.
4338 *
4339 * Return: None
4340 */
4341static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4342 uint32_t *msg_buf)
4343{
4344 struct sir_sme_mgmt_frame_cb_req *sme_req =
4345 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4346
4347 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004348 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304349 return;
4350 }
4351 if (sme_req->callback)
4352 mac_ctx->mgmt_frame_ind_cb =
4353 (sir_mgmt_frame_ind_callback)sme_req->callback;
4354 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004355 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304356}
4357
4358/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304359 *__lim_process_send_disassoc_frame: function processes disassoc frame
4360 * @mac_ctx: pointer to mac context
4361 * @msg_buf: message buffer
4362 *
4363 * function processes disassoc request received from SME
4364 *
4365 * return: none
4366 */
4367static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4368 uint32_t *msg_buf)
4369{
4370 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004371 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304372 tpPESession session_entry = NULL;
4373 uint8_t sme_session_id;
4374 uint16_t sme_trans_id;
4375
4376 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004377 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304378 return;
4379 }
4380
4381 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4382 &sme_trans_id);
4383
4384 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4385 &sme_send_disassoc_frame_req,
4386 (uint8_t *)msg_buf);
4387
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004388 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304389 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4390 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004391 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304392 return;
4393 }
4394
4395 session_entry = pe_find_session_by_sme_session_id(
4396 mac_ctx, sme_session_id);
4397 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004398 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304399 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4400 return;
4401 }
4402
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004403 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 +05304404 sme_send_disassoc_frame_req.msg_type,
4405 sme_send_disassoc_frame_req.length,
4406 sme_send_disassoc_frame_req.session_id,
4407 sme_send_disassoc_frame_req.trans_id,
4408 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4409 sme_send_disassoc_frame_req.reason,
4410 sme_send_disassoc_frame_req.wait_for_ack);
4411
4412 lim_send_disassoc_mgmt_frame(mac_ctx,
4413 sme_send_disassoc_frame_req.reason,
4414 sme_send_disassoc_frame_req.peer_mac,
4415 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4416}
4417
4418/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004419 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4420 * @mac_ctx: Pointer to Global MAC structure
4421 * @pdev_id: pdev id to set the IE.
4422 * @nss: Nss values to prepare the HT IE.
4423 *
4424 * Prepares the HT IE with self capabilities for different
4425 * Nss values and sends the set HT IE req to FW.
4426 *
4427 * Return: None
4428 */
4429static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4430 uint8_t nss)
4431{
4432 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004433 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004434 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004435 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004436 tHtCaps *p_ht_cap;
4437 int i;
4438
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004439 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004440 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004441 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004442 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004443 ie_params->nss = i;
4444 ie_params->pdev_id = pdev_id;
4445 ie_params->ie_type = DOT11_HT_IE;
4446 /* 2 for IE len and EID */
4447 ie_params->ie_len = 2 + sizeof(tHtCaps);
4448 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004449 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004450 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004451 return;
4452 }
4453 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4454 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4455 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4456 ie_params->ie_len);
4457
4458 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004459 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4460 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004461 if (NULL == p_ie) {
4462 qdf_mem_free(ie_params->ie_ptr);
4463 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004464 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004465 return;
4466 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004467 p_ht_cap = (tHtCaps *)&p_ie[2];
4468 p_ht_cap->supportedMCSSet[1] = 0;
4469 p_ht_cap->txSTBC = 0;
4470 }
4471
4472 msg.type = WMA_SET_PDEV_IE_REQ;
4473 msg.bodyptr = ie_params;
4474 msg.bodyval = 0;
4475
4476 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004477 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004478 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004479 qdf_mem_free(ie_params->ie_ptr);
4480 qdf_mem_free(ie_params);
4481 return;
4482 }
4483 }
4484}
4485
4486/**
4487 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4488 * @mac_ctx: Pointer to Global MAC structure
4489 * @pdev_id: pdev id to set the IE.
4490 * @nss: Nss values to prepare the VHT IE.
4491 *
4492 * Prepares the VHT IE with self capabilities for different
4493 * Nss values and sends the set VHT IE req to FW.
4494 *
4495 * Return: None
4496 */
4497static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4498 uint8_t nss)
4499{
4500 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004501 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004502 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004503 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004504 tSirMacVHTCapabilityInfo *vht_cap;
4505 int i;
4506 tSirVhtMcsInfo *vht_mcs;
4507
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004508 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004509 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004510 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004511 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004512 ie_params->nss = i;
4513 ie_params->pdev_id = pdev_id;
4514 ie_params->ie_type = DOT11_VHT_IE;
4515 /* 2 for IE len and EID */
4516 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4517 sizeof(tSirVhtMcsInfo);
4518 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004519 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004520 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004521 return;
4522 }
4523 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4524 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4525 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4526 ie_params->ie_len);
4527
4528 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004529 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4530 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004531 if (NULL == p_ie) {
4532 qdf_mem_free(ie_params->ie_ptr);
4533 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004534 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004535 return;
4536 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004537 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4538 vht_cap->txSTBC = 0;
4539 vht_mcs =
4540 (tSirVhtMcsInfo *)&p_ie[2 +
4541 sizeof(tSirMacVHTCapabilityInfo)];
4542 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4543 vht_mcs->rxHighest =
4544 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4545 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4546 vht_mcs->txHighest =
4547 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4548 }
4549 msg.type = WMA_SET_PDEV_IE_REQ;
4550 msg.bodyptr = ie_params;
4551 msg.bodyval = 0;
4552
4553 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004554 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004555 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004556 qdf_mem_free(ie_params->ie_ptr);
4557 qdf_mem_free(ie_params);
4558 return;
4559 }
4560 }
4561}
4562
4563/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004564 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4565 * @mac_ctx: Pointer to Global MAC structure
4566 * @msg_buf: Pointer to the SME message buffer
4567 *
4568 * This function is called by limProcessMessageQueue(). This function sets the
4569 * VDEV IEs to the FW.
4570 *
4571 * Return: None
4572 */
4573static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4574 uint32_t *msg_buf)
4575{
4576 struct sir_set_vdev_ies_per_band *p_msg =
4577 (struct sir_set_vdev_ies_per_band *)msg_buf;
4578
4579 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004580 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004581 return;
4582 }
4583
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004584 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004585 p_msg->vdev_id);
4586 /* intentionally using NULL here so that self capabilty are sent */
4587 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4588 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004589 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004590}
4591
4592/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004593 * lim_process_set_pdev_IEs() - process the set pdev IE req
4594 * @mac_ctx: Pointer to Global MAC structure
4595 * @msg_buf: Pointer to the SME message buffer
4596 *
4597 * This function is called by limProcessMessageQueue(). This
4598 * function sets the PDEV IEs to the FW.
4599 *
4600 * Return: None
4601 */
4602static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4603{
4604 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4605
4606 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4607
4608 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004609 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004610 return;
4611 }
4612
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004613 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004614 ht_vht_cfg->nss);
4615 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4616
4617 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4618 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4619 ht_vht_cfg->nss);
4620}
4621
4622/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304623 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4624 *
4625 * access policy
4626 * @mac_ctx: pointer to mac context
4627 * @msg: message buffer
4628 *
4629 * function processes vendor IE and access policy from SME and updates PE
4630 *
4631 * session entry
4632 *
4633 * return: none
4634*/
4635static void lim_process_sme_update_access_policy_vendor_ie(
4636 tpAniSirGlobal mac_ctx,
4637 uint32_t *msg)
4638{
4639 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4640 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304641 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304642
4643 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004644 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304645 return;
4646 }
4647 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4648 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4649 update_vendor_ie->sme_session_id);
4650
4651 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004652 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304653 update_vendor_ie->sme_session_id);
4654 return;
4655 }
4656 if (pe_session_entry->access_policy_vendor_ie)
4657 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4658
4659 num_bytes = update_vendor_ie->ie[1] + 2;
4660 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004661 if (!pe_session_entry->access_policy_vendor_ie)
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304662 return;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304663 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4664 &update_vendor_ie->ie[0], num_bytes);
4665
4666 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4667}
4668
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004669#ifdef CONFIG_VDEV_SM
4670QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4671 uint16_t data_len, void *data)
4672{
4673 tpAniSirGlobal mac_ctx;
4674 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4675
4676 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4677 if (!mac_ctx) {
4678 pe_err("mac_ctx is NULL");
4679 if (data)
4680 qdf_mem_free(data);
4681 return QDF_STATUS_E_INVAL;
4682 }
4683 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4684
4685 switch (msg->type) {
4686 case eWNI_SME_DEAUTH_REQ:
4687 __lim_process_sme_deauth_req(mac_ctx,
4688 (uint32_t *)msg->bodyptr);
4689 break;
4690 case eWNI_SME_DISASSOC_CNF:
4691 case eWNI_SME_DEAUTH_CNF:
4692 __lim_process_sme_disassoc_cnf(mac_ctx,
4693 (uint32_t *)msg->bodyptr);
4694 break;
4695 case eWNI_SME_DISASSOC_REQ:
4696 __lim_process_sme_disassoc_req(mac_ctx,
4697 (uint32_t *)msg->bodyptr);
4698 break;
4699 default:
4700 pe_debug("Wrong message type received %d", msg->type);
4701 }
4702 return QDF_STATUS_SUCCESS;
4703}
4704#endif
4705
4706static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4707 struct scheduler_msg *msg)
4708{
4709#ifdef CONFIG_VDEV_SM
4710 tSirSmeDisassocCnf sme_disassoc_cnf;
4711 tpPESession session;
4712 uint8_t session_id;
4713 QDF_STATUS status;
4714
4715 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4716 sizeof(struct sSirSmeDisassocCnf));
4717
4718 session = pe_find_session_by_bssid(mac_ctx,
4719 sme_disassoc_cnf.bssid.bytes,
4720 &session_id);
4721
4722 if (LIM_IS_STA_ROLE(session)) {
4723 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4724 WLAN_VDEV_SM_EV_DOWN,
4725 sizeof(*msg),
4726 msg);
4727 } else {
4728 __lim_process_sme_disassoc_cnf(mac_ctx,
4729 (uint32_t *)msg->bodyptr);
4730 }
4731#else
4732 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4733#endif
4734}
4735
4736static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4737 struct scheduler_msg *msg)
4738{
4739#ifdef CONFIG_VDEV_SM
4740 tSirSmeDisassocReq disassoc_req;
4741 tpPESession session;
4742 uint8_t session_id;
4743 QDF_STATUS status;
4744
4745 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4746
4747 session = pe_find_session_by_bssid(mac_ctx,
4748 disassoc_req.bssid.bytes,
4749 &session_id);
4750 if (LIM_IS_STA_ROLE(session)) {
4751 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4752 WLAN_VDEV_SM_EV_DOWN,
4753 sizeof(*msg),
4754 msg);
4755 } else {
4756 __lim_process_sme_disassoc_req(mac_ctx,
4757 (uint32_t *)msg->bodyptr);
4758 }
4759#else
4760 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4761#endif
4762}
4763
4764static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4765 struct scheduler_msg *msg)
4766{
4767#ifdef CONFIG_VDEV_SM
4768 tSirSmeDeauthReq sme_deauth_req;
4769 tpPESession session;
4770 uint8_t session_id;
4771 QDF_STATUS status;
4772
4773 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4774
4775 session = pe_find_session_by_bssid(mac_ctx,
4776 sme_deauth_req.bssid.bytes,
4777 &session_id);
4778 if (LIM_IS_STA_ROLE(session)) {
4779 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4780 WLAN_VDEV_SM_EV_DOWN,
4781 sizeof(*msg),
4782 msg);
4783 } else {
4784 __lim_process_sme_deauth_req(mac_ctx,
4785 (uint32_t *)msg->bodyptr);
4786 }
4787#else
4788 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4789#endif
4790}
4791
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304792/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 * lim_process_sme_req_messages()
4794 *
4795 ***FUNCTION:
4796 * This function is called by limProcessMessageQueue(). This
4797 * function processes SME request messages from HDD or upper layer
4798 * application.
4799 *
4800 ***LOGIC:
4801 *
4802 ***ASSUMPTIONS:
4803 *
4804 ***NOTE:
4805 *
4806 * @param pMac Pointer to Global MAC structure
4807 * @param msgType Indicates the SME message type
4808 * @param *pMsgBuf A pointer to the SME message buffer
4809 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4810 * false - if pMsgBuf is not to be freed.
4811 */
4812
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004813bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4814 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815{
Jeff Johnson33142e62018-05-06 17:58:36 -07004816 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 -08004817 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004818
4819 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 lim_msg_str(pMsg->type), pMsg->type,
4821 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4822 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824 /* If no insert NOA required then execute the code below */
4825
4826 switch (pMsg->type) {
4827 case eWNI_SME_SYS_READY_IND:
4828 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4829 break;
4830
4831 case eWNI_SME_START_BSS_REQ:
4832 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4833 break;
4834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4836 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4837 break;
4838 case eWNI_SME_JOIN_REQ:
4839 __lim_process_sme_join_req(pMac, pMsgBuf);
4840 break;
4841
4842 case eWNI_SME_REASSOC_REQ:
4843 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4844 break;
4845
4846 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004847 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848 break;
4849
4850 case eWNI_SME_DISASSOC_CNF:
4851 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004852 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 break;
4854
4855 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004856 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 break;
4858
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304859 case eWNI_SME_SEND_DISASSOC_FRAME:
4860 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4861 break;
4862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004863 case eWNI_SME_SETCONTEXT_REQ:
4864 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4865 break;
4866
4867 case eWNI_SME_STOP_BSS_REQ:
4868 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4869 break;
4870
4871 case eWNI_SME_ASSOC_CNF:
4872 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004873 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4875 pMsgBuf);
4876 break;
4877
4878 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004879 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 __lim_process_sme_addts_req(pMac, pMsgBuf);
4881 break;
4882
4883 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004884 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 __lim_process_sme_delts_req(pMac, pMsgBuf);
4886 break;
4887
4888 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004889 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4891 break;
4892
4893 case eWNI_SME_GET_STATISTICS_REQ:
4894 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4895 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4896 bufConsumed = false;
4897 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004898#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899 case eWNI_SME_GET_TSM_STATS_REQ:
4900 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4901 bufConsumed = false;
4902 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004903#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 case eWNI_SME_GET_ASSOC_STAS_REQ:
4905 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4906 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304907 case eWNI_SME_SESSION_UPDATE_PARAM:
4908 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304910 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4911 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4912 bufConsumed = false;
4913 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004914 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4915 /* Update the beaconInterval */
4916 __lim_process_sme_change_bi(pMac, pMsgBuf);
4917 break;
4918
4919#ifdef QCA_HT_2040_COEX
4920 case eWNI_SME_SET_HT_2040_MODE:
4921 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4922 break;
4923#endif
4924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4926 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4927 __lim_process_report_message(pMac, pMsg);
4928 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 case eWNI_SME_FT_PRE_AUTH_REQ:
4931 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4932 break;
4933 case eWNI_SME_FT_UPDATE_KEY:
4934 lim_process_ft_update_key(pMac, pMsgBuf);
4935 break;
4936
4937 case eWNI_SME_FT_AGGR_QOS_REQ:
4938 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4939 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940
4941 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4942 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4943 break;
4944#ifdef FEATURE_WLAN_TDLS
4945 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4946 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4947 break;
4948 case eWNI_SME_TDLS_ADD_STA_REQ:
4949 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4950 break;
4951 case eWNI_SME_TDLS_DEL_STA_REQ:
4952 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4953 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954#endif
4955 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4956 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4957 break;
4958
4959 case eWNI_SME_CHANNEL_CHANGE_REQ:
4960 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4961 break;
4962
4963 case eWNI_SME_START_BEACON_REQ:
4964 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4965 break;
4966
4967 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4968 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4969 break;
4970
4971 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4972 lim_process_update_add_ies(pMac, pMsgBuf);
4973 break;
4974
4975 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4976 lim_process_modify_add_ies(pMac, pMsgBuf);
4977 break;
4978 case eWNI_SME_SET_HW_MODE_REQ:
4979 lim_process_set_hw_mode(pMac, pMsgBuf);
4980 break;
4981 case eWNI_SME_NSS_UPDATE_REQ:
4982 lim_process_nss_update_request(pMac, pMsgBuf);
4983 break;
4984 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4985 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4986 break;
4987 case eWNI_SME_SET_IE_REQ:
4988 lim_process_set_ie_req(pMac, pMsgBuf);
4989 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304990 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4991 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
4992 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304993 case eWNI_SME_EXT_CHANGE_CHANNEL:
4994 lim_process_ext_change_channel(pMac, pMsgBuf);
4995 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08004996 case eWNI_SME_SET_ANTENNA_MODE_REQ:
4997 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
4998 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004999 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5000 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005001 break;
5002 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5003 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5004 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305005 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5006 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5007 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005008 case eWNI_SME_UPDATE_CONFIG:
5009 lim_process_sme_update_config(pMac,
5010 (struct update_config *)pMsgBuf);
5011 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005012 case eWNI_SME_SET_ADDBA_ACCEPT:
5013 lim_process_sme_set_addba_accept(pMac,
5014 (struct sme_addba_accept *)pMsgBuf);
5015 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005016 case eWNI_SME_UPDATE_EDCA_PROFILE:
5017 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5018 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005019 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5020 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5021 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305023 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005024 pMsg->bodyptr = NULL;
5025 break;
5026 } /* switch (msgType) */
5027
5028 return bufConsumed;
5029} /*** end lim_process_sme_req_messages() ***/
5030
5031/**
5032 * lim_process_sme_start_beacon_req()
5033 *
5034 ***FUNCTION:
5035 * This function is called by limProcessMessageQueue(). This
5036 * function processes SME request messages from HDD or upper layer
5037 * application.
5038 *
5039 ***LOGIC:
5040 *
5041 ***ASSUMPTIONS:
5042 *
5043 ***NOTE:
5044 *
5045 * @param pMac Pointer to Global MAC structure
5046 * @param msgType Indicates the SME message type
5047 * @param *pMsgBuf A pointer to the SME message buffer
5048 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5049 * false - if pMsgBuf is not to be freed.
5050 */
5051static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5052{
5053 tpSirStartBeaconIndication pBeaconStartInd;
5054 tpPESession psessionEntry;
5055 uint8_t sessionId; /* PE sessionID */
5056
5057 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005058 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005059 return;
5060 }
5061
5062 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5063 psessionEntry = pe_find_session_by_bssid(pMac,
5064 pBeaconStartInd->bssid,
5065 &sessionId);
5066 if (psessionEntry == NULL) {
5067 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005068 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 return;
5070 }
5071
5072 if (pBeaconStartInd->beaconStartStatus == true) {
5073 /*
5074 * Currently this Indication comes from SAP
5075 * to start Beacon Tx on a DFS channel
5076 * since beaconing has to be done on DFS
5077 * channel only after CAC WAIT is completed.
5078 * On a DFS Channel LIM does not start beacon
5079 * Tx right after the WMA_ADD_BSS_RSP.
5080 */
5081 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305082 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 FL("Start Beacon with ssid %s Ch %d"),
5084 psessionEntry->ssId.ssId,
5085 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305086 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005087 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005088 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5089 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005091 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 return;
5093 }
5094}
5095
5096/**
5097 * lim_process_sme_channel_change_request() - process sme ch change req
5098 *
5099 * @mac_ctx: Pointer to Global MAC structure
5100 * @msg_buf: pointer to the SME message buffer
5101 *
5102 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5103 *
5104 * Return: None
5105 */
5106static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5107 uint32_t *msg_buf)
5108{
5109 tpSirChanChangeRequest ch_change_req;
5110 tpPESession session_entry;
5111 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005112 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 uint32_t val = 0;
5114
5115 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005116 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 return;
5118 }
5119 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5120
5121 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5122 ch_change_req->targetChannel);
5123
5124 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5125 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005126 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 return;
5128 }
5129
5130 session_entry = pe_find_session_by_bssid(mac_ctx,
5131 ch_change_req->bssid, &session_id);
5132 if (session_entry == NULL) {
5133 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005134 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 return;
5136 }
5137
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005138 if ((session_entry->currentOperChannel ==
5139 ch_change_req->targetChannel) &&
5140 (session_entry->ch_width == ch_change_req->ch_width)) {
5141 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5142 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 return;
5144 }
5145
5146 if (LIM_IS_AP_ROLE(session_entry))
5147 session_entry->channelChangeReasonCode =
5148 LIM_SWITCH_CHANNEL_SAP_DFS;
5149 else
5150 session_entry->channelChangeReasonCode =
5151 LIM_SWITCH_CHANNEL_OPERATION;
5152
Bala Venkateshb39ed152017-12-26 19:35:27 +05305153 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5154 session_entry->currentOperChannel,
5155 ch_change_req->targetChannel,
5156 ch_change_req->ch_width,
5157 ch_change_req->nw_type,
5158 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159
5160 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005161 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 session_entry->ch_center_freq_seg0 =
5163 ch_change_req->center_freq_seg_0;
5164 session_entry->ch_center_freq_seg1 =
5165 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005166 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005168 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 session_entry->htRecommendedTxWidthSet =
5170 session_entry->htSupportedChannelWidthSet;
5171 session_entry->currentOperChannel =
5172 ch_change_req->targetChannel;
5173 session_entry->limRFBand =
5174 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305175 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5176 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5177 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305178
5179 /* Update the global beacon filter */
5180 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005183 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005184 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005186 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005187 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 }
5189
5190 session_entry->lim11hEnable = val;
5191 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305192 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305193 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 &ch_change_req->operational_rateset,
5195 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305196 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 &ch_change_req->extended_rateset,
5198 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305199
5200#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305201 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305202 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5203 WLAN_VDEV_S_DFS_CAC_WAIT)
5204 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5205 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5206 sizeof(*session_entry),
5207 session_entry);
5208 else
5209 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5210 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5211 sizeof(*session_entry),
5212 session_entry);
5213
5214
5215#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5217 session_entry->ch_center_freq_seg0,
5218 session_entry->ch_center_freq_seg1,
5219 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005220 max_tx_pwr, session_entry->peSessionId,
5221 ch_change_req->cac_duration_ms,
5222 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305223#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224}
5225
5226/******************************************************************************
5227* lim_start_bss_update_add_ie_buffer()
5228*
5229***FUNCTION:
5230* This function checks the src buffer and its length and then malloc for
5231* dst buffer update the same
5232*
5233***LOGIC:
5234*
5235***ASSUMPTIONS:
5236*
5237***NOTE:
5238*
5239* @param pMac Pointer to Global MAC structure
5240* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5241* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5242* @param *pSrcData_buff A pointer of uint8_t src buffer
5243* @param srcDataLen src buffer length
5244******************************************************************************/
5245
5246static void
5247lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5248 uint8_t **pDstData_buff,
5249 uint16_t *pDstDataLen,
5250 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5251{
5252
5253 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5254 *pDstDataLen = srcDataLen;
5255
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305256 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005257 if (!*pDstData_buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005258 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305259 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 } else {
5261 *pDstData_buff = NULL;
5262 *pDstDataLen = 0;
5263 }
5264}
5265
5266/******************************************************************************
5267* lim_update_add_ie_buffer()
5268*
5269***FUNCTION:
5270* This function checks the src buffer and length if src buffer length more
5271* than dst buffer length then free the dst buffer and malloc for the new src
5272* length, and update the dst buffer and length. But if dst buffer is bigger
5273* than src buffer length then it just update the dst buffer and length
5274*
5275***LOGIC:
5276*
5277***ASSUMPTIONS:
5278*
5279***NOTE:
5280*
5281* @param pMac Pointer to Global MAC structure
5282* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5283* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5284* @param *pSrcData_buff A pointer of uint8_t src buffer
5285* @param srcDataLen src buffer length
5286******************************************************************************/
5287
5288static void
5289lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5290 uint8_t **pDstData_buff,
5291 uint16_t *pDstDataLen,
5292 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5293{
5294
5295 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005296 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 return;
5298 }
5299
5300 if (srcDataLen > *pDstDataLen) {
5301 *pDstDataLen = srcDataLen;
5302 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305303 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305305 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005306 if (!*pDstData_buff) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 *pDstDataLen = 0;
5308 return;
5309 }
5310 }
5311
5312 /* copy the content of buffer into dst buffer
5313 */
5314 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305315 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316
5317}
5318
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005319/**
5320 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5321 * @pMac : Pointer to Global MAC structure
5322 * @pDstData_buff : A pointer to pointer of dst buffer
5323 * @pDstDataLen : A pointer to pointer of dst buffer length
5324 * @pModifyIE : A pointer to tSirModifyIE
5325 *
5326 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5327 *
5328 * Return:
5329 * True or false depending upon whether IE is updated or not
5330 */
5331static bool
5332lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5333 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5334{
Hong Shi1553d692016-09-28 12:16:19 +08005335 int32_t oui_length;
5336 uint8_t *ibss_ie = NULL;
5337 uint8_t *vendor_ie;
5338#define MAC_VENDOR_OUI "\x00\x16\x32"
5339#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005340
5341 ibss_ie = pModifyIE->pIEBuffer;
5342 oui_length = pModifyIE->oui_length;
5343
5344 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005345 pe_err("Invalid set IBSS vendor IE command length %d",
5346 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005347 return false;
5348 }
5349
Hong Shi1553d692016-09-28 12:16:19 +08005350 /*
5351 * Why replace only beacon OUI data here:
5352 * 1. other ie (such as wpa) shall not be overwritten here.
5353 * 2. per spec, beacon oui ie might be set twice and original one
5354 * shall be updated.
5355 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005356 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005357 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5358 if (vendor_ie) {
5359 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5360 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5361 pModifyIE->ieBufferlength);
5362 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005363 uint16_t new_length;
5364 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005365
Naveen Rawat668dee32017-09-29 14:39:40 -07005366 /*
5367 * check for uint16 overflow before using sum of two numbers as
5368 * length of size to malloc
5369 */
5370 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5371 pe_err("U16 overflow due to %d + %d",
5372 pModifyIE->ieBufferlength, *pDstDataLen);
5373 return false;
5374 }
5375
5376 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5377 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005378 if (!new_ptr)
Hong Shi1553d692016-09-28 12:16:19 +08005379 return false;
Hong Shi1553d692016-09-28 12:16:19 +08005380 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5381 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5382 pModifyIE->ieBufferlength);
5383 qdf_mem_free(*pDstData_buff);
5384 *pDstDataLen = new_length;
5385 *pDstData_buff = new_ptr;
5386 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005387 return true;
5388}
5389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390/*
5391* lim_process_modify_add_ies() - process modify additional IE req.
5392*
5393* @mac_ctx: Pointer to Global MAC structure
5394* @msg_buf: pointer to the SME message buffer
5395*
5396* This function update the PE buffers for additional IEs.
5397*
5398* Return: None
5399*/
5400static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5401 uint32_t *msg_buf)
5402{
5403 tpSirModifyIEsInd modify_add_ies;
5404 tpPESession session_entry;
5405 uint8_t session_id;
5406 bool ret = false;
5407 tSirAddIeParams *add_ie_params;
5408
5409 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005410 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411 return;
5412 }
5413
5414 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5415 /* Incoming message has smeSession, use BSSID to find PE session */
5416 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005417 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418
5419 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005420 pe_err("Session not found for given bssid"
5421 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005422 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 goto end;
5424 }
5425 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5426 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5427 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005428 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429 modify_add_ies->modifyIE.pIEBuffer,
5430 modify_add_ies->modifyIE.ieBufferlength,
5431 modify_add_ies->modifyIE.ieID,
5432 modify_add_ies->modifyIE.ieIDLen,
5433 modify_add_ies->updateType);
5434 goto end;
5435 }
5436 add_ie_params = &session_entry->addIeParams;
5437 switch (modify_add_ies->updateType) {
5438 case eUPDATE_IE_PROBE_RESP:
5439 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005440 if (LIM_IS_IBSS_ROLE(session_entry)) {
5441 lim_update_ibss_prop_add_ies(mac_ctx,
5442 &add_ie_params->probeRespData_buff,
5443 &add_ie_params->probeRespDataLen,
5444 &modify_add_ies->modifyIE);
5445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446 break;
5447 case eUPDATE_IE_ASSOC_RESP:
5448 /* assoc resp IE */
5449 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305450 QDF_TRACE(QDF_MODULE_ID_PE,
5451 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 "assoc resp add ie not present %d"),
5453 add_ie_params->assocRespDataLen);
5454 }
5455 /* search through the buffer and modify the IE */
5456 break;
5457 case eUPDATE_IE_PROBE_BCN:
5458 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005459 if (LIM_IS_IBSS_ROLE(session_entry)) {
5460 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5461 &add_ie_params->probeRespBCNData_buff,
5462 &add_ie_params->probeRespBCNDataLen,
5463 &modify_add_ies->modifyIE);
5464 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465 if (ret == true && modify_add_ies->modifyIE.notify) {
5466 lim_handle_param_update(mac_ctx,
5467 modify_add_ies->updateType);
5468 }
5469 break;
5470 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005471 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472 modify_add_ies->updateType);
5473 break;
5474 }
5475end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305476 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 modify_add_ies->modifyIE.pIEBuffer = NULL;
5478}
5479
5480/*
5481* lim_process_update_add_ies() - process additional IE update req
5482*
5483* @mac_ctx: Pointer to Global MAC structure
5484* @msg_buf: pointer to the SME message buffer
5485*
5486* This function update the PE buffers for additional IEs.
5487*
5488* Return: None
5489*/
5490static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5491 uint32_t *msg_buf)
5492{
5493 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5494 uint8_t session_id;
5495 tpPESession session_entry;
5496 tSirAddIeParams *addn_ie;
5497 uint16_t new_length = 0;
5498 uint8_t *new_ptr = NULL;
5499 tSirUpdateIE *update_ie;
5500
5501 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005502 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 return;
5504 }
5505 update_ie = &update_add_ies->updateIE;
5506 /* incoming message has smeSession, use BSSID to find PE session */
5507 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005508 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005509
5510 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305511 pe_debug("Session not found for given bssid"
5512 MAC_ADDRESS_STR,
5513 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 goto end;
5515 }
5516 addn_ie = &session_entry->addIeParams;
5517 /* if len is 0, upper layer requested freeing of buffer */
5518 if (0 == update_ie->ieBufferlength) {
5519 switch (update_add_ies->updateType) {
5520 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305521 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 addn_ie->probeRespData_buff = NULL;
5523 addn_ie->probeRespDataLen = 0;
5524 break;
5525 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305526 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 addn_ie->assocRespData_buff = NULL;
5528 addn_ie->assocRespDataLen = 0;
5529 break;
5530 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305531 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 addn_ie->probeRespBCNData_buff = NULL;
5533 addn_ie->probeRespBCNDataLen = 0;
5534
5535 if (update_ie->notify)
5536 lim_handle_param_update(mac_ctx,
5537 update_add_ies->updateType);
5538 break;
5539 default:
5540 break;
5541 }
5542 return;
5543 }
5544 switch (update_add_ies->updateType) {
5545 case eUPDATE_IE_PROBE_RESP:
5546 if (update_ie->append) {
5547 /*
5548 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005549 * with combined length.
5550 * Multiple back to back append commands
5551 * can lead to a huge length.So, check
5552 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005554 if (addn_ie->probeRespDataLen >
5555 (USHRT_MAX - update_ie->ieBufferlength)) {
5556 pe_err("IE Length overflow, curr:%d, new:%d",
5557 addn_ie->probeRespDataLen,
5558 update_ie->ieBufferlength);
5559 goto end;
5560 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 new_length = update_ie->ieBufferlength +
5562 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305563 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005564 if (!new_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305567 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305569 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570 update_ie->pAdditionIEBuffer,
5571 update_ie->ieBufferlength);
5572 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305573 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 /* adjust length accordingly */
5575 addn_ie->probeRespDataLen = new_length;
5576 /* save refernece of local buffer in PE session */
5577 addn_ie->probeRespData_buff = new_ptr;
5578 goto end;
5579 }
5580 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5581 &addn_ie->probeRespDataLen,
5582 update_ie->pAdditionIEBuffer,
5583 update_ie->ieBufferlength);
5584 break;
5585 case eUPDATE_IE_ASSOC_RESP:
5586 /* assoc resp IE */
5587 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5588 &addn_ie->assocRespDataLen,
5589 update_ie->pAdditionIEBuffer,
5590 update_ie->ieBufferlength);
5591 break;
5592 case eUPDATE_IE_PROBE_BCN:
5593 /* probe resp Bcn IE */
5594 lim_update_add_ie_buffer(mac_ctx,
5595 &addn_ie->probeRespBCNData_buff,
5596 &addn_ie->probeRespBCNDataLen,
5597 update_ie->pAdditionIEBuffer,
5598 update_ie->ieBufferlength);
5599 if (update_ie->notify)
5600 lim_handle_param_update(mac_ctx,
5601 update_add_ies->updateType);
5602 break;
5603 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005604 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 break;
5606 }
5607end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305608 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 update_ie->pAdditionIEBuffer = NULL;
5610}
5611
5612/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305613 * send_extended_chan_switch_action_frame()- function to send ECSA
5614 * action frame for each sta connected to SAP/GO and AP in case of
5615 * STA .
5616 * @mac_ctx: pointer to global mac structure
5617 * @new_channel: new channel to switch to.
5618 * @ch_bandwidth: BW of channel to calculate op_class
5619 * @session_entry: pe session
5620 *
5621 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5622 *
5623 * Return: void
5624 */
5625
5626static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5627 uint16_t new_channel, uint8_t ch_bandwidth,
5628 tpPESession session_entry)
5629{
5630 uint16_t op_class;
5631 uint8_t switch_mode = 0, i;
5632 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005633 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305634
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005635 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305636 mac_ctx->scan.countryCodeCurrent,
5637 new_channel,
5638 ch_bandwidth);
5639
5640 if (LIM_IS_AP_ROLE(session_entry) &&
5641 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005642 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305643
gaoleze2920bd2017-03-21 17:38:42 +08005644 switch_count = session_entry->gLimChannelSwitch.switchCount;
5645
Abhishek Singh518323d2015-10-19 17:42:01 +05305646 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005647 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305648 psta =
5649 session_entry->dph.dphHashTable.pDphNodeArray + i;
5650 if (psta && psta->added)
5651 lim_send_extended_chan_switch_action_frame(
5652 mac_ctx,
5653 psta->staAddr,
5654 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005655 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305656 }
5657 } else if (LIM_IS_STA_ROLE(session_entry)) {
5658 lim_send_extended_chan_switch_action_frame(mac_ctx,
5659 session_entry->bssId,
5660 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005661 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305662 }
5663
5664}
5665
gaolez76d2a162017-03-21 19:23:58 +08005666void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5667 uint16_t new_channel,
5668 uint8_t ch_bandwidth,
5669 tpPESession session_entry)
5670{
5671 uint16_t op_class;
5672 uint8_t switch_mode = 0, i;
5673 uint8_t switch_count;
5674 tpDphHashNode psta;
5675 tpDphHashNode dph_node_array_ptr;
5676
5677 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5678
5679 op_class = wlan_reg_dmn_get_opclass_from_channel(
5680 mac_ctx->scan.countryCodeCurrent,
5681 new_channel, ch_bandwidth);
5682
5683 if (LIM_IS_AP_ROLE(session_entry) &&
5684 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5685 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5686
5687 switch_count = session_entry->gLimChannelSwitch.switchCount;
5688
5689 if (LIM_IS_AP_ROLE(session_entry)) {
5690 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5691 psta = dph_node_array_ptr + i;
5692 if (!(psta && psta->added))
5693 continue;
5694 if (session_entry->lim_non_ecsa_cap_num == 0)
5695 lim_send_extended_chan_switch_action_frame
5696 (mac_ctx, psta->staAddr, switch_mode,
5697 op_class, new_channel, switch_count,
5698 session_entry);
5699 else
5700 lim_send_channel_switch_mgmt_frame
5701 (mac_ctx, psta->staAddr, switch_mode,
5702 new_channel, switch_count,
5703 session_entry);
5704 }
5705 } else if (LIM_IS_STA_ROLE(session_entry)) {
5706 lim_send_extended_chan_switch_action_frame
5707 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5708 new_channel, switch_count, session_entry);
5709 }
5710}
5711
5712/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5714 *
5715 * @mac_ctx: Pointer to Global MAC structure
5716 * @msg_buf: pointer to the SME message buffer
5717 *
5718 * This function processes SME request messages from HDD or upper layer
5719 * application.
5720 *
5721 * Return: None
5722 */
5723static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5724 uint32_t *msg_buf)
5725{
5726 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5727 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005728 uint8_t session_id;
5729 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005730 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731
5732 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005733 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 return;
5735 }
5736
5737 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5738 session_entry = pe_find_session_by_bssid(mac_ctx,
5739 dfs_csa_ie_req->bssid, &session_id);
5740 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005741 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5743 return;
5744 }
5745
5746 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005747 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 GET_LIM_SYSTEM_ROLE(session_entry));
5749 return;
5750 }
5751
5752 /* target channel */
5753 session_entry->gLimChannelSwitch.primaryChannel =
5754 dfs_csa_ie_req->targetChannel;
5755
5756 /* Channel switch announcement needs to be included in beacon */
5757 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005758 session_entry->gLimChannelSwitch.switchCount =
5759 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005761 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305762 session_entry->gLimChannelSwitch.sec_ch_offset =
5763 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005765 session_entry->gLimChannelSwitch.switchMode =
5766 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767
5768 /*
5769 * Validate if SAP is operating HT or VHT mode and set the Channel
5770 * Switch Wrapper element with the Wide Band Switch subelement.
5771 */
5772 if (true != session_entry->vhtCapability)
5773 goto skip_vht;
5774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 /* Now encode the Wider Ch BW element depending on the ch width */
5776 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005777 switch (dfs_csa_ie_req->ch_params.ch_width) {
5778 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 /*
5780 * Wide channel BW sublement in channel wrapper element is not
5781 * required in case of 20 Mhz operation. Currently It is set
5782 * only set in case of 40/80 Mhz Operation.
5783 */
5784 session_entry->dfsIncludeChanWrapperIe = false;
5785 wider_bw_ch_switch->newChanWidth =
5786 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5787 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005788 case CH_WIDTH_40MHZ:
5789 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 wider_bw_ch_switch->newChanWidth =
5791 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5792 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005793 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 session_entry->dfsIncludeChanWrapperIe = true;
5795 wider_bw_ch_switch->newChanWidth =
5796 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5797 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005798 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 session_entry->dfsIncludeChanWrapperIe = true;
5800 wider_bw_ch_switch->newChanWidth =
5801 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5802 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005803 case CH_WIDTH_80P80MHZ:
5804 session_entry->dfsIncludeChanWrapperIe = true;
5805 wider_bw_ch_switch->newChanWidth =
5806 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005807 /*
5808 * This is not applicable for 20/40/80 Mhz.
5809 * Only used when we support 80+80 Mhz operation.
5810 * In case of 80+80 Mhz, this parameter indicates
5811 * center channel frequency index of 80 Mhz channel of
5812 * frequency segment 1.
5813 */
5814 wider_bw_ch_switch->newCenterChanFreq1 =
5815 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005816 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 default:
5818 session_entry->dfsIncludeChanWrapperIe = false;
5819 /*
5820 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5821 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5822 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005823 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005824 break;
5825 }
5826 /* Fetch the center channel based on the channel width */
5827 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005828 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829skip_vht:
5830 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305831 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305832
5833 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5834 ch_offset = BW80;
5835 else
5836 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5837
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005838 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305839 session_entry->gLimChannelSwitch.switchCount,
5840 session_entry->gLimChannelSwitch.primaryChannel,
5841 session_entry->gLimChannelSwitch.ch_width,
5842 session_entry->dfsIncludeChanWrapperIe,
5843 ch_offset);
5844
gaolez76d2a162017-03-21 19:23:58 +08005845 /* Send ECSA/CSA Action frame after updating the beacon */
5846 if (CHAN_HOP_ALL_BANDS_ENABLE)
5847 lim_send_chan_switch_action_frame(mac_ctx,
5848 session_entry->gLimChannelSwitch.primaryChannel,
5849 ch_offset, session_entry);
5850 else
5851 send_extended_chan_switch_action_frame(mac_ctx,
5852 session_entry->gLimChannelSwitch.primaryChannel,
5853 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854}
5855
5856/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305857 * lim_process_ext_change_channel()- function to send ECSA
5858 * action frame for STA/CLI .
5859 * @mac_ctx: pointer to global mac structure
5860 * @msg: params from sme for new channel.
5861 *
5862 * This function is called to send ECSA frame for STA/CLI.
5863 *
5864 * Return: void
5865 */
5866
5867static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5868 uint32_t *msg)
5869{
5870 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5871 (struct sir_sme_ext_cng_chan_req *) msg;
5872 tpPESession session_entry = NULL;
5873
5874 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005875 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305876 return;
5877 }
5878 session_entry =
5879 pe_find_session_by_sme_session_id(mac_ctx,
5880 ext_chng_channel->session_id);
5881 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005882 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305883 ext_chng_channel->session_id);
5884 return;
5885 }
5886 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005887 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305888 return;
5889 }
5890 send_extended_chan_switch_action_frame(mac_ctx,
5891 ext_chng_channel->new_channel,
5892 0, session_entry);
5893}
5894
5895/**
Abhishek Singhfc740be2018-10-12 11:34:26 +05305896 * lim_nss_update_rsp() - send NSS update response to SME
5897 * @mac_ctx Pointer to Global MAC structure
5898 * @vdev_id: vdev id
5899 * @status: nss update status
5900 *
5901 * Return: None
5902 */
5903static void lim_nss_update_rsp(tpAniSirGlobal mac_ctx,
5904 uint8_t vdev_id, QDF_STATUS status)
5905{
5906 struct scheduler_msg msg = {0};
5907 struct sir_bcn_update_rsp *nss_rsp;
5908 QDF_STATUS qdf_status;
5909
5910 nss_rsp = qdf_mem_malloc(sizeof(*nss_rsp));
5911 if (!nss_rsp) {
5912 pe_err("AllocateMemory failed for nss_rsp");
5913 return;
5914 }
5915
5916 nss_rsp->vdev_id = vdev_id;
5917 nss_rsp->status = status;
5918 nss_rsp->reason = REASON_NSS_UPDATE;
5919
5920 msg.type = eWNI_SME_NSS_UPDATE_RSP;
5921 msg.bodyptr = nss_rsp;
5922 msg.bodyval = 0;
5923 qdf_status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_SME,
5924 QDF_MODULE_ID_SME, &msg);
5925 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5926 pe_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
5927 qdf_mem_free(nss_rsp);
5928 }
5929}
5930
5931void lim_send_bcn_rsp(tpAniSirGlobal mac_ctx, tpSendbeaconParams rsp)
5932{
5933 if (!rsp) {
5934 pe_err("rsp is NULL");
5935 return;
5936 }
5937
5938 pe_debug("Send beacon resp status %d for reason %d",
5939 rsp->status, rsp->reason);
5940
5941 if (rsp->reason == REASON_NSS_UPDATE)
5942 lim_nss_update_rsp(mac_ctx, rsp->vdev_id, rsp->status);
5943}
5944
5945/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 * lim_process_nss_update_request() - process sme nss update req
5947 *
5948 * @mac_ctx: Pointer to Global MAC structure
5949 * @msg_buf: pointer to the SME message buffer
5950 *
5951 * This function processes SME request messages from HDD or upper layer
5952 * application.
5953 *
5954 * Return: None
5955 */
5956static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5957 uint32_t *msg_buf)
5958{
5959 struct sir_nss_update_request *nss_update_req_ptr;
5960 tpPESession session_entry = NULL;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305961 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5962 uint8_t vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005963
Abhishek Singhfc740be2018-10-12 11:34:26 +05305964 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005965 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 return;
5967 }
5968
5969 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305970 vdev_id = nss_update_req_ptr->vdev_id;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305971 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305973 if (!session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005974 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305976 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005977 }
5978
5979 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005980 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 GET_LIM_SYSTEM_ROLE(session_entry));
Abhishek Singhfc740be2018-10-12 11:34:26 +05305982 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 }
5984
5985 /* populate nss field in the beacon */
5986 session_entry->gLimOperatingMode.present = 1;
5987 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305988 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5989
5990 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5991 (session_entry->ch_width > CH_WIDTH_80MHZ))
5992 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
5993
Abhishek Singhfc740be2018-10-12 11:34:26 +05305994 pe_debug("ch width %d Rx NSS %d",
5995 session_entry->gLimOperatingMode.chanWidth,
5996 session_entry->gLimOperatingMode.rxNSS);
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 /* Send nss update request from here */
Abhishek Singhfc740be2018-10-12 11:34:26 +05305999 status = sch_set_fixed_beacon_fields(mac_ctx, session_entry);
6000 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006001 pe_err("Unable to set op mode IE in beacon");
Abhishek Singhfc740be2018-10-12 11:34:26 +05306002 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 }
6004
Abhishek Singhfc740be2018-10-12 11:34:26 +05306005 status = lim_send_beacon_ind(mac_ctx, session_entry, REASON_NSS_UPDATE);
6006 if (QDF_IS_STATUS_SUCCESS(status))
6007 return;
6008
6009 pe_err("Unable to send beacon");
6010end:
6011 /*
6012 * send resp only in case of failure,
6013 * success case response will be from wma.
6014 */
6015 lim_nss_update_rsp(mac_ctx, vdev_id, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016}
6017
6018/**
6019 * lim_process_set_ie_req() - process sme set IE request
6020 *
6021 * @mac_ctx: Pointer to Global MAC structure
6022 * @msg_buf: pointer to the SME message buffer
6023 *
6024 * This function processes SME request messages from HDD or upper layer
6025 * application.
6026 *
6027 * Return: None
6028 */
6029static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6030{
6031 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306032 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033
6034 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006035 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006036 return;
6037 }
6038
6039 msg = (struct send_extcap_ie *)msg_buf;
6040 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306041 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006042 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006043
6044}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006045
6046#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006047
6048/**
6049 * obss_color_collision_process_color_disable() - Disable bss color
6050 * @mac_ctx: Pointer to Global MAC structure
6051 * @session: pointer to session
6052 *
6053 * This function will disbale bss color.
6054 *
6055 * Return: None
6056 */
6057static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6058 tpPESession session)
6059{
6060 tUpdateBeaconParams beacon_params;
6061
6062 if (!session) {
6063 pe_err("Invalid session");
6064 return;
6065 }
6066
6067 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6068 pe_err("Invalid SystemRole %d",
6069 GET_LIM_SYSTEM_ROLE(session));
6070 return;
6071 }
6072
6073 if (session->bss_color_changing == 1) {
6074 pe_warn("%d: color change in progress", session->smeSessionId);
6075 /* Continue color collision detection */
6076 lim_send_obss_color_collision_cfg(mac_ctx, session,
6077 OBSS_COLOR_COLLISION_DETECTION);
6078 return;
6079 }
6080
6081 if (session->he_op.bss_col_disabled == 1) {
6082 pe_warn("%d: bss color already disabled",
6083 session->smeSessionId);
6084 /* Continue free color detection */
6085 lim_send_obss_color_collision_cfg(mac_ctx, session,
6086 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6087 return;
6088 }
6089
6090 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6091 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6092 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006093 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006094 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006095
6096 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006097 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006098 pe_err("Unable to set op mode IE in beacon");
6099 return;
6100 }
6101
6102 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6103 lim_send_obss_color_collision_cfg(mac_ctx, session,
6104 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6105}
6106
6107/**
6108 * obss_color_collision_process_color_change() - Process bss color change
6109 * @mac_ctx: Pointer to Global MAC structure
6110 * @session: pointer to session
6111 * @obss_color_info: obss color collision/free slot indication info
6112 *
6113 * This function selects new color ib case of bss color collision.
6114 *
6115 * Return: None
6116 */
6117static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6118 tpPESession session,
6119 struct wmi_obss_color_collision_info *obss_color_info)
6120{
6121 int i, num_bss_color = 0;
6122 uint32_t bss_color_bitmap;
6123 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6124 uint32_t rand_byte = 0;
6125 struct sir_set_he_bss_color he_bss_color;
6126 bool is_color_collision = false;
6127
6128
6129 if (session->bss_color_changing == 1) {
6130 pe_err("%d: color change in progress", session->smeSessionId);
6131 return;
6132 }
6133
6134 if (!session->he_op.bss_col_disabled) {
6135 if (session->he_op.bss_color < 32)
6136 is_color_collision = (obss_color_info->
6137 obss_color_bitmap_bit0to31 >>
6138 session->he_op.bss_color) & 0x01;
6139 else
6140 is_color_collision = (obss_color_info->
6141 obss_color_bitmap_bit32to63 >>
6142 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006143 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006144 if (!is_color_collision) {
6145 pe_err("%d: color collision not found, curr_color: %d",
6146 session->smeSessionId,
6147 session->he_op.bss_color);
6148 return;
6149 }
6150 }
6151
6152 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6153
6154 /* Skip color zero */
6155 bss_color_bitmap = bss_color_bitmap >> 1;
6156 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6157 if (!(bss_color_bitmap & 0x01)) {
6158 bss_color_index_array[num_bss_color] = i + 1;
6159 num_bss_color++;
6160 }
6161 bss_color_bitmap = bss_color_bitmap >> 1;
6162 }
6163
6164 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6165 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6166 if (!(bss_color_bitmap & 0x01)) {
6167 bss_color_index_array[num_bss_color] = i + 32;
6168 num_bss_color++;
6169 }
6170 bss_color_bitmap = bss_color_bitmap >> 1;
6171 }
6172
6173 if (num_bss_color) {
6174 qdf_get_random_bytes((void *) &rand_byte, 1);
6175 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6176 num_bss_color;
6177 pe_debug("New bss color = %d", bss_color_index_array[i]);
6178 he_bss_color.session_id = obss_color_info->vdev_id;
6179 he_bss_color.bss_color = bss_color_index_array[i];
6180 lim_process_set_he_bss_color(mac_ctx,
6181 (uint32_t *)&he_bss_color);
6182 } else {
6183 pe_err("Unable to find bss color from bitmasp");
6184 if (obss_color_info->evt_type ==
6185 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6186 session->obss_color_collision_dec_evt ==
6187 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6188 /* In dot11BSSColorCollisionAPPeriod and
6189 * timer expired, time to disable bss color.
6190 */
6191 obss_color_collision_process_color_disable(mac_ctx,
6192 session);
6193 else
6194 /*
6195 * Enter dot11BSSColorCollisionAPPeriod period.
6196 */
6197 lim_send_obss_color_collision_cfg(mac_ctx, session,
6198 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6199 }
6200}
6201
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006202void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6203{
6204 struct sir_set_he_bss_color *bss_color;
6205 tpPESession session_entry = NULL;
6206 tUpdateBeaconParams beacon_params;
6207
6208 if (!msg_buf) {
6209 pe_err("Buffer is Pointing to NULL");
6210 return;
6211 }
6212
6213 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6214 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6215 bss_color->session_id);
6216 if (!session_entry) {
6217 pe_err("Session not found for given session_id %d",
6218 bss_color->session_id);
6219 return;
6220 }
6221
6222 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6223 pe_err("Invalid SystemRole %d",
6224 GET_LIM_SYSTEM_ROLE(session_entry));
6225 return;
6226 }
6227
6228 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6229 pe_err("No change in BSS color, current BSS color %d",
6230 bss_color->bss_color);
6231 return;
6232 }
6233 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6234 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6235 session_entry->he_op.bss_col_disabled = 1;
6236 session_entry->he_bss_color_change.countdown =
6237 BSS_COLOR_SWITCH_COUNTDOWN;
6238 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006239 beacon_params.bss_color_disabled = 1;
6240 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006241 session_entry->bss_color_changing = 1;
6242
6243 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006244 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006245 pe_err("Unable to set op mode IE in beacon");
6246 return;
6247 }
6248
6249 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006250 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6251 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6252}
6253
6254void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6255 tpPESession session,
6256 enum wmi_obss_color_collision_evt_type
6257 event_type)
6258{
6259 struct wmi_obss_color_collision_cfg_param *cfg_param;
6260 struct scheduler_msg msg = {0};
6261
6262 if (!session) {
6263 pe_err("Invalid session");
6264 return;
6265 }
6266
6267 if (!session->he_capable ||
6268 !session->is_session_obss_color_collision_det_enabled) {
6269 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6270 session->smeSessionId, session->he_capable,
6271 session->is_session_obss_color_collision_det_enabled,
6272 mac_ctx->lim.global_obss_color_collision_det_offload);
6273 return;
6274 }
6275
6276 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006277 if (!cfg_param)
Arif Hussain05fb4872018-01-03 16:02:55 -08006278 return;
Arif Hussain05fb4872018-01-03 16:02:55 -08006279
6280 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6281 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6282 cfg_param->vdev_id = session->smeSessionId;
6283 cfg_param->evt_type = event_type;
6284 if (LIM_IS_AP_ROLE(session))
6285 cfg_param->detection_period_ms =
6286 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6287 else
6288 cfg_param->detection_period_ms =
6289 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6290
6291 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6292 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6293 cfg_param->free_slot_expiry_time_ms =
6294 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6295
6296 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6297 msg.bodyptr = cfg_param;
6298 msg.reserved = 0;
6299
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306300 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6301 QDF_MODULE_ID_WMA,
6302 QDF_MODULE_ID_WMA,
6303 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006304 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6305 qdf_mem_free(cfg_param);
6306 } else {
6307 session->obss_color_collision_dec_evt = event_type;
6308 }
6309}
6310
6311void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6312 uint32_t *msg_buf)
6313{
6314 struct wmi_obss_color_collision_info *obss_color_info;
6315 tpPESession session;
6316
6317 if (!msg_buf) {
6318 pe_err("Buffer is Pointing to NULL");
6319 return;
6320 }
6321
6322 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6323 session = pe_find_session_by_sme_session_id(mac_ctx,
6324 obss_color_info->vdev_id);
6325 if (!session) {
6326 pe_err("Session not found for given session_id %d",
6327 obss_color_info->vdev_id);
6328 return;
6329 }
6330
6331 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6332 obss_color_info->vdev_id,
6333 obss_color_info->evt_type,
6334 session->obss_color_collision_dec_evt,
6335 obss_color_info->obss_color_bitmap_bit0to31,
6336 obss_color_info->obss_color_bitmap_bit32to63,
6337 session->he_capable,
6338 session->is_session_obss_color_collision_det_enabled,
6339 mac_ctx->lim.global_obss_color_collision_det_offload);
6340
6341 if (!session->he_capable ||
6342 !session->is_session_obss_color_collision_det_enabled) {
6343 return;
6344 }
6345
6346 switch (obss_color_info->evt_type) {
6347 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6348 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6349 session->smeSessionId, session->he_capable,
6350 session->is_session_obss_color_collision_det_enabled,
6351 mac_ctx->lim.global_obss_color_collision_det_offload);
6352 session->is_session_obss_color_collision_det_enabled = false;
6353 return;
6354 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6355 case OBSS_COLOR_COLLISION_DETECTION:
6356 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6357 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6358 pe_debug("Invalid System Role %d",
6359 GET_LIM_SYSTEM_ROLE(session));
6360 return;
6361 }
6362
6363 if (session->obss_color_collision_dec_evt !=
6364 obss_color_info->evt_type) {
6365 pe_debug("%d: Wrong event: %d, skiping",
6366 obss_color_info->vdev_id,
6367 obss_color_info->evt_type);
6368 return;
6369 }
6370 obss_color_collision_process_color_change(mac_ctx, session,
6371 obss_color_info);
6372 break;
6373 default:
6374 pe_err("%d: Invalid event type %d",
6375 obss_color_info->vdev_id, obss_color_info->evt_type);
6376 return;
6377 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006378}
6379#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306380
6381#ifdef CONFIG_VDEV_SM
6382void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6383{
6384 tpPESession session;
6385
6386 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6387
6388 if (!session) {
6389 pe_err("session not found for vdev id %d", vdev_id);
6390 return;
6391 }
6392
6393 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6394 WLAN_VDEV_SM_EV_CSA_RESTART,
6395 sizeof(*session), session);
6396}
6397#endif