blob: 90eacc23f50f66443ef30d5f917cba215c0213ea [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "sap_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053055#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070056#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/*
59 * This overhead is time for sending NOA start to host in case of GO/sending
60 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
61 * with init scan req/rsp plus in case of concurrency, taking care of sending
62 * null data and receiving ACK to/from AP/Also SetChannel with calibration
63 * is taking around 7ms .
64 */
65#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
66#define JOIN_NOA_DURATION 2000 /* in msecs */
67#define OEM_DATA_NOA_DURATION 60 /* in msecs */
68#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
69
70#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
71
Paul Zhangd2315472017-02-22 10:02:50 +080072#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
73#define STA_BURST_SCAN_DURATION 120 /* in msecs */
74
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* SME REQ processing function templates */
76static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080077static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
78 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
80static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
81static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
82static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080085static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
86 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053087static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
88 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
90 uint32_t *pMsg);
91static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
92static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
93static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
94static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95
96static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
97 uint8_t **pDstData_buff,
98 uint16_t *pDstDataLen,
99 uint8_t *pSrcData_buff,
100 uint16_t srcDataLen);
101
102static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800106static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Abhishek Singh518323d2015-10-19 17:42:01 +0530114static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
115 uint32_t *msg);
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
118 * lim_process_set_hw_mode() - Send set HW mode command to WMA
119 * @mac: Globacl MAC pointer
120 * @msg: Message containing the hw mode index
121 *
122 * Send the set HW mode command to WMA
123 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530124 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530126static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700129 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800130 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 uint32_t len;
132 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700133 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 struct sir_set_hw_mode_resp *param;
135
136 buf = (struct s_sir_set_hw_mode *) msg;
137 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700138 pe_err("Set HW mode param is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530139 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 /* To free the active command list */
141 goto fail;
142 }
143
144 len = sizeof(*req_msg);
145
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530146 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530147 if (!req_msg) {
148 pe_debug("failed to allocate memory");
149 status = QDF_STATUS_E_NOMEM;
150 goto fail;
151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530154 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 /* Other parameters are not needed for WMA */
156
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800157 message.bodyptr = req_msg;
158 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700160 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530161 status = scheduler_post_message(QDF_MODULE_ID_PE,
162 QDF_MODULE_ID_WMA,
163 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530164 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700165 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 goto fail;
169 }
170 return status;
171fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530172 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700173 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 param->status = SET_HW_MODE_STATUS_ECANCELED;
176 param->cfgd_hw_mode_index = 0;
177 param->num_vdev_mac_entries = 0;
178 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
179 resp_msg.bodyptr = param;
180 resp_msg.bodyval = 0;
181 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530182 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183}
184
185/**
186 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
187 * @mac: Global MAC pointer
188 * @msg: Message containing the dual mac config parameter
189 *
190 * Send the set dual mac config command to WMA
191 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195 uint32_t *msg)
196{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530197 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700198 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800199 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 uint32_t len;
201 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700202 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 struct sir_dual_mac_config_resp *param;
204
205 buf = (struct sir_set_dual_mac_cfg *) msg;
206 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700207 pe_err("Set Dual mac config is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530208 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /* To free the active command list */
210 goto fail;
211 }
212
213 len = sizeof(*req_msg);
214
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530215 req_msg = qdf_mem_malloc(len);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530216 if (!req_msg) {
217 pe_debug("failed to allocate memory");
218 status = QDF_STATUS_E_NOMEM;
219 goto fail;
220 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 req_msg->scan_config = buf->set_dual_mac.scan_config;
223 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
224 /* Other parameters are not needed for WMA */
225
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800226 message.bodyptr = req_msg;
227 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700229 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530231 status = scheduler_post_message(QDF_MODULE_ID_PE,
232 QDF_MODULE_ID_WMA,
233 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700235 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530237 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 goto fail;
239 }
240 return status;
241fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530242 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700243 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 param->status = SET_HW_MODE_STATUS_ECANCELED;
246 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
247 resp_msg.bodyptr = param;
248 resp_msg.bodyval = 0;
249 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530250 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251}
252
253/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800254 * lim_process_set_antenna_mode_req() - Set antenna mode command
255 * to WMA
256 * @mac: Global MAC pointer
257 * @msg: Message containing the antenna mode parameter
258 *
259 * Send the set antenna mode command to WMA
260 *
261 * Return: QDF_STATUS_SUCCESS if message posting is successful
262 */
263static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
264 uint32_t *msg)
265{
266 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700267 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 struct sir_antenna_mode_param *req_msg;
269 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700270 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800271 struct sir_antenna_mode_resp *param;
272
273 buf = (struct sir_set_antenna_mode *) msg;
274 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700275 pe_err("Set antenna mode is NULL");
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530276 status = QDF_STATUS_E_INVAL;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800277 /* To free the active command list */
278 goto fail;
279 }
280
281 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530282 if (!req_msg) {
283 pe_debug("failed to allocate memory");
284 status = QDF_STATUS_E_NOMEM;
285 goto fail;
286 }
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800287
288 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
289 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
290
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800291 message.bodyptr = req_msg;
292 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800293
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700294 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800295 req_msg->num_rx_chains,
296 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530297 status = scheduler_post_message(QDF_MODULE_ID_PE,
298 QDF_MODULE_ID_WMA,
299 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800300 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700301 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800302 status);
303 qdf_mem_free(req_msg);
304 goto fail;
305 }
306 return status;
307fail:
308 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700309 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800311 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
312 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
313 resp_msg.bodyptr = param;
314 resp_msg.bodyval = 0;
315 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Abhishek Singhd93a0b22018-10-30 17:04:56 +0530316 return status;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800317}
318
319/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 * __lim_is_sme_assoc_cnf_valid()
321 *
322 ***FUNCTION:
323 * This function is called by __lim_process_sme_assoc_cnf_new() upon
324 * receiving SME_ASSOC_CNF.
325 *
326 ***LOGIC:
327 * Message validity checks are performed in this function
328 *
329 ***ASSUMPTIONS:
330 *
331 ***NOTE:
332 *
333 * @param pMeasReq Pointer to Received ASSOC_CNF message
334 * @return true When received SME_ASSOC_CNF is formatted
335 * correctly
336 * false otherwise
337 */
338
339static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
340{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530341 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 return false;
343 else
344 return true;
345} /*** end __lim_is_sme_assoc_cnf_valid() ***/
346
347/**
348 * __lim_get_sme_join_req_size_for_alloc()
349 *
350 ***FUNCTION:
351 * This function is called in various places to get IE length
352 * from tSirBssDescription structure
353 * number being scanned.
354 *
355 ***PARAMS:
356 *
357 ***LOGIC:
358 *
359 ***ASSUMPTIONS:
360 * NA
361 *
362 ***NOTE:
363 * NA
364 *
365 * @param pBssDescr
366 * @return Total IE length
367 */
368
369static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
370{
371 uint16_t len = 0;
372
373 if (!pBuf)
374 return len;
375
376 pBuf += sizeof(uint16_t);
377 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700378 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379}
380
381/**
382 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
383 * @pMac: Global MAC context
384 * @pMsg: Pointer to message posted from SME to LIM.
385 *
386 * Has role only if 11h is enabled. Not used on STA side.
387 * Defers the message if SME is in learn state and brings
388 * the LIM back to normal mode.
389 *
390 * Return: true - If defered false - Otherwise
391 */
392
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800393static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
394 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395{
396 if (lim_is_system_in_scan_state(pMac)) {
397 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700398 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 return false;
400 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700401 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 pMsg->type);
403 return true;
404 }
405 return false;
406}
407
408/**
409 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
410 * @mac_ctx: Pointer to Global MAC structure
411 * @message: Pointer to message posted from SME to LIM.
412 *
413 * Has role only if 11h is enabled. Not used on STA side.
414 * Defers the message if radar is detected.
415 *
416 * Return: true, if defered otherwise return false.
417 */
418static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800419__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
420 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421{
422 /*
423 * fRadarDetCurOperChan will be set only if we
424 * detect radar in current operating channel and
425 * System Role == AP ROLE
426 *
427 * TODO: Need to take care radar detection.
428 *
429 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
430 */
431 if (0) {
432 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700433 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 return false;
435 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700436 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 message->type);
438 return true;
439 }
440 return false;
441}
442
443/**
444 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
445 * @pMac: Global MAC context
446 * @pMsgBuf: Message from WMA
447 *
448 * handles the notification from HDD. PE just forwards this message to HAL.
449 *
450 * Return: true-Posting to HAL failed, so PE will consume the buffer.
451 * false-Posting to HAL successful, so HAL will consume the buffer.
452 */
453
454static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
455{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700456 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
458
459 msg.type = WMA_SYS_READY_IND;
460 msg.reserved = 0;
461 msg.bodyptr = pMsgBuf;
462 msg.bodyval = 0;
463
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700464 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800465 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530466 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700467 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700468 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530469 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700471
472 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
474
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700475 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700476 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 return true;
478 }
479 return false;
480}
481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482/**
483 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
484 *@mac_ctx: Pointer to Global MAC structure
485 *@session: A pointer to session entry
486 *@sme_start_bss_req: Start BSS Request from upper layers.
487 *
488 * This function is used to configure the start bss parameters
489 * in to the session.
490 *
491 * Return: None.
492 */
493static void
494lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
495 tpSirSmeStartBssReq sme_start_bss_req)
496{
497 session->limSystemRole = eLIM_AP_ROLE;
498 session->privacy = sme_start_bss_req->privacy;
499 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
500 session->authType = sme_start_bss_req->authType;
501 /* Store the DTIM period */
502 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
503 /* Enable/disable UAPSD */
504 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530505 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 session->proxyProbeRspEn = 0;
507 } else {
508 /*
509 * To detect PBC overlap in SAP WPS mode,
510 * Host handles Probe Requests.
511 */
512 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
513 session->proxyProbeRspEn = 1;
514 else
515 session->proxyProbeRspEn = 0;
516 }
517 session->ssidHidden = sme_start_bss_req->ssidHidden;
518 session->wps_state = sme_start_bss_req->wps_state;
519 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530520 session->vendor_vht_sap =
521 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
523 &session->shortSlotTimeSupported);
524 session->isCoalesingInIBSSAllowed =
525 sme_start_bss_req->isCoalesingInIBSSAllowed;
526
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800527 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
528
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529}
530
531/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530532 * lim_send_start_vdev_req() - send vdev start request
533 *@session: pe session
534 *@mlm_start_req: vdev start req
535 *
536 * Return: QDF_STATUS
537 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530538#ifdef CONFIG_VDEV_SM
539static QDF_STATUS
540lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
541{
542 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
543 WLAN_VDEV_SM_EV_START,
544 sizeof(*mlm_start_req),
545 mlm_start_req);
546}
547#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530548static QDF_STATUS
549lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
550{
551 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
552
553 return QDF_STATUS_SUCCESS;
554}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530555#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530556
557/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
559 *@mac_ctx: Pointer to Global MAC structure
560 *@msg_buf: A pointer to the SME message buffer
561 *
562 * This function is called to process SME_START_BSS_REQ message
563 * from HDD or upper layer application.
564 *
565 * Return: None
566 */
567static void
568__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
569{
570 uint16_t size;
571 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700572 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 tSirMacChanNum channel_number;
574 tLimMlmStartReq *mlm_start_req = NULL;
575 tpSirSmeStartBssReq sme_start_bss_req = NULL;
576 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
577 /* Flag Used in case of IBSS to Auto generate BSSID. */
578 uint32_t auto_gen_bssid = false;
579 uint8_t session_id;
580 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800581 uint8_t sme_session_id = 0xFF;
582 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700584 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530585 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586
587/* FEATURE_WLAN_DIAG_SUPPORT */
588#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
589 /*
590 * Since the session is not created yet, sending NULL.
591 * The response should have the correct state.
592 */
593 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
594 NULL, 0, 0);
595#endif /* FEATURE_WLAN_DIAG_SUPPORT */
596
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700597 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800598 size = sizeof(tSirSmeStartBssReq);
599 sme_start_bss_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700600 if (!sme_start_bss_req) {
Krunal Sonib37bb352016-12-20 14:12:21 -0800601 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
602 goto free;
603 }
604 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
605 sme_session_id = sme_start_bss_req->sessionId;
606 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
609 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
611 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700612 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 ret_code = eSIR_SME_INVALID_PARAMETERS;
614 goto free;
615 }
616
617 /*
618 * This is the place where PE is going to create a session.
619 * If session is not existed, then create a new session
620 */
621 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800622 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700624 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
626 session = NULL;
627 goto free;
628 } else {
629 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800630 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530632 sme_start_bss_req->bssType,
633 sme_start_bss_req->sessionId);
634 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700635 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
637 goto free;
638 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530639
640 /* Update the beacon/probe filter in mac_ctx */
641 lim_set_bcn_probe_filter(mac_ctx, session,
642 &sme_start_bss_req->ssId,
643 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 }
645
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700646 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
647 /* Probe resp add ie */
648 lim_start_bss_update_add_ie_buffer(mac_ctx,
649 &session->addIeParams.probeRespData_buff,
650 &session->addIeParams.probeRespDataLen,
651 sme_start_bss_req->addIeParams.
652 probeRespData_buff,
653 sme_start_bss_req->addIeParams.
654 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700656 /* Probe Beacon add ie */
657 lim_start_bss_update_add_ie_buffer(mac_ctx,
658 &session->addIeParams.probeRespBCNData_buff,
659 &session->addIeParams.probeRespBCNDataLen,
660 sme_start_bss_req->addIeParams.
661 probeRespBCNData_buff,
662 sme_start_bss_req->addIeParams.
663 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700665 /* Assoc resp IE */
666 lim_start_bss_update_add_ie_buffer(mac_ctx,
667 &session->addIeParams.assocRespData_buff,
668 &session->addIeParams.assocRespDataLen,
669 sme_start_bss_req->addIeParams.
670 assocRespData_buff,
671 sme_start_bss_req->addIeParams.
672 assocRespDataLen);
673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 /* Store the session related params in newly created session */
675 session->pLimStartBssReq = sme_start_bss_req;
676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 session->transactionId = sme_start_bss_req->transactionId;
678
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 &(sme_start_bss_req->htConfig),
681 sizeof(session->htConfig));
682
Sandeep Puligilla98917432016-06-10 13:50:28 -0700683 qdf_mem_copy(&(session->vht_config),
684 &(sme_start_bss_req->vht_config),
685 sizeof(session->vht_config));
686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800688 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689
690 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 (uint8_t *) &sme_start_bss_req->ssId,
693 (sme_start_bss_req->ssId.length + 1));
694
695 session->bssType = sme_start_bss_req->bssType;
696
697 session->nwType = sme_start_bss_req->nwType;
698
699 session->beaconParams.beaconInterval =
700 sme_start_bss_req->beaconInterval;
701
702 /* Store the channel number in session Table */
703 session->currentOperChannel =
704 sme_start_bss_req->channelId;
705
706 /* Store Persona */
707 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530708 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 FL("PE PERSONA=%d"), session->pePersona);
710
711 /* Update the phymode */
712 session->gLimPhyMode = sme_start_bss_req->nwType;
713
714 session->maxTxPower =
715 cfg_get_regulatory_max_transmit_power(mac_ctx,
716 session->currentOperChannel);
717 /* Store the dot 11 mode in to the session Table */
718 session->dot11mode = sme_start_bss_req->dot11mode;
719#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
720 session->cc_switch_mode =
721 sme_start_bss_req->cc_switch_mode;
722#endif
723 session->htCapability =
724 IS_DOT11_MODE_HT(session->dot11mode);
725 session->vhtCapability =
726 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800727
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700728 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800729 session->htCapability, session->vhtCapability);
730
731 if (IS_DOT11_MODE_HE(session->dot11mode)) {
732 lim_update_session_he_capable(mac_ctx, session);
733 lim_copy_bss_he_cap(session, sme_start_bss_req);
734 }
735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 session->txLdpcIniFeatureEnabled =
737 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738#ifdef WLAN_FEATURE_11W
739 session->limRmfEnabled =
740 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700741 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742#endif
743
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530744 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 (void *)&sme_start_bss_req->operationalRateSet,
746 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 (void *)&sme_start_bss_req->extendedRateSet,
749 sizeof(tSirMacRateSet));
750
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700751 if (IS_5G_CH(session->currentOperChannel))
752 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
753 else
754 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 switch (sme_start_bss_req->bssType) {
757 case eSIR_INFRA_AP_MODE:
758 lim_configure_ap_start_bss_session(mac_ctx, session,
759 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700760 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700761 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700762 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700763 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 break;
765 case eSIR_IBSS_MODE:
766 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
767 lim_get_short_slot_from_phy_mode(mac_ctx, session,
768 session->gLimPhyMode,
769 &session->shortSlotTimeSupported);
770
771 /*
772 * initialize to "OPEN".
773 * will be updated upon key installation
774 */
775 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700776 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
778 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700779 case eSIR_NDI_MODE:
780 session->limSystemRole = eLIM_NDI_ROLE;
781 break;
782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 /*
785 * There is one more mode called auto mode.
786 * which is used no where
787 */
788
789 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
790
791 default:
792 /* not used anywhere...used in scan function */
793 break;
794 }
795
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700796 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700797 session->pePersona, session->vdev_nss);
798 session->nss = session->vdev_nss;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530799 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700800 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700802 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 * parsed (Re)Assoc request structure
804 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700805 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700808 size * sizeof(tpSirAssocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700809 if (!session->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
811 goto free;
812 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700815 if (!sme_start_bss_req->channelId &&
816 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700817 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 ret_code = eSIR_SME_INVALID_PARAMETERS;
819 goto free;
820 }
821 channel_number = sme_start_bss_req->channelId;
822#ifdef QCA_HT_2040_COEX
823 if (sme_start_bss_req->obssEnabled)
824 session->htSupportedChannelWidthSet =
825 session->htCapability;
826 else
827#endif
828 session->htSupportedChannelWidthSet =
829 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
830 session->htSecondaryChannelOffset =
831 sme_start_bss_req->sec_ch_offset;
832 session->htRecommendedTxWidthSet =
833 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530834 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800836 if (lim_is_session_he_capable(session) ||
837 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700839 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800840 sme_start_bss_req->vht_channel_width,
841 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 session->ch_width = chanwidth;
843 if (session->htSupportedChannelWidthSet) {
844 session->ch_center_freq_seg0 =
845 sme_start_bss_req->center_freq_seg0;
846 session->ch_center_freq_seg1 =
847 sme_start_bss_req->center_freq_seg1;
848 } else {
849 session->ch_center_freq_seg0 = 0;
850 session->ch_center_freq_seg1 = 0;
851 }
852 }
Gaurank Kathpalia511634b2018-10-23 03:41:16 -0700853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800855 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700857 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700859 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700860 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861
862 /* Delete pre-auth list if any */
863 lim_delete_pre_auth_list(mac_ctx);
864
865 /*
866 * keep the RSN/WPA IE information in PE Session Entry
867 * later will be using this to check when received (Re)Assoc req
868 */
869 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
870 &sme_start_bss_req->rsnIE, session);
871
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700872 if (LIM_IS_AP_ROLE(session) ||
873 LIM_IS_IBSS_ROLE(session) ||
874 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 session->gLimProtectionControl =
876 sme_start_bss_req->protEnabled;
877 /*
878 * each byte will have the following info
879 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
880 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
881 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530882 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 (void *)&sme_start_bss_req->ht_capab,
884 sizeof(uint16_t));
885 /* Initialize WPS PBC session link list */
886 session->pAPWPSPBCSession = NULL;
887 }
888 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700890 if (!mlm_start_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
892 goto free;
893 }
894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530896 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 (uint8_t *) &sme_start_bss_req->ssId,
898 sme_start_bss_req->ssId.length + 1);
899 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
900 mlm_start_req->obssProtEnabled =
901 sme_start_bss_req->obssProtEnabled;
902
903 mlm_start_req->bssType = session->bssType;
904
905 /* Fill PE session Id from the session Table */
906 mlm_start_req->sessionId = session->peSessionId;
907
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700908 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
909 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 /*
911 * Copy the BSSId from sessionTable to
912 * mlmStartReq struct
913 */
914 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
915 } else {
916 /* ibss mode */
917 mac_ctx->lim.gLimIbssCoalescingHappened = false;
918
919 ret_status = wlan_cfg_get_int(mac_ctx,
920 WNI_CFG_IBSS_AUTO_BSSID,
921 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700922 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700923 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530925 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 goto free;
927 }
928
929 if (!auto_gen_bssid) {
930 /*
931 * We're not auto generating BSSID.
932 * Instead, get it from session entry
933 */
934 sir_copy_mac_addr(mlm_start_req->bssId,
935 session->bssId);
936 /*
937 * Start IBSS group BSSID
938 * Auto Generating BSSID.
939 */
940 auto_gen_bssid = ((mlm_start_req->bssId[0] &
941 0x01) ? true : false);
942 }
943
944 if (auto_gen_bssid) {
945 /*
946 * if BSSID is not any uc id.
947 * then use locally generated BSSID.
948 * Autogenerate the BSSID
949 */
950 lim_get_random_bssid(mac_ctx,
951 mlm_start_req->bssId);
952 mlm_start_req->bssId[0] = 0x02;
953
954 /*
955 * Copy randomly generated BSSID
956 * to the session Table
957 */
958 sir_copy_mac_addr(session->bssId,
959 mlm_start_req->bssId);
960 }
961 }
962 /* store the channel num in mlmstart req structure */
963 mlm_start_req->channelNumber = session->currentOperChannel;
964 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
965 mlm_start_req->beaconPeriod =
966 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700967 mlm_start_req->cac_duration_ms =
968 sme_start_bss_req->cac_duration_ms;
969 mlm_start_req->dfs_regdomain =
970 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (LIM_IS_AP_ROLE(session)) {
972 mlm_start_req->dtimPeriod = session->dtimPeriod;
973 mlm_start_req->wps_state = session->wps_state;
974
975 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530976 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 mlm_start_req->dtimPeriod = (uint8_t) val;
978 }
979
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530980 mlm_start_req->cfParamSet.cfpPeriod =
981 mac_ctx->mlme_cfg->rates.cfp_period;
982 mlm_start_req->cfParamSet.cfpMaxDuration =
983 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 /*
986 * this may not be needed anymore now,
987 * as rateSet is now included in the
988 * session entry and MLM has session context.
989 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 (void *)&session->rateSet,
992 sizeof(tSirMacRateSet));
993
994 /* Now populate the 11n related parameters */
995 mlm_start_req->nwType = session->nwType;
996 mlm_start_req->htCapable = session->htCapability;
997
998 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
999 /* Unused */
1000 mlm_start_req->dualCTSProtection =
1001 mac_ctx->lim.gHTDualCTSProtection;
1002 mlm_start_req->txChannelWidthSet =
1003 session->htRecommendedTxWidthSet;
1004
1005 session->limRFBand = lim_get_rf_band(channel_number);
1006
1007 /* Initialize 11h Enable Flag */
1008 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001009 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1010 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001011 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001013 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001014 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 else
1016 session->lim11hEnable = val;
1017
1018 if (session->lim11hEnable &&
1019 (eSIR_INFRA_AP_MODE ==
1020 mlm_start_req->bssType)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001021 session->lim11hEnable =
1022 mac_ctx->mlme_cfg->
1023 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 }
1026
1027 if (!session->lim11hEnable) {
1028 if (cfg_set_int(mac_ctx,
1029 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001030 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 /*
1032 * Failed to set the CFG param
1033 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1034 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001035 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 }
1037
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001038 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 session->limPrevSmeState = session->limSmeState;
1041 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1042 MTRACE(mac_trace
1043 (mac_ctx, TRACE_CODE_SME_STATE,
1044 session->peSessionId,
1045 session->limSmeState));
1046
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301047 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1048 if (QDF_IS_STATUS_ERROR(qdf_status))
1049 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301050 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 return;
1052 } else {
1053
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001054 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 mac_ctx->lim.gLimSmeState);
1056 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001057 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1059
1060free:
1061 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001062 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 session->pLimStartBssReq = NULL;
1064 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001065 if (NULL != sme_start_bss_req)
1066 qdf_mem_free(sme_start_bss_req);
1067 if (NULL != mlm_start_req)
1068 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 if (NULL != session) {
1070 pe_delete_session(mac_ctx, session);
1071 session = NULL;
1072 }
1073 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1074 session, sme_session_id, sme_transaction_id);
1075}
1076
1077/**
1078 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1079 *
1080 * @pMac: Global MAC context
1081 * @pMsg: Message pointer
1082 *
1083 * Wrapper for the function __lim_handle_sme_start_bss_request
1084 * This message will be defered until softmac come out of
1085 * scan mode or if we have detected radar on the current
1086 * operating channel.
1087 *
1088 * return true - If we consumed the buffer
1089 * false - If have defered the message.
1090 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001091static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1092 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093{
1094 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1095 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1096 /**
1097 * If message defered, buffer is not consumed yet.
1098 * So return false
1099 */
1100 return false;
1101 }
1102
1103 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1104 return true;
1105}
1106
1107/**
1108 * lim_get_random_bssid()
1109 *
1110 * FUNCTION:This function is called to process generate the random number for bssid
1111 * This function is called to process SME_SCAN_REQ message
1112 * from HDD or upper layer application.
1113 *
1114 * LOGIC:
1115 *
1116 * ASSUMPTIONS:
1117 *
1118 * NOTE:
1119 * 1. geneartes the unique random number for bssid in ibss
1120 *
1121 * @param pMac Pointer to Global MAC structure
1122 * @param *data Pointer to bssid buffer
1123 * @return None
1124 */
1125void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1126{
1127 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 random[0] = tx_time_get();
1130 random[0] |= (random[0] << 15);
1131 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301132 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133}
1134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135/**
1136 * __lim_process_clear_dfs_channel_list()
1137 *
1138 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001139 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 .*This message is sent from SME.
1141 *
1142 ***LOGIC:
1143 *
1144 ***ASSUMPTIONS:
1145 *
1146 ***NOTE:
1147 *
1148 * @param pMac Pointer to Global MAC structure
1149 * @param *pMsgBuf A pointer to the SME message buffer
1150 * @return None
1151 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001152static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1153 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156}
1157
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301158#ifdef WLAN_FEATURE_SAE
1159
1160/**
1161 * lim_update_sae_config()- This API update SAE session info to csr config
1162 * from join request.
1163 * @session: PE session
1164 * @sme_join_req: pointer to join request
1165 *
1166 * Return: None
1167 */
1168static void lim_update_sae_config(tpPESession session,
1169 tpSirSmeJoinReq sme_join_req)
1170{
1171 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1172
1173 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1174 session->sae_pmk_cached,
1175 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1176}
1177#else
1178static inline void lim_update_sae_config(tpPESession session,
1179 tpSirSmeJoinReq sme_join_req)
1180{}
1181#endif
1182
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001183/**
Jianmin Zhu09236602018-10-15 15:36:10 +08001184 * lim_send_join_req() - send vdev start request for assoc
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001185 *@session: pe session
1186 *@mlm_join_req: join req
1187 *
1188 * Return: QDF_STATUS
1189 */
1190
1191#ifdef CONFIG_VDEV_SM
1192static QDF_STATUS lim_send_join_req(tpPESession session,
1193 tLimMlmJoinReq *mlm_join_req)
1194{
Jianmin Zhu09236602018-10-15 15:36:10 +08001195 mlme_set_assoc_type(session->vdev, VDEV_ASSOC);
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001196 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1197 WLAN_VDEV_SM_EV_START,
1198 sizeof(*mlm_join_req),
1199 mlm_join_req);
1200}
1201#else
1202static QDF_STATUS lim_send_join_req(tpPESession session,
1203 tLimMlmJoinReq *mlm_join_req)
1204{
1205 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1206
1207 return QDF_STATUS_SUCCESS;
1208}
1209#endif
1210
Jianmin Zhu09236602018-10-15 15:36:10 +08001211/**
1212 * lim_send_reassoc_req() - send vdev start request for reassoc
1213 *@session: pe session
1214 *@mlm_join_req: join req
1215 *
1216 * Return: QDF_STATUS
1217 */
1218
1219#ifdef CONFIG_VDEV_SM
1220static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1221 tLimMlmReassocReq *reassoc_req)
1222{
1223 mlme_set_assoc_type(session->vdev, VDEV_REASSOC);
1224 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1225 WLAN_VDEV_SM_EV_START,
1226 sizeof(*reassoc_req),
1227 reassoc_req);
1228}
1229#else
1230static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1231 tLimMlmReassocReq *reassoc_req)
1232{
1233 lim_process_mlm_reassoc_req(session->mac_ctx, reassoc_req);
1234
1235 return QDF_STATUS_SUCCESS;
1236}
1237#endif
1238
1239/**
1240 * lim_send_ft_reassoc_req() - send vdev start request for ft_reassoc
1241 *@session: pe session
1242 *@mlm_join_req: join req
1243 *
1244 * Return: QDF_STATUS
1245 */
1246
1247#ifdef CONFIG_VDEV_SM
1248static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1249{
1250 mlme_set_assoc_type(session->vdev, VDEV_FT_REASSOC);
1251 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1252 WLAN_VDEV_SM_EV_START,
1253 sizeof(*session),
1254 session);
1255}
1256#else
1257static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1258{
1259 lim_process_mlm_ft_reassoc_req(session->mac_ctx, session);
1260
1261 return QDF_STATUS_SUCCESS;
1262}
1263#endif
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265/**
1266 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1267 * @mac_ctx: Pointer to Global MAC structure
1268 * @msg_buf: A pointer to the SME message buffer
1269 *
1270 * This function is called to process SME_JOIN_REQ message
1271 * from HDD or upper layer application.
1272 *
1273 * Return: None
1274 */
1275static void
1276__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1277{
1278 tpSirSmeJoinReq sme_join_req = NULL;
1279 tLimMlmJoinReq *mlm_join_req;
1280 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1281 uint32_t val = 0;
1282 uint16_t n_size;
1283 uint8_t session_id;
1284 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301285 uint8_t sme_session_id = 0;
1286 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001287 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001289 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001290 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291
Arif Hussain995fcaf2016-07-18 11:28:22 -07001292 if (!mac_ctx || !msg_buf) {
1293 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1294 FL("JOIN REQ with invalid data"));
1295 return;
1296 }
1297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298/* FEATURE_WLAN_DIAG_SUPPORT */
1299#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1300 /*
1301 * Not sending any session, since it is not created yet.
1302 * The response whould have correct state.
1303 */
1304 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1305#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 /*
1308 * Expect Join request in idle state.
1309 * Reassociate request is expected in link established state.
1310 */
1311
1312 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1313 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1314 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1315 msg_buf);
1316
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301317 sme_join_req = qdf_mem_malloc(n_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001318 if (!sme_join_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301320 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301322 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 n_size);
1324
1325 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1326 /* Received invalid eWNI_SME_JOIN_REQ */
1327 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001328 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 sme_join_req->sessionId);
1330 ret_code = eSIR_SME_INVALID_PARAMETERS;
1331 goto end;
1332 }
1333
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001334 /*
1335 * Update the capability here itself as this is used in
1336 * lim_extract_ap_capability() below. If not updated issues
1337 * like not honoring power constraint on 1st association after
1338 * driver loading might occur.
1339 */
1340 lim_update_rrm_capability(mac_ctx, sme_join_req);
1341
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001342 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001344 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 &session_id);
1346
1347 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001348 pe_err("Session(%d) Already exists for BSSID: "
1349 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001351 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 session->limSmeState);
1353
1354 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1355 session->smeSessionId == sme_join_req->sessionId) {
1356 /*
1357 * Received eWNI_SME_JOIN_REQ for same
1358 * BSS as currently associated.
1359 * Log the event and send success
1360 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001361 pe_warn("SessionId: %d", session_id);
1362 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 /* Send Join success response to host */
1364 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1365 session = NULL;
1366 goto end;
1367 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001368 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 ret_code = eSIR_SME_REFUSED;
1370 session = NULL;
1371 goto end;
1372 }
1373 } else {
1374 /*
1375 * Session Entry does not exist for given BSSId
1376 * Try to Create a new session
1377 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001378 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301380 eSIR_INFRASTRUCTURE_MODE,
1381 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001383 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1385 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301386 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001387 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301389 }
1390
1391 /* Update the beacon/probe filter in mac_ctx */
1392 lim_set_bcn_probe_filter(mac_ctx, session,
1393 &sme_join_req->ssId,
1394 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001396 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001397 session->enable_session_twt_support =
1398 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 /*
1400 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402
1403 /* store the smejoin req handle in session table */
1404 session->pLimJoinReq = sme_join_req;
1405
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 /* Store SME transaction Id in session Table */
1407 session->transactionId = sme_join_req->transactionId;
1408
1409 /* Store beaconInterval */
1410 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001411 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301413 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 sizeof(session->htConfig));
1415
Sandeep Puligilla98917432016-06-10 13:50:28 -07001416 qdf_mem_copy(&(session->vht_config),
1417 &(sme_join_req->vht_config),
1418 sizeof(session->vht_config));
1419
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 /* Copying of bssId is already done, while creating session */
1421 sir_copy_mac_addr(session->selfMacAddr,
1422 sme_join_req->selfMacAddr);
1423 session->bssType = sme_join_req->bsstype;
1424
1425 session->statypeForBss = STA_ENTRY_PEER;
1426 session->limWmeEnabled = sme_join_req->isWMEenabled;
1427 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301428 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001429 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301431 session->enable_bcast_probe_rsp =
1432 sme_join_req->enable_bcast_probe_rsp;
1433
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001434 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001435 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1437
Naveen Rawat08db88f2017-09-08 15:07:48 -07001438 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001440 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001443 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 session->isCiscoVendorAP = true;
1445 } else {
1446 session->isCiscoVendorAP = false;
1447 }
1448
1449 /* Copy the dot 11 mode in to the session table */
1450
1451 session->dot11mode = sme_join_req->dot11mode;
1452#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1453 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1454#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001455 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1457 session->enableHtSmps = sme_join_req->enableHtSmps;
1458 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001459 session->send_smps_action =
1460 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001461 /*
1462 * By default supported NSS 1x1 is set to true
1463 * and later on updated while determining session
1464 * supported rates which is the intersection of
1465 * self and peer rates
1466 */
1467 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301468 /*Store Persona */
1469 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001470 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 -08001471 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001472 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001473 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301474 session->supported_nss_1x1,
1475 session->pePersona,
1476 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001477
1478 /*Store Persona */
1479 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301480 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301481 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001482 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301483 session->nwType, session->dot11mode,
1484 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001485
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001486 /* Copy The channel Id to the session Table */
1487 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 session->vhtCapability =
1490 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301492 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001493 session->vht_config.su_beam_formee =
1494 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001496 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 session->enableVhtpAid =
1499 sme_join_req->enableVhtpAid;
1500 session->enableVhtGid =
1501 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001502 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001503 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 }
Krunal Soni53993f72016-07-08 18:20:03 -07001505
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001506 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301507 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001508 session->vht_config.su_beam_formee,
1509 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001510 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001512 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301514 session->force_24ghz_in_ht20 =
1515 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 /* cbMode is already merged value of peer and self -
1517 * done by csr in csr_get_cb_mode_from_ies */
1518 session->htSupportedChannelWidthSet =
1519 (sme_join_req->cbMode) ? 1 : 0;
1520 session->htRecommendedTxWidthSet =
1521 session->htSupportedChannelWidthSet;
1522 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1523
1524 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1525 session->ch_center_freq_seg0 =
1526 session->currentOperChannel - 2;
1527 session->ch_width = CH_WIDTH_40MHZ;
1528 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1529 sme_join_req->cbMode) {
1530 session->ch_center_freq_seg0 =
1531 session->currentOperChannel + 2;
1532 session->ch_width = CH_WIDTH_40MHZ;
1533 } else {
1534 session->ch_center_freq_seg0 = 0;
1535 session->ch_width = CH_WIDTH_20MHZ;
1536 }
1537
Naveen Rawataeca1b92017-10-16 16:55:31 -07001538 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1539 lim_update_session_he_capable(mac_ctx, session);
1540 lim_copy_join_req_he_cap(session, sme_join_req);
1541 }
1542
1543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 /* Record if management frames need to be protected */
1545#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301546 if ((eSIR_ED_AES_128_CMAC ==
1547 sme_join_req->MgmtEncryptionType) ||
1548 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1549 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001551 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553#endif
1554
1555#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001556 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557#endif
1558
1559 /* Copy the SSID from smejoinreq to session entry */
1560 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 session->ssId.length);
1563
1564 /*
1565 * Determin 11r or ESE connection based on input from SME
1566 * which inturn is dependent on the profile the user wants
1567 * to connect to, So input is coming from supplicant
1568 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570#ifdef FEATURE_WLAN_ESE
1571 session->isESEconnection = sme_join_req->isESEconnection;
1572#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 session->isFastTransitionEnabled =
1574 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 session->isFastRoamIniFeatureEnabled =
1577 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 session->txLdpcIniFeatureEnabled =
1579 sme_join_req->txLdpcIniFeatureEnabled;
1580
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301581 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301582 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1584 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 } else {
1586 /*
1587 * Throw an error and return and make
1588 * sure to delete the session.
1589 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001590 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 session->bssType);
1592 ret_code = eSIR_SME_INVALID_PARAMETERS;
1593 goto end;
1594 }
1595
1596 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 &sme_join_req->addIEScan, sizeof(tSirAddie));
1599
1600 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301601 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1603
1604 val = sizeof(tLimMlmJoinReq) +
1605 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301606 mlm_join_req = qdf_mem_malloc(val);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001607 if (!mlm_join_req) {
Nitesh Shah0102cac2016-07-13 14:38:30 +05301608 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1609 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611
1612 /* PE SessionId is stored as a part of JoinReq */
1613 mlm_join_req->sessionId = session->peSessionId;
1614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301616 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 (void *)&sme_join_req->operationalRateSet,
1618 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301619 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 (void *)&sme_join_req->extendedRateSet,
1621 sizeof(tSirMacRateSet));
1622 /*
1623 * this may not be needed anymore now, as rateSet is now
1624 * included in the session entry and MLM has session context.
1625 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301626 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 (void *)&session->rateSet,
1628 sizeof(tSirMacRateSet));
1629
1630 session->encryptType = sme_join_req->UCEncryptionType;
1631
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301632 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1633 session->vdev_nss = sme_join_req->vdev_nss;
1634 session->nss = sme_join_req->nss;
1635 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1636
1637 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1638 session->nss,
1639 session->vdev_nss,
1640 session->supported_nss_1x1);
1641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 mlm_join_req->bssDescription.length =
1643 session->pLimJoinReq->bssDescription.length;
1644
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301645 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 (uint8_t *)
1647 &session->pLimJoinReq->bssDescription.bssId,
1648 session->pLimJoinReq->bssDescription.length + 2);
1649
1650 session->limCurrentBssCaps =
1651 session->pLimJoinReq->bssDescription.capabilityInfo;
1652
1653 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1654 session->currentOperChannel);
1655 local_power_constraint = reg_max;
1656
1657 lim_extract_ap_capability(mac_ctx,
1658 (uint8_t *)
1659 session->pLimJoinReq->bssDescription.ieFields,
1660 lim_get_ielen_from_bss_description(
1661 &session->pLimJoinReq->bssDescription),
1662 &session->limCurrentBssQosCaps,
1663 &session->limCurrentBssPropCap,
1664 &session->gLimCurrentBssUapsd,
1665 &local_power_constraint, session);
1666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 session->maxTxPower = lim_get_max_tx_power(reg_max,
1668 local_power_constraint,
1669 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301670 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301671
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001672 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301673 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301675 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1676 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1677 pe_debug("Update MaxTxPower in join Req to %d",
1678 sme_join_req->powerCap.maxTxPower);
1679 }
1680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 if (session->gLimCurrentBssUapsd) {
1682 session->gUapsdPerAcBitmask =
1683 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001684 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 session->gUapsdPerAcBitmask);
1686
1687 /* resetting the dynamic uapsd mask */
1688 session->gUapsdPerAcDeliveryEnableMask = 0;
1689 session->gUapsdPerAcTriggerEnableMask = 0;
1690 }
1691
1692 session->limRFBand =
1693 lim_get_rf_band(session->currentOperChannel);
1694
1695 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001696 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001698 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001699 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 session->lim11hEnable =
1701 WNI_CFG_11H_ENABLED_STADEF;
1702 } else {
1703 session->lim11hEnable = val;
1704 }
1705 } else {
1706 session->lim11hEnable = 0;
1707 }
1708
1709 /*
1710 * To care of the scenario when STA transitions from
1711 * IBSS to Infrastructure mode.
1712 */
1713 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1714
1715 session->limPrevSmeState = session->limSmeState;
1716 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1717 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1718 session->peSessionId,
1719 session->limSmeState));
1720
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 /* Indicate whether spectrum management is enabled */
1722 session->spectrumMgtEnabled =
1723 sme_join_req->spectrumMgtIndicator;
1724
1725 /* Enable the spectrum management if this is a DFS channel */
1726 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001727 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 session->currentOperChannel))
1729 session->spectrumMgtEnabled = true;
1730
1731 session->isOSENConnection = sme_join_req->isOSENConnection;
1732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001734 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 return;
1736
1737 } else {
1738 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001739 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 mac_ctx->lim.gLimSmeState);
1741 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1742 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1743 session = NULL;
1744 goto end;
1745 }
1746
1747end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301748 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1749 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750
1751 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301752 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 sme_join_req = NULL;
1754 if (NULL != session)
1755 session->pLimJoinReq = NULL;
1756 }
1757 if (ret_code != eSIR_SME_SUCCESS) {
1758 if (NULL != session) {
1759 pe_delete_session(mac_ctx, session);
1760 session = NULL;
1761 }
1762 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001763 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 sme_session_id, ret_code);
1765 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1766 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1767 sme_transaction_id);
1768}
1769
Amar Singhala297bfa2015-10-15 15:07:29 -07001770uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 uint8_t iniTxPower)
1772{
1773 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301774 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001775
Anurag Chouhan6d760662016-02-20 16:05:43 +05301776 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1778 maxTxPower = txPower;
1779 else if (txPower < MIN_TX_PWR_CAP)
1780 maxTxPower = MIN_TX_PWR_CAP;
1781 else
1782 maxTxPower = MAX_TX_PWR_CAP;
1783
1784 return maxTxPower;
1785}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786
1787/**
1788 * __lim_process_sme_reassoc_req() - process reassoc req
1789 *
1790 * @mac_ctx: Pointer to Global MAC structure
1791 * @msg_buf: pointer to the SME message buffer
1792 *
1793 * This function is called to process SME_REASSOC_REQ message
1794 * from HDD or upper layer application.
1795 *
1796 * Return: None
1797 */
1798
1799static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1800 uint32_t *msg_buf)
1801{
1802 uint16_t caps;
1803 uint32_t val;
1804 tpSirSmeJoinReq reassoc_req = NULL;
1805 tLimMlmReassocReq *mlm_reassoc_req;
1806 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1807 tpPESession session_entry = NULL;
1808 uint8_t session_id;
1809 uint8_t sme_session_id;
1810 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001811 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 uint32_t tele_bcn_en = 0;
1813 uint16_t size;
1814
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301816 reassoc_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001817 if (!reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1819 goto end;
1820 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301821 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822
1823 if (!lim_is_sme_join_req_valid(mac_ctx,
1824 (tpSirSmeJoinReq)reassoc_req)) {
1825 /*
1826 * Received invalid eWNI_SME_REASSOC_REQ
1827 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001828 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 ret_code = eSIR_SME_INVALID_PARAMETERS;
1831 goto end;
1832 }
Jianmin Zhu09236602018-10-15 15:36:10 +08001833 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1834 &sme_session_id, &transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835
1836 session_entry = pe_find_session_by_bssid(mac_ctx,
1837 reassoc_req->bssDescription.bssId,
1838 &session_id);
1839 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001840 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001841 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1842 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001844 session_entry =
1845 pe_find_session_by_sme_session_id(mac_ctx,
1846 sme_session_id);
1847 if (session_entry != NULL)
1848 lim_handle_sme_join_result(mac_ctx,
1849 eSIR_SME_INVALID_PARAMETERS,
1850 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1851 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 goto end;
1853 }
1854#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1855 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001856 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1858 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1859
1860 /* Store the reassoc handle in the session Table */
1861 session_entry->pLimReAssocReq = reassoc_req;
1862
1863 session_entry->dot11mode = reassoc_req->dot11mode;
1864 session_entry->vhtCapability =
1865 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001866
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301867 if (session_entry->vhtCapability) {
1868 if (session_entry->pePersona == QDF_STA_MODE) {
1869 session_entry->vht_config.su_beam_formee =
1870 reassoc_req->vht_config.su_beam_formee;
1871 } else {
1872 reassoc_req->vht_config.su_beam_formee = 0;
1873 }
1874 session_entry->enableVhtpAid =
1875 reassoc_req->enableVhtpAid;
1876 session_entry->enableVhtGid =
1877 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001878 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301879 }
1880
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301881 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1882 session_entry->vdev_nss = reassoc_req->vdev_nss;
1883 session_entry->nss = reassoc_req->nss;
1884 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1885
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001886 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301887 session_entry->vhtCapability,
1888 session_entry->vht_config.su_beam_formee,
1889 session_entry->vht_config.su_beam_former);
1890
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001891 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1892 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001893 session_entry->send_smps_action =
1894 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001895 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001896 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001897 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001898 session_entry->send_smps_action,
1899 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 /*
1901 * Reassociate request is expected
1902 * in link established state only.
1903 */
1904
1905 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1907 /*
1908 * May be from 11r FT pre-auth. So lets check it
1909 * before we bail out
1910 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001911 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 session_entry->peSessionId);
1913
1914 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301915 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 session_entry->limReAssocbssId,
1917 6)) {
1918 lim_print_mac_addr(mac_ctx,
1919 reassoc_req->bssDescription.
1920 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001921 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 ret_code = eSIR_SME_INVALID_PARAMETERS;
1923 goto end;
1924 }
1925
Jianmin Zhu09236602018-10-15 15:36:10 +08001926 session_entry->smeSessionId = sme_session_id;
1927 session_entry->transactionId = transaction_id;
1928 lim_send_ft_reassoc_req(session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 return;
1930 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 /*
1932 * Should not have received eWNI_SME_REASSOC_REQ
1933 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001934 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 session_entry->limSmeState);
1936 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1937
1938 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1939 goto end;
1940 }
1941
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301942 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 session_entry->pLimReAssocReq->bssDescription.bssId,
1944 sizeof(tSirMacAddr));
1945
1946 session_entry->limReassocChannelId =
1947 session_entry->pLimReAssocReq->bssDescription.channelId;
1948
1949 session_entry->reAssocHtSupportedChannelWidthSet =
1950 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1951 session_entry->reAssocHtRecommendedTxWidthSet =
1952 session_entry->reAssocHtSupportedChannelWidthSet;
1953 session_entry->reAssocHtSecondaryChannelOffset =
1954 session_entry->pLimReAssocReq->cbMode;
1955
1956 session_entry->limReassocBssCaps =
1957 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1958 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1959 session_entry->currentOperChannel);
1960 local_pwr_constraint = reg_max;
1961
1962 lim_extract_ap_capability(mac_ctx,
1963 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1964 lim_get_ielen_from_bss_description(
1965 &session_entry->pLimReAssocReq->bssDescription),
1966 &session_entry->limReassocBssQosCaps,
1967 &session_entry->limReassocBssPropCap,
1968 &session_entry->gLimCurrentBssUapsd,
1969 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301970 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001971 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301972 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973 /* Copy the SSID from session entry to local variable */
1974 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301975 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 reassoc_req->ssId.ssId,
1977 session_entry->limReassocSSID.length);
1978 if (session_entry->gLimCurrentBssUapsd) {
1979 session_entry->gUapsdPerAcBitmask =
1980 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001981 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 session_entry->gUapsdPerAcBitmask);
1983 }
1984
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301985 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001986 if (!mlm_reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1988 goto end;
1989 }
1990
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301991 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001995 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001996 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301997
1998 lim_update_caps_info_for_bss(mac_ctx, &caps,
1999 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002000 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 mlm_reassoc_req->capabilityInfo = caps;
2003
2004 /* Update PE session_id */
2005 mlm_reassoc_req->sessionId = session_id;
2006
2007 /*
2008 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302009 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302012 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302014 if (tele_bcn_en)
2015 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2016 else
2017 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018
2019 mlm_reassoc_req->listenInterval = (uint16_t) val;
2020
2021 /* Indicate whether spectrum management is enabled */
2022 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2023
2024 /* Enable the spectrum management if this is a DFS channel */
2025 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002026 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 session_entry->currentOperChannel))
2028 session_entry->spectrumMgtEnabled = true;
2029
2030 session_entry->limPrevSmeState = session_entry->limSmeState;
2031 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2032
2033 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2034 session_entry->peSessionId,
2035 session_entry->limSmeState));
2036
Jianmin Zhu09236602018-10-15 15:36:10 +08002037 lim_send_reassoc_req(session_entry, mlm_reassoc_req);
2038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 return;
2040end:
2041 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302042 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 if (session_entry)
2044 session_entry->pLimReAssocReq = NULL;
2045 }
2046
2047 if (session_entry) {
2048 /*
2049 * error occurred after we determined the session so extract
2050 * session and transaction info from there
2051 */
2052 sme_session_id = session_entry->smeSessionId;
2053 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002054 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 /*
2056 * error occurred before or during the time we determined
2057 * the session so extract the session and transaction info
2058 * from the message
2059 */
2060 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2061 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002062 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 /*
2064 * Send Reassoc failure response to host
2065 * (note session_entry may be NULL, but that's OK)
2066 */
2067 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2068 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2069 session_entry, sme_session_id,
2070 transaction_id);
2071}
2072
2073bool send_disassoc_frame = 1;
2074/**
2075 * __lim_process_sme_disassoc_req()
2076 *
2077 ***FUNCTION:
2078 * This function is called to process SME_DISASSOC_REQ message
2079 * from HDD or upper layer application.
2080 *
2081 ***LOGIC:
2082 *
2083 ***ASSUMPTIONS:
2084 *
2085 ***NOTE:
2086 *
2087 * @param pMac Pointer to Global MAC structure
2088 * @param *pMsgBuf A pointer to the SME message buffer
2089 * @return None
2090 */
2091
2092static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2093{
2094 uint16_t disassocTrigger, reasonCode;
2095 tLimMlmDisassocReq *pMlmDisassocReq;
2096 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2097 tSirSmeDisassocReq smeDisassocReq;
2098 tpPESession psessionEntry = NULL;
2099 uint8_t sessionId;
2100 uint8_t smesessionId;
2101 uint16_t smetransactionId;
2102
2103 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002104 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 return;
2106 }
2107
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 smesessionId = smeDisassocReq.sessionId;
2110 smetransactionId = smeDisassocReq.transactionId;
2111 if (!lim_is_sme_disassoc_req_valid(pMac,
2112 &smeDisassocReq,
2113 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002114 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 if (pMac->lim.gLimRspReqd) {
2116 pMac->lim.gLimRspReqd = false;
2117
2118 retCode = eSIR_SME_INVALID_PARAMETERS;
2119 disassocTrigger = eLIM_HOST_DISASSOC;
2120 goto sendDisassoc;
2121 }
2122
2123 return;
2124 }
2125
2126 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002127 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 &sessionId);
2129 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002130 pe_err("session does not exist for given bssId "
2131 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002132 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 retCode = eSIR_SME_INVALID_PARAMETERS;
2134 disassocTrigger = eLIM_HOST_DISASSOC;
2135 goto sendDisassoc;
2136 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002137 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2138 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2140 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002141 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142
2143#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2144 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2145 0, smeDisassocReq.reasonCode);
2146#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2147
2148 /* Update SME session Id and SME transaction ID */
2149
2150 psessionEntry->smeSessionId = smesessionId;
2151 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002152 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002153 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154
2155 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2156 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 switch (psessionEntry->limSmeState) {
2158 case eLIM_SME_ASSOCIATED_STATE:
2159 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002160 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002161 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162 psessionEntry->limPrevSmeState =
2163 psessionEntry->limSmeState;
2164 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 /* Delete all TDLS peers connected before leaving BSS */
2166 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002167 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2168 psessionEntry->peSessionId,
2169 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 break;
2171
2172 case eLIM_SME_WT_DEAUTH_STATE:
2173 /* PE shall still process the DISASSOC_REQ and proceed with
2174 * link tear down even if it had already sent a DEAUTH_IND to
2175 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2176 * its been set when PE entered WT_DEAUTH_STATE.
2177 */
2178 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2179 MTRACE(mac_trace
2180 (pMac, TRACE_CODE_SME_STATE,
2181 psessionEntry->peSessionId,
2182 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002183 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 break;
2185
2186 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002187 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2189 * PE can continue processing DISASSOC_REQ and send the response instead
2190 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2191 * for disassoc frame.
2192 *
2193 * It will send a disassoc, which is ok. However, we can use the global flag
2194 * sendDisassoc to not send disassoc frame.
2195 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002196 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 break;
2198
2199 case eLIM_SME_JOIN_FAILURE_STATE: {
2200 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002201 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202 if (pMac->lim.gLimRspReqd) {
2203 retCode = eSIR_SME_SUCCESS;
2204 disassocTrigger = eLIM_HOST_DISASSOC;
2205 goto sendDisassoc;
2206 }
2207 }
2208 break;
2209 default:
2210 /**
2211 * STA is not currently associated.
2212 * Log error and send response to host
2213 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002214 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215 psessionEntry->limSmeState);
2216 lim_print_sme_state(pMac, LOGE,
2217 psessionEntry->limSmeState);
2218
2219 if (pMac->lim.gLimRspReqd) {
2220 if (psessionEntry->limSmeState !=
2221 eLIM_SME_WT_ASSOC_STATE)
2222 pMac->lim.gLimRspReqd = false;
2223
2224 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2225 disassocTrigger = eLIM_HOST_DISASSOC;
2226 goto sendDisassoc;
2227 }
2228
2229 return;
2230 }
2231
2232 break;
2233
2234 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 /* Fall through */
2236 break;
2237
2238 case eLIM_STA_IN_IBSS_ROLE:
2239 default:
2240 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002241 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 GET_LIM_SYSTEM_ROLE(psessionEntry));
2243
2244 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2245 disassocTrigger = eLIM_HOST_DISASSOC;
2246 goto sendDisassoc;
2247 } /* end switch (pMac->lim.gLimSystemRole) */
2248
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302249 disassocTrigger = eLIM_HOST_DISASSOC;
2250 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251
2252 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002253 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002254 send_disassoc_frame = 0;
2255 }
2256 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002257 pe_debug("Sending Disasscoc with disassoc Trigger"
2258 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 disassocTrigger, reasonCode);
2260
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302261 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002262 if (!pMlmDisassocReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264
Anurag Chouhanc5548422016-02-24 18:33:27 +05302265 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002266 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267
2268 pMlmDisassocReq->reasonCode = reasonCode;
2269 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2270
2271 /* Update PE session ID */
2272 pMlmDisassocReq->sessionId = sessionId;
2273
2274 lim_post_mlm_message(pMac,
2275 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2276 return;
2277
2278sendDisassoc:
2279 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002280 lim_send_sme_disassoc_ntf(pMac,
2281 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 retCode,
2283 disassocTrigger,
2284 1, smesessionId, smetransactionId,
2285 psessionEntry);
2286 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002287 lim_send_sme_disassoc_ntf(pMac,
2288 smeDisassocReq.peer_macaddr.bytes,
2289 retCode, disassocTrigger, 1,
2290 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291
2292} /*** end __lim_process_sme_disassoc_req() ***/
2293
2294/** -----------------------------------------------------------------
2295 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2296
2297 This function is called to process SME_DISASSOC_CNF message
2298 from HDD or upper layer application.
2299
2300 \param pMac - global mac structure
2301 \param pStaDs - station dph hash node
2302 \return none
2303 \sa
2304 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002305void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306{
2307 tSirSmeDisassocCnf smeDisassocCnf;
2308 uint16_t aid;
2309 tpDphHashNode pStaDs;
2310 tpPESession psessionEntry;
2311 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302312 uint32_t *msg = NULL;
2313 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302315 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 sizeof(struct sSirSmeDisassocCnf));
2317
2318 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002319 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 &sessionId);
2321 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002322 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302323 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302324 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302325 eSIR_SME_INVALID_SESSION,
2326 NULL);
2327 if (QDF_IS_STATUS_SUCCESS(status))
2328 lim_send_sme_disassoc_deauth_ntf(pMac,
2329 QDF_STATUS_SUCCESS,
2330 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 return;
2332 }
2333
2334 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002335 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302336 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2337 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302338 eSIR_SME_INVALID_PARAMETERS,
2339 &smeDisassocCnf.bssid.bytes[0]);
2340 if (QDF_IS_STATUS_SUCCESS(status))
2341 lim_send_sme_disassoc_deauth_ntf(pMac,
2342 QDF_STATUS_SUCCESS,
2343 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 return;
2345 }
2346#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2347 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2348 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2349 psessionEntry,
2350 (uint16_t) smeDisassocCnf.statusCode, 0);
2351 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2352 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2353 psessionEntry,
2354 (uint16_t) smeDisassocCnf.statusCode, 0);
2355#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2356
2357 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2358 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2360 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2361 && (psessionEntry->limSmeState !=
2362 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002363 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 psessionEntry->limSmeState);
2365 lim_print_sme_state(pMac, LOGE,
2366 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302367 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302368 psessionEntry->smeSessionId,
2369 eSIR_SME_INVALID_STATE,
2370 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302371 if (QDF_IS_STATUS_SUCCESS(status))
2372 lim_send_sme_disassoc_deauth_ntf(pMac,
2373 QDF_STATUS_SUCCESS,
2374 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 return;
2376 }
2377 break;
2378
2379 case eLIM_AP_ROLE:
2380 /* Fall through */
2381 break;
2382
2383 case eLIM_STA_IN_IBSS_ROLE:
2384 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002385 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302387 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2388 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302389 eSIR_SME_INVALID_STATE,
2390 &smeDisassocCnf.bssid.bytes[0]);
2391 if (QDF_IS_STATUS_SUCCESS(status))
2392 lim_send_sme_disassoc_deauth_ntf(pMac,
2393 QDF_STATUS_SUCCESS,
2394 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 return;
2396 }
2397
2398 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2399 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2400 LIM_IS_AP_ROLE(psessionEntry)) {
2401 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002402 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 &psessionEntry->dph.dphHashTable);
2404 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002405 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2406 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002407 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302408 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302409 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302410 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302411 &smeDisassocCnf.bssid.bytes[0]);
2412 if (QDF_IS_STATUS_SUCCESS(status))
2413 lim_send_sme_disassoc_deauth_ntf(pMac,
2414 QDF_STATUS_SUCCESS,
2415 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 return;
2417 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302418
2419 if ((pStaDs->mlmStaContext.mlmState ==
2420 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2421 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002422 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002423 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002424 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302425 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302426 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302427 psessionEntry->smeSessionId,
2428 eSIR_SME_SUCCESS,
2429 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302430 if (QDF_IS_STATUS_SUCCESS(status))
2431 lim_send_sme_disassoc_deauth_ntf(pMac,
2432 QDF_STATUS_SUCCESS,
2433 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302434 return;
2435 }
2436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 /* Delete FT session if there exists one */
2438 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2440
2441 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002442 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 }
2444
2445 return;
2446}
2447
2448/**
2449 * __lim_process_sme_deauth_req() - process sme deauth req
2450 * @mac_ctx: Pointer to Global MAC structure
2451 * @msg_buf: pointer to the SME message buffer
2452 *
2453 * This function is called to process SME_DEAUTH_REQ message
2454 * from HDD or upper layer application.
2455 *
2456 * Return: None
2457 */
2458
2459static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2460 uint32_t *msg_buf)
2461{
2462 uint16_t deauth_trigger, reason_code;
2463 tLimMlmDeauthReq *mlm_deauth_req;
2464 tSirSmeDeauthReq sme_deauth_req;
2465 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2466 tpPESession session_entry;
2467 uint8_t session_id; /* PE sessionId */
2468 uint8_t sme_session_id;
2469 uint16_t sme_transaction_id;
2470
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302471 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 sme_session_id = sme_deauth_req.sessionId;
2473 sme_transaction_id = sme_deauth_req.transactionId;
2474
2475 /*
2476 * We need to get a session first but we don't even know
2477 * if the message is correct.
2478 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002479 session_entry = pe_find_session_by_bssid(mac_ctx,
2480 sme_deauth_req.bssid.bytes,
2481 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002483 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 ret_code = eSIR_SME_INVALID_PARAMETERS;
2485 deauth_trigger = eLIM_HOST_DEAUTH;
2486 goto send_deauth;
2487 }
2488
2489 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2490 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002491 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 mac_ctx->lim.gLimRspReqd = false;
2493
2494 ret_code = eSIR_SME_INVALID_PARAMETERS;
2495 deauth_trigger = eLIM_HOST_DEAUTH;
2496 goto send_deauth;
2497 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002498 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2499 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2501 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002502 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2504 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2505 session_entry, 0, sme_deauth_req.reasonCode);
2506#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2507
2508 /* Update SME session ID and Transaction ID */
2509 session_entry->smeSessionId = sme_session_id;
2510 session_entry->transactionId = sme_transaction_id;
2511
2512 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2513 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 switch (session_entry->limSmeState) {
2515 case eLIM_SME_ASSOCIATED_STATE:
2516 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302517 /* Delete all TDLS peers connected before leaving BSS */
2518 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302519 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 case eLIM_SME_WT_ASSOC_STATE:
2521 case eLIM_SME_JOIN_FAILURE_STATE:
2522 case eLIM_SME_IDLE_STATE:
2523 session_entry->limPrevSmeState =
2524 session_entry->limSmeState;
2525 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2526 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2527 session_entry->peSessionId,
2528 session_entry->limSmeState));
2529 /* Send Deauthentication request to MLM below */
2530 break;
2531 case eLIM_SME_WT_DEAUTH_STATE:
2532 case eLIM_SME_WT_DISASSOC_STATE:
2533 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002534 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2536 * Which means host is also trying to disconnect.
2537 * PE can continue processing DEAUTH_REQ and send
2538 * the response instead of failing the request.
2539 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2540 * was sent for deauth/disassoc frame.
2541 */
2542 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002543 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 break;
2545 default:
2546 /*
2547 * STA is not in a state to deauthenticate with
2548 * peer. Log error and send response to host.
2549 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002550 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 session_entry->limSmeState);
2552 lim_print_sme_state(mac_ctx, LOGE,
2553 session_entry->limSmeState);
2554
2555 if (mac_ctx->lim.gLimRspReqd) {
2556 mac_ctx->lim.gLimRspReqd = false;
2557
2558 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2559 deauth_trigger = eLIM_HOST_DEAUTH;
2560
wadesong42968e92017-06-08 14:11:21 +08002561 /*
2562 * here we received deauth request from AP so
2563 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2564 * have ISSUED delSta then mlm state should be
2565 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2566 * delBSS rsp then mlm state should be
2567 * eLIM_MLM_IDLE_STATE so the below condition
2568 * captures the state where delSta not done
2569 * and firmware still in connected state.
2570 */
2571 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 eLIM_SME_WT_DEAUTH_STATE &&
2573 session_entry->limMlmState !=
2574 eLIM_MLM_IDLE_STATE &&
2575 session_entry->limMlmState !=
2576 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002577 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 goto send_deauth;
2579 }
2580 return;
2581 }
2582 break;
2583
2584 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002585 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586 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 case eLIM_AP_ROLE:
2594 break;
2595 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002596 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 GET_LIM_SYSTEM_ROLE(session_entry));
2598 if (mac_ctx->lim.gLimRspReqd) {
2599 mac_ctx->lim.gLimRspReqd = false;
2600 ret_code = eSIR_SME_INVALID_PARAMETERS;
2601 deauth_trigger = eLIM_HOST_DEAUTH;
2602 goto send_deauth;
2603 }
2604 return;
2605 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2606
Yu Ouyang57c25532018-09-07 17:14:01 +08002607 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2608 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002610 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2612 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2613 } else {
2614 deauth_trigger = eLIM_HOST_DEAUTH;
2615 reason_code = sme_deauth_req.reasonCode;
2616 }
2617
2618 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302619 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002620 if (!mlm_deauth_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 if (mac_ctx->lim.gLimRspReqd) {
2622 mac_ctx->lim.gLimRspReqd = false;
2623 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2624 deauth_trigger = eLIM_HOST_DEAUTH;
2625 goto send_deauth;
2626 }
2627 return;
2628 }
2629
Anurag Chouhanc5548422016-02-24 18:33:27 +05302630 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002631 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632
2633 mlm_deauth_req->reasonCode = reason_code;
2634 mlm_deauth_req->deauthTrigger = deauth_trigger;
2635
2636 /* Update PE session Id */
2637 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002638 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 return;
2641
2642send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002643 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2644 ret_code, deauth_trigger, 1,
2645 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646}
2647
2648/**
2649 * __lim_process_sme_set_context_req()
2650 *
2651 * @mac_ctx: Pointer to Global MAC structure
2652 * @msg_buf: pointer to the SME message buffer
2653 *
2654 * This function is called to process SME_SETCONTEXT_REQ message
2655 * from HDD or upper layer application.
2656 *
2657 * Return: None
2658 */
2659
2660static void
2661__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2662{
2663 tpSirSmeSetContextReq set_context_req;
2664 tLimMlmSetKeysReq *mlm_set_key_req;
2665 tpPESession session_entry;
2666 uint8_t session_id; /* PE sessionID */
2667 uint8_t sme_session_id;
2668 uint16_t sme_transaction_id;
2669
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002671 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 return;
2673 }
2674
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302675 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002676 if (!set_context_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302678 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 sizeof(struct sSirSmeSetContextReq));
2680 sme_session_id = set_context_req->sessionId;
2681 sme_transaction_id = set_context_req->transactionId;
2682
2683 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002684 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 goto end;
2686 }
2687
2688 if (set_context_req->keyMaterial.numKeys >
2689 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002690 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691 set_context_req->keyMaterial.numKeys);
2692 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002693 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 eSIR_SME_INVALID_PARAMETERS, NULL,
2695 sme_session_id, sme_transaction_id);
2696 goto end;
2697 }
2698
2699 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002700 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002702 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002704 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 eSIR_SME_INVALID_PARAMETERS, NULL,
2706 sme_session_id, sme_transaction_id);
2707 goto end;
2708 }
2709#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2710 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2711 session_entry, 0, 0);
2712#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2713
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002714 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2716 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002717 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2719 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302720 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002721 if (!mlm_set_key_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2724 mlm_set_key_req->numKeys =
2725 set_context_req->keyMaterial.numKeys;
2726 if (mlm_set_key_req->numKeys >
2727 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002728 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002729 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 goto end;
2731 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302732 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002733 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302735 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 (uint8_t *) &set_context_req->keyMaterial.key,
2737 sizeof(tSirKeys) *
2738 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2739 numKeys : 1));
2740
2741 mlm_set_key_req->sessionId = session_id;
2742 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002743 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745
2746 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2747 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2748 LIM_IS_AP_ROLE(session_entry)) {
2749 if (set_context_req->keyMaterial.key[0].keyLength) {
2750 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 key_id =
2753 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302754 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 &session_entry->WEPKeyMaterial[key_id],
2756 (uint8_t *) &set_context_req->keyMaterial,
2757 sizeof(tSirKeyMaterial));
2758 } else {
2759 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2762 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302763 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 &mlm_set_key_req->key[i],
2765 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2766 sizeof(tSirKeys));
2767 }
2768 }
2769 }
2770 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2771 (uint32_t *) mlm_set_key_req);
2772 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002773 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 GET_LIM_SYSTEM_ROLE(session_entry),
2775 session_entry->limSmeState);
2776 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2777
2778 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002779 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2781 session_entry, sme_session_id,
2782 sme_transaction_id);
2783 }
2784end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302785 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 return;
2787}
2788
2789/**
2790 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2791 *
2792 * @mac_ctx: Pointer to Global MAC structure
2793 * @msg_buf: pointer to the SME message buffer
2794 *
2795 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2796 * from HDD or upper layer application.
2797 *
2798 * Return: None
2799 */
2800
Jeff Johnson801f1532016-10-07 07:54:50 -07002801static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2802 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803{
2804 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2805 tpDphHashNode sta_ds = NULL;
2806 tpPESession session_entry = NULL;
2807 tSap_Event sap_event;
2808 tpWLAN_SAPEventCB sap_event_cb = NULL;
2809 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2810 uint8_t session_id = CSR_SESSION_ID_INVALID;
2811 uint8_t assoc_id = 0;
2812 uint8_t sta_cnt = 0;
2813
2814 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002815 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 return;
2817 }
2818
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302819 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 sizeof(struct sSirSmeGetAssocSTAsReq));
2821 /*
2822 * Get Associated stations from PE.
2823 * Find PE session Entry
2824 */
2825 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002826 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 &session_id);
2828 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002829 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 goto lim_assoc_sta_end;
2831 }
2832
2833 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002834 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 session_entry->limSmeState,
2836 GET_LIM_SYSTEM_ROLE(session_entry));
2837 goto lim_assoc_sta_end;
2838 }
2839 /* Retrieve values obtained in the request message */
2840 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2841 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2842
2843 if (NULL == assoc_sta_tmp)
2844 goto lim_assoc_sta_end;
2845 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2846 assoc_id++) {
2847 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2848 &session_entry->dph.dphHashTable);
2849 if (NULL == sta_ds)
2850 continue;
2851 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302852 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302854 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2856 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2857
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302858 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 (uint8_t *)&sta_ds->supportedRates,
2860 sizeof(tSirSupportedRates));
2861 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2862 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2863 assoc_sta_tmp->Support40Mhz =
2864 sta_ds->htDsssCckRate40MHzSupport;
2865
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002866 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002868 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002870 pe_debug("Association Id: %d Station Index: %d",
2871 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 assoc_sta_tmp++;
2873 sta_cnt++;
2874 }
2875 }
2876lim_assoc_sta_end:
2877 /*
2878 * Call hdd callback with sap event to send the list of
2879 * associated stations from PE
2880 */
2881 if (sap_event_cb != NULL) {
2882 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2883 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302884 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2886 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2887 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2888 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2889 }
2890}
2891
2892/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 * __lim_counter_measures()
2894 *
2895 * FUNCTION:
2896 * This function is called to "implement" MIC counter measure
2897 * and is *temporary* only
2898 *
2899 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2900 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002901 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 *
2903 ***ASSUMPTIONS:
2904 *
2905 ***NOTE:
2906 *
2907 * @param pMac Pointer to Global MAC structure
2908 * @return None
2909 */
2910
2911static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2912{
2913 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002914
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002915 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2917 mac, psessionEntry, false);
2918};
2919
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302920void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2921 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302922{
2923 session->limSmeState = session->limPrevSmeState;
2924
2925 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2926 session->limSmeState));
2927
2928 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2929 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2930 session->transactionId);
2931}
2932
2933void lim_delete_all_peers(tpPESession session)
2934{
2935 uint8_t i = 0;
2936 tpAniSirGlobal mac_ctx = session->mac_ctx;
2937 tpDphHashNode sta_ds = NULL;
2938 QDF_STATUS status;
2939
2940 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2941 sta_ds = dph_get_hash_entry(mac_ctx, i,
2942 &session->dph.dphHashTable);
2943 if (!sta_ds)
2944 continue;
2945 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2946 if (QDF_STATUS_SUCCESS == status) {
2947 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2948 sta_ds->assocId, session);
2949 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2950 } else {
2951 pe_err("lim_del_sta failed with Status: %d", status);
2952 QDF_ASSERT(0);
2953 }
2954 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302955
2956#ifdef CONFIG_VDEV_SM
2957 status =
2958 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2959 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2960 sizeof(*session), session);
2961 if (QDF_IS_STATUS_ERROR(status)) {
2962 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2963 session->smeSessionId);
2964 lim_send_stop_bss_failure_resp(mac_ctx, session);
2965 }
2966#endif
2967
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302968}
2969
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002970QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2971{
2972 tpAniSirGlobal mac_ctx = session->mac_ctx;
2973 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2974 tpDphHashNode sta_ds = NULL;
2975
2976 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2977 &session->dph.dphHashTable);
2978 if (!sta_ds) {
2979 pe_err("DPH Entry for STA is missing, failed to send delbss");
2980 goto end;
2981 }
2982
2983 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2984 if (QDF_IS_STATUS_ERROR(status))
2985 pe_err("delBss failed for bss %d", session->bssIdx);
2986
2987end:
2988 return status;
2989}
2990
Abhishek Singhcaa61852018-09-12 15:50:04 +05302991QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302992{
2993 tpAniSirGlobal mac_ctx = session->mac_ctx;
2994 QDF_STATUS status;
2995
2996 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2997
2998 if (QDF_IS_STATUS_ERROR(status)) {
2999 pe_err("delBss failed for bss %d", session->bssIdx);
3000 lim_send_stop_bss_failure_resp(mac_ctx, session);
3001 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05303002
3003 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303004}
3005
3006/**
3007 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
3008 * @session: session pointer
3009 *
3010 * Return None
3011 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303012#ifdef CONFIG_VDEV_SM
3013static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3014{
3015 tpAniSirGlobal mac_ctx = session->mac_ctx;
3016 QDF_STATUS status;
3017
Abhishek Singhc5a54082018-09-12 16:08:03 +05303018 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3019 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3020 status =
3021 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3022 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303023 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303024 else
3025 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3026 WLAN_VDEV_SM_EV_DOWN,
3027 sizeof(*session),
3028 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303029 if (QDF_IS_STATUS_ERROR(status)) {
3030 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3031 session->smeSessionId);
3032 lim_send_stop_bss_failure_resp(mac_ctx, session);
3033 }
3034}
3035#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303036static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3037{
3038 lim_delete_all_peers(session);
3039 /* send a delBss to HAL and wait for a response */
3040 lim_send_vdev_stop(session);
3041}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303042#endif
3043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044static void
3045__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3046{
3047 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 tLimSmeStates prevState;
3049 tpPESession psessionEntry;
3050 uint8_t smesessionId;
3051 uint8_t sessionId;
3052 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 smesessionId = stopBssReq.sessionId;
3056 smetransactionId = stopBssReq.transactionId;
3057
3058 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003059 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 /* Send Stop BSS response to host */
3061 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3062 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3063 smetransactionId);
3064 return;
3065 }
3066
3067 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003068 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 &sessionId);
3070 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003071 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3073 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3074 smetransactionId);
3075 return;
3076 }
3077#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3078 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3079 0, 0);
3080#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3081
3082 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3083 LIM_IS_STA_ROLE(psessionEntry)) {
3084 /**
3085 * Should not have received STOP_BSS_REQ in states
3086 * other than 'normal' state or on STA in Infrastructure
3087 * mode. Log error and return response to host.
3088 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003089 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 psessionEntry->limSmeState,
3091 GET_LIM_SYSTEM_ROLE(psessionEntry));
3092 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3093 /* / Send Stop BSS response to host */
3094 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3095 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3096 smetransactionId);
3097 return;
3098 }
3099
3100 if (LIM_IS_AP_ROLE(psessionEntry))
3101 lim_wpspbc_close(pMac, psessionEntry);
3102
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003103 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 stopBssReq.reasonCode);
3105
3106 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303107 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108
3109 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3110 MTRACE(mac_trace
3111 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3112 psessionEntry->limSmeState));
3113
3114 /* Update SME session Id and Transaction Id */
3115 psessionEntry->smeSessionId = smesessionId;
3116 psessionEntry->transactionId = smetransactionId;
3117
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003118 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3119 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3120 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3124 /* Send disassoc all stations associated thru TKIP */
3125 __lim_counter_measures(pMac, psessionEntry);
3126 else
3127 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003128 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3129 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 }
3131
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003132 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3133 /* Free the buffer allocated in START_BSS_REQ */
3134 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3135 psessionEntry->addIeParams.probeRespDataLen = 0;
3136 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003138 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3139 psessionEntry->addIeParams.assocRespDataLen = 0;
3140 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003142 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3143 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3144 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003146 /*
3147 * lim_del_bss is also called as part of coalescing,
3148 * when we send DEL BSS followed by Add Bss msg.
3149 */
3150 pMac->lim.gLimIbssCoalescingHappened = false;
3151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303153 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155}
3156
3157/**
3158 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3159 * @pMac: Global MAC context
3160 * @pMsg: Message from SME
3161 *
3162 * Wrapper for the function __lim_handle_sme_stop_bss_request
3163 * This message will be defered until softmac come out of
3164 * scan mode. Message should be handled even if we have
3165 * detected radar in the current operating channel.
3166 *
3167 * Return: true - If we consumed the buffer
3168 * false - If have defered the message.
3169 */
3170
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003171static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3172 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173{
3174 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3175 /**
3176 * If message defered, buffer is not consumed yet.
3177 * So return false
3178 */
3179 return false;
3180 }
3181 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3182 return true;
3183} /*** end __lim_process_sme_stop_bss_req() ***/
3184
3185void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3186 uint32_t body, tpPESession psessionEntry)
3187{
3188
3189 (void)body;
3190 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3191 lim_ibss_delete(pMac, psessionEntry);
3192 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3193 lim_delete_pre_auth_list(pMac);
3194 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3195 psessionEntry->smeSessionId,
3196 psessionEntry->transactionId);
3197 return;
3198}
3199
3200/**
3201 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3202 *
3203 * @mac_ctx: pointer to mac context
3204 * @msg_type: message type
3205 * @msg_buf: pointer to the SME message buffer
3206 *
3207 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3208 * in BTAMP AP.
3209 *
3210 * Return: None
3211 */
3212
3213void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3214 uint32_t *msg_buf)
3215{
3216 tSirSmeAssocCnf assoc_cnf;
3217 tpDphHashNode sta_ds = NULL;
3218 tpPESession session_entry = NULL;
3219 uint8_t session_id;
3220 tpSirAssocReq assoc_req;
3221
3222 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003223 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 goto end;
3225 }
3226
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003229 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 goto end;
3231 }
3232
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003233 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 &session_id);
3235 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003236 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 goto end;
3238 }
3239
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003240 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3242 (session_entry->limSmeState !=
3243 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003244 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 msg_type, session_entry->limSmeState,
3246 GET_LIM_SYSTEM_ROLE(session_entry));
3247 goto end;
3248 }
3249 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3250 &session_entry->dph.dphHashTable);
3251 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003252 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303254 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
3256 /*
3257 * send a DISASSOC_IND message to WSM to make sure
3258 * the state in WSM and LIM is the same
3259 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003260 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 eSIR_SME_STA_NOT_ASSOCIATED,
3262 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3263 session_entry->smeSessionId,
3264 session_entry->transactionId,
3265 session_entry);
3266 goto end;
3267 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303268 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003269 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303270 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003271 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 assoc_cnf.aid);
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 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3278 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3279 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3280 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3281 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003282 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3283 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303285 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 goto end;
3287 }
3288 /*
3289 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3290 * has been received
3291 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003292 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3294 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3295
3296 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3297 /*
3298 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3299 * when it had received Assoc Request frame. Now, PE just needs
3300 * to send association rsp frame to the requesting BTAMP-STA.
3301 */
3302 sta_ds->mlmStaContext.mlmState =
3303 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003304 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003306 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 sta_ds->assocId, sta_ds->staAddr,
3308 sta_ds->mlmStaContext.subType, sta_ds,
3309 session_entry);
3310 goto end;
3311 } else {
3312 /*
3313 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3314 * to be associated since the HAL sta entry is created for
3315 * denied STA we need to remove this HAL entry.
3316 * So to do that set updateContext to 1
3317 */
3318 if (!sta_ds->mlmStaContext.updateContext)
3319 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003320 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 assoc_cnf.statusCode, sta_ds->assocId);
3322 lim_reject_association(mac_ctx, sta_ds->staAddr,
3323 sta_ds->mlmStaContext.subType,
3324 true, sta_ds->mlmStaContext.authType,
3325 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003326 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 session_entry);
3328 }
3329end:
3330 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3331 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3332 assoc_req = (tpSirAssocReq)
3333 session_entry->parsedAssocReq[sta_ds->assocId];
3334 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303335 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 assoc_req->assocReqFrame = NULL;
3337 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303338 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3340 }
3341}
3342
3343static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3344{
3345 tpDphHashNode pStaDs;
3346 tSirMacAddr peerMac;
3347 tpSirAddtsReq pSirAddts;
3348 uint32_t timeout;
3349 tpPESession psessionEntry;
3350 uint8_t sessionId; /* PE sessionId */
3351 uint8_t smesessionId;
3352 uint16_t smetransactionId;
3353
3354 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003355 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 return;
3357 }
3358
3359 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3360 &smetransactionId);
3361
3362 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3363
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003364 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3365 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003367 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003368 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303369 NULL, pSirAddts->req.tspec,
3370 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 return;
3372 }
3373#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3374 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3375 0);
3376#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3377
3378 /* if sta
3379 * - verify assoc state
3380 * - send addts request to ap
3381 * - wait for addts response from ap
3382 * if ap, just ignore with error log
3383 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003384 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3385 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3386 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003388 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003389 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303390 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
3393 pStaDs =
3394 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3395 &psessionEntry->dph.dphHashTable);
3396
3397 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003398 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303399 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 }
3401
3402 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3403 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003404 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303405 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 }
3407
3408 pSirAddts->req.wsmTspecPresent = 0;
3409 pSirAddts->req.wmeTspecPresent = 0;
3410 pSirAddts->req.lleTspecPresent = 0;
3411
3412 if ((pStaDs->wsmEnabled) &&
3413 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3414 SIR_MAC_ACCESSPOLICY_EDCA))
3415 pSirAddts->req.wsmTspecPresent = 1;
3416 else if (pStaDs->wmeEnabled)
3417 pSirAddts->req.wmeTspecPresent = 1;
3418 else if (pStaDs->lleEnabled)
3419 pSirAddts->req.lleTspecPresent = 1;
3420 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003421 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303422 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 }
3424
3425 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3426 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303429 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 }
3431
3432 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003433 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 pMac->lim.gLimAddtsReq.req.dialogToken,
3435 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3436 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3437 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303438 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 }
3440
3441 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3442
3443 /* save the addts request */
3444 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303445 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3447
3448 /* ship out the message now */
3449 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3450 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303451 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 /* start a timer to wait for the response */
3453 if (pSirAddts->timeout)
3454 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003455 else
3456 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457
3458 timeout = SYS_MS_TO_TICKS(timeout);
3459 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3460 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003461 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303462 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 }
3464 pMac->lim.gLimAddtsRspTimerCount++;
3465 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3466 pMac->lim.gLimAddtsRspTimerCount) !=
3467 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003468 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303469 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 }
3471 MTRACE(mac_trace
3472 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3473 eLIM_ADDTS_RSP_TIMER));
3474
3475 /* add the sessionId to the timer object */
3476 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3477 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3478 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003479 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303480 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 }
3482 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303483
3484send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003485 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303486 psessionEntry, pSirAddts->req.tspec,
3487 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488}
3489
3490static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3491{
3492 tSirMacAddr peerMacAddr;
3493 uint8_t ac;
3494 tSirMacTSInfo *pTsinfo;
3495 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3496 tpDphHashNode pStaDs = NULL;
3497 tpPESession psessionEntry;
3498 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003499 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500 uint8_t smesessionId;
3501 uint16_t smetransactionId;
3502
3503 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3504 &smetransactionId);
3505
3506 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003507 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 &sessionId);
3509 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003510 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003511 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 goto end;
3513 }
3514#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3515 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3516 0);
3517#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3518
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003519 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003521 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003522 status = QDF_STATUS_E_FAILURE;
3523 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 smesessionId, smetransactionId);
3525 return;
3526 }
3527
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003528 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3529 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3531
3532 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3533 pDeltsReq->req.wmeTspecPresent,
3534 &pDeltsReq->req.tsinfo,
3535 &pDeltsReq->req.tspec, psessionEntry);
3536
3537 pTsinfo =
3538 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3539 tsinfo : &pDeltsReq->req.tsinfo;
3540
3541 /* We've successfully send DELTS frame to AP. Update the
3542 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3543 * is no longer trigger enabled or delivery enabled
3544 */
3545 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3546 pTsinfo, CLEAR_UAPSD_MASK);
3547
3548 /* We're deleting the TSPEC, so this particular AC is no longer
3549 * admitted. PE needs to downgrade the EDCA
3550 * parameters(for the AC for which TS is being deleted) to the
3551 * next best AC for which ACM is not enabled, and send the
3552 * updated values to HAL.
3553 */
3554 ac = upToAc(pTsinfo->traffic.userPrio);
3555
3556 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3557 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3558 ~(1 << ac);
3559 } else if (pTsinfo->traffic.direction ==
3560 SIR_MAC_DIRECTION_DNLINK) {
3561 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3562 ~(1 << ac);
3563 } else if (pTsinfo->traffic.direction ==
3564 SIR_MAC_DIRECTION_BIDIR) {
3565 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3566 ~(1 << ac);
3567 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3568 ~(1 << ac);
3569 }
3570
3571 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3572 psessionEntry);
3573
3574 pStaDs =
3575 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3576 &psessionEntry->dph.dphHashTable);
3577 if (pStaDs != NULL) {
3578 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003579 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003580 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003582 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003583 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 }
3585#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587#endif
3588
3589 /* send an sme response back */
3590end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003591 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 smesessionId, smetransactionId);
3593}
3594
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303595void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596{
3597 /* fetch the sessionEntry based on the sessionId */
3598 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 psessionEntry = pe_find_session_by_session_id(pMac,
3601 pMac->lim.limTimers.gLimAddtsRspTimer.
3602 sessionId);
3603 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003604 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 return;
3606 }
3607
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003608 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003609 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 GET_LIM_SYSTEM_ROLE(psessionEntry));
3611 pMac->lim.gLimAddtsSent = false;
3612 return;
3613 }
3614
3615 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003616 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 return;
3618 }
3619
3620 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003621 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 pMac->lim.gLimAddtsRspTimerCount);
3623 return;
3624 }
3625 /* this a real response timeout */
3626 pMac->lim.gLimAddtsSent = false;
3627 pMac->lim.gLimAddtsRspTimerCount++;
3628
3629 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3630 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3631 psessionEntry->smeSessionId,
3632 psessionEntry->transactionId);
3633}
3634
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003635#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636/**
3637 * __lim_process_sme_get_statistics_request()
3638 *
3639 ***FUNCTION:
3640 *
3641 *
3642 ***NOTE:
3643 *
3644 * @param pMac Pointer to Global MAC structure
3645 * @param *pMsgBuf A pointer to the SME message buffer
3646 * @return None
3647 */
3648static void
3649__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3650{
3651 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003652 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653
3654 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3655
3656 msgQ.type = WMA_GET_STATISTICS_REQ;
3657
3658 msgQ.reserved = 0;
3659 msgQ.bodyptr = pMsgBuf;
3660 msgQ.bodyval = 0;
3661 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3662
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003663 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303664 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003666 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 return;
3668 }
3669
3670 return;
3671}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003672#else
3673static void __lim_process_sme_get_statistics_request(
3674 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3675#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003677#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003679 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003681 * @pMac: Pointer to Global MAC structure
3682 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003684 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 */
3686static void
3687__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3688{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003689 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690
3691 msgQ.type = WMA_TSM_STATS_REQ;
3692 msgQ.reserved = 0;
3693 msgQ.bodyptr = pMsgBuf;
3694 msgQ.bodyval = 0;
3695 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3696
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003697 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303698 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003700 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 return;
3702 }
3703}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003704#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003706static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3707 struct sme_addba_accept *msg)
3708{
3709 if (!msg) {
3710 pe_err("Msg Buffer is NULL");
3711 return;
3712 }
3713 if (!msg->addba_accept)
3714 mac_ctx->reject_addba_req = 1;
3715 else
3716 mac_ctx->reject_addba_req = 0;
3717}
3718
Arif Hussaineb8ba362018-03-07 19:15:13 -08003719static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3720 uint32_t sme_session_id)
3721{
3722 tpPESession pe_session;
3723 tpDphHashNode sta_ds_ptr;
3724
3725 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3726 if (!pe_session) {
3727 pe_err("Session does not exist: sme_id %d", sme_session_id);
3728 return;
3729 }
3730 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3731 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3732 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3733 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3734 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3735 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3736 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3737 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3738 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3739 &pe_session->dph.dphHashTable);
3740 if (sta_ds_ptr)
3741 lim_send_edca_params(mac_ctx,
3742 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003743 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003744 else
3745 pe_err("Self entry missing in Hash Table");
3746}
3747
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003748static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3749 uint32_t sme_session_id)
3750{
3751 tpPESession pe_session;
3752 tpDphHashNode sta_ds_ptr;
3753
3754 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3755 if (!pe_session) {
3756 pe_err("Session does not exist: sme_id %d", sme_session_id);
3757 return;
3758 }
3759 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3760 &pe_session->dph.dphHashTable);
3761 if (sta_ds_ptr)
3762 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3763 sta_ds_ptr->bssId, true);
3764 else
3765 pe_err("Self entry missing in Hash Table");
3766}
3767
Naveen Rawat8029a402017-06-01 10:54:19 -07003768static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3769 struct update_config *msg)
3770{
3771 tpPESession pe_session;
3772
3773 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3774 if (msg == NULL) {
3775 pe_err("Buffer is Pointing to NULL");
3776 return;
3777 }
3778
3779 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3780 msg->sme_session_id);
3781 if (pe_session == NULL) {
3782 pe_warn("Session does not exist for given BSSID");
3783 return;
3784 }
3785
3786 switch (msg->capab) {
3787 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3788 pe_session->htConfig.ht_rx_ldpc = msg->value;
3789 break;
3790 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3791 pe_session->htConfig.ht_tx_stbc = msg->value;
3792 break;
3793 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3794 pe_session->htConfig.ht_rx_stbc = msg->value;
3795 break;
3796 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3797 pe_session->htConfig.ht_sgi20 = msg->value;
3798 break;
3799 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3800 pe_session->htConfig.ht_sgi40 = msg->value;
3801 break;
3802 }
3803
3804 if (LIM_IS_AP_ROLE(pe_session)) {
3805 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
Abhishek Singhfc740be2018-10-12 11:34:26 +05303806 lim_send_beacon_ind(mac_ctx, pe_session, REASON_CONFIG_UPDATE);
Naveen Rawat8029a402017-06-01 10:54:19 -07003807 }
3808}
3809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810void
3811lim_send_vdev_restart(tpAniSirGlobal pMac,
3812 tpPESession psessionEntry, uint8_t sessionId)
3813{
3814 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003815 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003816 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817
3818 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003819 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 return;
3821 }
3822
3823 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303824 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003825 if (!pHalHiddenSsidVdevRestart)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827
3828 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3829 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003830 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003831
3832 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3833 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3834 msgQ.bodyval = 0;
3835
3836 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003837 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003838 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303839 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 }
3841}
3842
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303843/**
3844 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3845 * @mac_ctx: Pointer to Global MAC structure
3846 * @msg_buf: Pointer to SME message buffer
3847 *
3848 * Return: None
3849 */
3850static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3851 uint32_t *msg_buf)
3852{
3853 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003854 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003855 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303856 tSirRoamOffloadScanReq *req_buffer;
3857 uint16_t local_ie_len;
3858 uint8_t *local_ie_buf;
3859
3860 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3861 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3862 req_buffer->sessionId);
3863
3864 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3865 if (!local_ie_buf) {
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303866 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303867 return;
3868 }
3869
3870 local_ie_len = req_buffer->assoc_ie.length;
3871 /* Update ext cap IE if present */
3872 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003873 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3874 local_ie_buf, &local_ie_len)) {
3875 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003876 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3877 req_buffer->assoc_ie.length = local_ie_len;
3878 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3879 local_ie_buf, local_ie_len);
3880 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303881 }
3882 qdf_mem_free(local_ie_buf);
3883
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303884 if (pe_session)
3885 lim_update_fils_rik(pe_session, req_buffer);
3886
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303887 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3888 wma_msg.bodyptr = req_buffer;
3889
3890 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003891 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003892 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303893 qdf_mem_free(req_buffer);
3894 }
3895}
3896
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303897/*
3898 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3899 * @mac_ctx: Pointer to global mac context
3900 * @session: Pointer to PE session
3901 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3902 * 1 - Disable broadcast SSID
3903 *
3904 * Return: None
3905 */
3906static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3907 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003909 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003910 session->ssidHidden, ssid_hidden);
3911
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003912 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303913 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003914 } else {
3915 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303916 return;
3917 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918
Abhishek Singh6c681f42018-09-12 15:52:36 +05303919#ifdef CONFIG_VDEV_SM
3920 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3921 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3922 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3923 sizeof(*session), session);
3924#else
3925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303927 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303928#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303931}
3932
3933/**
3934 * __lim_process_sme_session_update - process SME session update msg
3935 *
3936 * @mac_ctx: Pointer to global mac context
3937 * @msg_buf: Pointer to the received message buffer
3938 *
3939 * Return: None
3940 */
3941static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3942 uint32_t *msg_buf)
3943{
3944 struct sir_update_session_param *msg;
3945 tpPESession session;
3946
3947 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003948 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303949 return;
3950 }
3951
3952 msg = (struct sir_update_session_param *) msg_buf;
3953
3954 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3955 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003956 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303957 msg->session_id);
3958 return;
3959 }
3960
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003961 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303962 msg->param_type, msg->param_val);
3963 switch (msg->param_type) {
3964 case SIR_PARAM_SSID_HIDDEN:
3965 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3966 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303967 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3968 session->ignore_assoc_disallowed = msg->param_val;
3969 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303970 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003971 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303972 break;
3973 }
3974}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976/*
3977 Update the beacon Interval dynamically if beaconInterval is different in MCC
3978 */
3979static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3980{
3981 tpSirChangeBIParams pChangeBIParams;
3982 tpPESession psessionEntry;
3983 uint8_t sessionId = 0;
3984 tUpdateBeaconParams beaconParams;
3985
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003986 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987
3988 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003989 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 return;
3991 }
3992
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303993 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3995
3996 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003997 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 &sessionId);
3999 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004000 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 return;
4002 }
4003
4004 /*Update sessionEntry Beacon Interval */
4005 if (psessionEntry->beaconParams.beaconInterval !=
4006 pChangeBIParams->beaconInterval) {
4007 psessionEntry->beaconParams.beaconInterval =
4008 pChangeBIParams->beaconInterval;
4009 }
4010
4011 /*Update sch beaconInterval */
4012 if (pMac->sch.schObject.gSchBeaconInterval !=
4013 pChangeBIParams->beaconInterval) {
4014 pMac->sch.schObject.gSchBeaconInterval =
4015 pChangeBIParams->beaconInterval;
4016
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004017 pe_debug("LIM send update BeaconInterval Indication: %d",
4018 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019
4020 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4021 /* Update beacon */
4022 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4023
4024 beaconParams.bssIdx = psessionEntry->bssIdx;
4025 /* Set change in beacon Interval */
4026 beaconParams.beaconInterval =
4027 pChangeBIParams->beaconInterval;
4028 beaconParams.paramChangeBitmap =
4029 PARAM_BCN_INTERVAL_CHANGED;
4030 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4031 }
4032 }
4033
4034 return;
4035} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4036
4037#ifdef QCA_HT_2040_COEX
4038static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4039 uint32_t *pMsgBuf)
4040{
4041 tpSirSetHT2040Mode pSetHT2040Mode;
4042 tpPESession psessionEntry;
4043 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004044 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 tUpdateVHTOpMode *pHtOpMode = NULL;
4046 uint16_t staId = 0;
4047 tpDphHashNode pStaDs = NULL;
4048
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004049 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004051 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052 return;
4053 }
4054
4055 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4056
4057 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004058 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 &sessionId);
4060 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004061 pe_debug("Session does not exist for given BSSID");
4062 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 return;
4064 }
4065
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004066 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 pSetHT2040Mode->cbMode);
4068 /*Update sessionEntry HT related fields */
4069 switch (pSetHT2040Mode->cbMode) {
4070 case PHY_SINGLE_CHANNEL_CENTERED:
4071 psessionEntry->htSecondaryChannelOffset =
4072 PHY_SINGLE_CHANNEL_CENTERED;
4073 psessionEntry->htRecommendedTxWidthSet = 0;
4074 if (pSetHT2040Mode->obssEnabled)
4075 psessionEntry->htSupportedChannelWidthSet
4076 = eHT_CHANNEL_WIDTH_40MHZ;
4077 else
4078 psessionEntry->htSupportedChannelWidthSet
4079 = eHT_CHANNEL_WIDTH_20MHZ;
4080 break;
4081 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4082 psessionEntry->htSecondaryChannelOffset =
4083 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4084 psessionEntry->htRecommendedTxWidthSet = 1;
4085 break;
4086 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4087 psessionEntry->htSecondaryChannelOffset =
4088 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4089 psessionEntry->htRecommendedTxWidthSet = 1;
4090 break;
4091 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004092 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 return;
4094 }
4095
4096 /* Update beacon */
4097 sch_set_fixed_beacon_fields(pMac, psessionEntry);
Abhishek Singhfc740be2018-10-12 11:34:26 +05304098 lim_send_beacon_ind(pMac, psessionEntry, REASON_SET_HT2040);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099
4100 /* update OP Mode for each associated peer */
4101 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4102 pStaDs = dph_get_hash_entry(pMac, staId,
4103 &psessionEntry->dph.dphHashTable);
4104 if (NULL == pStaDs)
4105 continue;
4106
4107 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304108 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004109 if (!pHtOpMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 pHtOpMode->opMode =
4112 (psessionEntry->htSecondaryChannelOffset ==
4113 PHY_SINGLE_CHANNEL_CENTERED) ?
4114 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4115 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304116 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 sizeof(tSirMacAddr));
4118 pHtOpMode->smesessionId = sessionId;
4119
4120 msg.type = WMA_UPDATE_OP_MODE;
4121 msg.reserved = 0;
4122 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004123 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304124 (scheduler_post_message(QDF_MODULE_ID_PE,
4125 QDF_MODULE_ID_WMA,
4126 QDF_MODULE_ID_WMA,
4127 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004128 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304129 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 return;
4131 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004132 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004133 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134
4135 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004136 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 }
4138
4139 return;
4140}
4141#endif
4142
4143/* -------------------------------------------------------------------- */
4144/**
4145 * __lim_process_report_message
4146 *
4147 * FUNCTION: Processes the next received Radio Resource Management message
4148 *
4149 * LOGIC:
4150 *
4151 * ASSUMPTIONS:
4152 *
4153 * NOTE:
4154 *
4155 * @param None
4156 * @return None
4157 */
4158
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004159static void __lim_process_report_message(tpAniSirGlobal pMac,
4160 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 switch (pMsg->type) {
4163 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4164 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4165 break;
4166 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004168 break;
4169 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004170 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172}
4173
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004174/* -------------------------------------------------------------------- */
4175/**
4176 * lim_send_set_max_tx_power_req
4177 *
4178 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4179 *
4180 * LOGIC:
4181 *
4182 * ASSUMPTIONS:
4183 *
4184 * NOTE:
4185 *
4186 * @param txPower txPower to be set.
4187 * @param pSessionEntry session entry.
4188 * @return None
4189 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004190QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004191lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 tpPESession pSessionEntry)
4193{
4194 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004195 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004196 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197
4198 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004199 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 }
4202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304203 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004204 if (!pMaxTxParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004205 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304207 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304208 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304209 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004210 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304211 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212
4213 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4214 msgQ.bodyptr = pMaxTxParams;
4215 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004216 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4218 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004219 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004220 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304221 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 }
4223 return retCode;
4224}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225
4226/**
4227 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4228 *
4229 * @mac_ctx: Pointer to Global MAC structure
4230 * @msg_buf: pointer to the SME message buffer
4231 *
4232 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4233 * from SME. It Register this information within PE.
4234 *
4235 * Return: None
4236 */
4237static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4238 uint32_t *msg_buf)
4239{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304240 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4242 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4243 struct mgmt_frm_reg_info *next = NULL;
4244 bool match = false;
4245
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004246 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 sme_req->registerFrame, sme_req->frameType,
4248 sme_req->matchLen);
4249 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304250 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304251 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4252 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304253 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254
4255 while (lim_mgmt_regn != NULL) {
4256 if (lim_mgmt_regn->frameType != sme_req->frameType)
4257 goto skip_match;
4258 if (sme_req->matchLen) {
4259 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304260 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 sme_req->matchData,
4262 lim_mgmt_regn->matchLen))) {
4263 /* found match! */
4264 match = true;
4265 break;
4266 }
4267 } else {
4268 /* found match! */
4269 match = true;
4270 break;
4271 }
4272skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304273 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304274 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304276 (qdf_list_node_t *)lim_mgmt_regn,
4277 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304278 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 lim_mgmt_regn = next;
4280 next = NULL;
4281 }
4282 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304283 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004284 if (QDF_STATUS_SUCCESS ==
4285 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004287 (qdf_list_node_t *)lim_mgmt_regn))
4288 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304289 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 }
4291
4292 if (sme_req->registerFrame) {
4293 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304294 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 sme_req->matchLen);
4296 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 lim_mgmt_regn->frameType = sme_req->frameType;
4298 lim_mgmt_regn->matchLen = sme_req->matchLen;
4299 lim_mgmt_regn->sessionId = sme_req->sessionId;
4300 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304301 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 sme_req->matchData,
4303 sme_req->matchLen);
4304 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304305 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304307 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 gLimMgmtFrameRegistratinQueue,
4309 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304310 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 &mac_ctx->lim.lim_frame_register_lock);
4312 }
4313 }
4314 return;
4315}
4316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317static void
4318__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4319{
4320 tpSirResetAPCapsChange pResetCapsChange;
4321 tpPESession psessionEntry;
4322 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004323
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004325 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 return;
4327 }
4328
4329 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4330 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004331 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4332 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004334 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 return;
4336 }
4337
4338 psessionEntry->limSentCapsChangeNtf = false;
4339 return;
4340}
4341
4342/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304343 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4344 * indication callback in PE.
4345 * @mac_ptr: Mac pointer
4346 * @msg_buf: Msg pointer containing the callback
4347 *
4348 * This function is used save the Management frame
4349 * indication callback in PE.
4350 *
4351 * Return: None
4352 */
4353static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4354 uint32_t *msg_buf)
4355{
4356 struct sir_sme_mgmt_frame_cb_req *sme_req =
4357 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4358
4359 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004360 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304361 return;
4362 }
4363 if (sme_req->callback)
4364 mac_ctx->mgmt_frame_ind_cb =
4365 (sir_mgmt_frame_ind_callback)sme_req->callback;
4366 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004367 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304368}
4369
4370/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304371 *__lim_process_send_disassoc_frame: function processes disassoc frame
4372 * @mac_ctx: pointer to mac context
4373 * @msg_buf: message buffer
4374 *
4375 * function processes disassoc request received from SME
4376 *
4377 * return: none
4378 */
4379static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4380 uint32_t *msg_buf)
4381{
4382 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004383 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304384 tpPESession session_entry = NULL;
4385 uint8_t sme_session_id;
4386 uint16_t sme_trans_id;
4387
4388 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004389 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304390 return;
4391 }
4392
4393 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4394 &sme_trans_id);
4395
4396 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4397 &sme_send_disassoc_frame_req,
4398 (uint8_t *)msg_buf);
4399
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004400 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304401 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4402 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004403 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304404 return;
4405 }
4406
4407 session_entry = pe_find_session_by_sme_session_id(
4408 mac_ctx, sme_session_id);
4409 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004410 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304411 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4412 return;
4413 }
4414
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004415 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 +05304416 sme_send_disassoc_frame_req.msg_type,
4417 sme_send_disassoc_frame_req.length,
4418 sme_send_disassoc_frame_req.session_id,
4419 sme_send_disassoc_frame_req.trans_id,
4420 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4421 sme_send_disassoc_frame_req.reason,
4422 sme_send_disassoc_frame_req.wait_for_ack);
4423
4424 lim_send_disassoc_mgmt_frame(mac_ctx,
4425 sme_send_disassoc_frame_req.reason,
4426 sme_send_disassoc_frame_req.peer_mac,
4427 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4428}
4429
4430/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004431 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4432 * @mac_ctx: Pointer to Global MAC structure
4433 * @pdev_id: pdev id to set the IE.
4434 * @nss: Nss values to prepare the HT IE.
4435 *
4436 * Prepares the HT IE with self capabilities for different
4437 * Nss values and sends the set HT IE req to FW.
4438 *
4439 * Return: None
4440 */
4441static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4442 uint8_t nss)
4443{
4444 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004445 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004446 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004447 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004448 tHtCaps *p_ht_cap;
4449 int i;
4450
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004451 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004452 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004453 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004454 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004455 ie_params->nss = i;
4456 ie_params->pdev_id = pdev_id;
4457 ie_params->ie_type = DOT11_HT_IE;
4458 /* 2 for IE len and EID */
4459 ie_params->ie_len = 2 + sizeof(tHtCaps);
4460 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004461 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004462 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004463 return;
4464 }
4465 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4466 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4467 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4468 ie_params->ie_len);
4469
4470 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004471 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4472 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004473 if (NULL == p_ie) {
4474 qdf_mem_free(ie_params->ie_ptr);
4475 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004476 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004477 return;
4478 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004479 p_ht_cap = (tHtCaps *)&p_ie[2];
4480 p_ht_cap->supportedMCSSet[1] = 0;
4481 p_ht_cap->txSTBC = 0;
4482 }
4483
4484 msg.type = WMA_SET_PDEV_IE_REQ;
4485 msg.bodyptr = ie_params;
4486 msg.bodyval = 0;
4487
4488 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004489 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004490 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004491 qdf_mem_free(ie_params->ie_ptr);
4492 qdf_mem_free(ie_params);
4493 return;
4494 }
4495 }
4496}
4497
4498/**
4499 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4500 * @mac_ctx: Pointer to Global MAC structure
4501 * @pdev_id: pdev id to set the IE.
4502 * @nss: Nss values to prepare the VHT IE.
4503 *
4504 * Prepares the VHT IE with self capabilities for different
4505 * Nss values and sends the set VHT IE req to FW.
4506 *
4507 * Return: None
4508 */
4509static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4510 uint8_t nss)
4511{
4512 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004513 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004514 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004515 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004516 tSirMacVHTCapabilityInfo *vht_cap;
4517 int i;
4518 tSirVhtMcsInfo *vht_mcs;
4519
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004520 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004521 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004522 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004523 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004524 ie_params->nss = i;
4525 ie_params->pdev_id = pdev_id;
4526 ie_params->ie_type = DOT11_VHT_IE;
4527 /* 2 for IE len and EID */
4528 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4529 sizeof(tSirVhtMcsInfo);
4530 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004531 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004532 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004533 return;
4534 }
4535 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4536 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4537 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4538 ie_params->ie_len);
4539
4540 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004541 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4542 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004543 if (NULL == p_ie) {
4544 qdf_mem_free(ie_params->ie_ptr);
4545 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004546 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004547 return;
4548 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004549 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4550 vht_cap->txSTBC = 0;
4551 vht_mcs =
4552 (tSirVhtMcsInfo *)&p_ie[2 +
4553 sizeof(tSirMacVHTCapabilityInfo)];
4554 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4555 vht_mcs->rxHighest =
4556 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4557 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4558 vht_mcs->txHighest =
4559 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4560 }
4561 msg.type = WMA_SET_PDEV_IE_REQ;
4562 msg.bodyptr = ie_params;
4563 msg.bodyval = 0;
4564
4565 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004566 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004567 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004568 qdf_mem_free(ie_params->ie_ptr);
4569 qdf_mem_free(ie_params);
4570 return;
4571 }
4572 }
4573}
4574
4575/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004576 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4577 * @mac_ctx: Pointer to Global MAC structure
4578 * @msg_buf: Pointer to the SME message buffer
4579 *
4580 * This function is called by limProcessMessageQueue(). This function sets the
4581 * VDEV IEs to the FW.
4582 *
4583 * Return: None
4584 */
4585static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4586 uint32_t *msg_buf)
4587{
4588 struct sir_set_vdev_ies_per_band *p_msg =
4589 (struct sir_set_vdev_ies_per_band *)msg_buf;
4590
4591 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004592 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004593 return;
4594 }
4595
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004596 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004597 p_msg->vdev_id);
4598 /* intentionally using NULL here so that self capabilty are sent */
4599 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4600 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004601 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004602}
4603
4604/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004605 * lim_process_set_pdev_IEs() - process the set pdev IE req
4606 * @mac_ctx: Pointer to Global MAC structure
4607 * @msg_buf: Pointer to the SME message buffer
4608 *
4609 * This function is called by limProcessMessageQueue(). This
4610 * function sets the PDEV IEs to the FW.
4611 *
4612 * Return: None
4613 */
4614static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4615{
4616 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4617
4618 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4619
4620 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004621 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004622 return;
4623 }
4624
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004625 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004626 ht_vht_cfg->nss);
4627 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4628
4629 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4630 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4631 ht_vht_cfg->nss);
4632}
4633
4634/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304635 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4636 *
4637 * access policy
4638 * @mac_ctx: pointer to mac context
4639 * @msg: message buffer
4640 *
4641 * function processes vendor IE and access policy from SME and updates PE
4642 *
4643 * session entry
4644 *
4645 * return: none
4646*/
4647static void lim_process_sme_update_access_policy_vendor_ie(
4648 tpAniSirGlobal mac_ctx,
4649 uint32_t *msg)
4650{
4651 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4652 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304653 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304654
4655 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004656 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304657 return;
4658 }
4659 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4660 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4661 update_vendor_ie->sme_session_id);
4662
4663 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004664 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304665 update_vendor_ie->sme_session_id);
4666 return;
4667 }
4668 if (pe_session_entry->access_policy_vendor_ie)
4669 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4670
4671 num_bytes = update_vendor_ie->ie[1] + 2;
4672 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004673 if (!pe_session_entry->access_policy_vendor_ie)
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304674 return;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304675 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4676 &update_vendor_ie->ie[0], num_bytes);
4677
4678 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4679}
4680
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004681#ifdef CONFIG_VDEV_SM
4682QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4683 uint16_t data_len, void *data)
4684{
4685 tpAniSirGlobal mac_ctx;
4686 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4687
4688 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4689 if (!mac_ctx) {
4690 pe_err("mac_ctx is NULL");
4691 if (data)
4692 qdf_mem_free(data);
4693 return QDF_STATUS_E_INVAL;
4694 }
4695 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4696
4697 switch (msg->type) {
4698 case eWNI_SME_DEAUTH_REQ:
4699 __lim_process_sme_deauth_req(mac_ctx,
4700 (uint32_t *)msg->bodyptr);
4701 break;
4702 case eWNI_SME_DISASSOC_CNF:
4703 case eWNI_SME_DEAUTH_CNF:
4704 __lim_process_sme_disassoc_cnf(mac_ctx,
4705 (uint32_t *)msg->bodyptr);
4706 break;
4707 case eWNI_SME_DISASSOC_REQ:
4708 __lim_process_sme_disassoc_req(mac_ctx,
4709 (uint32_t *)msg->bodyptr);
4710 break;
4711 default:
4712 pe_debug("Wrong message type received %d", msg->type);
4713 }
4714 return QDF_STATUS_SUCCESS;
4715}
4716#endif
4717
4718static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4719 struct scheduler_msg *msg)
4720{
4721#ifdef CONFIG_VDEV_SM
4722 tSirSmeDisassocCnf sme_disassoc_cnf;
4723 tpPESession session;
4724 uint8_t session_id;
4725 QDF_STATUS status;
4726
4727 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4728 sizeof(struct sSirSmeDisassocCnf));
4729
4730 session = pe_find_session_by_bssid(mac_ctx,
4731 sme_disassoc_cnf.bssid.bytes,
4732 &session_id);
4733
4734 if (LIM_IS_STA_ROLE(session)) {
4735 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4736 WLAN_VDEV_SM_EV_DOWN,
4737 sizeof(*msg),
4738 msg);
4739 } else {
4740 __lim_process_sme_disassoc_cnf(mac_ctx,
4741 (uint32_t *)msg->bodyptr);
4742 }
4743#else
4744 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4745#endif
4746}
4747
4748static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4749 struct scheduler_msg *msg)
4750{
4751#ifdef CONFIG_VDEV_SM
4752 tSirSmeDisassocReq disassoc_req;
4753 tpPESession session;
4754 uint8_t session_id;
4755 QDF_STATUS status;
4756
4757 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4758
4759 session = pe_find_session_by_bssid(mac_ctx,
4760 disassoc_req.bssid.bytes,
4761 &session_id);
4762 if (LIM_IS_STA_ROLE(session)) {
4763 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4764 WLAN_VDEV_SM_EV_DOWN,
4765 sizeof(*msg),
4766 msg);
4767 } else {
4768 __lim_process_sme_disassoc_req(mac_ctx,
4769 (uint32_t *)msg->bodyptr);
4770 }
4771#else
4772 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4773#endif
4774}
4775
4776static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4777 struct scheduler_msg *msg)
4778{
4779#ifdef CONFIG_VDEV_SM
4780 tSirSmeDeauthReq sme_deauth_req;
4781 tpPESession session;
4782 uint8_t session_id;
4783 QDF_STATUS status;
4784
4785 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4786
4787 session = pe_find_session_by_bssid(mac_ctx,
4788 sme_deauth_req.bssid.bytes,
4789 &session_id);
4790 if (LIM_IS_STA_ROLE(session)) {
4791 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4792 WLAN_VDEV_SM_EV_DOWN,
4793 sizeof(*msg),
4794 msg);
4795 } else {
4796 __lim_process_sme_deauth_req(mac_ctx,
4797 (uint32_t *)msg->bodyptr);
4798 }
4799#else
4800 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4801#endif
4802}
4803
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304804/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805 * lim_process_sme_req_messages()
4806 *
4807 ***FUNCTION:
4808 * This function is called by limProcessMessageQueue(). This
4809 * function processes SME request messages from HDD or upper layer
4810 * application.
4811 *
4812 ***LOGIC:
4813 *
4814 ***ASSUMPTIONS:
4815 *
4816 ***NOTE:
4817 *
4818 * @param pMac Pointer to Global MAC structure
4819 * @param msgType Indicates the SME message type
4820 * @param *pMsgBuf A pointer to the SME message buffer
4821 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4822 * false - if pMsgBuf is not to be freed.
4823 */
4824
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004825bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4826 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827{
Jeff Johnson33142e62018-05-06 17:58:36 -07004828 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 -08004829 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004830
4831 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 lim_msg_str(pMsg->type), pMsg->type,
4833 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4834 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 /* If no insert NOA required then execute the code below */
4837
4838 switch (pMsg->type) {
4839 case eWNI_SME_SYS_READY_IND:
4840 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4841 break;
4842
4843 case eWNI_SME_START_BSS_REQ:
4844 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4845 break;
4846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4848 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4849 break;
4850 case eWNI_SME_JOIN_REQ:
4851 __lim_process_sme_join_req(pMac, pMsgBuf);
4852 break;
4853
4854 case eWNI_SME_REASSOC_REQ:
4855 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4856 break;
4857
4858 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004859 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 break;
4861
4862 case eWNI_SME_DISASSOC_CNF:
4863 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004864 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 break;
4866
4867 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004868 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 break;
4870
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304871 case eWNI_SME_SEND_DISASSOC_FRAME:
4872 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4873 break;
4874
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 case eWNI_SME_SETCONTEXT_REQ:
4876 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4877 break;
4878
4879 case eWNI_SME_STOP_BSS_REQ:
4880 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4881 break;
4882
4883 case eWNI_SME_ASSOC_CNF:
4884 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004885 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4887 pMsgBuf);
4888 break;
4889
4890 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004891 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 __lim_process_sme_addts_req(pMac, pMsgBuf);
4893 break;
4894
4895 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004896 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004897 __lim_process_sme_delts_req(pMac, pMsgBuf);
4898 break;
4899
4900 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004901 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4903 break;
4904
4905 case eWNI_SME_GET_STATISTICS_REQ:
4906 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4907 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4908 bufConsumed = false;
4909 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004910#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 case eWNI_SME_GET_TSM_STATS_REQ:
4912 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4913 bufConsumed = false;
4914 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004915#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 case eWNI_SME_GET_ASSOC_STAS_REQ:
4917 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4918 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304919 case eWNI_SME_SESSION_UPDATE_PARAM:
4920 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304922 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4923 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4924 bufConsumed = false;
4925 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4927 /* Update the beaconInterval */
4928 __lim_process_sme_change_bi(pMac, pMsgBuf);
4929 break;
4930
4931#ifdef QCA_HT_2040_COEX
4932 case eWNI_SME_SET_HT_2040_MODE:
4933 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4934 break;
4935#endif
4936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4938 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4939 __lim_process_report_message(pMac, pMsg);
4940 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 case eWNI_SME_FT_PRE_AUTH_REQ:
4943 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4944 break;
4945 case eWNI_SME_FT_UPDATE_KEY:
4946 lim_process_ft_update_key(pMac, pMsgBuf);
4947 break;
4948
4949 case eWNI_SME_FT_AGGR_QOS_REQ:
4950 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4951 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952
4953 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4954 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4955 break;
4956#ifdef FEATURE_WLAN_TDLS
4957 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4958 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4959 break;
4960 case eWNI_SME_TDLS_ADD_STA_REQ:
4961 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4962 break;
4963 case eWNI_SME_TDLS_DEL_STA_REQ:
4964 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4965 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966#endif
4967 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4968 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4969 break;
4970
4971 case eWNI_SME_CHANNEL_CHANGE_REQ:
4972 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4973 break;
4974
4975 case eWNI_SME_START_BEACON_REQ:
4976 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4977 break;
4978
4979 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4980 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4981 break;
4982
4983 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4984 lim_process_update_add_ies(pMac, pMsgBuf);
4985 break;
4986
4987 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4988 lim_process_modify_add_ies(pMac, pMsgBuf);
4989 break;
4990 case eWNI_SME_SET_HW_MODE_REQ:
4991 lim_process_set_hw_mode(pMac, pMsgBuf);
4992 break;
4993 case eWNI_SME_NSS_UPDATE_REQ:
4994 lim_process_nss_update_request(pMac, pMsgBuf);
4995 break;
4996 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4997 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4998 break;
4999 case eWNI_SME_SET_IE_REQ:
5000 lim_process_set_ie_req(pMac, pMsgBuf);
5001 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305002 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5003 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5004 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305005 case eWNI_SME_EXT_CHANGE_CHANNEL:
5006 lim_process_ext_change_channel(pMac, pMsgBuf);
5007 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005008 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5009 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5010 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005011 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5012 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005013 break;
5014 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5015 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5016 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305017 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5018 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5019 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005020 case eWNI_SME_UPDATE_CONFIG:
5021 lim_process_sme_update_config(pMac,
5022 (struct update_config *)pMsgBuf);
5023 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005024 case eWNI_SME_SET_ADDBA_ACCEPT:
5025 lim_process_sme_set_addba_accept(pMac,
5026 (struct sme_addba_accept *)pMsgBuf);
5027 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005028 case eWNI_SME_UPDATE_EDCA_PROFILE:
5029 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5030 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005031 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5032 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5033 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005034 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305035 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 pMsg->bodyptr = NULL;
5037 break;
5038 } /* switch (msgType) */
5039
5040 return bufConsumed;
5041} /*** end lim_process_sme_req_messages() ***/
5042
5043/**
5044 * lim_process_sme_start_beacon_req()
5045 *
5046 ***FUNCTION:
5047 * This function is called by limProcessMessageQueue(). This
5048 * function processes SME request messages from HDD or upper layer
5049 * application.
5050 *
5051 ***LOGIC:
5052 *
5053 ***ASSUMPTIONS:
5054 *
5055 ***NOTE:
5056 *
5057 * @param pMac Pointer to Global MAC structure
5058 * @param msgType Indicates the SME message type
5059 * @param *pMsgBuf A pointer to the SME message buffer
5060 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5061 * false - if pMsgBuf is not to be freed.
5062 */
5063static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5064{
5065 tpSirStartBeaconIndication pBeaconStartInd;
5066 tpPESession psessionEntry;
5067 uint8_t sessionId; /* PE sessionID */
5068
5069 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005070 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 return;
5072 }
5073
5074 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5075 psessionEntry = pe_find_session_by_bssid(pMac,
5076 pBeaconStartInd->bssid,
5077 &sessionId);
5078 if (psessionEntry == NULL) {
5079 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005080 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 return;
5082 }
5083
5084 if (pBeaconStartInd->beaconStartStatus == true) {
5085 /*
5086 * Currently this Indication comes from SAP
5087 * to start Beacon Tx on a DFS channel
5088 * since beaconing has to be done on DFS
5089 * channel only after CAC WAIT is completed.
5090 * On a DFS Channel LIM does not start beacon
5091 * Tx right after the WMA_ADD_BSS_RSP.
5092 */
5093 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305094 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005095 FL("Start Beacon with ssid %s Ch %d"),
5096 psessionEntry->ssId.ssId,
5097 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305098 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005099 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005100 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5101 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005103 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 return;
5105 }
5106}
5107
5108/**
5109 * lim_process_sme_channel_change_request() - process sme ch change req
5110 *
5111 * @mac_ctx: Pointer to Global MAC structure
5112 * @msg_buf: pointer to the SME message buffer
5113 *
5114 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5115 *
5116 * Return: None
5117 */
5118static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5119 uint32_t *msg_buf)
5120{
5121 tpSirChanChangeRequest ch_change_req;
5122 tpPESession session_entry;
5123 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005124 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 uint32_t val = 0;
5126
5127 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005128 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 return;
5130 }
5131 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5132
5133 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5134 ch_change_req->targetChannel);
5135
5136 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5137 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005138 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 return;
5140 }
5141
5142 session_entry = pe_find_session_by_bssid(mac_ctx,
5143 ch_change_req->bssid, &session_id);
5144 if (session_entry == NULL) {
5145 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005146 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 return;
5148 }
5149
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005150 if ((session_entry->currentOperChannel ==
5151 ch_change_req->targetChannel) &&
5152 (session_entry->ch_width == ch_change_req->ch_width)) {
5153 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5154 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155 return;
5156 }
5157
5158 if (LIM_IS_AP_ROLE(session_entry))
5159 session_entry->channelChangeReasonCode =
5160 LIM_SWITCH_CHANNEL_SAP_DFS;
5161 else
5162 session_entry->channelChangeReasonCode =
5163 LIM_SWITCH_CHANNEL_OPERATION;
5164
Bala Venkateshb39ed152017-12-26 19:35:27 +05305165 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5166 session_entry->currentOperChannel,
5167 ch_change_req->targetChannel,
5168 ch_change_req->ch_width,
5169 ch_change_req->nw_type,
5170 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171
5172 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005173 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005174 session_entry->ch_center_freq_seg0 =
5175 ch_change_req->center_freq_seg_0;
5176 session_entry->ch_center_freq_seg1 =
5177 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005178 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005179 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005180 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 session_entry->htRecommendedTxWidthSet =
5182 session_entry->htSupportedChannelWidthSet;
5183 session_entry->currentOperChannel =
5184 ch_change_req->targetChannel;
5185 session_entry->limRFBand =
5186 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305187 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5188 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5189 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305190
5191 /* Update the global beacon filter */
5192 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005195 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005196 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005198 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005199 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005200 }
5201
5202 session_entry->lim11hEnable = val;
5203 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305204 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305205 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 &ch_change_req->operational_rateset,
5207 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305208 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005209 &ch_change_req->extended_rateset,
5210 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305211
5212#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305213 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305214 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5215 WLAN_VDEV_S_DFS_CAC_WAIT)
5216 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5217 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5218 sizeof(*session_entry),
5219 session_entry);
5220 else
5221 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5222 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5223 sizeof(*session_entry),
5224 session_entry);
5225
5226
5227#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5229 session_entry->ch_center_freq_seg0,
5230 session_entry->ch_center_freq_seg1,
5231 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005232 max_tx_pwr, session_entry->peSessionId,
5233 ch_change_req->cac_duration_ms,
5234 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305235#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236}
5237
5238/******************************************************************************
5239* lim_start_bss_update_add_ie_buffer()
5240*
5241***FUNCTION:
5242* This function checks the src buffer and its length and then malloc for
5243* dst buffer update the same
5244*
5245***LOGIC:
5246*
5247***ASSUMPTIONS:
5248*
5249***NOTE:
5250*
5251* @param pMac Pointer to Global MAC structure
5252* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5253* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5254* @param *pSrcData_buff A pointer of uint8_t src buffer
5255* @param srcDataLen src buffer length
5256******************************************************************************/
5257
5258static void
5259lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5260 uint8_t **pDstData_buff,
5261 uint16_t *pDstDataLen,
5262 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5263{
5264
5265 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5266 *pDstDataLen = srcDataLen;
5267
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305268 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005269 if (!*pDstData_buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305271 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 } else {
5273 *pDstData_buff = NULL;
5274 *pDstDataLen = 0;
5275 }
5276}
5277
5278/******************************************************************************
5279* lim_update_add_ie_buffer()
5280*
5281***FUNCTION:
5282* This function checks the src buffer and length if src buffer length more
5283* than dst buffer length then free the dst buffer and malloc for the new src
5284* length, and update the dst buffer and length. But if dst buffer is bigger
5285* than src buffer length then it just update the dst buffer and length
5286*
5287***LOGIC:
5288*
5289***ASSUMPTIONS:
5290*
5291***NOTE:
5292*
5293* @param pMac Pointer to Global MAC structure
5294* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5295* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5296* @param *pSrcData_buff A pointer of uint8_t src buffer
5297* @param srcDataLen src buffer length
5298******************************************************************************/
5299
5300static void
5301lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5302 uint8_t **pDstData_buff,
5303 uint16_t *pDstDataLen,
5304 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5305{
5306
5307 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005308 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 return;
5310 }
5311
5312 if (srcDataLen > *pDstDataLen) {
5313 *pDstDataLen = srcDataLen;
5314 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305315 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305317 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005318 if (!*pDstData_buff) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 *pDstDataLen = 0;
5320 return;
5321 }
5322 }
5323
5324 /* copy the content of buffer into dst buffer
5325 */
5326 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305327 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328
5329}
5330
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005331/**
5332 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5333 * @pMac : Pointer to Global MAC structure
5334 * @pDstData_buff : A pointer to pointer of dst buffer
5335 * @pDstDataLen : A pointer to pointer of dst buffer length
5336 * @pModifyIE : A pointer to tSirModifyIE
5337 *
5338 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5339 *
5340 * Return:
5341 * True or false depending upon whether IE is updated or not
5342 */
5343static bool
5344lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5345 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5346{
Hong Shi1553d692016-09-28 12:16:19 +08005347 int32_t oui_length;
5348 uint8_t *ibss_ie = NULL;
5349 uint8_t *vendor_ie;
5350#define MAC_VENDOR_OUI "\x00\x16\x32"
5351#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005352
5353 ibss_ie = pModifyIE->pIEBuffer;
5354 oui_length = pModifyIE->oui_length;
5355
5356 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005357 pe_err("Invalid set IBSS vendor IE command length %d",
5358 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005359 return false;
5360 }
5361
Hong Shi1553d692016-09-28 12:16:19 +08005362 /*
5363 * Why replace only beacon OUI data here:
5364 * 1. other ie (such as wpa) shall not be overwritten here.
5365 * 2. per spec, beacon oui ie might be set twice and original one
5366 * shall be updated.
5367 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005368 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005369 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5370 if (vendor_ie) {
5371 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5372 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5373 pModifyIE->ieBufferlength);
5374 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005375 uint16_t new_length;
5376 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005377
Naveen Rawat668dee32017-09-29 14:39:40 -07005378 /*
5379 * check for uint16 overflow before using sum of two numbers as
5380 * length of size to malloc
5381 */
5382 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5383 pe_err("U16 overflow due to %d + %d",
5384 pModifyIE->ieBufferlength, *pDstDataLen);
5385 return false;
5386 }
5387
5388 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5389 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005390 if (!new_ptr)
Hong Shi1553d692016-09-28 12:16:19 +08005391 return false;
Hong Shi1553d692016-09-28 12:16:19 +08005392 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5393 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5394 pModifyIE->ieBufferlength);
5395 qdf_mem_free(*pDstData_buff);
5396 *pDstDataLen = new_length;
5397 *pDstData_buff = new_ptr;
5398 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005399 return true;
5400}
5401
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402/*
5403* lim_process_modify_add_ies() - process modify additional IE req.
5404*
5405* @mac_ctx: Pointer to Global MAC structure
5406* @msg_buf: pointer to the SME message buffer
5407*
5408* This function update the PE buffers for additional IEs.
5409*
5410* Return: None
5411*/
5412static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5413 uint32_t *msg_buf)
5414{
5415 tpSirModifyIEsInd modify_add_ies;
5416 tpPESession session_entry;
5417 uint8_t session_id;
5418 bool ret = false;
5419 tSirAddIeParams *add_ie_params;
5420
5421 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005422 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 return;
5424 }
5425
5426 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5427 /* Incoming message has smeSession, use BSSID to find PE session */
5428 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005429 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430
5431 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005432 pe_err("Session not found for given bssid"
5433 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005434 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435 goto end;
5436 }
5437 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5438 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5439 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005440 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 modify_add_ies->modifyIE.pIEBuffer,
5442 modify_add_ies->modifyIE.ieBufferlength,
5443 modify_add_ies->modifyIE.ieID,
5444 modify_add_ies->modifyIE.ieIDLen,
5445 modify_add_ies->updateType);
5446 goto end;
5447 }
5448 add_ie_params = &session_entry->addIeParams;
5449 switch (modify_add_ies->updateType) {
5450 case eUPDATE_IE_PROBE_RESP:
5451 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005452 if (LIM_IS_IBSS_ROLE(session_entry)) {
5453 lim_update_ibss_prop_add_ies(mac_ctx,
5454 &add_ie_params->probeRespData_buff,
5455 &add_ie_params->probeRespDataLen,
5456 &modify_add_ies->modifyIE);
5457 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 break;
5459 case eUPDATE_IE_ASSOC_RESP:
5460 /* assoc resp IE */
5461 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305462 QDF_TRACE(QDF_MODULE_ID_PE,
5463 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 "assoc resp add ie not present %d"),
5465 add_ie_params->assocRespDataLen);
5466 }
5467 /* search through the buffer and modify the IE */
5468 break;
5469 case eUPDATE_IE_PROBE_BCN:
5470 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005471 if (LIM_IS_IBSS_ROLE(session_entry)) {
5472 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5473 &add_ie_params->probeRespBCNData_buff,
5474 &add_ie_params->probeRespBCNDataLen,
5475 &modify_add_ies->modifyIE);
5476 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005477 if (ret == true && modify_add_ies->modifyIE.notify) {
5478 lim_handle_param_update(mac_ctx,
5479 modify_add_ies->updateType);
5480 }
5481 break;
5482 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005483 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 modify_add_ies->updateType);
5485 break;
5486 }
5487end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305488 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 modify_add_ies->modifyIE.pIEBuffer = NULL;
5490}
5491
5492/*
5493* lim_process_update_add_ies() - process additional IE update req
5494*
5495* @mac_ctx: Pointer to Global MAC structure
5496* @msg_buf: pointer to the SME message buffer
5497*
5498* This function update the PE buffers for additional IEs.
5499*
5500* Return: None
5501*/
5502static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5503 uint32_t *msg_buf)
5504{
5505 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5506 uint8_t session_id;
5507 tpPESession session_entry;
5508 tSirAddIeParams *addn_ie;
5509 uint16_t new_length = 0;
5510 uint8_t *new_ptr = NULL;
5511 tSirUpdateIE *update_ie;
5512
5513 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005514 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 return;
5516 }
5517 update_ie = &update_add_ies->updateIE;
5518 /* incoming message has smeSession, use BSSID to find PE session */
5519 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005520 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521
5522 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305523 pe_debug("Session not found for given bssid"
5524 MAC_ADDRESS_STR,
5525 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 goto end;
5527 }
5528 addn_ie = &session_entry->addIeParams;
5529 /* if len is 0, upper layer requested freeing of buffer */
5530 if (0 == update_ie->ieBufferlength) {
5531 switch (update_add_ies->updateType) {
5532 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305533 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534 addn_ie->probeRespData_buff = NULL;
5535 addn_ie->probeRespDataLen = 0;
5536 break;
5537 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305538 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 addn_ie->assocRespData_buff = NULL;
5540 addn_ie->assocRespDataLen = 0;
5541 break;
5542 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305543 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 addn_ie->probeRespBCNData_buff = NULL;
5545 addn_ie->probeRespBCNDataLen = 0;
5546
5547 if (update_ie->notify)
5548 lim_handle_param_update(mac_ctx,
5549 update_add_ies->updateType);
5550 break;
5551 default:
5552 break;
5553 }
5554 return;
5555 }
5556 switch (update_add_ies->updateType) {
5557 case eUPDATE_IE_PROBE_RESP:
5558 if (update_ie->append) {
5559 /*
5560 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005561 * with combined length.
5562 * Multiple back to back append commands
5563 * can lead to a huge length.So, check
5564 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005566 if (addn_ie->probeRespDataLen >
5567 (USHRT_MAX - update_ie->ieBufferlength)) {
5568 pe_err("IE Length overflow, curr:%d, new:%d",
5569 addn_ie->probeRespDataLen,
5570 update_ie->ieBufferlength);
5571 goto end;
5572 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 new_length = update_ie->ieBufferlength +
5574 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305575 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005576 if (!new_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305579 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305581 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 update_ie->pAdditionIEBuffer,
5583 update_ie->ieBufferlength);
5584 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305585 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005586 /* adjust length accordingly */
5587 addn_ie->probeRespDataLen = new_length;
5588 /* save refernece of local buffer in PE session */
5589 addn_ie->probeRespData_buff = new_ptr;
5590 goto end;
5591 }
5592 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5593 &addn_ie->probeRespDataLen,
5594 update_ie->pAdditionIEBuffer,
5595 update_ie->ieBufferlength);
5596 break;
5597 case eUPDATE_IE_ASSOC_RESP:
5598 /* assoc resp IE */
5599 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5600 &addn_ie->assocRespDataLen,
5601 update_ie->pAdditionIEBuffer,
5602 update_ie->ieBufferlength);
5603 break;
5604 case eUPDATE_IE_PROBE_BCN:
5605 /* probe resp Bcn IE */
5606 lim_update_add_ie_buffer(mac_ctx,
5607 &addn_ie->probeRespBCNData_buff,
5608 &addn_ie->probeRespBCNDataLen,
5609 update_ie->pAdditionIEBuffer,
5610 update_ie->ieBufferlength);
5611 if (update_ie->notify)
5612 lim_handle_param_update(mac_ctx,
5613 update_add_ies->updateType);
5614 break;
5615 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005616 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 break;
5618 }
5619end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305620 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 update_ie->pAdditionIEBuffer = NULL;
5622}
5623
5624/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305625 * send_extended_chan_switch_action_frame()- function to send ECSA
5626 * action frame for each sta connected to SAP/GO and AP in case of
5627 * STA .
5628 * @mac_ctx: pointer to global mac structure
5629 * @new_channel: new channel to switch to.
5630 * @ch_bandwidth: BW of channel to calculate op_class
5631 * @session_entry: pe session
5632 *
5633 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5634 *
5635 * Return: void
5636 */
5637
5638static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5639 uint16_t new_channel, uint8_t ch_bandwidth,
5640 tpPESession session_entry)
5641{
5642 uint16_t op_class;
5643 uint8_t switch_mode = 0, i;
5644 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005645 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305646
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005647 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305648 mac_ctx->scan.countryCodeCurrent,
5649 new_channel,
5650 ch_bandwidth);
5651
5652 if (LIM_IS_AP_ROLE(session_entry) &&
5653 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005654 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305655
gaoleze2920bd2017-03-21 17:38:42 +08005656 switch_count = session_entry->gLimChannelSwitch.switchCount;
5657
Abhishek Singh518323d2015-10-19 17:42:01 +05305658 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005659 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305660 psta =
5661 session_entry->dph.dphHashTable.pDphNodeArray + i;
5662 if (psta && psta->added)
5663 lim_send_extended_chan_switch_action_frame(
5664 mac_ctx,
5665 psta->staAddr,
5666 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005667 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305668 }
5669 } else if (LIM_IS_STA_ROLE(session_entry)) {
5670 lim_send_extended_chan_switch_action_frame(mac_ctx,
5671 session_entry->bssId,
5672 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005673 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305674 }
5675
5676}
5677
gaolez76d2a162017-03-21 19:23:58 +08005678void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5679 uint16_t new_channel,
5680 uint8_t ch_bandwidth,
5681 tpPESession session_entry)
5682{
5683 uint16_t op_class;
5684 uint8_t switch_mode = 0, i;
5685 uint8_t switch_count;
5686 tpDphHashNode psta;
5687 tpDphHashNode dph_node_array_ptr;
5688
5689 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5690
5691 op_class = wlan_reg_dmn_get_opclass_from_channel(
5692 mac_ctx->scan.countryCodeCurrent,
5693 new_channel, ch_bandwidth);
5694
5695 if (LIM_IS_AP_ROLE(session_entry) &&
5696 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5697 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5698
5699 switch_count = session_entry->gLimChannelSwitch.switchCount;
5700
5701 if (LIM_IS_AP_ROLE(session_entry)) {
5702 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5703 psta = dph_node_array_ptr + i;
5704 if (!(psta && psta->added))
5705 continue;
5706 if (session_entry->lim_non_ecsa_cap_num == 0)
5707 lim_send_extended_chan_switch_action_frame
5708 (mac_ctx, psta->staAddr, switch_mode,
5709 op_class, new_channel, switch_count,
5710 session_entry);
5711 else
5712 lim_send_channel_switch_mgmt_frame
5713 (mac_ctx, psta->staAddr, switch_mode,
5714 new_channel, switch_count,
5715 session_entry);
5716 }
5717 } else if (LIM_IS_STA_ROLE(session_entry)) {
5718 lim_send_extended_chan_switch_action_frame
5719 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5720 new_channel, switch_count, session_entry);
5721 }
5722}
5723
5724/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5726 *
5727 * @mac_ctx: Pointer to Global MAC structure
5728 * @msg_buf: pointer to the SME message buffer
5729 *
5730 * This function processes SME request messages from HDD or upper layer
5731 * application.
5732 *
5733 * Return: None
5734 */
5735static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5736 uint32_t *msg_buf)
5737{
5738 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5739 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 uint8_t session_id;
5741 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005742 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743
5744 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005745 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746 return;
5747 }
5748
5749 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5750 session_entry = pe_find_session_by_bssid(mac_ctx,
5751 dfs_csa_ie_req->bssid, &session_id);
5752 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005753 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5755 return;
5756 }
5757
5758 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005759 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 GET_LIM_SYSTEM_ROLE(session_entry));
5761 return;
5762 }
5763
5764 /* target channel */
5765 session_entry->gLimChannelSwitch.primaryChannel =
5766 dfs_csa_ie_req->targetChannel;
5767
5768 /* Channel switch announcement needs to be included in beacon */
5769 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005770 session_entry->gLimChannelSwitch.switchCount =
5771 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005773 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305774 session_entry->gLimChannelSwitch.sec_ch_offset =
5775 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005777 session_entry->gLimChannelSwitch.switchMode =
5778 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779
5780 /*
5781 * Validate if SAP is operating HT or VHT mode and set the Channel
5782 * Switch Wrapper element with the Wide Band Switch subelement.
5783 */
5784 if (true != session_entry->vhtCapability)
5785 goto skip_vht;
5786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 /* Now encode the Wider Ch BW element depending on the ch width */
5788 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005789 switch (dfs_csa_ie_req->ch_params.ch_width) {
5790 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 /*
5792 * Wide channel BW sublement in channel wrapper element is not
5793 * required in case of 20 Mhz operation. Currently It is set
5794 * only set in case of 40/80 Mhz Operation.
5795 */
5796 session_entry->dfsIncludeChanWrapperIe = false;
5797 wider_bw_ch_switch->newChanWidth =
5798 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5799 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005800 case CH_WIDTH_40MHZ:
5801 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 wider_bw_ch_switch->newChanWidth =
5803 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5804 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005805 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 session_entry->dfsIncludeChanWrapperIe = true;
5807 wider_bw_ch_switch->newChanWidth =
5808 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5809 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005810 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005811 session_entry->dfsIncludeChanWrapperIe = true;
5812 wider_bw_ch_switch->newChanWidth =
5813 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5814 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005815 case CH_WIDTH_80P80MHZ:
5816 session_entry->dfsIncludeChanWrapperIe = true;
5817 wider_bw_ch_switch->newChanWidth =
5818 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005819 /*
5820 * This is not applicable for 20/40/80 Mhz.
5821 * Only used when we support 80+80 Mhz operation.
5822 * In case of 80+80 Mhz, this parameter indicates
5823 * center channel frequency index of 80 Mhz channel of
5824 * frequency segment 1.
5825 */
5826 wider_bw_ch_switch->newCenterChanFreq1 =
5827 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005828 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829 default:
5830 session_entry->dfsIncludeChanWrapperIe = false;
5831 /*
5832 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5833 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5834 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005835 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 break;
5837 }
5838 /* Fetch the center channel based on the channel width */
5839 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005840 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841skip_vht:
5842 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305843 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305844
5845 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5846 ch_offset = BW80;
5847 else
5848 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5849
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005850 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305851 session_entry->gLimChannelSwitch.switchCount,
5852 session_entry->gLimChannelSwitch.primaryChannel,
5853 session_entry->gLimChannelSwitch.ch_width,
5854 session_entry->dfsIncludeChanWrapperIe,
5855 ch_offset);
5856
gaolez76d2a162017-03-21 19:23:58 +08005857 /* Send ECSA/CSA Action frame after updating the beacon */
5858 if (CHAN_HOP_ALL_BANDS_ENABLE)
5859 lim_send_chan_switch_action_frame(mac_ctx,
5860 session_entry->gLimChannelSwitch.primaryChannel,
5861 ch_offset, session_entry);
5862 else
5863 send_extended_chan_switch_action_frame(mac_ctx,
5864 session_entry->gLimChannelSwitch.primaryChannel,
5865 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866}
5867
5868/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305869 * lim_process_ext_change_channel()- function to send ECSA
5870 * action frame for STA/CLI .
5871 * @mac_ctx: pointer to global mac structure
5872 * @msg: params from sme for new channel.
5873 *
5874 * This function is called to send ECSA frame for STA/CLI.
5875 *
5876 * Return: void
5877 */
5878
5879static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5880 uint32_t *msg)
5881{
5882 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5883 (struct sir_sme_ext_cng_chan_req *) msg;
5884 tpPESession session_entry = NULL;
5885
5886 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005887 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305888 return;
5889 }
5890 session_entry =
5891 pe_find_session_by_sme_session_id(mac_ctx,
5892 ext_chng_channel->session_id);
5893 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005894 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305895 ext_chng_channel->session_id);
5896 return;
5897 }
5898 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005899 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305900 return;
5901 }
5902 send_extended_chan_switch_action_frame(mac_ctx,
5903 ext_chng_channel->new_channel,
5904 0, session_entry);
5905}
5906
5907/**
Abhishek Singhfc740be2018-10-12 11:34:26 +05305908 * lim_nss_update_rsp() - send NSS update response to SME
5909 * @mac_ctx Pointer to Global MAC structure
5910 * @vdev_id: vdev id
5911 * @status: nss update status
5912 *
5913 * Return: None
5914 */
5915static void lim_nss_update_rsp(tpAniSirGlobal mac_ctx,
5916 uint8_t vdev_id, QDF_STATUS status)
5917{
5918 struct scheduler_msg msg = {0};
5919 struct sir_bcn_update_rsp *nss_rsp;
5920 QDF_STATUS qdf_status;
5921
5922 nss_rsp = qdf_mem_malloc(sizeof(*nss_rsp));
5923 if (!nss_rsp) {
5924 pe_err("AllocateMemory failed for nss_rsp");
5925 return;
5926 }
5927
5928 nss_rsp->vdev_id = vdev_id;
5929 nss_rsp->status = status;
5930 nss_rsp->reason = REASON_NSS_UPDATE;
5931
5932 msg.type = eWNI_SME_NSS_UPDATE_RSP;
5933 msg.bodyptr = nss_rsp;
5934 msg.bodyval = 0;
5935 qdf_status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_SME,
5936 QDF_MODULE_ID_SME, &msg);
5937 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5938 pe_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
5939 qdf_mem_free(nss_rsp);
5940 }
5941}
5942
5943void lim_send_bcn_rsp(tpAniSirGlobal mac_ctx, tpSendbeaconParams rsp)
5944{
5945 if (!rsp) {
5946 pe_err("rsp is NULL");
5947 return;
5948 }
5949
5950 pe_debug("Send beacon resp status %d for reason %d",
5951 rsp->status, rsp->reason);
5952
5953 if (rsp->reason == REASON_NSS_UPDATE)
5954 lim_nss_update_rsp(mac_ctx, rsp->vdev_id, rsp->status);
5955}
5956
5957/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 * lim_process_nss_update_request() - process sme nss update req
5959 *
5960 * @mac_ctx: Pointer to Global MAC structure
5961 * @msg_buf: pointer to the SME message buffer
5962 *
5963 * This function processes SME request messages from HDD or upper layer
5964 * application.
5965 *
5966 * Return: None
5967 */
5968static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5969 uint32_t *msg_buf)
5970{
5971 struct sir_nss_update_request *nss_update_req_ptr;
5972 tpPESession session_entry = NULL;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305973 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5974 uint8_t vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975
Abhishek Singhfc740be2018-10-12 11:34:26 +05305976 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005977 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 return;
5979 }
5980
5981 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305982 vdev_id = nss_update_req_ptr->vdev_id;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305983 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305985 if (!session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005986 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005987 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305988 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 }
5990
5991 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005992 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 GET_LIM_SYSTEM_ROLE(session_entry));
Abhishek Singhfc740be2018-10-12 11:34:26 +05305994 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 }
5996
5997 /* populate nss field in the beacon */
5998 session_entry->gLimOperatingMode.present = 1;
5999 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306000 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6001
6002 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6003 (session_entry->ch_width > CH_WIDTH_80MHZ))
6004 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6005
Abhishek Singhfc740be2018-10-12 11:34:26 +05306006 pe_debug("ch width %d Rx NSS %d",
6007 session_entry->gLimOperatingMode.chanWidth,
6008 session_entry->gLimOperatingMode.rxNSS);
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 /* Send nss update request from here */
Abhishek Singhfc740be2018-10-12 11:34:26 +05306011 status = sch_set_fixed_beacon_fields(mac_ctx, session_entry);
6012 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006013 pe_err("Unable to set op mode IE in beacon");
Abhishek Singhfc740be2018-10-12 11:34:26 +05306014 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 }
6016
Abhishek Singhfc740be2018-10-12 11:34:26 +05306017 status = lim_send_beacon_ind(mac_ctx, session_entry, REASON_NSS_UPDATE);
6018 if (QDF_IS_STATUS_SUCCESS(status))
6019 return;
6020
6021 pe_err("Unable to send beacon");
6022end:
6023 /*
6024 * send resp only in case of failure,
6025 * success case response will be from wma.
6026 */
6027 lim_nss_update_rsp(mac_ctx, vdev_id, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006028}
6029
6030/**
6031 * lim_process_set_ie_req() - process sme set IE request
6032 *
6033 * @mac_ctx: Pointer to Global MAC structure
6034 * @msg_buf: pointer to the SME message buffer
6035 *
6036 * This function processes SME request messages from HDD or upper layer
6037 * application.
6038 *
6039 * Return: None
6040 */
6041static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6042{
6043 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306044 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045
6046 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006047 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 return;
6049 }
6050
6051 msg = (struct send_extcap_ie *)msg_buf;
6052 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306053 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006054 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055
6056}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006057
6058#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006059
6060/**
6061 * obss_color_collision_process_color_disable() - Disable bss color
6062 * @mac_ctx: Pointer to Global MAC structure
6063 * @session: pointer to session
6064 *
6065 * This function will disbale bss color.
6066 *
6067 * Return: None
6068 */
6069static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6070 tpPESession session)
6071{
6072 tUpdateBeaconParams beacon_params;
6073
6074 if (!session) {
6075 pe_err("Invalid session");
6076 return;
6077 }
6078
6079 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6080 pe_err("Invalid SystemRole %d",
6081 GET_LIM_SYSTEM_ROLE(session));
6082 return;
6083 }
6084
6085 if (session->bss_color_changing == 1) {
6086 pe_warn("%d: color change in progress", session->smeSessionId);
6087 /* Continue color collision detection */
6088 lim_send_obss_color_collision_cfg(mac_ctx, session,
6089 OBSS_COLOR_COLLISION_DETECTION);
6090 return;
6091 }
6092
6093 if (session->he_op.bss_col_disabled == 1) {
6094 pe_warn("%d: bss color already disabled",
6095 session->smeSessionId);
6096 /* Continue free color detection */
6097 lim_send_obss_color_collision_cfg(mac_ctx, session,
6098 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6099 return;
6100 }
6101
6102 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6103 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6104 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006105 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006106 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006107
6108 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006109 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006110 pe_err("Unable to set op mode IE in beacon");
6111 return;
6112 }
6113
6114 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6115 lim_send_obss_color_collision_cfg(mac_ctx, session,
6116 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6117}
6118
6119/**
6120 * obss_color_collision_process_color_change() - Process bss color change
6121 * @mac_ctx: Pointer to Global MAC structure
6122 * @session: pointer to session
6123 * @obss_color_info: obss color collision/free slot indication info
6124 *
6125 * This function selects new color ib case of bss color collision.
6126 *
6127 * Return: None
6128 */
6129static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6130 tpPESession session,
6131 struct wmi_obss_color_collision_info *obss_color_info)
6132{
6133 int i, num_bss_color = 0;
6134 uint32_t bss_color_bitmap;
6135 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6136 uint32_t rand_byte = 0;
6137 struct sir_set_he_bss_color he_bss_color;
6138 bool is_color_collision = false;
6139
6140
6141 if (session->bss_color_changing == 1) {
6142 pe_err("%d: color change in progress", session->smeSessionId);
6143 return;
6144 }
6145
6146 if (!session->he_op.bss_col_disabled) {
6147 if (session->he_op.bss_color < 32)
6148 is_color_collision = (obss_color_info->
6149 obss_color_bitmap_bit0to31 >>
6150 session->he_op.bss_color) & 0x01;
6151 else
6152 is_color_collision = (obss_color_info->
6153 obss_color_bitmap_bit32to63 >>
6154 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006155 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006156 if (!is_color_collision) {
6157 pe_err("%d: color collision not found, curr_color: %d",
6158 session->smeSessionId,
6159 session->he_op.bss_color);
6160 return;
6161 }
6162 }
6163
6164 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6165
6166 /* Skip color zero */
6167 bss_color_bitmap = bss_color_bitmap >> 1;
6168 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6169 if (!(bss_color_bitmap & 0x01)) {
6170 bss_color_index_array[num_bss_color] = i + 1;
6171 num_bss_color++;
6172 }
6173 bss_color_bitmap = bss_color_bitmap >> 1;
6174 }
6175
6176 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6177 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6178 if (!(bss_color_bitmap & 0x01)) {
6179 bss_color_index_array[num_bss_color] = i + 32;
6180 num_bss_color++;
6181 }
6182 bss_color_bitmap = bss_color_bitmap >> 1;
6183 }
6184
6185 if (num_bss_color) {
6186 qdf_get_random_bytes((void *) &rand_byte, 1);
6187 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6188 num_bss_color;
6189 pe_debug("New bss color = %d", bss_color_index_array[i]);
6190 he_bss_color.session_id = obss_color_info->vdev_id;
6191 he_bss_color.bss_color = bss_color_index_array[i];
6192 lim_process_set_he_bss_color(mac_ctx,
6193 (uint32_t *)&he_bss_color);
6194 } else {
6195 pe_err("Unable to find bss color from bitmasp");
6196 if (obss_color_info->evt_type ==
6197 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6198 session->obss_color_collision_dec_evt ==
6199 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6200 /* In dot11BSSColorCollisionAPPeriod and
6201 * timer expired, time to disable bss color.
6202 */
6203 obss_color_collision_process_color_disable(mac_ctx,
6204 session);
6205 else
6206 /*
6207 * Enter dot11BSSColorCollisionAPPeriod period.
6208 */
6209 lim_send_obss_color_collision_cfg(mac_ctx, session,
6210 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6211 }
6212}
6213
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006214void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6215{
6216 struct sir_set_he_bss_color *bss_color;
6217 tpPESession session_entry = NULL;
6218 tUpdateBeaconParams beacon_params;
6219
6220 if (!msg_buf) {
6221 pe_err("Buffer is Pointing to NULL");
6222 return;
6223 }
6224
6225 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6226 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6227 bss_color->session_id);
6228 if (!session_entry) {
6229 pe_err("Session not found for given session_id %d",
6230 bss_color->session_id);
6231 return;
6232 }
6233
6234 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6235 pe_err("Invalid SystemRole %d",
6236 GET_LIM_SYSTEM_ROLE(session_entry));
6237 return;
6238 }
6239
6240 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6241 pe_err("No change in BSS color, current BSS color %d",
6242 bss_color->bss_color);
6243 return;
6244 }
6245 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6246 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6247 session_entry->he_op.bss_col_disabled = 1;
6248 session_entry->he_bss_color_change.countdown =
6249 BSS_COLOR_SWITCH_COUNTDOWN;
6250 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006251 beacon_params.bss_color_disabled = 1;
6252 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006253 session_entry->bss_color_changing = 1;
6254
6255 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006256 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006257 pe_err("Unable to set op mode IE in beacon");
6258 return;
6259 }
6260
6261 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006262 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6263 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6264}
6265
6266void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6267 tpPESession session,
6268 enum wmi_obss_color_collision_evt_type
6269 event_type)
6270{
6271 struct wmi_obss_color_collision_cfg_param *cfg_param;
6272 struct scheduler_msg msg = {0};
6273
6274 if (!session) {
6275 pe_err("Invalid session");
6276 return;
6277 }
6278
6279 if (!session->he_capable ||
6280 !session->is_session_obss_color_collision_det_enabled) {
6281 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6282 session->smeSessionId, session->he_capable,
6283 session->is_session_obss_color_collision_det_enabled,
6284 mac_ctx->lim.global_obss_color_collision_det_offload);
6285 return;
6286 }
6287
6288 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006289 if (!cfg_param)
Arif Hussain05fb4872018-01-03 16:02:55 -08006290 return;
Arif Hussain05fb4872018-01-03 16:02:55 -08006291
6292 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6293 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6294 cfg_param->vdev_id = session->smeSessionId;
6295 cfg_param->evt_type = event_type;
6296 if (LIM_IS_AP_ROLE(session))
6297 cfg_param->detection_period_ms =
6298 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6299 else
6300 cfg_param->detection_period_ms =
6301 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6302
6303 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6304 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6305 cfg_param->free_slot_expiry_time_ms =
6306 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6307
6308 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6309 msg.bodyptr = cfg_param;
6310 msg.reserved = 0;
6311
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306312 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6313 QDF_MODULE_ID_WMA,
6314 QDF_MODULE_ID_WMA,
6315 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006316 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6317 qdf_mem_free(cfg_param);
6318 } else {
6319 session->obss_color_collision_dec_evt = event_type;
6320 }
6321}
6322
6323void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6324 uint32_t *msg_buf)
6325{
6326 struct wmi_obss_color_collision_info *obss_color_info;
6327 tpPESession session;
6328
6329 if (!msg_buf) {
6330 pe_err("Buffer is Pointing to NULL");
6331 return;
6332 }
6333
6334 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6335 session = pe_find_session_by_sme_session_id(mac_ctx,
6336 obss_color_info->vdev_id);
6337 if (!session) {
6338 pe_err("Session not found for given session_id %d",
6339 obss_color_info->vdev_id);
6340 return;
6341 }
6342
6343 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6344 obss_color_info->vdev_id,
6345 obss_color_info->evt_type,
6346 session->obss_color_collision_dec_evt,
6347 obss_color_info->obss_color_bitmap_bit0to31,
6348 obss_color_info->obss_color_bitmap_bit32to63,
6349 session->he_capable,
6350 session->is_session_obss_color_collision_det_enabled,
6351 mac_ctx->lim.global_obss_color_collision_det_offload);
6352
6353 if (!session->he_capable ||
6354 !session->is_session_obss_color_collision_det_enabled) {
6355 return;
6356 }
6357
6358 switch (obss_color_info->evt_type) {
6359 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6360 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6361 session->smeSessionId, session->he_capable,
6362 session->is_session_obss_color_collision_det_enabled,
6363 mac_ctx->lim.global_obss_color_collision_det_offload);
6364 session->is_session_obss_color_collision_det_enabled = false;
6365 return;
6366 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6367 case OBSS_COLOR_COLLISION_DETECTION:
6368 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6369 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6370 pe_debug("Invalid System Role %d",
6371 GET_LIM_SYSTEM_ROLE(session));
6372 return;
6373 }
6374
6375 if (session->obss_color_collision_dec_evt !=
6376 obss_color_info->evt_type) {
6377 pe_debug("%d: Wrong event: %d, skiping",
6378 obss_color_info->vdev_id,
6379 obss_color_info->evt_type);
6380 return;
6381 }
6382 obss_color_collision_process_color_change(mac_ctx, session,
6383 obss_color_info);
6384 break;
6385 default:
6386 pe_err("%d: Invalid event type %d",
6387 obss_color_info->vdev_id, obss_color_info->evt_type);
6388 return;
6389 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006390}
6391#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306392
6393#ifdef CONFIG_VDEV_SM
6394void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6395{
6396 tpPESession session;
6397
6398 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6399
6400 if (!session) {
6401 pe_err("session not found for vdev id %d", vdev_id);
6402 return;
6403 }
6404
6405 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6406 WLAN_VDEV_SM_EV_CSA_RESTART,
6407 sizeof(*session), session);
6408}
6409#endif