blob: 9041a394acf2f1d874350504574d30fb519e140e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jingxiang Ge4168a232018-01-03 18:47:15 +08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_process_sme_req_messages.cc contains the code
21 * for processing SME request messages.
22 * Author: Chandra Modumudi
23 * Date: 02/11/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 *
28 */
29
30#include "cds_api.h"
31#include "wni_api.h"
32#include "wni_cfg.h"
33#include "cfg_api.h"
34#include "sir_api.h"
35#include "sch_api.h"
36#include "utils_api.h"
37#include "lim_types.h"
38#include "lim_utils.h"
39#include "lim_assoc_utils.h"
40#include "lim_security_utils.h"
41#include "lim_ser_des_utils.h"
42#include "lim_sme_req_utils.h"
43#include "lim_ibss_peer_mgmt.h"
44#include "lim_admit_control.h"
45#include "dph_hash_table.h"
46#include "lim_send_messages.h"
47#include "lim_api.h"
48#include "wmm_apsd.h"
49#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080050#include "rrm_api.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "sap_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070054#include "cds_regdomain.h"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053055#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070056#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057
58/*
59 * This overhead is time for sending NOA start to host in case of GO/sending
60 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
61 * with init scan req/rsp plus in case of concurrency, taking care of sending
62 * null data and receiving ACK to/from AP/Also SetChannel with calibration
63 * is taking around 7ms .
64 */
65#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
66#define JOIN_NOA_DURATION 2000 /* in msecs */
67#define OEM_DATA_NOA_DURATION 60 /* in msecs */
68#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
69
70#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
71
Paul Zhangd2315472017-02-22 10:02:50 +080072#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
73#define STA_BURST_SCAN_DURATION 120 /* in msecs */
74
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075/* SME REQ processing function templates */
76static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080077static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
78 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
80static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
81static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
82static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
83static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
84static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080085static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
86 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053087static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
88 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
90 uint32_t *pMsg);
91static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
92static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
93static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
94static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
95
96static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
97 uint8_t **pDstData_buff,
98 uint16_t *pDstDataLen,
99 uint8_t *pSrcData_buff,
100 uint16_t srcDataLen);
101
102static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800106static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
111
112static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
Abhishek Singh518323d2015-10-19 17:42:01 +0530114static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
115 uint32_t *msg);
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
118 * lim_process_set_hw_mode() - Send set HW mode command to WMA
119 * @mac: Globacl MAC pointer
120 * @msg: Message containing the hw mode index
121 *
122 * Send the set HW mode command to WMA
123 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530124 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530126static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530128 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700129 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800130 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 uint32_t len;
132 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700133 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 struct sir_set_hw_mode_resp *param;
135
136 buf = (struct s_sir_set_hw_mode *) msg;
137 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700138 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 /* To free the active command list */
140 goto fail;
141 }
142
143 len = sizeof(*req_msg);
144
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530145 req_msg = qdf_mem_malloc(len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700146 if (!req_msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530147 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530150 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* Other parameters are not needed for WMA */
152
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800153 message.bodyptr = req_msg;
154 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700156 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530157 status = scheduler_post_message(QDF_MODULE_ID_PE,
158 QDF_MODULE_ID_WMA,
159 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530160 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700161 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530163 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 goto fail;
165 }
166 return status;
167fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530168 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700169 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530170 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 param->status = SET_HW_MODE_STATUS_ECANCELED;
172 param->cfgd_hw_mode_index = 0;
173 param->num_vdev_mac_entries = 0;
174 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
175 resp_msg.bodyptr = param;
176 resp_msg.bodyval = 0;
177 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530178 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179}
180
181/**
182 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
183 * @mac: Global MAC pointer
184 * @msg: Message containing the dual mac config parameter
185 *
186 * Send the set dual mac config command to WMA
187 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530188 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530190static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 uint32_t *msg)
192{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700194 struct scheduler_msg message = {0};
Srinivas Girigowdaeb6ecf32018-02-15 17:04:22 -0800195 struct policy_mgr_dual_mac_config *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196 uint32_t len;
197 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700198 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 struct sir_dual_mac_config_resp *param;
200
201 buf = (struct sir_set_dual_mac_cfg *) msg;
202 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700203 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 /* To free the active command list */
205 goto fail;
206 }
207
208 len = sizeof(*req_msg);
209
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530210 req_msg = qdf_mem_malloc(len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700211 if (!req_msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530212 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 req_msg->scan_config = buf->set_dual_mac.scan_config;
215 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
216 /* Other parameters are not needed for WMA */
217
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800218 message.bodyptr = req_msg;
219 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700221 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 req_msg->scan_config, req_msg->fw_mode_config);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530223 status = scheduler_post_message(QDF_MODULE_ID_PE,
224 QDF_MODULE_ID_WMA,
225 QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530226 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700227 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530229 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 goto fail;
231 }
232 return status;
233fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700235 if (!param)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530236 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 param->status = SET_HW_MODE_STATUS_ECANCELED;
238 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
239 resp_msg.bodyptr = param;
240 resp_msg.bodyval = 0;
241 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530242 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243}
244
245/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800246 * lim_process_set_antenna_mode_req() - Set antenna mode command
247 * to WMA
248 * @mac: Global MAC pointer
249 * @msg: Message containing the antenna mode parameter
250 *
251 * Send the set antenna mode command to WMA
252 *
253 * Return: QDF_STATUS_SUCCESS if message posting is successful
254 */
255static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
256 uint32_t *msg)
257{
258 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700259 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800260 struct sir_antenna_mode_param *req_msg;
261 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700262 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800263 struct sir_antenna_mode_resp *param;
264
265 buf = (struct sir_set_antenna_mode *) msg;
266 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700267 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 /* To free the active command list */
269 goto fail;
270 }
271
272 req_msg = qdf_mem_malloc(sizeof(*req_msg));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700273 if (!req_msg)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800274 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800275
276 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
277 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
278
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800279 message.bodyptr = req_msg;
280 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700282 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800283 req_msg->num_rx_chains,
284 req_msg->num_tx_chains);
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530285 status = scheduler_post_message(QDF_MODULE_ID_PE,
286 QDF_MODULE_ID_WMA,
287 QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800288 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700289 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800290 status);
291 qdf_mem_free(req_msg);
292 goto fail;
293 }
294 return status;
295fail:
296 param = qdf_mem_malloc(sizeof(*param));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700297 if (!param)
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800298 return QDF_STATUS_E_NOMEM;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800299 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
300 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
301 resp_msg.bodyptr = param;
302 resp_msg.bodyval = 0;
303 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
304 return QDF_STATUS_SUCCESS;
305}
306
307/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 * __lim_is_sme_assoc_cnf_valid()
309 *
310 ***FUNCTION:
311 * This function is called by __lim_process_sme_assoc_cnf_new() upon
312 * receiving SME_ASSOC_CNF.
313 *
314 ***LOGIC:
315 * Message validity checks are performed in this function
316 *
317 ***ASSUMPTIONS:
318 *
319 ***NOTE:
320 *
321 * @param pMeasReq Pointer to Received ASSOC_CNF message
322 * @return true When received SME_ASSOC_CNF is formatted
323 * correctly
324 * false otherwise
325 */
326
327static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
328{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530329 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 return false;
331 else
332 return true;
333} /*** end __lim_is_sme_assoc_cnf_valid() ***/
334
335/**
336 * __lim_get_sme_join_req_size_for_alloc()
337 *
338 ***FUNCTION:
339 * This function is called in various places to get IE length
340 * from tSirBssDescription structure
341 * number being scanned.
342 *
343 ***PARAMS:
344 *
345 ***LOGIC:
346 *
347 ***ASSUMPTIONS:
348 * NA
349 *
350 ***NOTE:
351 * NA
352 *
353 * @param pBssDescr
354 * @return Total IE length
355 */
356
357static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
358{
359 uint16_t len = 0;
360
361 if (!pBuf)
362 return len;
363
364 pBuf += sizeof(uint16_t);
365 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700366 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367}
368
369/**
370 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
371 * @pMac: Global MAC context
372 * @pMsg: Pointer to message posted from SME to LIM.
373 *
374 * Has role only if 11h is enabled. Not used on STA side.
375 * Defers the message if SME is in learn state and brings
376 * the LIM back to normal mode.
377 *
378 * Return: true - If defered false - Otherwise
379 */
380
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800381static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
382 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383{
384 if (lim_is_system_in_scan_state(pMac)) {
385 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700386 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 return false;
388 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700389 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 pMsg->type);
391 return true;
392 }
393 return false;
394}
395
396/**
397 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
398 * @mac_ctx: Pointer to Global MAC structure
399 * @message: Pointer to message posted from SME to LIM.
400 *
401 * Has role only if 11h is enabled. Not used on STA side.
402 * Defers the message if radar is detected.
403 *
404 * Return: true, if defered otherwise return false.
405 */
406static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800407__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
408 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409{
410 /*
411 * fRadarDetCurOperChan will be set only if we
412 * detect radar in current operating channel and
413 * System Role == AP ROLE
414 *
415 * TODO: Need to take care radar detection.
416 *
417 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
418 */
419 if (0) {
420 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700421 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 return false;
423 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700424 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 message->type);
426 return true;
427 }
428 return false;
429}
430
431/**
432 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
433 * @pMac: Global MAC context
434 * @pMsgBuf: Message from WMA
435 *
436 * handles the notification from HDD. PE just forwards this message to HAL.
437 *
438 * Return: true-Posting to HAL failed, so PE will consume the buffer.
439 * false-Posting to HAL successful, so HAL will consume the buffer.
440 */
441
442static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
443{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700444 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
446
447 msg.type = WMA_SYS_READY_IND;
448 msg.reserved = 0;
449 msg.bodyptr = pMsgBuf;
450 msg.bodyval = 0;
451
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700452 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800453 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530454 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700455 pe_register_callbacks_with_wma(pMac, ready_req);
Sandeep Puligilla1426d612017-04-12 18:22:06 -0700456 pMac->lim.sme_msg_callback = ready_req->sme_msg_cb;
Vignesh Viswanathan3d478032018-08-02 20:18:53 +0530457 pMac->lim.stop_roaming_callback = ready_req->stop_roaming_cb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700459
460 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
462
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700463 if (QDF_STATUS_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700464 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 return true;
466 }
467 return false;
468}
469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470/**
471 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
472 *@mac_ctx: Pointer to Global MAC structure
473 *@session: A pointer to session entry
474 *@sme_start_bss_req: Start BSS Request from upper layers.
475 *
476 * This function is used to configure the start bss parameters
477 * in to the session.
478 *
479 * Return: None.
480 */
481static void
482lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
483 tpSirSmeStartBssReq sme_start_bss_req)
484{
485 session->limSystemRole = eLIM_AP_ROLE;
486 session->privacy = sme_start_bss_req->privacy;
487 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
488 session->authType = sme_start_bss_req->authType;
489 /* Store the DTIM period */
490 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
491 /* Enable/disable UAPSD */
492 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530493 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 session->proxyProbeRspEn = 0;
495 } else {
496 /*
497 * To detect PBC overlap in SAP WPS mode,
498 * Host handles Probe Requests.
499 */
500 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
501 session->proxyProbeRspEn = 1;
502 else
503 session->proxyProbeRspEn = 0;
504 }
505 session->ssidHidden = sme_start_bss_req->ssidHidden;
506 session->wps_state = sme_start_bss_req->wps_state;
507 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530508 session->vendor_vht_sap =
509 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
511 &session->shortSlotTimeSupported);
512 session->isCoalesingInIBSSAllowed =
513 sme_start_bss_req->isCoalesingInIBSSAllowed;
514
Jiachao Wu712d4fd2017-08-23 16:52:34 +0800515 session->beacon_tx_rate = sme_start_bss_req->beacon_tx_rate;
516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517}
518
519/**
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530520 * lim_send_start_vdev_req() - send vdev start request
521 *@session: pe session
522 *@mlm_start_req: vdev start req
523 *
524 * Return: QDF_STATUS
525 */
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530526#ifdef CONFIG_VDEV_SM
527static QDF_STATUS
528lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
529{
530 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
531 WLAN_VDEV_SM_EV_START,
532 sizeof(*mlm_start_req),
533 mlm_start_req);
534}
535#else
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530536static QDF_STATUS
537lim_send_start_vdev_req(tpPESession session, tLimMlmStartReq *mlm_start_req)
538{
539 lim_process_mlm_start_req(session->mac_ctx, mlm_start_req);
540
541 return QDF_STATUS_SUCCESS;
542}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +0530543#endif
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530544
545/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
547 *@mac_ctx: Pointer to Global MAC structure
548 *@msg_buf: A pointer to the SME message buffer
549 *
550 * This function is called to process SME_START_BSS_REQ message
551 * from HDD or upper layer application.
552 *
553 * Return: None
554 */
555static void
556__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
557{
558 uint16_t size;
559 uint32_t val = 0;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700560 QDF_STATUS ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 tSirMacChanNum channel_number;
562 tLimMlmStartReq *mlm_start_req = NULL;
563 tpSirSmeStartBssReq sme_start_bss_req = NULL;
564 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
565 /* Flag Used in case of IBSS to Auto generate BSSID. */
566 uint32_t auto_gen_bssid = false;
567 uint8_t session_id;
568 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800569 uint8_t sme_session_id = 0xFF;
570 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700572 struct vdev_type_nss *vdev_type_nss;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530573 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530574 struct policy_mgr_hw_mode_params hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575
576/* FEATURE_WLAN_DIAG_SUPPORT */
577#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
578 /*
579 * Since the session is not created yet, sending NULL.
580 * The response should have the correct state.
581 */
582 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
583 NULL, 0, 0);
584#endif /* FEATURE_WLAN_DIAG_SUPPORT */
585
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700586 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800587 size = sizeof(tSirSmeStartBssReq);
588 sme_start_bss_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700589 if (!sme_start_bss_req) {
Krunal Sonib37bb352016-12-20 14:12:21 -0800590 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
591 goto free;
592 }
593 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
594 sme_session_id = sme_start_bss_req->sessionId;
595 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
598 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
600 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700601 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602 ret_code = eSIR_SME_INVALID_PARAMETERS;
603 goto free;
604 }
605
606 /*
607 * This is the place where PE is going to create a session.
608 * If session is not existed, then create a new session
609 */
610 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800611 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700613 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
615 session = NULL;
616 goto free;
617 } else {
618 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800619 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530621 sme_start_bss_req->bssType,
622 sme_start_bss_req->sessionId);
623 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700624 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
626 goto free;
627 }
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530628
629 /* Update the beacon/probe filter in mac_ctx */
630 lim_set_bcn_probe_filter(mac_ctx, session,
631 &sme_start_bss_req->ssId,
632 sme_start_bss_req->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 }
634
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700635 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
636 /* Probe resp add ie */
637 lim_start_bss_update_add_ie_buffer(mac_ctx,
638 &session->addIeParams.probeRespData_buff,
639 &session->addIeParams.probeRespDataLen,
640 sme_start_bss_req->addIeParams.
641 probeRespData_buff,
642 sme_start_bss_req->addIeParams.
643 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700645 /* Probe Beacon add ie */
646 lim_start_bss_update_add_ie_buffer(mac_ctx,
647 &session->addIeParams.probeRespBCNData_buff,
648 &session->addIeParams.probeRespBCNDataLen,
649 sme_start_bss_req->addIeParams.
650 probeRespBCNData_buff,
651 sme_start_bss_req->addIeParams.
652 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700654 /* Assoc resp IE */
655 lim_start_bss_update_add_ie_buffer(mac_ctx,
656 &session->addIeParams.assocRespData_buff,
657 &session->addIeParams.assocRespDataLen,
658 sme_start_bss_req->addIeParams.
659 assocRespData_buff,
660 sme_start_bss_req->addIeParams.
661 assocRespDataLen);
662 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 /* Store the session related params in newly created session */
664 session->pLimStartBssReq = sme_start_bss_req;
665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 session->transactionId = sme_start_bss_req->transactionId;
667
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530668 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 &(sme_start_bss_req->htConfig),
670 sizeof(session->htConfig));
671
Sandeep Puligilla98917432016-06-10 13:50:28 -0700672 qdf_mem_copy(&(session->vht_config),
673 &(sme_start_bss_req->vht_config),
674 sizeof(session->vht_config));
675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800677 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678
679 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530680 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 (uint8_t *) &sme_start_bss_req->ssId,
682 (sme_start_bss_req->ssId.length + 1));
683
684 session->bssType = sme_start_bss_req->bssType;
685
686 session->nwType = sme_start_bss_req->nwType;
687
688 session->beaconParams.beaconInterval =
689 sme_start_bss_req->beaconInterval;
690
691 /* Store the channel number in session Table */
692 session->currentOperChannel =
693 sme_start_bss_req->channelId;
694
695 /* Store Persona */
696 session->pePersona = sme_start_bss_req->bssPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +0530697 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 FL("PE PERSONA=%d"), session->pePersona);
699
700 /* Update the phymode */
701 session->gLimPhyMode = sme_start_bss_req->nwType;
702
703 session->maxTxPower =
704 cfg_get_regulatory_max_transmit_power(mac_ctx,
705 session->currentOperChannel);
706 /* Store the dot 11 mode in to the session Table */
707 session->dot11mode = sme_start_bss_req->dot11mode;
708#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
709 session->cc_switch_mode =
710 sme_start_bss_req->cc_switch_mode;
711#endif
712 session->htCapability =
713 IS_DOT11_MODE_HT(session->dot11mode);
714 session->vhtCapability =
715 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800716
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700717 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800718 session->htCapability, session->vhtCapability);
719
720 if (IS_DOT11_MODE_HE(session->dot11mode)) {
721 lim_update_session_he_capable(mac_ctx, session);
722 lim_copy_bss_he_cap(session, sme_start_bss_req);
723 }
724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 session->txLdpcIniFeatureEnabled =
726 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727#ifdef WLAN_FEATURE_11W
728 session->limRmfEnabled =
729 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700730 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731#endif
732
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530733 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 (void *)&sme_start_bss_req->operationalRateSet,
735 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530736 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 (void *)&sme_start_bss_req->extendedRateSet,
738 sizeof(tSirMacRateSet));
739
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700740 if (IS_5G_CH(session->currentOperChannel))
741 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
742 else
743 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
744
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 switch (sme_start_bss_req->bssType) {
746 case eSIR_INFRA_AP_MODE:
747 lim_configure_ap_start_bss_session(mac_ctx, session,
748 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700749 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700750 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700751 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700752 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 break;
754 case eSIR_IBSS_MODE:
755 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
756 lim_get_short_slot_from_phy_mode(mac_ctx, session,
757 session->gLimPhyMode,
758 &session->shortSlotTimeSupported);
759
760 /*
761 * initialize to "OPEN".
762 * will be updated upon key installation
763 */
764 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700765 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
767 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700768 case eSIR_NDI_MODE:
769 session->limSystemRole = eLIM_NDI_ROLE;
770 break;
771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 /*
774 * There is one more mode called auto mode.
775 * which is used no where
776 */
777
778 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
779
780 default:
781 /* not used anywhere...used in scan function */
782 break;
783 }
784
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700785 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700786 session->pePersona, session->vdev_nss);
787 session->nss = session->vdev_nss;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530788 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2)
Kiran Kumar Lokerebc6fb2f2018-05-09 19:04:11 -0700789 session->nss = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700791 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 * parsed (Re)Assoc request structure
793 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700794 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700797 size * sizeof(tpSirAssocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700798 if (!session->parsedAssocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
800 goto free;
801 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 }
803
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700804 if (!sme_start_bss_req->channelId &&
805 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700806 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 ret_code = eSIR_SME_INVALID_PARAMETERS;
808 goto free;
809 }
810 channel_number = sme_start_bss_req->channelId;
811#ifdef QCA_HT_2040_COEX
812 if (sme_start_bss_req->obssEnabled)
813 session->htSupportedChannelWidthSet =
814 session->htCapability;
815 else
816#endif
817 session->htSupportedChannelWidthSet =
818 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
819 session->htSecondaryChannelOffset =
820 sme_start_bss_req->sec_ch_offset;
821 session->htRecommendedTxWidthSet =
822 (session->htSecondaryChannelOffset) ? 1 : 0;
Abhishek Singh4294f802017-08-10 16:37:07 +0530823 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800825 if (lim_is_session_he_capable(session) ||
826 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700828 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800829 sme_start_bss_req->vht_channel_width,
830 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 session->ch_width = chanwidth;
832 if (session->htSupportedChannelWidthSet) {
833 session->ch_center_freq_seg0 =
834 sme_start_bss_req->center_freq_seg0;
835 session->ch_center_freq_seg1 =
836 sme_start_bss_req->center_freq_seg1;
837 } else {
838 session->ch_center_freq_seg0 = 0;
839 session->ch_center_freq_seg1 = 0;
840 }
841 }
gaurank kathpaliad88ef882018-08-14 15:20:11 +0530842 if (policy_mgr_is_hw_dbs_capable(mac_ctx->psoc) &&
843 (policy_mgr_get_current_hw_mode(mac_ctx->psoc, &hw_mode) ==
844 QDF_STATUS_SUCCESS) &&
845 hw_mode.dbs_cap) {
846 session->nss = 1;
847 pe_debug("HW is in DBS mode. Nss set to [%d]",
848 session->nss);
849 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800851 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700853 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700855 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700856 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
858 /* Delete pre-auth list if any */
859 lim_delete_pre_auth_list(mac_ctx);
860
861 /*
862 * keep the RSN/WPA IE information in PE Session Entry
863 * later will be using this to check when received (Re)Assoc req
864 */
865 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
866 &sme_start_bss_req->rsnIE, session);
867
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700868 if (LIM_IS_AP_ROLE(session) ||
869 LIM_IS_IBSS_ROLE(session) ||
870 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 session->gLimProtectionControl =
872 sme_start_bss_req->protEnabled;
873 /*
874 * each byte will have the following info
875 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
876 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
877 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530878 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 (void *)&sme_start_bss_req->ht_capab,
880 sizeof(uint16_t));
881 /* Initialize WPS PBC session link list */
882 session->pAPWPSPBCSession = NULL;
883 }
884 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530885 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700886 if (!mlm_start_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
888 goto free;
889 }
890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530892 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 (uint8_t *) &sme_start_bss_req->ssId,
894 sme_start_bss_req->ssId.length + 1);
895 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
896 mlm_start_req->obssProtEnabled =
897 sme_start_bss_req->obssProtEnabled;
898
899 mlm_start_req->bssType = session->bssType;
900
901 /* Fill PE session Id from the session Table */
902 mlm_start_req->sessionId = session->peSessionId;
903
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700904 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
905 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 /*
907 * Copy the BSSId from sessionTable to
908 * mlmStartReq struct
909 */
910 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
911 } else {
912 /* ibss mode */
913 mac_ctx->lim.gLimIbssCoalescingHappened = false;
914
915 ret_status = wlan_cfg_get_int(mac_ctx,
916 WNI_CFG_IBSS_AUTO_BSSID,
917 &auto_gen_bssid);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700918 if (ret_status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700919 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 ret_status);
Abhishek Singh4294f802017-08-10 16:37:07 +0530921 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 goto free;
923 }
924
925 if (!auto_gen_bssid) {
926 /*
927 * We're not auto generating BSSID.
928 * Instead, get it from session entry
929 */
930 sir_copy_mac_addr(mlm_start_req->bssId,
931 session->bssId);
932 /*
933 * Start IBSS group BSSID
934 * Auto Generating BSSID.
935 */
936 auto_gen_bssid = ((mlm_start_req->bssId[0] &
937 0x01) ? true : false);
938 }
939
940 if (auto_gen_bssid) {
941 /*
942 * if BSSID is not any uc id.
943 * then use locally generated BSSID.
944 * Autogenerate the BSSID
945 */
946 lim_get_random_bssid(mac_ctx,
947 mlm_start_req->bssId);
948 mlm_start_req->bssId[0] = 0x02;
949
950 /*
951 * Copy randomly generated BSSID
952 * to the session Table
953 */
954 sir_copy_mac_addr(session->bssId,
955 mlm_start_req->bssId);
956 }
957 }
958 /* store the channel num in mlmstart req structure */
959 mlm_start_req->channelNumber = session->currentOperChannel;
960 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
961 mlm_start_req->beaconPeriod =
962 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -0700963 mlm_start_req->cac_duration_ms =
964 sme_start_bss_req->cac_duration_ms;
965 mlm_start_req->dfs_regdomain =
966 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 if (LIM_IS_AP_ROLE(session)) {
968 mlm_start_req->dtimPeriod = session->dtimPeriod;
969 mlm_start_req->wps_state = session->wps_state;
970
971 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530972 val = mac_ctx->mlme_cfg->sap_cfg.dtim_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 mlm_start_req->dtimPeriod = (uint8_t) val;
974 }
975
Karthik Kantamneni22dd0f62018-08-07 14:53:50 +0530976 mlm_start_req->cfParamSet.cfpPeriod =
977 mac_ctx->mlme_cfg->rates.cfp_period;
978 mlm_start_req->cfParamSet.cfpMaxDuration =
979 mac_ctx->mlme_cfg->rates.cfp_max_duration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980
981 /*
982 * this may not be needed anymore now,
983 * as rateSet is now included in the
984 * session entry and MLM has session context.
985 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530986 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 (void *)&session->rateSet,
988 sizeof(tSirMacRateSet));
989
990 /* Now populate the 11n related parameters */
991 mlm_start_req->nwType = session->nwType;
992 mlm_start_req->htCapable = session->htCapability;
993
994 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
995 /* Unused */
996 mlm_start_req->dualCTSProtection =
997 mac_ctx->lim.gHTDualCTSProtection;
998 mlm_start_req->txChannelWidthSet =
999 session->htRecommendedTxWidthSet;
1000
1001 session->limRFBand = lim_get_rf_band(channel_number);
1002
1003 /* Initialize 11h Enable Flag */
1004 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001005 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1006 (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001007 BAND_5G == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 if (wlan_cfg_get_int(mac_ctx,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001009 WNI_CFG_11H_ENABLED, &val) != QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001010 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 else
1012 session->lim11hEnable = val;
1013
1014 if (session->lim11hEnable &&
1015 (eSIR_INFRA_AP_MODE ==
1016 mlm_start_req->bssType)) {
Arif Hussain88d1fdd2018-09-26 16:12:24 -07001017 session->lim11hEnable =
1018 mac_ctx->mlme_cfg->
1019 dfs_cfg.dfs_master_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 }
1022
1023 if (!session->lim11hEnable) {
1024 if (cfg_set_int(mac_ctx,
1025 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001026 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 /*
1028 * Failed to set the CFG param
1029 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1030 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001031 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 }
1033
Jiachao Wu712d4fd2017-08-23 16:52:34 +08001034 mlm_start_req->beacon_tx_rate = session->beacon_tx_rate;
1035
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 session->limPrevSmeState = session->limSmeState;
1037 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1038 MTRACE(mac_trace
1039 (mac_ctx, TRACE_CODE_SME_STATE,
1040 session->peSessionId,
1041 session->limSmeState));
1042
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301043 qdf_status = lim_send_start_vdev_req(session, mlm_start_req);
1044 if (QDF_IS_STATUS_ERROR(qdf_status))
1045 goto free;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301046 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 return;
1048 } else {
1049
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001050 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 mac_ctx->lim.gLimSmeState);
1052 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001053 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1055
1056free:
1057 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001058 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 session->pLimStartBssReq = NULL;
1060 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001061 if (NULL != sme_start_bss_req)
1062 qdf_mem_free(sme_start_bss_req);
1063 if (NULL != mlm_start_req)
1064 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 if (NULL != session) {
1066 pe_delete_session(mac_ctx, session);
1067 session = NULL;
1068 }
1069 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1070 session, sme_session_id, sme_transaction_id);
1071}
1072
1073/**
1074 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1075 *
1076 * @pMac: Global MAC context
1077 * @pMsg: Message pointer
1078 *
1079 * Wrapper for the function __lim_handle_sme_start_bss_request
1080 * This message will be defered until softmac come out of
1081 * scan mode or if we have detected radar on the current
1082 * operating channel.
1083 *
1084 * return true - If we consumed the buffer
1085 * false - If have defered the message.
1086 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001087static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1088 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089{
1090 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1091 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1092 /**
1093 * If message defered, buffer is not consumed yet.
1094 * So return false
1095 */
1096 return false;
1097 }
1098
1099 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1100 return true;
1101}
1102
1103/**
1104 * lim_get_random_bssid()
1105 *
1106 * FUNCTION:This function is called to process generate the random number for bssid
1107 * This function is called to process SME_SCAN_REQ message
1108 * from HDD or upper layer application.
1109 *
1110 * LOGIC:
1111 *
1112 * ASSUMPTIONS:
1113 *
1114 * NOTE:
1115 * 1. geneartes the unique random number for bssid in ibss
1116 *
1117 * @param pMac Pointer to Global MAC structure
1118 * @param *data Pointer to bssid buffer
1119 * @return None
1120 */
1121void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1122{
1123 uint32_t random[2];
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 random[0] = tx_time_get();
1126 random[0] |= (random[0] << 15);
1127 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301128 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129}
1130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131/**
1132 * __lim_process_clear_dfs_channel_list()
1133 *
1134 ***FUNCTION:
Jeff Johnsonc00ae5b2018-05-06 16:06:35 -07001135 ***Clear DFS channel list when country is changed/acquired.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 .*This message is sent from SME.
1137 *
1138 ***LOGIC:
1139 *
1140 ***ASSUMPTIONS:
1141 *
1142 ***NOTE:
1143 *
1144 * @param pMac Pointer to Global MAC structure
1145 * @param *pMsgBuf A pointer to the SME message buffer
1146 * @return None
1147 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001148static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1149 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301151 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152}
1153
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301154#ifdef WLAN_FEATURE_SAE
1155
1156/**
1157 * lim_update_sae_config()- This API update SAE session info to csr config
1158 * from join request.
1159 * @session: PE session
1160 * @sme_join_req: pointer to join request
1161 *
1162 * Return: None
1163 */
1164static void lim_update_sae_config(tpPESession session,
1165 tpSirSmeJoinReq sme_join_req)
1166{
1167 session->sae_pmk_cached = sme_join_req->sae_pmk_cached;
1168
1169 pe_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
1170 session->sae_pmk_cached,
1171 MAC_ADDR_ARRAY(sme_join_req->bssDescription.bssId));
1172}
1173#else
1174static inline void lim_update_sae_config(tpPESession session,
1175 tpSirSmeJoinReq sme_join_req)
1176{}
1177#endif
1178
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001179/**
Jianmin Zhu09236602018-10-15 15:36:10 +08001180 * lim_send_join_req() - send vdev start request for assoc
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001181 *@session: pe session
1182 *@mlm_join_req: join req
1183 *
1184 * Return: QDF_STATUS
1185 */
1186
1187#ifdef CONFIG_VDEV_SM
1188static QDF_STATUS lim_send_join_req(tpPESession session,
1189 tLimMlmJoinReq *mlm_join_req)
1190{
Jianmin Zhu09236602018-10-15 15:36:10 +08001191 mlme_set_assoc_type(session->vdev, VDEV_ASSOC);
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001192 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1193 WLAN_VDEV_SM_EV_START,
1194 sizeof(*mlm_join_req),
1195 mlm_join_req);
1196}
1197#else
1198static QDF_STATUS lim_send_join_req(tpPESession session,
1199 tLimMlmJoinReq *mlm_join_req)
1200{
1201 lim_process_mlm_join_req(session->mac_ctx, mlm_join_req);
1202
1203 return QDF_STATUS_SUCCESS;
1204}
1205#endif
1206
Jianmin Zhu09236602018-10-15 15:36:10 +08001207/**
1208 * lim_send_reassoc_req() - send vdev start request for reassoc
1209 *@session: pe session
1210 *@mlm_join_req: join req
1211 *
1212 * Return: QDF_STATUS
1213 */
1214
1215#ifdef CONFIG_VDEV_SM
1216static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1217 tLimMlmReassocReq *reassoc_req)
1218{
1219 mlme_set_assoc_type(session->vdev, VDEV_REASSOC);
1220 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1221 WLAN_VDEV_SM_EV_START,
1222 sizeof(*reassoc_req),
1223 reassoc_req);
1224}
1225#else
1226static QDF_STATUS lim_send_reassoc_req(tpPESession session,
1227 tLimMlmReassocReq *reassoc_req)
1228{
1229 lim_process_mlm_reassoc_req(session->mac_ctx, reassoc_req);
1230
1231 return QDF_STATUS_SUCCESS;
1232}
1233#endif
1234
1235/**
1236 * lim_send_ft_reassoc_req() - send vdev start request for ft_reassoc
1237 *@session: pe session
1238 *@mlm_join_req: join req
1239 *
1240 * Return: QDF_STATUS
1241 */
1242
1243#ifdef CONFIG_VDEV_SM
1244static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1245{
1246 mlme_set_assoc_type(session->vdev, VDEV_FT_REASSOC);
1247 return wlan_vdev_mlme_sm_deliver_evt(session->vdev,
1248 WLAN_VDEV_SM_EV_START,
1249 sizeof(*session),
1250 session);
1251}
1252#else
1253static QDF_STATUS lim_send_ft_reassoc_req(tpPESession session)
1254{
1255 lim_process_mlm_ft_reassoc_req(session->mac_ctx, session);
1256
1257 return QDF_STATUS_SUCCESS;
1258}
1259#endif
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261/**
1262 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1263 * @mac_ctx: Pointer to Global MAC structure
1264 * @msg_buf: A pointer to the SME message buffer
1265 *
1266 * This function is called to process SME_JOIN_REQ message
1267 * from HDD or upper layer application.
1268 *
1269 * Return: None
1270 */
1271static void
1272__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1273{
1274 tpSirSmeJoinReq sme_join_req = NULL;
1275 tLimMlmJoinReq *mlm_join_req;
1276 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1277 uint32_t val = 0;
1278 uint16_t n_size;
1279 uint8_t session_id;
1280 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301281 uint8_t sme_session_id = 0;
1282 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001283 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 uint16_t ie_len;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001285 const uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001286 tSirBssDescription *bss_desc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287
Arif Hussain995fcaf2016-07-18 11:28:22 -07001288 if (!mac_ctx || !msg_buf) {
1289 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1290 FL("JOIN REQ with invalid data"));
1291 return;
1292 }
1293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294/* FEATURE_WLAN_DIAG_SUPPORT */
1295#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1296 /*
1297 * Not sending any session, since it is not created yet.
1298 * The response whould have correct state.
1299 */
1300 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1301#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 /*
1304 * Expect Join request in idle state.
1305 * Reassociate request is expected in link established state.
1306 */
1307
1308 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1309 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1310 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1311 msg_buf);
1312
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301313 sme_join_req = qdf_mem_malloc(n_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001314 if (!sme_join_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301316 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301318 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319 n_size);
1320
1321 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1322 /* Received invalid eWNI_SME_JOIN_REQ */
1323 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001324 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 sme_join_req->sessionId);
1326 ret_code = eSIR_SME_INVALID_PARAMETERS;
1327 goto end;
1328 }
1329
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001330 /*
1331 * Update the capability here itself as this is used in
1332 * lim_extract_ap_capability() below. If not updated issues
1333 * like not honoring power constraint on 1st association after
1334 * driver loading might occur.
1335 */
1336 lim_update_rrm_capability(mac_ctx, sme_join_req);
1337
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001338 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001340 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 &session_id);
1342
1343 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001344 pe_err("Session(%d) Already exists for BSSID: "
1345 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001347 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 session->limSmeState);
1349
1350 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1351 session->smeSessionId == sme_join_req->sessionId) {
1352 /*
1353 * Received eWNI_SME_JOIN_REQ for same
1354 * BSS as currently associated.
1355 * Log the event and send success
1356 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001357 pe_warn("SessionId: %d", session_id);
1358 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 /* Send Join success response to host */
1360 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1361 session = NULL;
1362 goto end;
1363 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001364 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 ret_code = eSIR_SME_REFUSED;
1366 session = NULL;
1367 goto end;
1368 }
1369 } else {
1370 /*
1371 * Session Entry does not exist for given BSSId
1372 * Try to Create a new session
1373 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001374 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 &session_id, mac_ctx->lim.maxStation,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301376 eSIR_INFRASTRUCTURE_MODE,
1377 sme_join_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001379 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1381 goto end;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301382 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001383 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 session_id);
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +05301385 }
1386
1387 /* Update the beacon/probe filter in mac_ctx */
1388 lim_set_bcn_probe_filter(mac_ctx, session,
1389 &sme_join_req->ssId,
1390 bss_desc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001392 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Arif Hussain6686c0b2018-08-21 18:21:05 -07001393 session->enable_session_twt_support =
1394 sme_join_req->enable_session_twt_support;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 /*
1396 * Store Session related parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398
1399 /* store the smejoin req handle in session table */
1400 session->pLimJoinReq = sme_join_req;
1401
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 /* Store SME transaction Id in session Table */
1403 session->transactionId = sme_join_req->transactionId;
1404
1405 /* Store beaconInterval */
1406 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001407 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301409 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 sizeof(session->htConfig));
1411
Sandeep Puligilla98917432016-06-10 13:50:28 -07001412 qdf_mem_copy(&(session->vht_config),
1413 &(sme_join_req->vht_config),
1414 sizeof(session->vht_config));
1415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 /* Copying of bssId is already done, while creating session */
1417 sir_copy_mac_addr(session->selfMacAddr,
1418 sme_join_req->selfMacAddr);
1419 session->bssType = sme_join_req->bsstype;
1420
1421 session->statypeForBss = STA_ENTRY_PEER;
1422 session->limWmeEnabled = sme_join_req->isWMEenabled;
1423 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301424 session->wps_registration = sme_join_req->wps_registration;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001425 session->he_with_wep_tkip = sme_join_req->he_with_wep_tkip;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301427 session->enable_bcast_probe_rsp =
1428 sme_join_req->enable_bcast_probe_rsp;
1429
Jeff Johnson179fd8a2018-05-11 14:20:05 -07001430 /* Store vendor specific IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001431 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1433
Naveen Rawat08db88f2017-09-08 15:07:48 -07001434 vendor_ie = wlan_get_vendor_ie_ptr_from_oui(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001436 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437
1438 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001439 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 session->isCiscoVendorAP = true;
1441 } else {
1442 session->isCiscoVendorAP = false;
1443 }
1444
1445 /* Copy the dot 11 mode in to the session table */
1446
1447 session->dot11mode = sme_join_req->dot11mode;
1448#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1449 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1450#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001451 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1453 session->enableHtSmps = sme_join_req->enableHtSmps;
1454 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001455 session->send_smps_action =
1456 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001457 /*
1458 * By default supported NSS 1x1 is set to true
1459 * and later on updated while determining session
1460 * supported rates which is the intersection of
1461 * self and peer rates
1462 */
1463 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301464 /*Store Persona */
1465 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001466 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 -08001467 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001468 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001469 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301470 session->supported_nss_1x1,
1471 session->pePersona,
1472 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001473
1474 /*Store Persona */
1475 session->pePersona = sme_join_req->staPersona;
Abhishek Singh4294f802017-08-10 16:37:07 +05301476 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301477 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001478 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301479 session->nwType, session->dot11mode,
1480 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001481
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001482 /* Copy The channel Id to the session Table */
1483 session->currentOperChannel = bss_desc->channelId;
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 session->vhtCapability =
1486 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301488 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001489 session->vht_config.su_beam_formee =
1490 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001492 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 session->enableVhtpAid =
1495 sme_join_req->enableVhtpAid;
1496 session->enableVhtGid =
1497 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001498 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001499 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 }
Krunal Soni53993f72016-07-08 18:20:03 -07001501
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001502 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301503 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001504 session->vht_config.su_beam_formee,
1505 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001506 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001508 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301510 session->force_24ghz_in_ht20 =
1511 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 /* cbMode is already merged value of peer and self -
1513 * done by csr in csr_get_cb_mode_from_ies */
1514 session->htSupportedChannelWidthSet =
1515 (sme_join_req->cbMode) ? 1 : 0;
1516 session->htRecommendedTxWidthSet =
1517 session->htSupportedChannelWidthSet;
1518 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1519
1520 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1521 session->ch_center_freq_seg0 =
1522 session->currentOperChannel - 2;
1523 session->ch_width = CH_WIDTH_40MHZ;
1524 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1525 sme_join_req->cbMode) {
1526 session->ch_center_freq_seg0 =
1527 session->currentOperChannel + 2;
1528 session->ch_width = CH_WIDTH_40MHZ;
1529 } else {
1530 session->ch_center_freq_seg0 = 0;
1531 session->ch_width = CH_WIDTH_20MHZ;
1532 }
1533
Naveen Rawataeca1b92017-10-16 16:55:31 -07001534 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1535 lim_update_session_he_capable(mac_ctx, session);
1536 lim_copy_join_req_he_cap(session, sme_join_req);
1537 }
1538
1539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 /* Record if management frames need to be protected */
1541#ifdef WLAN_FEATURE_11W
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +05301542 if ((eSIR_ED_AES_128_CMAC ==
1543 sme_join_req->MgmtEncryptionType) ||
1544 (eSIR_ED_AES_GMAC_128 == sme_join_req->MgmtEncryptionType) ||
1545 (eSIR_ED_AES_GMAC_256 == sme_join_req->MgmtEncryptionType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001547 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549#endif
1550
1551#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001552 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553#endif
1554
1555 /* Copy the SSID from smejoinreq to session entry */
1556 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301557 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 session->ssId.length);
1559
1560 /*
1561 * Determin 11r or ESE connection based on input from SME
1562 * which inturn is dependent on the profile the user wants
1563 * to connect to, So input is coming from supplicant
1564 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566#ifdef FEATURE_WLAN_ESE
1567 session->isESEconnection = sme_join_req->isESEconnection;
1568#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 session->isFastTransitionEnabled =
1570 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 session->isFastRoamIniFeatureEnabled =
1573 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 session->txLdpcIniFeatureEnabled =
1575 sme_join_req->txLdpcIniFeatureEnabled;
1576
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301577 lim_update_fils_config(session, sme_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +05301578 lim_update_sae_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1580 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 } else {
1582 /*
1583 * Throw an error and return and make
1584 * sure to delete the session.
1585 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001586 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 session->bssType);
1588 ret_code = eSIR_SME_INVALID_PARAMETERS;
1589 goto end;
1590 }
1591
1592 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301593 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 &sme_join_req->addIEScan, sizeof(tSirAddie));
1595
1596 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301597 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1599
1600 val = sizeof(tLimMlmJoinReq) +
1601 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 mlm_join_req = qdf_mem_malloc(val);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001603 if (!mlm_join_req) {
Nitesh Shah0102cac2016-07-13 14:38:30 +05301604 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1605 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
1608 /* PE SessionId is stored as a part of JoinReq */
1609 mlm_join_req->sessionId = session->peSessionId;
1610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301612 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 (void *)&sme_join_req->operationalRateSet,
1614 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301615 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 (void *)&sme_join_req->extendedRateSet,
1617 sizeof(tSirMacRateSet));
1618 /*
1619 * this may not be needed anymore now, as rateSet is now
1620 * included in the session entry and MLM has session context.
1621 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301622 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 (void *)&session->rateSet,
1624 sizeof(tSirMacRateSet));
1625
1626 session->encryptType = sme_join_req->UCEncryptionType;
1627
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301628 session->supported_nss_1x1 = sme_join_req->supported_nss_1x1;
1629 session->vdev_nss = sme_join_req->vdev_nss;
1630 session->nss = sme_join_req->nss;
1631 session->nss_forced_1x1 = sme_join_req->nss_forced_1x1;
1632
1633 pe_debug("nss %d, vdev_nss %d, supported_nss_1x1 %d",
1634 session->nss,
1635 session->vdev_nss,
1636 session->supported_nss_1x1);
1637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 mlm_join_req->bssDescription.length =
1639 session->pLimJoinReq->bssDescription.length;
1640
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301641 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 (uint8_t *)
1643 &session->pLimJoinReq->bssDescription.bssId,
1644 session->pLimJoinReq->bssDescription.length + 2);
1645
1646 session->limCurrentBssCaps =
1647 session->pLimJoinReq->bssDescription.capabilityInfo;
1648
1649 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1650 session->currentOperChannel);
1651 local_power_constraint = reg_max;
1652
1653 lim_extract_ap_capability(mac_ctx,
1654 (uint8_t *)
1655 session->pLimJoinReq->bssDescription.ieFields,
1656 lim_get_ielen_from_bss_description(
1657 &session->pLimJoinReq->bssDescription),
1658 &session->limCurrentBssQosCaps,
1659 &session->limCurrentBssPropCap,
1660 &session->gLimCurrentBssUapsd,
1661 &local_power_constraint, session);
1662
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 session->maxTxPower = lim_get_max_tx_power(reg_max,
1664 local_power_constraint,
1665 mac_ctx->roam.configParam.nTxPowerCap);
Abhinav Kumard528d192018-03-09 17:31:12 +05301666 session->def_max_tx_pwr = session->maxTxPower;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301667
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001668 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301669 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301671 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1672 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1673 pe_debug("Update MaxTxPower in join Req to %d",
1674 sme_join_req->powerCap.maxTxPower);
1675 }
1676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 if (session->gLimCurrentBssUapsd) {
1678 session->gUapsdPerAcBitmask =
1679 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001680 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 session->gUapsdPerAcBitmask);
1682
1683 /* resetting the dynamic uapsd mask */
1684 session->gUapsdPerAcDeliveryEnableMask = 0;
1685 session->gUapsdPerAcTriggerEnableMask = 0;
1686 }
1687
1688 session->limRFBand =
1689 lim_get_rf_band(session->currentOperChannel);
1690
1691 /* Initialize 11h Enable Flag */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001692 if (BAND_5G == session->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001694 &val) != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001695 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 session->lim11hEnable =
1697 WNI_CFG_11H_ENABLED_STADEF;
1698 } else {
1699 session->lim11hEnable = val;
1700 }
1701 } else {
1702 session->lim11hEnable = 0;
1703 }
1704
1705 /*
1706 * To care of the scenario when STA transitions from
1707 * IBSS to Infrastructure mode.
1708 */
1709 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1710
1711 session->limPrevSmeState = session->limSmeState;
1712 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1713 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1714 session->peSessionId,
1715 session->limSmeState));
1716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 /* Indicate whether spectrum management is enabled */
1718 session->spectrumMgtEnabled =
1719 sme_join_req->spectrumMgtIndicator;
1720
1721 /* Enable the spectrum management if this is a DFS channel */
1722 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001723 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 session->currentOperChannel))
1725 session->spectrumMgtEnabled = true;
1726
1727 session->isOSENConnection = sme_join_req->isOSENConnection;
1728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 /* Issue LIM_MLM_JOIN_REQ to MLM */
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07001730 lim_send_join_req(session, mlm_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 return;
1732
1733 } else {
1734 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001735 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 mac_ctx->lim.gLimSmeState);
1737 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1738 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1739 session = NULL;
1740 goto end;
1741 }
1742
1743end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301744 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1745 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746
1747 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301748 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 sme_join_req = NULL;
1750 if (NULL != session)
1751 session->pLimJoinReq = NULL;
1752 }
1753 if (ret_code != eSIR_SME_SUCCESS) {
1754 if (NULL != session) {
1755 pe_delete_session(mac_ctx, session);
1756 session = NULL;
1757 }
1758 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001759 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 sme_session_id, ret_code);
1761 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1762 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1763 sme_transaction_id);
1764}
1765
Amar Singhala297bfa2015-10-15 15:07:29 -07001766uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 uint8_t iniTxPower)
1768{
1769 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301770 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001771
Anurag Chouhan6d760662016-02-20 16:05:43 +05301772 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1774 maxTxPower = txPower;
1775 else if (txPower < MIN_TX_PWR_CAP)
1776 maxTxPower = MIN_TX_PWR_CAP;
1777 else
1778 maxTxPower = MAX_TX_PWR_CAP;
1779
1780 return maxTxPower;
1781}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782
1783/**
1784 * __lim_process_sme_reassoc_req() - process reassoc req
1785 *
1786 * @mac_ctx: Pointer to Global MAC structure
1787 * @msg_buf: pointer to the SME message buffer
1788 *
1789 * This function is called to process SME_REASSOC_REQ message
1790 * from HDD or upper layer application.
1791 *
1792 * Return: None
1793 */
1794
1795static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
1796 uint32_t *msg_buf)
1797{
1798 uint16_t caps;
1799 uint32_t val;
1800 tpSirSmeJoinReq reassoc_req = NULL;
1801 tLimMlmReassocReq *mlm_reassoc_req;
1802 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1803 tpPESession session_entry = NULL;
1804 uint8_t session_id;
1805 uint8_t sme_session_id;
1806 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001807 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 uint32_t tele_bcn_en = 0;
1809 uint16_t size;
1810
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301812 reassoc_req = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001813 if (!reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1815 goto end;
1816 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818
1819 if (!lim_is_sme_join_req_valid(mac_ctx,
1820 (tpSirSmeJoinReq)reassoc_req)) {
1821 /*
1822 * Received invalid eWNI_SME_REASSOC_REQ
1823 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001824 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825
1826 ret_code = eSIR_SME_INVALID_PARAMETERS;
1827 goto end;
1828 }
Jianmin Zhu09236602018-10-15 15:36:10 +08001829 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
1830 &sme_session_id, &transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831
1832 session_entry = pe_find_session_by_bssid(mac_ctx,
1833 reassoc_req->bssDescription.bssId,
1834 &session_id);
1835 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001836 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001837 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
1838 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07001840 session_entry =
1841 pe_find_session_by_sme_session_id(mac_ctx,
1842 sme_session_id);
1843 if (session_entry != NULL)
1844 lim_handle_sme_join_result(mac_ctx,
1845 eSIR_SME_INVALID_PARAMETERS,
1846 eSIR_MAC_UNSPEC_FAILURE_STATUS,
1847 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 goto end;
1849 }
1850#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
1851 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001852 session_entry, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1854 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
1855
1856 /* Store the reassoc handle in the session Table */
1857 session_entry->pLimReAssocReq = reassoc_req;
1858
1859 session_entry->dot11mode = reassoc_req->dot11mode;
1860 session_entry->vhtCapability =
1861 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001862
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301863 if (session_entry->vhtCapability) {
1864 if (session_entry->pePersona == QDF_STA_MODE) {
1865 session_entry->vht_config.su_beam_formee =
1866 reassoc_req->vht_config.su_beam_formee;
1867 } else {
1868 reassoc_req->vht_config.su_beam_formee = 0;
1869 }
1870 session_entry->enableVhtpAid =
1871 reassoc_req->enableVhtpAid;
1872 session_entry->enableVhtGid =
1873 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001874 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301875 }
1876
Vignesh Viswanathand5a5f2e2018-06-01 15:35:51 +05301877 session_entry->supported_nss_1x1 = reassoc_req->supported_nss_1x1;
1878 session_entry->vdev_nss = reassoc_req->vdev_nss;
1879 session_entry->nss = reassoc_req->nss;
1880 session_entry->nss_forced_1x1 = reassoc_req->nss_forced_1x1;
1881
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001882 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05301883 session_entry->vhtCapability,
1884 session_entry->vht_config.su_beam_formee,
1885 session_entry->vht_config.su_beam_former);
1886
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001887 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
1888 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001889 session_entry->send_smps_action =
1890 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001891 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001892 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001893 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001894 session_entry->send_smps_action,
1895 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 /*
1897 * Reassociate request is expected
1898 * in link established state only.
1899 */
1900
1901 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
1903 /*
1904 * May be from 11r FT pre-auth. So lets check it
1905 * before we bail out
1906 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001907 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 session_entry->peSessionId);
1909
1910 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301911 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 session_entry->limReAssocbssId,
1913 6)) {
1914 lim_print_mac_addr(mac_ctx,
1915 reassoc_req->bssDescription.
1916 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001917 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 ret_code = eSIR_SME_INVALID_PARAMETERS;
1919 goto end;
1920 }
1921
Jianmin Zhu09236602018-10-15 15:36:10 +08001922 session_entry->smeSessionId = sme_session_id;
1923 session_entry->transactionId = transaction_id;
1924 lim_send_ft_reassoc_req(session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 return;
1926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 /*
1928 * Should not have received eWNI_SME_REASSOC_REQ
1929 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001930 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 session_entry->limSmeState);
1932 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
1933
1934 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1935 goto end;
1936 }
1937
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301938 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 session_entry->pLimReAssocReq->bssDescription.bssId,
1940 sizeof(tSirMacAddr));
1941
1942 session_entry->limReassocChannelId =
1943 session_entry->pLimReAssocReq->bssDescription.channelId;
1944
1945 session_entry->reAssocHtSupportedChannelWidthSet =
1946 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
1947 session_entry->reAssocHtRecommendedTxWidthSet =
1948 session_entry->reAssocHtSupportedChannelWidthSet;
1949 session_entry->reAssocHtSecondaryChannelOffset =
1950 session_entry->pLimReAssocReq->cbMode;
1951
1952 session_entry->limReassocBssCaps =
1953 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
1954 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1955 session_entry->currentOperChannel);
1956 local_pwr_constraint = reg_max;
1957
1958 lim_extract_ap_capability(mac_ctx,
1959 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
1960 lim_get_ielen_from_bss_description(
1961 &session_entry->pLimReAssocReq->bssDescription),
1962 &session_entry->limReassocBssQosCaps,
1963 &session_entry->limReassocBssPropCap,
1964 &session_entry->gLimCurrentBssUapsd,
1965 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301966 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001967 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301968 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 /* Copy the SSID from session entry to local variable */
1970 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301971 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 reassoc_req->ssId.ssId,
1973 session_entry->limReassocSSID.length);
1974 if (session_entry->gLimCurrentBssUapsd) {
1975 session_entry->gUapsdPerAcBitmask =
1976 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001977 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978 session_entry->gUapsdPerAcBitmask);
1979 }
1980
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301981 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001982 if (!mlm_reassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1984 goto end;
1985 }
1986
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301987 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
1989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001991 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001992 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301993
1994 lim_update_caps_info_for_bss(mac_ctx, &caps,
1995 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001996 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05301997
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 mlm_reassoc_req->capabilityInfo = caps;
1999
2000 /* Update PE session_id */
2001 mlm_reassoc_req->sessionId = session_id;
2002
2003 /*
2004 * If telescopic beaconing is enabled, set listen interval to
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302005 * CFG_TELE_BCN_MAX_LI
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302008 tele_bcn_en = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_wakeup_en;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05302010 if (tele_bcn_en)
2011 val = mac_ctx->mlme_cfg->sap_cfg.tele_bcn_max_li;
2012 else
2013 val = mac_ctx->mlme_cfg->sap_cfg.listen_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014
2015 mlm_reassoc_req->listenInterval = (uint16_t) val;
2016
2017 /* Indicate whether spectrum management is enabled */
2018 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2019
2020 /* Enable the spectrum management if this is a DFS channel */
2021 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002022 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 session_entry->currentOperChannel))
2024 session_entry->spectrumMgtEnabled = true;
2025
2026 session_entry->limPrevSmeState = session_entry->limSmeState;
2027 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2028
2029 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2030 session_entry->peSessionId,
2031 session_entry->limSmeState));
2032
Jianmin Zhu09236602018-10-15 15:36:10 +08002033 lim_send_reassoc_req(session_entry, mlm_reassoc_req);
2034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 return;
2036end:
2037 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302038 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 if (session_entry)
2040 session_entry->pLimReAssocReq = NULL;
2041 }
2042
2043 if (session_entry) {
2044 /*
2045 * error occurred after we determined the session so extract
2046 * session and transaction info from there
2047 */
2048 sme_session_id = session_entry->smeSessionId;
2049 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002050 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 /*
2052 * error occurred before or during the time we determined
2053 * the session so extract the session and transaction info
2054 * from the message
2055 */
2056 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2057 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002058 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059 /*
2060 * Send Reassoc failure response to host
2061 * (note session_entry may be NULL, but that's OK)
2062 */
2063 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2064 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2065 session_entry, sme_session_id,
2066 transaction_id);
2067}
2068
2069bool send_disassoc_frame = 1;
2070/**
2071 * __lim_process_sme_disassoc_req()
2072 *
2073 ***FUNCTION:
2074 * This function is called to process SME_DISASSOC_REQ message
2075 * from HDD or upper layer application.
2076 *
2077 ***LOGIC:
2078 *
2079 ***ASSUMPTIONS:
2080 *
2081 ***NOTE:
2082 *
2083 * @param pMac Pointer to Global MAC structure
2084 * @param *pMsgBuf A pointer to the SME message buffer
2085 * @return None
2086 */
2087
2088static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2089{
2090 uint16_t disassocTrigger, reasonCode;
2091 tLimMlmDisassocReq *pMlmDisassocReq;
2092 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2093 tSirSmeDisassocReq smeDisassocReq;
2094 tpPESession psessionEntry = NULL;
2095 uint8_t sessionId;
2096 uint8_t smesessionId;
2097 uint16_t smetransactionId;
2098
2099 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002100 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 return;
2102 }
2103
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302104 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 smesessionId = smeDisassocReq.sessionId;
2106 smetransactionId = smeDisassocReq.transactionId;
2107 if (!lim_is_sme_disassoc_req_valid(pMac,
2108 &smeDisassocReq,
2109 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002110 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 if (pMac->lim.gLimRspReqd) {
2112 pMac->lim.gLimRspReqd = false;
2113
2114 retCode = eSIR_SME_INVALID_PARAMETERS;
2115 disassocTrigger = eLIM_HOST_DISASSOC;
2116 goto sendDisassoc;
2117 }
2118
2119 return;
2120 }
2121
2122 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002123 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 &sessionId);
2125 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002126 pe_err("session does not exist for given bssId "
2127 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002128 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 retCode = eSIR_SME_INVALID_PARAMETERS;
2130 disassocTrigger = eLIM_HOST_DISASSOC;
2131 goto sendDisassoc;
2132 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002133 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2134 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2136 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002137 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138
2139#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2140 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2141 0, smeDisassocReq.reasonCode);
2142#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2143
2144 /* Update SME session Id and SME transaction ID */
2145
2146 psessionEntry->smeSessionId = smesessionId;
2147 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002149 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150
2151 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2152 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 switch (psessionEntry->limSmeState) {
2154 case eLIM_SME_ASSOCIATED_STATE:
2155 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002156 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002157 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 psessionEntry->limPrevSmeState =
2159 psessionEntry->limSmeState;
2160 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 /* Delete all TDLS peers connected before leaving BSS */
2162 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002163 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2164 psessionEntry->peSessionId,
2165 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 break;
2167
2168 case eLIM_SME_WT_DEAUTH_STATE:
2169 /* PE shall still process the DISASSOC_REQ and proceed with
2170 * link tear down even if it had already sent a DEAUTH_IND to
2171 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2172 * its been set when PE entered WT_DEAUTH_STATE.
2173 */
2174 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2175 MTRACE(mac_trace
2176 (pMac, TRACE_CODE_SME_STATE,
2177 psessionEntry->peSessionId,
2178 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002179 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180 break;
2181
2182 case eLIM_SME_WT_DISASSOC_STATE:
Jeff Johnson47d75242018-05-12 15:58:53 -07002183 /* PE Received a Disassoc frame. Normally it gets DISASSOC_CNF but it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2185 * PE can continue processing DISASSOC_REQ and send the response instead
2186 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2187 * for disassoc frame.
2188 *
2189 * It will send a disassoc, which is ok. However, we can use the global flag
2190 * sendDisassoc to not send disassoc frame.
2191 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002192 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 break;
2194
2195 case eLIM_SME_JOIN_FAILURE_STATE: {
2196 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002197 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 if (pMac->lim.gLimRspReqd) {
2199 retCode = eSIR_SME_SUCCESS;
2200 disassocTrigger = eLIM_HOST_DISASSOC;
2201 goto sendDisassoc;
2202 }
2203 }
2204 break;
2205 default:
2206 /**
2207 * STA is not currently associated.
2208 * Log error and send response to host
2209 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002210 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 psessionEntry->limSmeState);
2212 lim_print_sme_state(pMac, LOGE,
2213 psessionEntry->limSmeState);
2214
2215 if (pMac->lim.gLimRspReqd) {
2216 if (psessionEntry->limSmeState !=
2217 eLIM_SME_WT_ASSOC_STATE)
2218 pMac->lim.gLimRspReqd = false;
2219
2220 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2221 disassocTrigger = eLIM_HOST_DISASSOC;
2222 goto sendDisassoc;
2223 }
2224
2225 return;
2226 }
2227
2228 break;
2229
2230 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 /* Fall through */
2232 break;
2233
2234 case eLIM_STA_IN_IBSS_ROLE:
2235 default:
2236 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002237 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 GET_LIM_SYSTEM_ROLE(psessionEntry));
2239
2240 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2241 disassocTrigger = eLIM_HOST_DISASSOC;
2242 goto sendDisassoc;
2243 } /* end switch (pMac->lim.gLimSystemRole) */
2244
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302245 disassocTrigger = eLIM_HOST_DISASSOC;
2246 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247
2248 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002249 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 send_disassoc_frame = 0;
2251 }
2252 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002253 pe_debug("Sending Disasscoc with disassoc Trigger"
2254 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 disassocTrigger, reasonCode);
2256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302257 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002258 if (!pMlmDisassocReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260
Anurag Chouhanc5548422016-02-24 18:33:27 +05302261 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002262 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263
2264 pMlmDisassocReq->reasonCode = reasonCode;
2265 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2266
2267 /* Update PE session ID */
2268 pMlmDisassocReq->sessionId = sessionId;
2269
2270 lim_post_mlm_message(pMac,
2271 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2272 return;
2273
2274sendDisassoc:
2275 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002276 lim_send_sme_disassoc_ntf(pMac,
2277 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 retCode,
2279 disassocTrigger,
2280 1, smesessionId, smetransactionId,
2281 psessionEntry);
2282 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002283 lim_send_sme_disassoc_ntf(pMac,
2284 smeDisassocReq.peer_macaddr.bytes,
2285 retCode, disassocTrigger, 1,
2286 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287
2288} /*** end __lim_process_sme_disassoc_req() ***/
2289
2290/** -----------------------------------------------------------------
2291 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2292
2293 This function is called to process SME_DISASSOC_CNF message
2294 from HDD or upper layer application.
2295
2296 \param pMac - global mac structure
2297 \param pStaDs - station dph hash node
2298 \return none
2299 \sa
2300 ----------------------------------------------------------------- */
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002301void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302{
2303 tSirSmeDisassocCnf smeDisassocCnf;
2304 uint16_t aid;
2305 tpDphHashNode pStaDs;
2306 tpPESession psessionEntry;
2307 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302308 uint32_t *msg = NULL;
2309 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302311 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 sizeof(struct sSirSmeDisassocCnf));
2313
2314 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002315 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 &sessionId);
2317 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002318 pe_err("session does not exist for given bssId");
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302319 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302320 smeDisassocCnf.sme_session_id,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302321 eSIR_SME_INVALID_SESSION,
2322 NULL);
2323 if (QDF_IS_STATUS_SUCCESS(status))
2324 lim_send_sme_disassoc_deauth_ntf(pMac,
2325 QDF_STATUS_SUCCESS,
2326 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 return;
2328 }
2329
2330 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002331 pe_err("received invalid SME_DISASSOC_CNF message");
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302332 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2333 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302334 eSIR_SME_INVALID_PARAMETERS,
2335 &smeDisassocCnf.bssid.bytes[0]);
2336 if (QDF_IS_STATUS_SUCCESS(status))
2337 lim_send_sme_disassoc_deauth_ntf(pMac,
2338 QDF_STATUS_SUCCESS,
2339 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340 return;
2341 }
2342#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2343 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2344 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2345 psessionEntry,
2346 (uint16_t) smeDisassocCnf.statusCode, 0);
2347 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2348 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2349 psessionEntry,
2350 (uint16_t) smeDisassocCnf.statusCode, 0);
2351#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2352
2353 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2354 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2356 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2357 && (psessionEntry->limSmeState !=
2358 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002359 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 psessionEntry->limSmeState);
2361 lim_print_sme_state(pMac, LOGE,
2362 psessionEntry->limSmeState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302363 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302364 psessionEntry->smeSessionId,
2365 eSIR_SME_INVALID_STATE,
2366 &smeDisassocCnf.bssid.bytes[0]);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302367 if (QDF_IS_STATUS_SUCCESS(status))
2368 lim_send_sme_disassoc_deauth_ntf(pMac,
2369 QDF_STATUS_SUCCESS,
2370 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 return;
2372 }
2373 break;
2374
2375 case eLIM_AP_ROLE:
2376 /* Fall through */
2377 break;
2378
2379 case eLIM_STA_IN_IBSS_ROLE:
2380 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002381 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 GET_LIM_SYSTEM_ROLE(psessionEntry));
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302383 status = lim_prepare_disconnect_done_ind(pMac, &msg,
2384 psessionEntry->smeSessionId,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302385 eSIR_SME_INVALID_STATE,
2386 &smeDisassocCnf.bssid.bytes[0]);
2387 if (QDF_IS_STATUS_SUCCESS(status))
2388 lim_send_sme_disassoc_deauth_ntf(pMac,
2389 QDF_STATUS_SUCCESS,
2390 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 return;
2392 }
2393
2394 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2395 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2396 LIM_IS_AP_ROLE(psessionEntry)) {
2397 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002398 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 &psessionEntry->dph.dphHashTable);
2400 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002401 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2402 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002403 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302404 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302405 psessionEntry->smeSessionId,
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05302406 eSIR_SME_INVALID_PARAMETERS,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302407 &smeDisassocCnf.bssid.bytes[0]);
2408 if (QDF_IS_STATUS_SUCCESS(status))
2409 lim_send_sme_disassoc_deauth_ntf(pMac,
2410 QDF_STATUS_SUCCESS,
2411 (uint32_t *)msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 return;
2413 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302414
2415 if ((pStaDs->mlmStaContext.mlmState ==
2416 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2417 (pStaDs->mlmStaContext.mlmState ==
Arif Hussain5fa13782018-05-10 11:29:52 -07002418 eLIM_MLM_WT_DEL_BSS_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002419 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002420 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302421 pStaDs->mlmStaContext.mlmState);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302422 status = lim_prepare_disconnect_done_ind(pMac, &msg,
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05302423 psessionEntry->smeSessionId,
2424 eSIR_SME_SUCCESS,
2425 NULL);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05302426 if (QDF_IS_STATUS_SUCCESS(status))
2427 lim_send_sme_disassoc_deauth_ntf(pMac,
2428 QDF_STATUS_SUCCESS,
2429 (uint32_t *)msg);
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302430 return;
2431 }
2432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 /* Delete FT session if there exists one */
2434 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2436
2437 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002438 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 }
2440
2441 return;
2442}
2443
2444/**
2445 * __lim_process_sme_deauth_req() - process sme deauth req
2446 * @mac_ctx: Pointer to Global MAC structure
2447 * @msg_buf: pointer to the SME message buffer
2448 *
2449 * This function is called to process SME_DEAUTH_REQ message
2450 * from HDD or upper layer application.
2451 *
2452 * Return: None
2453 */
2454
2455static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2456 uint32_t *msg_buf)
2457{
2458 uint16_t deauth_trigger, reason_code;
2459 tLimMlmDeauthReq *mlm_deauth_req;
2460 tSirSmeDeauthReq sme_deauth_req;
2461 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2462 tpPESession session_entry;
2463 uint8_t session_id; /* PE sessionId */
2464 uint8_t sme_session_id;
2465 uint16_t sme_transaction_id;
2466
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302467 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 sme_session_id = sme_deauth_req.sessionId;
2469 sme_transaction_id = sme_deauth_req.transactionId;
2470
2471 /*
2472 * We need to get a session first but we don't even know
2473 * if the message is correct.
2474 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002475 session_entry = pe_find_session_by_bssid(mac_ctx,
2476 sme_deauth_req.bssid.bytes,
2477 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002479 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 ret_code = eSIR_SME_INVALID_PARAMETERS;
2481 deauth_trigger = eLIM_HOST_DEAUTH;
2482 goto send_deauth;
2483 }
2484
2485 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2486 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002487 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 mac_ctx->lim.gLimRspReqd = false;
2489
2490 ret_code = eSIR_SME_INVALID_PARAMETERS;
2491 deauth_trigger = eLIM_HOST_DEAUTH;
2492 goto send_deauth;
2493 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002494 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2495 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2497 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002498 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2500 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2501 session_entry, 0, sme_deauth_req.reasonCode);
2502#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2503
2504 /* Update SME session ID and Transaction ID */
2505 session_entry->smeSessionId = sme_session_id;
2506 session_entry->transactionId = sme_transaction_id;
2507
2508 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2509 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 switch (session_entry->limSmeState) {
2511 case eLIM_SME_ASSOCIATED_STATE:
2512 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302513 /* Delete all TDLS peers connected before leaving BSS */
2514 lim_delete_tdls_peers(mac_ctx, session_entry);
Abhinav Kumarac12c762018-05-02 13:51:02 +05302515 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 case eLIM_SME_WT_ASSOC_STATE:
2517 case eLIM_SME_JOIN_FAILURE_STATE:
2518 case eLIM_SME_IDLE_STATE:
2519 session_entry->limPrevSmeState =
2520 session_entry->limSmeState;
2521 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2522 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2523 session_entry->peSessionId,
2524 session_entry->limSmeState));
2525 /* Send Deauthentication request to MLM below */
2526 break;
2527 case eLIM_SME_WT_DEAUTH_STATE:
2528 case eLIM_SME_WT_DISASSOC_STATE:
2529 /*
Jeff Johnson47d75242018-05-12 15:58:53 -07002530 * PE Received a Deauth/Disassoc frame. Normally it get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2532 * Which means host is also trying to disconnect.
2533 * PE can continue processing DEAUTH_REQ and send
2534 * the response instead of failing the request.
2535 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2536 * was sent for deauth/disassoc frame.
2537 */
2538 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002539 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 break;
2541 default:
2542 /*
2543 * STA is not in a state to deauthenticate with
2544 * peer. Log error and send response to host.
2545 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002546 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 session_entry->limSmeState);
2548 lim_print_sme_state(mac_ctx, LOGE,
2549 session_entry->limSmeState);
2550
2551 if (mac_ctx->lim.gLimRspReqd) {
2552 mac_ctx->lim.gLimRspReqd = false;
2553
2554 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2555 deauth_trigger = eLIM_HOST_DEAUTH;
2556
wadesong42968e92017-06-08 14:11:21 +08002557 /*
2558 * here we received deauth request from AP so
2559 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2560 * have ISSUED delSta then mlm state should be
2561 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2562 * delBSS rsp then mlm state should be
2563 * eLIM_MLM_IDLE_STATE so the below condition
2564 * captures the state where delSta not done
2565 * and firmware still in connected state.
2566 */
2567 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 eLIM_SME_WT_DEAUTH_STATE &&
2569 session_entry->limMlmState !=
2570 eLIM_MLM_IDLE_STATE &&
2571 session_entry->limMlmState !=
2572 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002573 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 goto send_deauth;
2575 }
2576 return;
2577 }
2578 break;
2579
2580 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002581 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 if (mac_ctx->lim.gLimRspReqd) {
2583 mac_ctx->lim.gLimRspReqd = false;
2584 ret_code = eSIR_SME_INVALID_PARAMETERS;
2585 deauth_trigger = eLIM_HOST_DEAUTH;
2586 goto send_deauth;
2587 }
2588 return;
2589 case eLIM_AP_ROLE:
2590 break;
2591 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002592 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 GET_LIM_SYSTEM_ROLE(session_entry));
2594 if (mac_ctx->lim.gLimRspReqd) {
2595 mac_ctx->lim.gLimRspReqd = false;
2596 ret_code = eSIR_SME_INVALID_PARAMETERS;
2597 deauth_trigger = eLIM_HOST_DEAUTH;
2598 goto send_deauth;
2599 }
2600 return;
2601 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2602
Yu Ouyang57c25532018-09-07 17:14:01 +08002603 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH &&
2604 session_entry->limSystemRole == eLIM_STA_ROLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002606 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2608 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2609 } else {
2610 deauth_trigger = eLIM_HOST_DEAUTH;
2611 reason_code = sme_deauth_req.reasonCode;
2612 }
2613
2614 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302615 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002616 if (!mlm_deauth_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 if (mac_ctx->lim.gLimRspReqd) {
2618 mac_ctx->lim.gLimRspReqd = false;
2619 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2620 deauth_trigger = eLIM_HOST_DEAUTH;
2621 goto send_deauth;
2622 }
2623 return;
2624 }
2625
Anurag Chouhanc5548422016-02-24 18:33:27 +05302626 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002627 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628
2629 mlm_deauth_req->reasonCode = reason_code;
2630 mlm_deauth_req->deauthTrigger = deauth_trigger;
2631
2632 /* Update PE session Id */
2633 mlm_deauth_req->sessionId = session_id;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002634 lim_process_mlm_deauth_req(mac_ctx, (uint32_t *)mlm_deauth_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 return;
2637
2638send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002639 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2640 ret_code, deauth_trigger, 1,
2641 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642}
2643
2644/**
2645 * __lim_process_sme_set_context_req()
2646 *
2647 * @mac_ctx: Pointer to Global MAC structure
2648 * @msg_buf: pointer to the SME message buffer
2649 *
2650 * This function is called to process SME_SETCONTEXT_REQ message
2651 * from HDD or upper layer application.
2652 *
2653 * Return: None
2654 */
2655
2656static void
2657__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2658{
2659 tpSirSmeSetContextReq set_context_req;
2660 tLimMlmSetKeysReq *mlm_set_key_req;
2661 tpPESession session_entry;
2662 uint8_t session_id; /* PE sessionID */
2663 uint8_t sme_session_id;
2664 uint16_t sme_transaction_id;
2665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002667 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 return;
2669 }
2670
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302671 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002672 if (!set_context_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 sizeof(struct sSirSmeSetContextReq));
2676 sme_session_id = set_context_req->sessionId;
2677 sme_transaction_id = set_context_req->transactionId;
2678
2679 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002680 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 goto end;
2682 }
2683
2684 if (set_context_req->keyMaterial.numKeys >
2685 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002686 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 set_context_req->keyMaterial.numKeys);
2688 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002689 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 eSIR_SME_INVALID_PARAMETERS, NULL,
2691 sme_session_id, sme_transaction_id);
2692 goto end;
2693 }
2694
2695 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002696 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002698 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002700 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 eSIR_SME_INVALID_PARAMETERS, NULL,
2702 sme_session_id, sme_transaction_id);
2703 goto end;
2704 }
2705#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2706 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2707 session_entry, 0, 0);
2708#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2709
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002710 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2712 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002713 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2715 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302716 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002717 if (!mlm_set_key_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2720 mlm_set_key_req->numKeys =
2721 set_context_req->keyMaterial.numKeys;
2722 if (mlm_set_key_req->numKeys >
2723 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002724 pe_err("no.of keys exceeded max num of default keys limit");
Jingxiang Ge4168a232018-01-03 18:47:15 +08002725 qdf_mem_free(mlm_set_key_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 goto end;
2727 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302728 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002729 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302731 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 (uint8_t *) &set_context_req->keyMaterial.key,
2733 sizeof(tSirKeys) *
2734 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2735 numKeys : 1));
2736
2737 mlm_set_key_req->sessionId = session_id;
2738 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002739 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741
2742 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2743 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2744 LIM_IS_AP_ROLE(session_entry)) {
2745 if (set_context_req->keyMaterial.key[0].keyLength) {
2746 uint8_t key_id;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 key_id =
2749 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302750 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 &session_entry->WEPKeyMaterial[key_id],
2752 (uint8_t *) &set_context_req->keyMaterial,
2753 sizeof(tSirKeyMaterial));
2754 } else {
2755 uint32_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2758 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302759 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 &mlm_set_key_req->key[i],
2761 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2762 sizeof(tSirKeys));
2763 }
2764 }
2765 }
2766 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2767 (uint32_t *) mlm_set_key_req);
2768 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002769 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 GET_LIM_SYSTEM_ROLE(session_entry),
2771 session_entry->limSmeState);
2772 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2773
2774 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002775 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2777 session_entry, sme_session_id,
2778 sme_transaction_id);
2779 }
2780end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302781 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 return;
2783}
2784
2785/**
2786 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2787 *
2788 * @mac_ctx: Pointer to Global MAC structure
2789 * @msg_buf: pointer to the SME message buffer
2790 *
2791 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2792 * from HDD or upper layer application.
2793 *
2794 * Return: None
2795 */
2796
Jeff Johnson801f1532016-10-07 07:54:50 -07002797static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2798 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799{
2800 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2801 tpDphHashNode sta_ds = NULL;
2802 tpPESession session_entry = NULL;
2803 tSap_Event sap_event;
2804 tpWLAN_SAPEventCB sap_event_cb = NULL;
2805 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2806 uint8_t session_id = CSR_SESSION_ID_INVALID;
2807 uint8_t assoc_id = 0;
2808 uint8_t sta_cnt = 0;
2809
2810 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002811 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 return;
2813 }
2814
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302815 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816 sizeof(struct sSirSmeGetAssocSTAsReq));
2817 /*
2818 * Get Associated stations from PE.
2819 * Find PE session Entry
2820 */
2821 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08002822 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 &session_id);
2824 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002825 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 goto lim_assoc_sta_end;
2827 }
2828
2829 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002830 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 session_entry->limSmeState,
2832 GET_LIM_SYSTEM_ROLE(session_entry));
2833 goto lim_assoc_sta_end;
2834 }
2835 /* Retrieve values obtained in the request message */
2836 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
2837 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2838
2839 if (NULL == assoc_sta_tmp)
2840 goto lim_assoc_sta_end;
2841 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
2842 assoc_id++) {
2843 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
2844 &session_entry->dph.dphHashTable);
2845 if (NULL == sta_ds)
2846 continue;
2847 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302848 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302850 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
2852 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
2853
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302854 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 (uint8_t *)&sta_ds->supportedRates,
2856 sizeof(tSirSupportedRates));
2857 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
2858 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
2859 assoc_sta_tmp->Support40Mhz =
2860 sta_ds->htDsssCckRate40MHzSupport;
2861
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002862 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002864 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002866 pe_debug("Association Id: %d Station Index: %d",
2867 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868 assoc_sta_tmp++;
2869 sta_cnt++;
2870 }
2871 }
2872lim_assoc_sta_end:
2873 /*
2874 * Call hdd callback with sap event to send the list of
2875 * associated stations from PE
2876 */
2877 if (sap_event_cb != NULL) {
2878 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
2879 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302880 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
2882 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
2883 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
2884 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
2885 }
2886}
2887
2888/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 * __lim_counter_measures()
2890 *
2891 * FUNCTION:
2892 * This function is called to "implement" MIC counter measure
2893 * and is *temporary* only
2894 *
2895 * LOGIC: on AP, disassoc all STA associated thru TKIP,
2896 * we don't do the proper STA disassoc sequence since the
Jeff Johnsond460e842018-05-11 13:25:53 -07002897 * BSS will be stopped anyway
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 *
2899 ***ASSUMPTIONS:
2900 *
2901 ***NOTE:
2902 *
2903 * @param pMac Pointer to Global MAC structure
2904 * @return None
2905 */
2906
2907static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
2908{
2909 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002910
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002911 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
2913 mac, psessionEntry, false);
2914};
2915
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05302916void lim_send_stop_bss_failure_resp(tpAniSirGlobal mac_ctx,
2917 tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302918{
2919 session->limSmeState = session->limPrevSmeState;
2920
2921 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE, session->peSessionId,
2922 session->limSmeState));
2923
2924 lim_send_sme_rsp(mac_ctx, eWNI_SME_STOP_BSS_RSP,
2925 eSIR_SME_STOP_BSS_FAILURE, session->smeSessionId,
2926 session->transactionId);
2927}
2928
2929void lim_delete_all_peers(tpPESession session)
2930{
2931 uint8_t i = 0;
2932 tpAniSirGlobal mac_ctx = session->mac_ctx;
2933 tpDphHashNode sta_ds = NULL;
2934 QDF_STATUS status;
2935
2936 for (i = 1; i < session->dph.dphHashTable.size; i++) {
2937 sta_ds = dph_get_hash_entry(mac_ctx, i,
2938 &session->dph.dphHashTable);
2939 if (!sta_ds)
2940 continue;
2941 status = lim_del_sta(mac_ctx, sta_ds, false, session);
2942 if (QDF_STATUS_SUCCESS == status) {
2943 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
2944 sta_ds->assocId, session);
2945 lim_release_peer_idx(mac_ctx, sta_ds->assocId, session);
2946 } else {
2947 pe_err("lim_del_sta failed with Status: %d", status);
2948 QDF_ASSERT(0);
2949 }
2950 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302951
2952#ifdef CONFIG_VDEV_SM
2953 status =
2954 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
2955 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
2956 sizeof(*session), session);
2957 if (QDF_IS_STATUS_ERROR(status)) {
2958 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
2959 session->smeSessionId);
2960 lim_send_stop_bss_failure_resp(mac_ctx, session);
2961 }
2962#endif
2963
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302964}
2965
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07002966QDF_STATUS lim_sta_send_del_bss(tpPESession session)
2967{
2968 tpAniSirGlobal mac_ctx = session->mac_ctx;
2969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
2970 tpDphHashNode sta_ds = NULL;
2971
2972 sta_ds = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
2973 &session->dph.dphHashTable);
2974 if (!sta_ds) {
2975 pe_err("DPH Entry for STA is missing, failed to send delbss");
2976 goto end;
2977 }
2978
2979 status = lim_del_bss(mac_ctx, sta_ds, 0, session);
2980 if (QDF_IS_STATUS_ERROR(status))
2981 pe_err("delBss failed for bss %d", session->bssIdx);
2982
2983end:
2984 return status;
2985}
2986
Abhishek Singhcaa61852018-09-12 15:50:04 +05302987QDF_STATUS lim_send_vdev_stop(tpPESession session)
Abhishek Singh2904a6a2018-08-30 17:45:59 +05302988{
2989 tpAniSirGlobal mac_ctx = session->mac_ctx;
2990 QDF_STATUS status;
2991
2992 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
2993
2994 if (QDF_IS_STATUS_ERROR(status)) {
2995 pe_err("delBss failed for bss %d", session->bssIdx);
2996 lim_send_stop_bss_failure_resp(mac_ctx, session);
2997 }
Abhishek Singhcaa61852018-09-12 15:50:04 +05302998
2999 return status;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303000}
3001
3002/**
3003 * lim_delete_peers_and_send_vdev_stop() -delete peers and send vdev stop
3004 * @session: session pointer
3005 *
3006 * Return None
3007 */
Abhishek Singhcaa61852018-09-12 15:50:04 +05303008#ifdef CONFIG_VDEV_SM
3009static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3010{
3011 tpAniSirGlobal mac_ctx = session->mac_ctx;
3012 QDF_STATUS status;
3013
Abhishek Singhc5a54082018-09-12 16:08:03 +05303014 if (wlan_vdev_mlme_get_substate(session->vdev) ==
3015 WLAN_VDEV_SS_START_RESTART_PROGRESS)
3016 status =
3017 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3018 WLAN_VDEV_SM_EV_RESTART_REQ_FAIL,
Abhishek Singhcaa61852018-09-12 15:50:04 +05303019 sizeof(*session), session);
Abhishek Singhc5a54082018-09-12 16:08:03 +05303020 else
3021 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3022 WLAN_VDEV_SM_EV_DOWN,
3023 sizeof(*session),
3024 session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05303025 if (QDF_IS_STATUS_ERROR(status)) {
3026 pe_err("failed to post WLAN_VDEV_SM_EV_DOWN for vdevid %d",
3027 session->smeSessionId);
3028 lim_send_stop_bss_failure_resp(mac_ctx, session);
3029 }
3030}
3031#else
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303032static void lim_delete_peers_and_send_vdev_stop(tpPESession session)
3033{
3034 lim_delete_all_peers(session);
3035 /* send a delBss to HAL and wait for a response */
3036 lim_send_vdev_stop(session);
3037}
Abhishek Singhcaa61852018-09-12 15:50:04 +05303038#endif
3039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040static void
3041__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3042{
3043 tSirSmeStopBssReq stopBssReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 tLimSmeStates prevState;
3045 tpPESession psessionEntry;
3046 uint8_t smesessionId;
3047 uint8_t sessionId;
3048 uint16_t smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303050 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 smesessionId = stopBssReq.sessionId;
3052 smetransactionId = stopBssReq.transactionId;
3053
3054 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003055 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 /* Send Stop BSS response to host */
3057 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3058 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3059 smetransactionId);
3060 return;
3061 }
3062
3063 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003064 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 &sessionId);
3066 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003067 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3069 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3070 smetransactionId);
3071 return;
3072 }
3073#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3074 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3075 0, 0);
3076#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3077
3078 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3079 LIM_IS_STA_ROLE(psessionEntry)) {
3080 /**
3081 * Should not have received STOP_BSS_REQ in states
3082 * other than 'normal' state or on STA in Infrastructure
3083 * mode. Log error and return response to host.
3084 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003085 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 psessionEntry->limSmeState,
3087 GET_LIM_SYSTEM_ROLE(psessionEntry));
3088 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3089 /* / Send Stop BSS response to host */
3090 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3091 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3092 smetransactionId);
3093 return;
3094 }
3095
3096 if (LIM_IS_AP_ROLE(psessionEntry))
3097 lim_wpspbc_close(pMac, psessionEntry);
3098
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003099 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 stopBssReq.reasonCode);
3101
3102 prevState = psessionEntry->limSmeState;
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303103 psessionEntry->limPrevSmeState = prevState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104
3105 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3106 MTRACE(mac_trace
3107 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3108 psessionEntry->limSmeState));
3109
3110 /* Update SME session Id and Transaction Id */
3111 psessionEntry->smeSessionId = smesessionId;
3112 psessionEntry->transactionId = smetransactionId;
3113
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003114 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3115 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3116 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3120 /* Send disassoc all stations associated thru TKIP */
3121 __lim_counter_measures(pMac, psessionEntry);
3122 else
3123 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003124 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3125 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 }
3127
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003128 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3129 /* Free the buffer allocated in START_BSS_REQ */
3130 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3131 psessionEntry->addIeParams.probeRespDataLen = 0;
3132 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003134 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3135 psessionEntry->addIeParams.assocRespDataLen = 0;
3136 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003138 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3139 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3140 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003142 /*
3143 * lim_del_bss is also called as part of coalescing,
3144 * when we send DEL BSS followed by Add Bss msg.
3145 */
3146 pMac->lim.gLimIbssCoalescingHappened = false;
3147 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148
Abhishek Singh2904a6a2018-08-30 17:45:59 +05303149 lim_delete_peers_and_send_vdev_stop(psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151}
3152
3153/**
3154 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3155 * @pMac: Global MAC context
3156 * @pMsg: Message from SME
3157 *
3158 * Wrapper for the function __lim_handle_sme_stop_bss_request
3159 * This message will be defered until softmac come out of
3160 * scan mode. Message should be handled even if we have
3161 * detected radar in the current operating channel.
3162 *
3163 * Return: true - If we consumed the buffer
3164 * false - If have defered the message.
3165 */
3166
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003167static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3168 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169{
3170 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3171 /**
3172 * If message defered, buffer is not consumed yet.
3173 * So return false
3174 */
3175 return false;
3176 }
3177 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3178 return true;
3179} /*** end __lim_process_sme_stop_bss_req() ***/
3180
3181void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3182 uint32_t body, tpPESession psessionEntry)
3183{
3184
3185 (void)body;
3186 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3187 lim_ibss_delete(pMac, psessionEntry);
3188 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3189 lim_delete_pre_auth_list(pMac);
3190 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3191 psessionEntry->smeSessionId,
3192 psessionEntry->transactionId);
3193 return;
3194}
3195
3196/**
3197 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3198 *
3199 * @mac_ctx: pointer to mac context
3200 * @msg_type: message type
3201 * @msg_buf: pointer to the SME message buffer
3202 *
3203 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3204 * in BTAMP AP.
3205 *
3206 * Return: None
3207 */
3208
3209void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3210 uint32_t *msg_buf)
3211{
3212 tSirSmeAssocCnf assoc_cnf;
3213 tpDphHashNode sta_ds = NULL;
3214 tpPESession session_entry = NULL;
3215 uint8_t session_id;
3216 tpSirAssocReq assoc_req;
3217
3218 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003219 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 goto end;
3221 }
3222
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303223 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003225 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 goto end;
3227 }
3228
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003229 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 &session_id);
3231 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003232 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 goto end;
3234 }
3235
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003236 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3238 (session_entry->limSmeState !=
3239 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 msg_type, session_entry->limSmeState,
3242 GET_LIM_SYSTEM_ROLE(session_entry));
3243 goto end;
3244 }
3245 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3246 &session_entry->dph.dphHashTable);
3247 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003248 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303250 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251
3252 /*
3253 * send a DISASSOC_IND message to WSM to make sure
3254 * the state in WSM and LIM is the same
3255 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003256 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 eSIR_SME_STA_NOT_ASSOCIATED,
3258 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3259 session_entry->smeSessionId,
3260 session_entry->transactionId,
3261 session_entry);
3262 goto end;
3263 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303264 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003265 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303266 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003267 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303269 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 goto end;
3271 }
3272
3273 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3274 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3275 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3276 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3277 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003278 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3279 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303281 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 goto end;
3283 }
3284 /*
3285 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3286 * has been received
3287 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003288 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3290 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3291
3292 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3293 /*
3294 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3295 * when it had received Assoc Request frame. Now, PE just needs
3296 * to send association rsp frame to the requesting BTAMP-STA.
3297 */
3298 sta_ds->mlmStaContext.mlmState =
3299 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003300 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 sta_ds->assocId);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003302 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 sta_ds->assocId, sta_ds->staAddr,
3304 sta_ds->mlmStaContext.subType, sta_ds,
3305 session_entry);
3306 goto end;
3307 } else {
3308 /*
3309 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3310 * to be associated since the HAL sta entry is created for
3311 * denied STA we need to remove this HAL entry.
3312 * So to do that set updateContext to 1
3313 */
3314 if (!sta_ds->mlmStaContext.updateContext)
3315 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003316 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 assoc_cnf.statusCode, sta_ds->assocId);
3318 lim_reject_association(mac_ctx, sta_ds->staAddr,
3319 sta_ds->mlmStaContext.subType,
3320 true, sta_ds->mlmStaContext.authType,
3321 sta_ds->assocId, true,
Sandeep Puligillaa9de16b2017-09-25 16:25:04 -07003322 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 session_entry);
3324 }
3325end:
3326 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3327 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3328 assoc_req = (tpSirAssocReq)
3329 session_entry->parsedAssocReq[sta_ds->assocId];
3330 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303331 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 assoc_req->assocReqFrame = NULL;
3333 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303334 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3336 }
3337}
3338
3339static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3340{
3341 tpDphHashNode pStaDs;
3342 tSirMacAddr peerMac;
3343 tpSirAddtsReq pSirAddts;
3344 uint32_t timeout;
3345 tpPESession psessionEntry;
3346 uint8_t sessionId; /* PE sessionId */
3347 uint8_t smesessionId;
3348 uint16_t smetransactionId;
3349
3350 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003351 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 return;
3353 }
3354
3355 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3356 &smetransactionId);
3357
3358 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3359
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003360 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3361 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003363 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003364 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303365 NULL, pSirAddts->req.tspec,
3366 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 return;
3368 }
3369#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3370 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3371 0);
3372#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3373
3374 /* if sta
3375 * - verify assoc state
3376 * - send addts request to ap
3377 * - wait for addts response from ap
3378 * if ap, just ignore with error log
3379 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003380 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3381 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3382 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003384 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003385 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303386 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388
3389 pStaDs =
3390 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3391 &psessionEntry->dph.dphHashTable);
3392
3393 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003394 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303395 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 }
3397
3398 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3399 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003400 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303401 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 }
3403
3404 pSirAddts->req.wsmTspecPresent = 0;
3405 pSirAddts->req.wmeTspecPresent = 0;
3406 pSirAddts->req.lleTspecPresent = 0;
3407
3408 if ((pStaDs->wsmEnabled) &&
3409 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3410 SIR_MAC_ACCESSPOLICY_EDCA))
3411 pSirAddts->req.wsmTspecPresent = 1;
3412 else if (pStaDs->wmeEnabled)
3413 pSirAddts->req.wmeTspecPresent = 1;
3414 else if (pStaDs->lleEnabled)
3415 pSirAddts->req.lleTspecPresent = 1;
3416 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003417 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303418 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 }
3420
3421 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3422 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003423 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303425 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 }
3427
3428 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003429 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 pMac->lim.gLimAddtsReq.req.dialogToken,
3431 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3432 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3433 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303434 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 }
3436
3437 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3438
3439 /* save the addts request */
3440 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303441 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3443
3444 /* ship out the message now */
3445 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3446 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303447 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 /* start a timer to wait for the response */
3449 if (pSirAddts->timeout)
3450 timeout = pSirAddts->timeout;
Arif Hussain43e09712018-09-18 19:31:57 -07003451 else
3452 timeout = pMac->mlme_cfg->timeouts.addts_rsp_timeout;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453
3454 timeout = SYS_MS_TO_TICKS(timeout);
3455 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3456 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003457 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303458 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 }
3460 pMac->lim.gLimAddtsRspTimerCount++;
3461 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3462 pMac->lim.gLimAddtsRspTimerCount) !=
3463 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003464 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303465 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 }
3467 MTRACE(mac_trace
3468 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3469 eLIM_ADDTS_RSP_TIMER));
3470
3471 /* add the sessionId to the timer object */
3472 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3473 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3474 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003475 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303476 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 }
3478 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303479
3480send_failure_addts_rsp:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003481 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, QDF_STATUS_E_FAILURE,
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303482 psessionEntry, pSirAddts->req.tspec,
3483 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484}
3485
3486static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3487{
3488 tSirMacAddr peerMacAddr;
3489 uint8_t ac;
3490 tSirMacTSInfo *pTsinfo;
3491 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3492 tpDphHashNode pStaDs = NULL;
3493 tpPESession psessionEntry;
3494 uint8_t sessionId;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003495 uint32_t status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 uint8_t smesessionId;
3497 uint16_t smetransactionId;
3498
3499 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3500 &smetransactionId);
3501
3502 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003503 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 &sessionId);
3505 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003506 pe_err("Session Does not exist for given bssId");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003507 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 goto end;
3509 }
3510#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3511 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3512 0);
3513#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3514
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003515 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003517 pe_err("lim_validate_delts_req failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003518 status = QDF_STATUS_E_FAILURE;
3519 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_E_FAILURE, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 smesessionId, smetransactionId);
3521 return;
3522 }
3523
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003524 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3525 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3527
3528 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3529 pDeltsReq->req.wmeTspecPresent,
3530 &pDeltsReq->req.tsinfo,
3531 &pDeltsReq->req.tspec, psessionEntry);
3532
3533 pTsinfo =
3534 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3535 tsinfo : &pDeltsReq->req.tsinfo;
3536
3537 /* We've successfully send DELTS frame to AP. Update the
3538 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3539 * is no longer trigger enabled or delivery enabled
3540 */
3541 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3542 pTsinfo, CLEAR_UAPSD_MASK);
3543
3544 /* We're deleting the TSPEC, so this particular AC is no longer
3545 * admitted. PE needs to downgrade the EDCA
3546 * parameters(for the AC for which TS is being deleted) to the
3547 * next best AC for which ACM is not enabled, and send the
3548 * updated values to HAL.
3549 */
3550 ac = upToAc(pTsinfo->traffic.userPrio);
3551
3552 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3553 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3554 ~(1 << ac);
3555 } else if (pTsinfo->traffic.direction ==
3556 SIR_MAC_DIRECTION_DNLINK) {
3557 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3558 ~(1 << ac);
3559 } else if (pTsinfo->traffic.direction ==
3560 SIR_MAC_DIRECTION_BIDIR) {
3561 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3562 ~(1 << ac);
3563 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3564 ~(1 << ac);
3565 }
3566
3567 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3568 psessionEntry);
3569
3570 pStaDs =
3571 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3572 &psessionEntry->dph.dphHashTable);
3573 if (pStaDs != NULL) {
3574 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003575 pStaDs->bssId, false);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003576 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003578 pe_err("Self entry missing in Hash Table");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003579 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 }
3581#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583#endif
3584
3585 /* send an sme response back */
3586end:
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003587 lim_send_sme_delts_rsp(pMac, pDeltsReq, QDF_STATUS_SUCCESS, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 smesessionId, smetransactionId);
3589}
3590
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303591void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592{
3593 /* fetch the sessionEntry based on the sessionId */
3594 tpPESession psessionEntry;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07003595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 psessionEntry = pe_find_session_by_session_id(pMac,
3597 pMac->lim.limTimers.gLimAddtsRspTimer.
3598 sessionId);
3599 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003600 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 return;
3602 }
3603
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003604 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003605 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 GET_LIM_SYSTEM_ROLE(psessionEntry));
3607 pMac->lim.gLimAddtsSent = false;
3608 return;
3609 }
3610
3611 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003612 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 return;
3614 }
3615
3616 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003617 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 pMac->lim.gLimAddtsRspTimerCount);
3619 return;
3620 }
3621 /* this a real response timeout */
3622 pMac->lim.gLimAddtsSent = false;
3623 pMac->lim.gLimAddtsRspTimerCount++;
3624
3625 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3626 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3627 psessionEntry->smeSessionId,
3628 psessionEntry->transactionId);
3629}
3630
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003631#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632/**
3633 * __lim_process_sme_get_statistics_request()
3634 *
3635 ***FUNCTION:
3636 *
3637 *
3638 ***NOTE:
3639 *
3640 * @param pMac Pointer to Global MAC structure
3641 * @param *pMsgBuf A pointer to the SME message buffer
3642 * @return None
3643 */
3644static void
3645__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3646{
3647 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003648 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649
3650 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3651
3652 msgQ.type = WMA_GET_STATISTICS_REQ;
3653
3654 msgQ.reserved = 0;
3655 msgQ.bodyptr = pMsgBuf;
3656 msgQ.bodyval = 0;
3657 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3658
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003659 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303660 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003662 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 return;
3664 }
3665
3666 return;
3667}
Naveen Rawatfa2a1002018-05-17 16:06:37 -07003668#else
3669static void __lim_process_sme_get_statistics_request(
3670 struct sAniSirGlobal *mac_ctx, uint32_t *pMsgBuf) {}
3671#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003673#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003675 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003677 * @pMac: Pointer to Global MAC structure
3678 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003680 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 */
3682static void
3683__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3684{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003685 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686
3687 msgQ.type = WMA_TSM_STATS_REQ;
3688 msgQ.reserved = 0;
3689 msgQ.bodyptr = pMsgBuf;
3690 msgQ.bodyval = 0;
3691 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3692
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003693 if (QDF_STATUS_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303694 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003696 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 return;
3698 }
3699}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003700#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08003702static void lim_process_sme_set_addba_accept(tpAniSirGlobal mac_ctx,
3703 struct sme_addba_accept *msg)
3704{
3705 if (!msg) {
3706 pe_err("Msg Buffer is NULL");
3707 return;
3708 }
3709 if (!msg->addba_accept)
3710 mac_ctx->reject_addba_req = 1;
3711 else
3712 mac_ctx->reject_addba_req = 0;
3713}
3714
Arif Hussaineb8ba362018-03-07 19:15:13 -08003715static void lim_process_sme_update_edca_params(tpAniSirGlobal mac_ctx,
3716 uint32_t sme_session_id)
3717{
3718 tpPESession pe_session;
3719 tpDphHashNode sta_ds_ptr;
3720
3721 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3722 if (!pe_session) {
3723 pe_err("Session does not exist: sme_id %d", sme_session_id);
3724 return;
3725 }
3726 pe_session->gLimEdcaParamsActive[EDCA_AC_BE].no_ack =
3727 mac_ctx->no_ack_policy_cfg[EDCA_AC_BE];
3728 pe_session->gLimEdcaParamsActive[EDCA_AC_BK].no_ack =
3729 mac_ctx->no_ack_policy_cfg[EDCA_AC_BK];
3730 pe_session->gLimEdcaParamsActive[EDCA_AC_VI].no_ack =
3731 mac_ctx->no_ack_policy_cfg[EDCA_AC_VI];
3732 pe_session->gLimEdcaParamsActive[EDCA_AC_VO].no_ack =
3733 mac_ctx->no_ack_policy_cfg[EDCA_AC_VO];
3734 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3735 &pe_session->dph.dphHashTable);
3736 if (sta_ds_ptr)
3737 lim_send_edca_params(mac_ctx,
3738 pe_session->gLimEdcaParamsActive,
Kiran Kumar Lokere27026ae2018-03-09 11:38:19 -08003739 sta_ds_ptr->bssId, false);
Arif Hussaineb8ba362018-03-07 19:15:13 -08003740 else
3741 pe_err("Self entry missing in Hash Table");
3742}
3743
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07003744static void lim_process_sme_update_mu_edca_params(tpAniSirGlobal mac_ctx,
3745 uint32_t sme_session_id)
3746{
3747 tpPESession pe_session;
3748 tpDphHashNode sta_ds_ptr;
3749
3750 pe_session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
3751 if (!pe_session) {
3752 pe_err("Session does not exist: sme_id %d", sme_session_id);
3753 return;
3754 }
3755 sta_ds_ptr = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
3756 &pe_session->dph.dphHashTable);
3757 if (sta_ds_ptr)
3758 lim_send_edca_params(mac_ctx, mac_ctx->usr_mu_edca_params,
3759 sta_ds_ptr->bssId, true);
3760 else
3761 pe_err("Self entry missing in Hash Table");
3762}
3763
Naveen Rawat8029a402017-06-01 10:54:19 -07003764static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3765 struct update_config *msg)
3766{
3767 tpPESession pe_session;
3768
3769 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3770 if (msg == NULL) {
3771 pe_err("Buffer is Pointing to NULL");
3772 return;
3773 }
3774
3775 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3776 msg->sme_session_id);
3777 if (pe_session == NULL) {
3778 pe_warn("Session does not exist for given BSSID");
3779 return;
3780 }
3781
3782 switch (msg->capab) {
3783 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3784 pe_session->htConfig.ht_rx_ldpc = msg->value;
3785 break;
3786 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3787 pe_session->htConfig.ht_tx_stbc = msg->value;
3788 break;
3789 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3790 pe_session->htConfig.ht_rx_stbc = msg->value;
3791 break;
3792 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3793 pe_session->htConfig.ht_sgi20 = msg->value;
3794 break;
3795 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3796 pe_session->htConfig.ht_sgi40 = msg->value;
3797 break;
3798 }
3799
3800 if (LIM_IS_AP_ROLE(pe_session)) {
3801 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
Abhishek Singhfc740be2018-10-12 11:34:26 +05303802 lim_send_beacon_ind(mac_ctx, pe_session, REASON_CONFIG_UPDATE);
Naveen Rawat8029a402017-06-01 10:54:19 -07003803 }
3804}
3805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806void
3807lim_send_vdev_restart(tpAniSirGlobal pMac,
3808 tpPESession psessionEntry, uint8_t sessionId)
3809{
3810 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003811 struct scheduler_msg msgQ = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003812 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813
3814 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003815 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 return;
3817 }
3818
3819 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303820 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Arif Hussainf5b6c412018-10-10 19:41:09 -07003821 if (!pHalHiddenSsidVdevRestart)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003822 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
3824 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3825 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003826 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827
3828 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
3829 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
3830 msgQ.bodyval = 0;
3831
3832 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003833 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003834 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303835 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 }
3837}
3838
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303839/**
3840 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
3841 * @mac_ctx: Pointer to Global MAC structure
3842 * @msg_buf: Pointer to SME message buffer
3843 *
3844 * Return: None
3845 */
3846static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
3847 uint32_t *msg_buf)
3848{
3849 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003850 struct scheduler_msg wma_msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003851 QDF_STATUS status;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303852 tSirRoamOffloadScanReq *req_buffer;
3853 uint16_t local_ie_len;
3854 uint8_t *local_ie_buf;
3855
3856 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
3857 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3858 req_buffer->sessionId);
3859
3860 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
3861 if (!local_ie_buf) {
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05303862 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303863 return;
3864 }
3865
3866 local_ie_len = req_buffer->assoc_ie.length;
3867 /* Update ext cap IE if present */
3868 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07003869 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
3870 local_ie_buf, &local_ie_len)) {
3871 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07003872 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
3873 req_buffer->assoc_ie.length = local_ie_len;
3874 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
3875 local_ie_buf, local_ie_len);
3876 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303877 }
3878 qdf_mem_free(local_ie_buf);
3879
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05303880 if (pe_session)
3881 lim_update_fils_rik(pe_session, req_buffer);
3882
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303883 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
3884 wma_msg.bodyptr = req_buffer;
3885
3886 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003887 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003888 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05303889 qdf_mem_free(req_buffer);
3890 }
3891}
3892
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303893/*
3894 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
3895 * @mac_ctx: Pointer to global mac context
3896 * @session: Pointer to PE session
3897 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
3898 * 1 - Disable broadcast SSID
3899 *
3900 * Return: None
3901 */
3902static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
3903 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003905 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003906 session->ssidHidden, ssid_hidden);
3907
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003908 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303909 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07003910 } else {
3911 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05303912 return;
3913 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914
Abhishek Singh6c681f42018-09-12 15:52:36 +05303915#ifdef CONFIG_VDEV_SM
3916 ap_mlme_set_hidden_ssid_restart_in_progress(session->vdev, true);
3917 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
3918 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
3919 sizeof(*session), session);
3920#else
3921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303923 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Abhishek Singh6c681f42018-09-12 15:52:36 +05303924#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303927}
3928
3929/**
3930 * __lim_process_sme_session_update - process SME session update msg
3931 *
3932 * @mac_ctx: Pointer to global mac context
3933 * @msg_buf: Pointer to the received message buffer
3934 *
3935 * Return: None
3936 */
3937static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
3938 uint32_t *msg_buf)
3939{
3940 struct sir_update_session_param *msg;
3941 tpPESession session;
3942
3943 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003944 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303945 return;
3946 }
3947
3948 msg = (struct sir_update_session_param *) msg_buf;
3949
3950 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
3951 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003952 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303953 msg->session_id);
3954 return;
3955 }
3956
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003957 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303958 msg->param_type, msg->param_val);
3959 switch (msg->param_type) {
3960 case SIR_PARAM_SSID_HIDDEN:
3961 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
3962 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05303963 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
3964 session->ignore_assoc_disallowed = msg->param_val;
3965 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303966 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003967 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05303968 break;
3969 }
3970}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972/*
3973 Update the beacon Interval dynamically if beaconInterval is different in MCC
3974 */
3975static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3976{
3977 tpSirChangeBIParams pChangeBIParams;
3978 tpPESession psessionEntry;
3979 uint8_t sessionId = 0;
3980 tUpdateBeaconParams beaconParams;
3981
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003982 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983
3984 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003985 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 return;
3987 }
3988
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303989 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
3991
3992 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08003993 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 &sessionId);
3995 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003996 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 return;
3998 }
3999
4000 /*Update sessionEntry Beacon Interval */
4001 if (psessionEntry->beaconParams.beaconInterval !=
4002 pChangeBIParams->beaconInterval) {
4003 psessionEntry->beaconParams.beaconInterval =
4004 pChangeBIParams->beaconInterval;
4005 }
4006
4007 /*Update sch beaconInterval */
4008 if (pMac->sch.schObject.gSchBeaconInterval !=
4009 pChangeBIParams->beaconInterval) {
4010 pMac->sch.schObject.gSchBeaconInterval =
4011 pChangeBIParams->beaconInterval;
4012
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004013 pe_debug("LIM send update BeaconInterval Indication: %d",
4014 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015
4016 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4017 /* Update beacon */
4018 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4019
4020 beaconParams.bssIdx = psessionEntry->bssIdx;
4021 /* Set change in beacon Interval */
4022 beaconParams.beaconInterval =
4023 pChangeBIParams->beaconInterval;
4024 beaconParams.paramChangeBitmap =
4025 PARAM_BCN_INTERVAL_CHANGED;
4026 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4027 }
4028 }
4029
4030 return;
4031} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4032
4033#ifdef QCA_HT_2040_COEX
4034static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4035 uint32_t *pMsgBuf)
4036{
4037 tpSirSetHT2040Mode pSetHT2040Mode;
4038 tpPESession psessionEntry;
4039 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004040 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 tUpdateVHTOpMode *pHtOpMode = NULL;
4042 uint16_t staId = 0;
4043 tpDphHashNode pStaDs = NULL;
4044
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004045 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004047 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 return;
4049 }
4050
4051 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4052
4053 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004054 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 &sessionId);
4056 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004057 pe_debug("Session does not exist for given BSSID");
4058 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059 return;
4060 }
4061
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004062 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 pSetHT2040Mode->cbMode);
4064 /*Update sessionEntry HT related fields */
4065 switch (pSetHT2040Mode->cbMode) {
4066 case PHY_SINGLE_CHANNEL_CENTERED:
4067 psessionEntry->htSecondaryChannelOffset =
4068 PHY_SINGLE_CHANNEL_CENTERED;
4069 psessionEntry->htRecommendedTxWidthSet = 0;
4070 if (pSetHT2040Mode->obssEnabled)
4071 psessionEntry->htSupportedChannelWidthSet
4072 = eHT_CHANNEL_WIDTH_40MHZ;
4073 else
4074 psessionEntry->htSupportedChannelWidthSet
4075 = eHT_CHANNEL_WIDTH_20MHZ;
4076 break;
4077 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4078 psessionEntry->htSecondaryChannelOffset =
4079 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4080 psessionEntry->htRecommendedTxWidthSet = 1;
4081 break;
4082 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4083 psessionEntry->htSecondaryChannelOffset =
4084 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4085 psessionEntry->htRecommendedTxWidthSet = 1;
4086 break;
4087 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004088 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 return;
4090 }
4091
4092 /* Update beacon */
4093 sch_set_fixed_beacon_fields(pMac, psessionEntry);
Abhishek Singhfc740be2018-10-12 11:34:26 +05304094 lim_send_beacon_ind(pMac, psessionEntry, REASON_SET_HT2040);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095
4096 /* update OP Mode for each associated peer */
4097 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4098 pStaDs = dph_get_hash_entry(pMac, staId,
4099 &psessionEntry->dph.dphHashTable);
4100 if (NULL == pStaDs)
4101 continue;
4102
4103 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304104 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004105 if (!pHtOpMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 pHtOpMode->opMode =
4108 (psessionEntry->htSecondaryChannelOffset ==
4109 PHY_SINGLE_CHANNEL_CENTERED) ?
4110 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4111 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304112 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 sizeof(tSirMacAddr));
4114 pHtOpMode->smesessionId = sessionId;
4115
4116 msg.type = WMA_UPDATE_OP_MODE;
4117 msg.reserved = 0;
4118 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004119 if (!QDF_IS_STATUS_SUCCESS
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05304120 (scheduler_post_message(QDF_MODULE_ID_PE,
4121 QDF_MODULE_ID_WMA,
4122 QDF_MODULE_ID_WMA,
4123 &msg))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304125 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 return;
4127 }
Jeff Johnson47d75242018-05-12 15:58:53 -07004128 pe_debug("Notified FW about OP mode: %d for staId=%d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004129 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130
4131 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004132 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 }
4134
4135 return;
4136}
4137#endif
4138
4139/* -------------------------------------------------------------------- */
4140/**
4141 * __lim_process_report_message
4142 *
4143 * FUNCTION: Processes the next received Radio Resource Management message
4144 *
4145 * LOGIC:
4146 *
4147 * ASSUMPTIONS:
4148 *
4149 * NOTE:
4150 *
4151 * @param None
4152 * @return None
4153 */
4154
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004155static void __lim_process_report_message(tpAniSirGlobal pMac,
4156 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 switch (pMsg->type) {
4159 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4160 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4161 break;
4162 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004164 break;
4165 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004166 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168}
4169
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004170/* -------------------------------------------------------------------- */
4171/**
4172 * lim_send_set_max_tx_power_req
4173 *
4174 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4175 *
4176 * LOGIC:
4177 *
4178 * ASSUMPTIONS:
4179 *
4180 * NOTE:
4181 *
4182 * @param txPower txPower to be set.
4183 * @param pSessionEntry session entry.
4184 * @return None
4185 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004186QDF_STATUS
Amar Singhala297bfa2015-10-15 15:07:29 -07004187lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188 tpPESession pSessionEntry)
4189{
4190 tpMaxTxPowerParams pMaxTxParams = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004191 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004192 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193
4194 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004195 pe_err("Invalid parameters");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004196 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 }
4198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304199 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004200 if (!pMaxTxParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004201 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304203 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304204 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304205 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004206 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304207 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208
4209 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4210 msgQ.bodyptr = pMaxTxParams;
4211 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004212 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4214 retCode = wma_post_ctrl_msg(pMac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004215 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004216 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304217 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 }
4219 return retCode;
4220}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221
4222/**
4223 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4224 *
4225 * @mac_ctx: Pointer to Global MAC structure
4226 * @msg_buf: pointer to the SME message buffer
4227 *
4228 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4229 * from SME. It Register this information within PE.
4230 *
4231 * Return: None
4232 */
4233static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4234 uint32_t *msg_buf)
4235{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304236 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4238 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4239 struct mgmt_frm_reg_info *next = NULL;
4240 bool match = false;
4241
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004242 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 sme_req->registerFrame, sme_req->frameType,
4244 sme_req->matchLen);
4245 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304246 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304247 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4248 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304249 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250
4251 while (lim_mgmt_regn != NULL) {
4252 if (lim_mgmt_regn->frameType != sme_req->frameType)
4253 goto skip_match;
4254 if (sme_req->matchLen) {
4255 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304256 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 sme_req->matchData,
4258 lim_mgmt_regn->matchLen))) {
4259 /* found match! */
4260 match = true;
4261 break;
4262 }
4263 } else {
4264 /* found match! */
4265 match = true;
4266 break;
4267 }
4268skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304269 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304270 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304272 (qdf_list_node_t *)lim_mgmt_regn,
4273 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304274 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 lim_mgmt_regn = next;
4276 next = NULL;
4277 }
4278 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304279 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004280 if (QDF_STATUS_SUCCESS ==
4281 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004283 (qdf_list_node_t *)lim_mgmt_regn))
4284 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304285 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
4287
4288 if (sme_req->registerFrame) {
4289 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304290 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 sme_req->matchLen);
4292 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 lim_mgmt_regn->frameType = sme_req->frameType;
4294 lim_mgmt_regn->matchLen = sme_req->matchLen;
4295 lim_mgmt_regn->sessionId = sme_req->sessionId;
4296 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304297 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 sme_req->matchData,
4299 sme_req->matchLen);
4300 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304301 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304303 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 gLimMgmtFrameRegistratinQueue,
4305 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304306 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 &mac_ctx->lim.lim_frame_register_lock);
4308 }
4309 }
4310 return;
4311}
4312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313static void
4314__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4315{
4316 tpSirResetAPCapsChange pResetCapsChange;
4317 tpPESession psessionEntry;
4318 uint8_t sessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004321 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 return;
4323 }
4324
4325 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4326 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004327 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4328 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004330 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 return;
4332 }
4333
4334 psessionEntry->limSentCapsChangeNtf = false;
4335 return;
4336}
4337
4338/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304339 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4340 * indication callback in PE.
4341 * @mac_ptr: Mac pointer
4342 * @msg_buf: Msg pointer containing the callback
4343 *
4344 * This function is used save the Management frame
4345 * indication callback in PE.
4346 *
4347 * Return: None
4348 */
4349static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4350 uint32_t *msg_buf)
4351{
4352 struct sir_sme_mgmt_frame_cb_req *sme_req =
4353 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4354
4355 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004356 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304357 return;
4358 }
4359 if (sme_req->callback)
4360 mac_ctx->mgmt_frame_ind_cb =
4361 (sir_mgmt_frame_ind_callback)sme_req->callback;
4362 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004363 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304364}
4365
4366/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304367 *__lim_process_send_disassoc_frame: function processes disassoc frame
4368 * @mac_ctx: pointer to mac context
4369 * @msg_buf: message buffer
4370 *
4371 * function processes disassoc request received from SME
4372 *
4373 * return: none
4374 */
4375static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4376 uint32_t *msg_buf)
4377{
4378 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004379 QDF_STATUS status;
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304380 tpPESession session_entry = NULL;
4381 uint8_t sme_session_id;
4382 uint16_t sme_trans_id;
4383
4384 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004385 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304386 return;
4387 }
4388
4389 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4390 &sme_trans_id);
4391
4392 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4393 &sme_send_disassoc_frame_req,
4394 (uint8_t *)msg_buf);
4395
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004396 if ((QDF_STATUS_E_FAILURE == status) ||
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304397 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4398 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004399 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304400 return;
4401 }
4402
4403 session_entry = pe_find_session_by_sme_session_id(
4404 mac_ctx, sme_session_id);
4405 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004406 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304407 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4408 return;
4409 }
4410
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004411 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 +05304412 sme_send_disassoc_frame_req.msg_type,
4413 sme_send_disassoc_frame_req.length,
4414 sme_send_disassoc_frame_req.session_id,
4415 sme_send_disassoc_frame_req.trans_id,
4416 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4417 sme_send_disassoc_frame_req.reason,
4418 sme_send_disassoc_frame_req.wait_for_ack);
4419
4420 lim_send_disassoc_mgmt_frame(mac_ctx,
4421 sme_send_disassoc_frame_req.reason,
4422 sme_send_disassoc_frame_req.peer_mac,
4423 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4424}
4425
4426/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004427 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4428 * @mac_ctx: Pointer to Global MAC structure
4429 * @pdev_id: pdev id to set the IE.
4430 * @nss: Nss values to prepare the HT IE.
4431 *
4432 * Prepares the HT IE with self capabilities for different
4433 * Nss values and sends the set HT IE req to FW.
4434 *
4435 * Return: None
4436 */
4437static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4438 uint8_t nss)
4439{
4440 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004441 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004442 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004443 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004444 tHtCaps *p_ht_cap;
4445 int i;
4446
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004447 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004448 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004449 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004450 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004451 ie_params->nss = i;
4452 ie_params->pdev_id = pdev_id;
4453 ie_params->ie_type = DOT11_HT_IE;
4454 /* 2 for IE len and EID */
4455 ie_params->ie_len = 2 + sizeof(tHtCaps);
4456 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004457 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004458 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004459 return;
4460 }
4461 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4462 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4463 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4464 ie_params->ie_len);
4465
4466 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004467 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
4468 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004469 if (NULL == p_ie) {
4470 qdf_mem_free(ie_params->ie_ptr);
4471 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004472 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004473 return;
4474 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004475 p_ht_cap = (tHtCaps *)&p_ie[2];
4476 p_ht_cap->supportedMCSSet[1] = 0;
4477 p_ht_cap->txSTBC = 0;
4478 }
4479
4480 msg.type = WMA_SET_PDEV_IE_REQ;
4481 msg.bodyptr = ie_params;
4482 msg.bodyval = 0;
4483
4484 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004485 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004486 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004487 qdf_mem_free(ie_params->ie_ptr);
4488 qdf_mem_free(ie_params);
4489 return;
4490 }
4491 }
4492}
4493
4494/**
4495 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4496 * @mac_ctx: Pointer to Global MAC structure
4497 * @pdev_id: pdev id to set the IE.
4498 * @nss: Nss values to prepare the VHT IE.
4499 *
4500 * Prepares the VHT IE with self capabilities for different
4501 * Nss values and sends the set VHT IE req to FW.
4502 *
4503 * Return: None
4504 */
4505static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4506 uint8_t nss)
4507{
4508 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004509 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004510 QDF_STATUS rc = QDF_STATUS_SUCCESS;
Naveen Rawat08db88f2017-09-08 15:07:48 -07004511 const uint8_t *p_ie = NULL;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004512 tSirMacVHTCapabilityInfo *vht_cap;
4513 int i;
4514 tSirVhtMcsInfo *vht_mcs;
4515
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004516 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004517 ie_params = qdf_mem_malloc(sizeof(*ie_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004518 if (!ie_params)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004519 return;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004520 ie_params->nss = i;
4521 ie_params->pdev_id = pdev_id;
4522 ie_params->ie_type = DOT11_VHT_IE;
4523 /* 2 for IE len and EID */
4524 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4525 sizeof(tSirVhtMcsInfo);
4526 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004527 if (!ie_params->ie_ptr) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004528 qdf_mem_free(ie_params);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004529 return;
4530 }
4531 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4532 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4533 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4534 ie_params->ie_len);
4535
4536 if (NSS_1x1_MODE == i) {
Naveen Rawat08db88f2017-09-08 15:07:48 -07004537 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS,
4538 ie_params->ie_ptr, ie_params->ie_len);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004539 if (NULL == p_ie) {
4540 qdf_mem_free(ie_params->ie_ptr);
4541 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004542 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004543 return;
4544 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004545 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4546 vht_cap->txSTBC = 0;
4547 vht_mcs =
4548 (tSirVhtMcsInfo *)&p_ie[2 +
4549 sizeof(tSirMacVHTCapabilityInfo)];
4550 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4551 vht_mcs->rxHighest =
4552 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4553 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4554 vht_mcs->txHighest =
4555 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4556 }
4557 msg.type = WMA_SET_PDEV_IE_REQ;
4558 msg.bodyptr = ie_params;
4559 msg.bodyval = 0;
4560
4561 rc = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004562 if (rc != QDF_STATUS_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004563 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004564 qdf_mem_free(ie_params->ie_ptr);
4565 qdf_mem_free(ie_params);
4566 return;
4567 }
4568 }
4569}
4570
4571/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004572 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4573 * @mac_ctx: Pointer to Global MAC structure
4574 * @msg_buf: Pointer to the SME message buffer
4575 *
4576 * This function is called by limProcessMessageQueue(). This function sets the
4577 * VDEV IEs to the FW.
4578 *
4579 * Return: None
4580 */
4581static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4582 uint32_t *msg_buf)
4583{
4584 struct sir_set_vdev_ies_per_band *p_msg =
4585 (struct sir_set_vdev_ies_per_band *)msg_buf;
4586
4587 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004588 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004589 return;
4590 }
4591
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004592 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004593 p_msg->vdev_id);
4594 /* intentionally using NULL here so that self capabilty are sent */
4595 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4596 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004597 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004598}
4599
4600/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004601 * lim_process_set_pdev_IEs() - process the set pdev IE req
4602 * @mac_ctx: Pointer to Global MAC structure
4603 * @msg_buf: Pointer to the SME message buffer
4604 *
4605 * This function is called by limProcessMessageQueue(). This
4606 * function sets the PDEV IEs to the FW.
4607 *
4608 * Return: None
4609 */
4610static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4611{
4612 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4613
4614 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4615
4616 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004617 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004618 return;
4619 }
4620
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004621 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004622 ht_vht_cfg->nss);
4623 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4624
4625 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4626 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4627 ht_vht_cfg->nss);
4628}
4629
4630/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304631 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4632 *
4633 * access policy
4634 * @mac_ctx: pointer to mac context
4635 * @msg: message buffer
4636 *
4637 * function processes vendor IE and access policy from SME and updates PE
4638 *
4639 * session entry
4640 *
4641 * return: none
4642*/
4643static void lim_process_sme_update_access_policy_vendor_ie(
4644 tpAniSirGlobal mac_ctx,
4645 uint32_t *msg)
4646{
4647 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4648 struct sPESession *pe_session_entry;
Pragaspathi Thilagaraj9b7a1162018-05-07 16:28:13 +05304649 uint16_t num_bytes;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304650
4651 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004652 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304653 return;
4654 }
4655 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4656 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4657 update_vendor_ie->sme_session_id);
4658
4659 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004660 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304661 update_vendor_ie->sme_session_id);
4662 return;
4663 }
4664 if (pe_session_entry->access_policy_vendor_ie)
4665 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4666
4667 num_bytes = update_vendor_ie->ie[1] + 2;
4668 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07004669 if (!pe_session_entry->access_policy_vendor_ie)
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304670 return;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304671 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4672 &update_vendor_ie->ie[0], num_bytes);
4673
4674 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4675}
4676
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004677#ifdef CONFIG_VDEV_SM
4678QDF_STATUS lim_sta_mlme_vdev_disconnect_bss(struct vdev_mlme_obj *vdev_mlme,
4679 uint16_t data_len, void *data)
4680{
4681 tpAniSirGlobal mac_ctx;
4682 struct scheduler_msg *msg = (struct scheduler_msg *)data;
4683
4684 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
4685 if (!mac_ctx) {
4686 pe_err("mac_ctx is NULL");
4687 if (data)
4688 qdf_mem_free(data);
4689 return QDF_STATUS_E_INVAL;
4690 }
4691 pe_debug("VDEV Manager disconnect bss callback type:(%d)", msg->type);
4692
4693 switch (msg->type) {
4694 case eWNI_SME_DEAUTH_REQ:
4695 __lim_process_sme_deauth_req(mac_ctx,
4696 (uint32_t *)msg->bodyptr);
4697 break;
4698 case eWNI_SME_DISASSOC_CNF:
4699 case eWNI_SME_DEAUTH_CNF:
4700 __lim_process_sme_disassoc_cnf(mac_ctx,
4701 (uint32_t *)msg->bodyptr);
4702 break;
4703 case eWNI_SME_DISASSOC_REQ:
4704 __lim_process_sme_disassoc_req(mac_ctx,
4705 (uint32_t *)msg->bodyptr);
4706 break;
4707 default:
4708 pe_debug("Wrong message type received %d", msg->type);
4709 }
4710 return QDF_STATUS_SUCCESS;
4711}
4712#endif
4713
4714static void lim_process_sme_disassoc_cnf(tpAniSirGlobal mac_ctx,
4715 struct scheduler_msg *msg)
4716{
4717#ifdef CONFIG_VDEV_SM
4718 tSirSmeDisassocCnf sme_disassoc_cnf;
4719 tpPESession session;
4720 uint8_t session_id;
4721 QDF_STATUS status;
4722
4723 qdf_mem_copy(&sme_disassoc_cnf, msg->bodyptr,
4724 sizeof(struct sSirSmeDisassocCnf));
4725
4726 session = pe_find_session_by_bssid(mac_ctx,
4727 sme_disassoc_cnf.bssid.bytes,
4728 &session_id);
4729
4730 if (LIM_IS_STA_ROLE(session)) {
4731 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4732 WLAN_VDEV_SM_EV_DOWN,
4733 sizeof(*msg),
4734 msg);
4735 } else {
4736 __lim_process_sme_disassoc_cnf(mac_ctx,
4737 (uint32_t *)msg->bodyptr);
4738 }
4739#else
4740 __lim_process_sme_disassoc_cnf(mac_ctx, (uint32_t *)msg->bodyptr);
4741#endif
4742}
4743
4744static void lim_process_sme_disassoc_req(tpAniSirGlobal mac_ctx,
4745 struct scheduler_msg *msg)
4746{
4747#ifdef CONFIG_VDEV_SM
4748 tSirSmeDisassocReq disassoc_req;
4749 tpPESession session;
4750 uint8_t session_id;
4751 QDF_STATUS status;
4752
4753 qdf_mem_copy(&disassoc_req, msg->bodyptr, sizeof(tSirSmeDisassocReq));
4754
4755 session = pe_find_session_by_bssid(mac_ctx,
4756 disassoc_req.bssid.bytes,
4757 &session_id);
4758 if (LIM_IS_STA_ROLE(session)) {
4759 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4760 WLAN_VDEV_SM_EV_DOWN,
4761 sizeof(*msg),
4762 msg);
4763 } else {
4764 __lim_process_sme_disassoc_req(mac_ctx,
4765 (uint32_t *)msg->bodyptr);
4766 }
4767#else
4768 __lim_process_sme_disassoc_req(mac_ctx, (uint32_t *)msg->bodyptr);
4769#endif
4770}
4771
4772static void lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
4773 struct scheduler_msg *msg)
4774{
4775#ifdef CONFIG_VDEV_SM
4776 tSirSmeDeauthReq sme_deauth_req;
4777 tpPESession session;
4778 uint8_t session_id;
4779 QDF_STATUS status;
4780
4781 qdf_mem_copy(&sme_deauth_req, msg->bodyptr, sizeof(tSirSmeDeauthReq));
4782
4783 session = pe_find_session_by_bssid(mac_ctx,
4784 sme_deauth_req.bssid.bytes,
4785 &session_id);
4786 if (LIM_IS_STA_ROLE(session)) {
4787 status = wlan_vdev_mlme_sm_deliver_evt(session->vdev,
4788 WLAN_VDEV_SM_EV_DOWN,
4789 sizeof(*msg),
4790 msg);
4791 } else {
4792 __lim_process_sme_deauth_req(mac_ctx,
4793 (uint32_t *)msg->bodyptr);
4794 }
4795#else
4796 __lim_process_sme_deauth_req(mac_ctx, (uint32_t *)msg->bodyptr);
4797#endif
4798}
4799
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304800/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801 * lim_process_sme_req_messages()
4802 *
4803 ***FUNCTION:
4804 * This function is called by limProcessMessageQueue(). This
4805 * function processes SME request messages from HDD or upper layer
4806 * application.
4807 *
4808 ***LOGIC:
4809 *
4810 ***ASSUMPTIONS:
4811 *
4812 ***NOTE:
4813 *
4814 * @param pMac Pointer to Global MAC structure
4815 * @param msgType Indicates the SME message type
4816 * @param *pMsgBuf A pointer to the SME message buffer
4817 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4818 * false - if pMsgBuf is not to be freed.
4819 */
4820
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004821bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
4822 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823{
Jeff Johnson33142e62018-05-06 17:58:36 -07004824 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 -08004825 uint32_t *pMsgBuf = pMsg->bodyptr;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004826
4827 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 lim_msg_str(pMsg->type), pMsg->type,
4829 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4830 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 /* If no insert NOA required then execute the code below */
4833
4834 switch (pMsg->type) {
4835 case eWNI_SME_SYS_READY_IND:
4836 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4837 break;
4838
4839 case eWNI_SME_START_BSS_REQ:
4840 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4841 break;
4842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4844 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4845 break;
4846 case eWNI_SME_JOIN_REQ:
4847 __lim_process_sme_join_req(pMac, pMsgBuf);
4848 break;
4849
4850 case eWNI_SME_REASSOC_REQ:
4851 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4852 break;
4853
4854 case eWNI_SME_DISASSOC_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004855 lim_process_sme_disassoc_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 break;
4857
4858 case eWNI_SME_DISASSOC_CNF:
4859 case eWNI_SME_DEAUTH_CNF:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004860 lim_process_sme_disassoc_cnf(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 break;
4862
4863 case eWNI_SME_DEAUTH_REQ:
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07004864 lim_process_sme_deauth_req(pMac, pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 break;
4866
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304867 case eWNI_SME_SEND_DISASSOC_FRAME:
4868 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
4869 break;
4870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 case eWNI_SME_SETCONTEXT_REQ:
4872 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4873 break;
4874
4875 case eWNI_SME_STOP_BSS_REQ:
4876 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4877 break;
4878
4879 case eWNI_SME_ASSOC_CNF:
4880 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004881 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4883 pMsgBuf);
4884 break;
4885
4886 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004887 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 __lim_process_sme_addts_req(pMac, pMsgBuf);
4889 break;
4890
4891 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004892 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 __lim_process_sme_delts_req(pMac, pMsgBuf);
4894 break;
4895
4896 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004897 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004898 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4899 break;
4900
4901 case eWNI_SME_GET_STATISTICS_REQ:
4902 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4903 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4904 bufConsumed = false;
4905 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004906#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 case eWNI_SME_GET_TSM_STATS_REQ:
4908 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4909 bufConsumed = false;
4910 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004911#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 case eWNI_SME_GET_ASSOC_STAS_REQ:
4913 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4914 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304915 case eWNI_SME_SESSION_UPDATE_PARAM:
4916 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304918 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
4919 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
4920 bufConsumed = false;
4921 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4923 /* Update the beaconInterval */
4924 __lim_process_sme_change_bi(pMac, pMsgBuf);
4925 break;
4926
4927#ifdef QCA_HT_2040_COEX
4928 case eWNI_SME_SET_HT_2040_MODE:
4929 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4930 break;
4931#endif
4932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4934 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4935 __lim_process_report_message(pMac, pMsg);
4936 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 case eWNI_SME_FT_PRE_AUTH_REQ:
4939 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4940 break;
4941 case eWNI_SME_FT_UPDATE_KEY:
4942 lim_process_ft_update_key(pMac, pMsgBuf);
4943 break;
4944
4945 case eWNI_SME_FT_AGGR_QOS_REQ:
4946 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4947 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948
4949 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4950 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4951 break;
4952#ifdef FEATURE_WLAN_TDLS
4953 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4954 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4955 break;
4956 case eWNI_SME_TDLS_ADD_STA_REQ:
4957 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4958 break;
4959 case eWNI_SME_TDLS_DEL_STA_REQ:
4960 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4961 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962#endif
4963 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4964 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4965 break;
4966
4967 case eWNI_SME_CHANNEL_CHANGE_REQ:
4968 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4969 break;
4970
4971 case eWNI_SME_START_BEACON_REQ:
4972 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4973 break;
4974
4975 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4976 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4977 break;
4978
4979 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4980 lim_process_update_add_ies(pMac, pMsgBuf);
4981 break;
4982
4983 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4984 lim_process_modify_add_ies(pMac, pMsgBuf);
4985 break;
4986 case eWNI_SME_SET_HW_MODE_REQ:
4987 lim_process_set_hw_mode(pMac, pMsgBuf);
4988 break;
4989 case eWNI_SME_NSS_UPDATE_REQ:
4990 lim_process_nss_update_request(pMac, pMsgBuf);
4991 break;
4992 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4993 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4994 break;
4995 case eWNI_SME_SET_IE_REQ:
4996 lim_process_set_ie_req(pMac, pMsgBuf);
4997 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05304998 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
4999 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5000 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305001 case eWNI_SME_EXT_CHANGE_CHANNEL:
5002 lim_process_ext_change_channel(pMac, pMsgBuf);
5003 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005004 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5005 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5006 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005007 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5008 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005009 break;
5010 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5011 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5012 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305013 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5014 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5015 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005016 case eWNI_SME_UPDATE_CONFIG:
5017 lim_process_sme_update_config(pMac,
5018 (struct update_config *)pMsgBuf);
5019 break;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08005020 case eWNI_SME_SET_ADDBA_ACCEPT:
5021 lim_process_sme_set_addba_accept(pMac,
5022 (struct sme_addba_accept *)pMsgBuf);
5023 break;
Arif Hussaineb8ba362018-03-07 19:15:13 -08005024 case eWNI_SME_UPDATE_EDCA_PROFILE:
5025 lim_process_sme_update_edca_params(pMac, pMsg->bodyval);
5026 break;
Kiran Kumar Lokerefba20632018-07-05 16:51:27 -07005027 case WNI_SME_UPDATE_MU_EDCA_PARAMS:
5028 lim_process_sme_update_mu_edca_params(pMac, pMsg->bodyval);
5029 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305031 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 pMsg->bodyptr = NULL;
5033 break;
5034 } /* switch (msgType) */
5035
5036 return bufConsumed;
5037} /*** end lim_process_sme_req_messages() ***/
5038
5039/**
5040 * lim_process_sme_start_beacon_req()
5041 *
5042 ***FUNCTION:
5043 * This function is called by limProcessMessageQueue(). This
5044 * function processes SME request messages from HDD or upper layer
5045 * application.
5046 *
5047 ***LOGIC:
5048 *
5049 ***ASSUMPTIONS:
5050 *
5051 ***NOTE:
5052 *
5053 * @param pMac Pointer to Global MAC structure
5054 * @param msgType Indicates the SME message type
5055 * @param *pMsgBuf A pointer to the SME message buffer
5056 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5057 * false - if pMsgBuf is not to be freed.
5058 */
5059static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5060{
5061 tpSirStartBeaconIndication pBeaconStartInd;
5062 tpPESession psessionEntry;
5063 uint8_t sessionId; /* PE sessionID */
5064
5065 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005066 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 return;
5068 }
5069
5070 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5071 psessionEntry = pe_find_session_by_bssid(pMac,
5072 pBeaconStartInd->bssid,
5073 &sessionId);
5074 if (psessionEntry == NULL) {
5075 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005076 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 return;
5078 }
5079
5080 if (pBeaconStartInd->beaconStartStatus == true) {
5081 /*
5082 * Currently this Indication comes from SAP
5083 * to start Beacon Tx on a DFS channel
5084 * since beaconing has to be done on DFS
5085 * channel only after CAC WAIT is completed.
5086 * On a DFS Channel LIM does not start beacon
5087 * Tx right after the WMA_ADD_BSS_RSP.
5088 */
5089 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305090 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 FL("Start Beacon with ssid %s Ch %d"),
5092 psessionEntry->ssId.ssId,
5093 psessionEntry->currentOperChannel);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05305094 lim_send_beacon(pMac, psessionEntry);
Arif Hussain1513cb22018-01-05 19:56:31 -08005095 lim_enable_obss_detection_config(pMac, psessionEntry);
Arif Hussain05fb4872018-01-03 16:02:55 -08005096 lim_send_obss_color_collision_cfg(pMac, psessionEntry,
5097 OBSS_COLOR_COLLISION_DETECTION);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005099 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 return;
5101 }
5102}
5103
5104/**
5105 * lim_process_sme_channel_change_request() - process sme ch change req
5106 *
5107 * @mac_ctx: Pointer to Global MAC structure
5108 * @msg_buf: pointer to the SME message buffer
5109 *
5110 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5111 *
5112 * Return: None
5113 */
5114static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5115 uint32_t *msg_buf)
5116{
5117 tpSirChanChangeRequest ch_change_req;
5118 tpPESession session_entry;
5119 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005120 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 uint32_t val = 0;
5122
5123 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005124 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 return;
5126 }
5127 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5128
5129 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5130 ch_change_req->targetChannel);
5131
5132 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5133 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005134 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005135 return;
5136 }
5137
5138 session_entry = pe_find_session_by_bssid(mac_ctx,
5139 ch_change_req->bssid, &session_id);
5140 if (session_entry == NULL) {
5141 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005142 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005143 return;
5144 }
5145
Manjunathappa Prakash34fda792018-02-07 18:23:42 -08005146 if ((session_entry->currentOperChannel ==
5147 ch_change_req->targetChannel) &&
5148 (session_entry->ch_width == ch_change_req->ch_width)) {
5149 pe_err("Target channel and mode is same as current channel and mode channel %d and mode %d",
5150 session_entry->currentOperChannel, session_entry->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 return;
5152 }
5153
5154 if (LIM_IS_AP_ROLE(session_entry))
5155 session_entry->channelChangeReasonCode =
5156 LIM_SWITCH_CHANNEL_SAP_DFS;
5157 else
5158 session_entry->channelChangeReasonCode =
5159 LIM_SWITCH_CHANNEL_OPERATION;
5160
Bala Venkateshb39ed152017-12-26 19:35:27 +05305161 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d, nw_type %d, dot11mode %d",
5162 session_entry->currentOperChannel,
5163 ch_change_req->targetChannel,
5164 ch_change_req->ch_width,
5165 ch_change_req->nw_type,
5166 ch_change_req->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167
5168 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005169 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170 session_entry->ch_center_freq_seg0 =
5171 ch_change_req->center_freq_seg_0;
5172 session_entry->ch_center_freq_seg1 =
5173 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005174 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005176 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 session_entry->htRecommendedTxWidthSet =
5178 session_entry->htSupportedChannelWidthSet;
5179 session_entry->currentOperChannel =
5180 ch_change_req->targetChannel;
5181 session_entry->limRFBand =
5182 lim_get_rf_band(session_entry->currentOperChannel);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305183 session_entry->cac_duration_ms = ch_change_req->cac_duration_ms;
5184 session_entry->dfs_regdomain = ch_change_req->dfs_regdomain;
5185 session_entry->maxTxPower = max_tx_pwr;
Vignesh Viswanathan153ae932018-04-11 14:24:13 +05305186
5187 /* Update the global beacon filter */
5188 lim_update_bcn_probe_filter(mac_ctx, session_entry);
5189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005191 if (CHAN_HOP_ALL_BANDS_ENABLE ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005192 BAND_5G == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005194 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005195 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 }
5197
5198 session_entry->lim11hEnable = val;
5199 session_entry->dot11mode = ch_change_req->dot11mode;
Bala Venkateshb39ed152017-12-26 19:35:27 +05305200 session_entry->nwType = ch_change_req->nw_type;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305201 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 &ch_change_req->operational_rateset,
5203 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305204 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 &ch_change_req->extended_rateset,
5206 sizeof(session_entry->extRateSet));
Abhishek Singh20a8e442018-09-12 15:50:44 +05305207
5208#ifdef CONFIG_VDEV_SM
Abhishek Singha063f1c2018-09-19 11:37:51 +05305209 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305210 if (wlan_vdev_mlme_get_state(session_entry->vdev) ==
5211 WLAN_VDEV_S_DFS_CAC_WAIT)
5212 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5213 WLAN_VDEV_SM_EV_RADAR_DETECTED,
5214 sizeof(*session_entry),
5215 session_entry);
5216 else
5217 wlan_vdev_mlme_sm_deliver_evt(session_entry->vdev,
5218 WLAN_VDEV_SM_EV_CSA_COMPLETE,
5219 sizeof(*session_entry),
5220 session_entry);
5221
5222
5223#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005224 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5225 session_entry->ch_center_freq_seg0,
5226 session_entry->ch_center_freq_seg1,
5227 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005228 max_tx_pwr, session_entry->peSessionId,
5229 ch_change_req->cac_duration_ms,
5230 ch_change_req->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05305231#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005232}
5233
5234/******************************************************************************
5235* lim_start_bss_update_add_ie_buffer()
5236*
5237***FUNCTION:
5238* This function checks the src buffer and its length and then malloc for
5239* dst buffer update the same
5240*
5241***LOGIC:
5242*
5243***ASSUMPTIONS:
5244*
5245***NOTE:
5246*
5247* @param pMac Pointer to Global MAC structure
5248* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5249* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5250* @param *pSrcData_buff A pointer of uint8_t src buffer
5251* @param srcDataLen src buffer length
5252******************************************************************************/
5253
5254static void
5255lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5256 uint8_t **pDstData_buff,
5257 uint16_t *pDstDataLen,
5258 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5259{
5260
5261 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5262 *pDstDataLen = srcDataLen;
5263
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305264 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005265 if (!*pDstData_buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305267 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 } else {
5269 *pDstData_buff = NULL;
5270 *pDstDataLen = 0;
5271 }
5272}
5273
5274/******************************************************************************
5275* lim_update_add_ie_buffer()
5276*
5277***FUNCTION:
5278* This function checks the src buffer and length if src buffer length more
5279* than dst buffer length then free the dst buffer and malloc for the new src
5280* length, and update the dst buffer and length. But if dst buffer is bigger
5281* than src buffer length then it just update the dst buffer and length
5282*
5283***LOGIC:
5284*
5285***ASSUMPTIONS:
5286*
5287***NOTE:
5288*
5289* @param pMac Pointer to Global MAC structure
5290* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5291* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5292* @param *pSrcData_buff A pointer of uint8_t src buffer
5293* @param srcDataLen src buffer length
5294******************************************************************************/
5295
5296static void
5297lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5298 uint8_t **pDstData_buff,
5299 uint16_t *pDstDataLen,
5300 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5301{
5302
5303 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005304 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 return;
5306 }
5307
5308 if (srcDataLen > *pDstDataLen) {
5309 *pDstDataLen = srcDataLen;
5310 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305311 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305313 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005314 if (!*pDstData_buff) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 *pDstDataLen = 0;
5316 return;
5317 }
5318 }
5319
5320 /* copy the content of buffer into dst buffer
5321 */
5322 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305323 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325}
5326
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005327/**
5328 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5329 * @pMac : Pointer to Global MAC structure
5330 * @pDstData_buff : A pointer to pointer of dst buffer
5331 * @pDstDataLen : A pointer to pointer of dst buffer length
5332 * @pModifyIE : A pointer to tSirModifyIE
5333 *
5334 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5335 *
5336 * Return:
5337 * True or false depending upon whether IE is updated or not
5338 */
5339static bool
5340lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5341 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5342{
Hong Shi1553d692016-09-28 12:16:19 +08005343 int32_t oui_length;
5344 uint8_t *ibss_ie = NULL;
5345 uint8_t *vendor_ie;
5346#define MAC_VENDOR_OUI "\x00\x16\x32"
5347#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005348
5349 ibss_ie = pModifyIE->pIEBuffer;
5350 oui_length = pModifyIE->oui_length;
5351
5352 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005353 pe_err("Invalid set IBSS vendor IE command length %d",
5354 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005355 return false;
5356 }
5357
Hong Shi1553d692016-09-28 12:16:19 +08005358 /*
5359 * Why replace only beacon OUI data here:
5360 * 1. other ie (such as wpa) shall not be overwritten here.
5361 * 2. per spec, beacon oui ie might be set twice and original one
5362 * shall be updated.
5363 */
Naveen Rawat08db88f2017-09-08 15:07:48 -07005364 vendor_ie = (uint8_t *)wlan_get_vendor_ie_ptr_from_oui(MAC_VENDOR_OUI,
Hong Shi1553d692016-09-28 12:16:19 +08005365 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5366 if (vendor_ie) {
5367 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5368 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5369 pModifyIE->ieBufferlength);
5370 } else {
Naveen Rawat668dee32017-09-29 14:39:40 -07005371 uint16_t new_length;
5372 uint8_t *new_ptr;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005373
Naveen Rawat668dee32017-09-29 14:39:40 -07005374 /*
5375 * check for uint16 overflow before using sum of two numbers as
5376 * length of size to malloc
5377 */
5378 if (USHRT_MAX - pModifyIE->ieBufferlength < *pDstDataLen) {
5379 pe_err("U16 overflow due to %d + %d",
5380 pModifyIE->ieBufferlength, *pDstDataLen);
5381 return false;
5382 }
5383
5384 new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5385 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005386 if (!new_ptr)
Hong Shi1553d692016-09-28 12:16:19 +08005387 return false;
Hong Shi1553d692016-09-28 12:16:19 +08005388 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5389 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5390 pModifyIE->ieBufferlength);
5391 qdf_mem_free(*pDstData_buff);
5392 *pDstDataLen = new_length;
5393 *pDstData_buff = new_ptr;
5394 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005395 return true;
5396}
5397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398/*
5399* lim_process_modify_add_ies() - process modify additional IE req.
5400*
5401* @mac_ctx: Pointer to Global MAC structure
5402* @msg_buf: pointer to the SME message buffer
5403*
5404* This function update the PE buffers for additional IEs.
5405*
5406* Return: None
5407*/
5408static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5409 uint32_t *msg_buf)
5410{
5411 tpSirModifyIEsInd modify_add_ies;
5412 tpPESession session_entry;
5413 uint8_t session_id;
5414 bool ret = false;
5415 tSirAddIeParams *add_ie_params;
5416
5417 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005418 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 return;
5420 }
5421
5422 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5423 /* Incoming message has smeSession, use BSSID to find PE session */
5424 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005425 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426
5427 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005428 pe_err("Session not found for given bssid"
5429 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005430 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431 goto end;
5432 }
5433 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5434 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5435 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005436 pe_err("Invalid request pIEBuffer %pK ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005437 modify_add_ies->modifyIE.pIEBuffer,
5438 modify_add_ies->modifyIE.ieBufferlength,
5439 modify_add_ies->modifyIE.ieID,
5440 modify_add_ies->modifyIE.ieIDLen,
5441 modify_add_ies->updateType);
5442 goto end;
5443 }
5444 add_ie_params = &session_entry->addIeParams;
5445 switch (modify_add_ies->updateType) {
5446 case eUPDATE_IE_PROBE_RESP:
5447 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005448 if (LIM_IS_IBSS_ROLE(session_entry)) {
5449 lim_update_ibss_prop_add_ies(mac_ctx,
5450 &add_ie_params->probeRespData_buff,
5451 &add_ie_params->probeRespDataLen,
5452 &modify_add_ies->modifyIE);
5453 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 break;
5455 case eUPDATE_IE_ASSOC_RESP:
5456 /* assoc resp IE */
5457 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305458 QDF_TRACE(QDF_MODULE_ID_PE,
5459 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 "assoc resp add ie not present %d"),
5461 add_ie_params->assocRespDataLen);
5462 }
5463 /* search through the buffer and modify the IE */
5464 break;
5465 case eUPDATE_IE_PROBE_BCN:
5466 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005467 if (LIM_IS_IBSS_ROLE(session_entry)) {
5468 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5469 &add_ie_params->probeRespBCNData_buff,
5470 &add_ie_params->probeRespBCNDataLen,
5471 &modify_add_ies->modifyIE);
5472 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 if (ret == true && modify_add_ies->modifyIE.notify) {
5474 lim_handle_param_update(mac_ctx,
5475 modify_add_ies->updateType);
5476 }
5477 break;
5478 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005479 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005480 modify_add_ies->updateType);
5481 break;
5482 }
5483end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305484 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 modify_add_ies->modifyIE.pIEBuffer = NULL;
5486}
5487
5488/*
5489* lim_process_update_add_ies() - process additional IE update req
5490*
5491* @mac_ctx: Pointer to Global MAC structure
5492* @msg_buf: pointer to the SME message buffer
5493*
5494* This function update the PE buffers for additional IEs.
5495*
5496* Return: None
5497*/
5498static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5499 uint32_t *msg_buf)
5500{
5501 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5502 uint8_t session_id;
5503 tpPESession session_entry;
5504 tSirAddIeParams *addn_ie;
5505 uint16_t new_length = 0;
5506 uint8_t *new_ptr = NULL;
5507 tSirUpdateIE *update_ie;
5508
5509 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005510 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005511 return;
5512 }
5513 update_ie = &update_add_ies->updateIE;
5514 /* incoming message has smeSession, use BSSID to find PE session */
5515 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005516 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517
5518 if (NULL == session_entry) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305519 pe_debug("Session not found for given bssid"
5520 MAC_ADDRESS_STR,
5521 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522 goto end;
5523 }
5524 addn_ie = &session_entry->addIeParams;
5525 /* if len is 0, upper layer requested freeing of buffer */
5526 if (0 == update_ie->ieBufferlength) {
5527 switch (update_add_ies->updateType) {
5528 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305529 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 addn_ie->probeRespData_buff = NULL;
5531 addn_ie->probeRespDataLen = 0;
5532 break;
5533 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305534 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 addn_ie->assocRespData_buff = NULL;
5536 addn_ie->assocRespDataLen = 0;
5537 break;
5538 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305539 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 addn_ie->probeRespBCNData_buff = NULL;
5541 addn_ie->probeRespBCNDataLen = 0;
5542
5543 if (update_ie->notify)
5544 lim_handle_param_update(mac_ctx,
5545 update_add_ies->updateType);
5546 break;
5547 default:
5548 break;
5549 }
5550 return;
5551 }
5552 switch (update_add_ies->updateType) {
5553 case eUPDATE_IE_PROBE_RESP:
5554 if (update_ie->append) {
5555 /*
5556 * In case of append, allocate new memory
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005557 * with combined length.
5558 * Multiple back to back append commands
5559 * can lead to a huge length.So, check
5560 * for the validity of the length.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 */
Varun Reddy Yeturu84637fc2017-10-02 11:52:37 -07005562 if (addn_ie->probeRespDataLen >
5563 (USHRT_MAX - update_ie->ieBufferlength)) {
5564 pe_err("IE Length overflow, curr:%d, new:%d",
5565 addn_ie->probeRespDataLen,
5566 update_ie->ieBufferlength);
5567 goto end;
5568 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 new_length = update_ie->ieBufferlength +
5570 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305571 new_ptr = qdf_mem_malloc(new_length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005572 if (!new_ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305575 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305577 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 update_ie->pAdditionIEBuffer,
5579 update_ie->ieBufferlength);
5580 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305581 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 /* adjust length accordingly */
5583 addn_ie->probeRespDataLen = new_length;
5584 /* save refernece of local buffer in PE session */
5585 addn_ie->probeRespData_buff = new_ptr;
5586 goto end;
5587 }
5588 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5589 &addn_ie->probeRespDataLen,
5590 update_ie->pAdditionIEBuffer,
5591 update_ie->ieBufferlength);
5592 break;
5593 case eUPDATE_IE_ASSOC_RESP:
5594 /* assoc resp IE */
5595 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5596 &addn_ie->assocRespDataLen,
5597 update_ie->pAdditionIEBuffer,
5598 update_ie->ieBufferlength);
5599 break;
5600 case eUPDATE_IE_PROBE_BCN:
5601 /* probe resp Bcn IE */
5602 lim_update_add_ie_buffer(mac_ctx,
5603 &addn_ie->probeRespBCNData_buff,
5604 &addn_ie->probeRespBCNDataLen,
5605 update_ie->pAdditionIEBuffer,
5606 update_ie->ieBufferlength);
5607 if (update_ie->notify)
5608 lim_handle_param_update(mac_ctx,
5609 update_add_ies->updateType);
5610 break;
5611 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005612 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613 break;
5614 }
5615end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305616 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 update_ie->pAdditionIEBuffer = NULL;
5618}
5619
5620/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305621 * send_extended_chan_switch_action_frame()- function to send ECSA
5622 * action frame for each sta connected to SAP/GO and AP in case of
5623 * STA .
5624 * @mac_ctx: pointer to global mac structure
5625 * @new_channel: new channel to switch to.
5626 * @ch_bandwidth: BW of channel to calculate op_class
5627 * @session_entry: pe session
5628 *
5629 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5630 *
5631 * Return: void
5632 */
5633
5634static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5635 uint16_t new_channel, uint8_t ch_bandwidth,
5636 tpPESession session_entry)
5637{
5638 uint16_t op_class;
5639 uint8_t switch_mode = 0, i;
5640 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005641 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305642
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005643 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305644 mac_ctx->scan.countryCodeCurrent,
5645 new_channel,
5646 ch_bandwidth);
5647
5648 if (LIM_IS_AP_ROLE(session_entry) &&
5649 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005650 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305651
gaoleze2920bd2017-03-21 17:38:42 +08005652 switch_count = session_entry->gLimChannelSwitch.switchCount;
5653
Abhishek Singh518323d2015-10-19 17:42:01 +05305654 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005655 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305656 psta =
5657 session_entry->dph.dphHashTable.pDphNodeArray + i;
5658 if (psta && psta->added)
5659 lim_send_extended_chan_switch_action_frame(
5660 mac_ctx,
5661 psta->staAddr,
5662 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005663 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305664 }
5665 } else if (LIM_IS_STA_ROLE(session_entry)) {
5666 lim_send_extended_chan_switch_action_frame(mac_ctx,
5667 session_entry->bssId,
5668 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005669 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305670 }
5671
5672}
5673
gaolez76d2a162017-03-21 19:23:58 +08005674void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5675 uint16_t new_channel,
5676 uint8_t ch_bandwidth,
5677 tpPESession session_entry)
5678{
5679 uint16_t op_class;
5680 uint8_t switch_mode = 0, i;
5681 uint8_t switch_count;
5682 tpDphHashNode psta;
5683 tpDphHashNode dph_node_array_ptr;
5684
5685 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5686
5687 op_class = wlan_reg_dmn_get_opclass_from_channel(
5688 mac_ctx->scan.countryCodeCurrent,
5689 new_channel, ch_bandwidth);
5690
5691 if (LIM_IS_AP_ROLE(session_entry) &&
5692 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5693 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5694
5695 switch_count = session_entry->gLimChannelSwitch.switchCount;
5696
5697 if (LIM_IS_AP_ROLE(session_entry)) {
5698 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5699 psta = dph_node_array_ptr + i;
5700 if (!(psta && psta->added))
5701 continue;
5702 if (session_entry->lim_non_ecsa_cap_num == 0)
5703 lim_send_extended_chan_switch_action_frame
5704 (mac_ctx, psta->staAddr, switch_mode,
5705 op_class, new_channel, switch_count,
5706 session_entry);
5707 else
5708 lim_send_channel_switch_mgmt_frame
5709 (mac_ctx, psta->staAddr, switch_mode,
5710 new_channel, switch_count,
5711 session_entry);
5712 }
5713 } else if (LIM_IS_STA_ROLE(session_entry)) {
5714 lim_send_extended_chan_switch_action_frame
5715 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5716 new_channel, switch_count, session_entry);
5717 }
5718}
5719
5720/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5722 *
5723 * @mac_ctx: Pointer to Global MAC structure
5724 * @msg_buf: pointer to the SME message buffer
5725 *
5726 * This function processes SME request messages from HDD or upper layer
5727 * application.
5728 *
5729 * Return: None
5730 */
5731static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5732 uint32_t *msg_buf)
5733{
5734 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5735 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 uint8_t session_id;
5737 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005738 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739
5740 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005741 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 return;
5743 }
5744
5745 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5746 session_entry = pe_find_session_by_bssid(mac_ctx,
5747 dfs_csa_ie_req->bssid, &session_id);
5748 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005749 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5751 return;
5752 }
5753
5754 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005755 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 GET_LIM_SYSTEM_ROLE(session_entry));
5757 return;
5758 }
5759
5760 /* target channel */
5761 session_entry->gLimChannelSwitch.primaryChannel =
5762 dfs_csa_ie_req->targetChannel;
5763
5764 /* Channel switch announcement needs to be included in beacon */
5765 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005766 session_entry->gLimChannelSwitch.switchCount =
5767 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005769 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305770 session_entry->gLimChannelSwitch.sec_ch_offset =
5771 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005773 session_entry->gLimChannelSwitch.switchMode =
5774 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775
5776 /*
5777 * Validate if SAP is operating HT or VHT mode and set the Channel
5778 * Switch Wrapper element with the Wide Band Switch subelement.
5779 */
5780 if (true != session_entry->vhtCapability)
5781 goto skip_vht;
5782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 /* Now encode the Wider Ch BW element depending on the ch width */
5784 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005785 switch (dfs_csa_ie_req->ch_params.ch_width) {
5786 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 /*
5788 * Wide channel BW sublement in channel wrapper element is not
5789 * required in case of 20 Mhz operation. Currently It is set
5790 * only set in case of 40/80 Mhz Operation.
5791 */
5792 session_entry->dfsIncludeChanWrapperIe = false;
5793 wider_bw_ch_switch->newChanWidth =
5794 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5795 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005796 case CH_WIDTH_40MHZ:
5797 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005798 wider_bw_ch_switch->newChanWidth =
5799 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5800 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005801 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 session_entry->dfsIncludeChanWrapperIe = true;
5803 wider_bw_ch_switch->newChanWidth =
5804 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5805 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005806 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005807 session_entry->dfsIncludeChanWrapperIe = true;
5808 wider_bw_ch_switch->newChanWidth =
5809 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5810 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005811 case CH_WIDTH_80P80MHZ:
5812 session_entry->dfsIncludeChanWrapperIe = true;
5813 wider_bw_ch_switch->newChanWidth =
5814 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005815 /*
5816 * This is not applicable for 20/40/80 Mhz.
5817 * Only used when we support 80+80 Mhz operation.
5818 * In case of 80+80 Mhz, this parameter indicates
5819 * center channel frequency index of 80 Mhz channel of
5820 * frequency segment 1.
5821 */
5822 wider_bw_ch_switch->newCenterChanFreq1 =
5823 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005824 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005825 default:
5826 session_entry->dfsIncludeChanWrapperIe = false;
5827 /*
5828 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5829 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5830 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005831 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 break;
5833 }
5834 /* Fetch the center channel based on the channel width */
5835 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005836 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837skip_vht:
5838 /* Send CSA IE request from here */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05305839 lim_send_dfs_chan_sw_ie_update(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305840
5841 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5842 ch_offset = BW80;
5843 else
5844 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5845
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005846 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305847 session_entry->gLimChannelSwitch.switchCount,
5848 session_entry->gLimChannelSwitch.primaryChannel,
5849 session_entry->gLimChannelSwitch.ch_width,
5850 session_entry->dfsIncludeChanWrapperIe,
5851 ch_offset);
5852
gaolez76d2a162017-03-21 19:23:58 +08005853 /* Send ECSA/CSA Action frame after updating the beacon */
5854 if (CHAN_HOP_ALL_BANDS_ENABLE)
5855 lim_send_chan_switch_action_frame(mac_ctx,
5856 session_entry->gLimChannelSwitch.primaryChannel,
5857 ch_offset, session_entry);
5858 else
5859 send_extended_chan_switch_action_frame(mac_ctx,
5860 session_entry->gLimChannelSwitch.primaryChannel,
5861 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862}
5863
5864/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305865 * lim_process_ext_change_channel()- function to send ECSA
5866 * action frame for STA/CLI .
5867 * @mac_ctx: pointer to global mac structure
5868 * @msg: params from sme for new channel.
5869 *
5870 * This function is called to send ECSA frame for STA/CLI.
5871 *
5872 * Return: void
5873 */
5874
5875static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5876 uint32_t *msg)
5877{
5878 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5879 (struct sir_sme_ext_cng_chan_req *) msg;
5880 tpPESession session_entry = NULL;
5881
5882 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005883 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05305884 return;
5885 }
5886 session_entry =
5887 pe_find_session_by_sme_session_id(mac_ctx,
5888 ext_chng_channel->session_id);
5889 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005890 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05305891 ext_chng_channel->session_id);
5892 return;
5893 }
5894 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005895 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05305896 return;
5897 }
5898 send_extended_chan_switch_action_frame(mac_ctx,
5899 ext_chng_channel->new_channel,
5900 0, session_entry);
5901}
5902
5903/**
Abhishek Singhfc740be2018-10-12 11:34:26 +05305904 * lim_nss_update_rsp() - send NSS update response to SME
5905 * @mac_ctx Pointer to Global MAC structure
5906 * @vdev_id: vdev id
5907 * @status: nss update status
5908 *
5909 * Return: None
5910 */
5911static void lim_nss_update_rsp(tpAniSirGlobal mac_ctx,
5912 uint8_t vdev_id, QDF_STATUS status)
5913{
5914 struct scheduler_msg msg = {0};
5915 struct sir_bcn_update_rsp *nss_rsp;
5916 QDF_STATUS qdf_status;
5917
5918 nss_rsp = qdf_mem_malloc(sizeof(*nss_rsp));
5919 if (!nss_rsp) {
5920 pe_err("AllocateMemory failed for nss_rsp");
5921 return;
5922 }
5923
5924 nss_rsp->vdev_id = vdev_id;
5925 nss_rsp->status = status;
5926 nss_rsp->reason = REASON_NSS_UPDATE;
5927
5928 msg.type = eWNI_SME_NSS_UPDATE_RSP;
5929 msg.bodyptr = nss_rsp;
5930 msg.bodyval = 0;
5931 qdf_status = scheduler_post_message(QDF_MODULE_ID_PE, QDF_MODULE_ID_SME,
5932 QDF_MODULE_ID_SME, &msg);
5933 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5934 pe_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
5935 qdf_mem_free(nss_rsp);
5936 }
5937}
5938
5939void lim_send_bcn_rsp(tpAniSirGlobal mac_ctx, tpSendbeaconParams rsp)
5940{
5941 if (!rsp) {
5942 pe_err("rsp is NULL");
5943 return;
5944 }
5945
5946 pe_debug("Send beacon resp status %d for reason %d",
5947 rsp->status, rsp->reason);
5948
5949 if (rsp->reason == REASON_NSS_UPDATE)
5950 lim_nss_update_rsp(mac_ctx, rsp->vdev_id, rsp->status);
5951}
5952
5953/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 * lim_process_nss_update_request() - process sme nss update req
5955 *
5956 * @mac_ctx: Pointer to Global MAC structure
5957 * @msg_buf: pointer to the SME message buffer
5958 *
5959 * This function processes SME request messages from HDD or upper layer
5960 * application.
5961 *
5962 * Return: None
5963 */
5964static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5965 uint32_t *msg_buf)
5966{
5967 struct sir_nss_update_request *nss_update_req_ptr;
5968 tpPESession session_entry = NULL;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305969 QDF_STATUS status = QDF_STATUS_E_FAILURE;
5970 uint8_t vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971
Abhishek Singhfc740be2018-10-12 11:34:26 +05305972 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005973 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 return;
5975 }
5976
5977 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Abhishek Singhfc740be2018-10-12 11:34:26 +05305978 vdev_id = nss_update_req_ptr->vdev_id;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305979 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305981 if (!session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005982 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 nss_update_req_ptr->vdev_id);
Abhishek Singhfc740be2018-10-12 11:34:26 +05305984 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 }
5986
5987 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005988 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005989 GET_LIM_SYSTEM_ROLE(session_entry));
Abhishek Singhfc740be2018-10-12 11:34:26 +05305990 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005991 }
5992
5993 /* populate nss field in the beacon */
5994 session_entry->gLimOperatingMode.present = 1;
5995 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05305996 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
5997
5998 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
5999 (session_entry->ch_width > CH_WIDTH_80MHZ))
6000 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6001
Abhishek Singhfc740be2018-10-12 11:34:26 +05306002 pe_debug("ch width %d Rx NSS %d",
6003 session_entry->gLimOperatingMode.chanWidth,
6004 session_entry->gLimOperatingMode.rxNSS);
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006006 /* Send nss update request from here */
Abhishek Singhfc740be2018-10-12 11:34:26 +05306007 status = sch_set_fixed_beacon_fields(mac_ctx, session_entry);
6008 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006009 pe_err("Unable to set op mode IE in beacon");
Abhishek Singhfc740be2018-10-12 11:34:26 +05306010 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 }
6012
Abhishek Singhfc740be2018-10-12 11:34:26 +05306013 status = lim_send_beacon_ind(mac_ctx, session_entry, REASON_NSS_UPDATE);
6014 if (QDF_IS_STATUS_SUCCESS(status))
6015 return;
6016
6017 pe_err("Unable to send beacon");
6018end:
6019 /*
6020 * send resp only in case of failure,
6021 * success case response will be from wma.
6022 */
6023 lim_nss_update_rsp(mac_ctx, vdev_id, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024}
6025
6026/**
6027 * lim_process_set_ie_req() - process sme set IE request
6028 *
6029 * @mac_ctx: Pointer to Global MAC structure
6030 * @msg_buf: pointer to the SME message buffer
6031 *
6032 * This function processes SME request messages from HDD or upper layer
6033 * application.
6034 *
6035 * Return: None
6036 */
6037static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6038{
6039 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306040 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041
6042 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006043 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 return;
6045 }
6046
6047 msg = (struct send_extcap_ie *)msg_buf;
6048 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306049 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006050 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051
6052}
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006053
6054#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Arif Hussain05fb4872018-01-03 16:02:55 -08006055
6056/**
6057 * obss_color_collision_process_color_disable() - Disable bss color
6058 * @mac_ctx: Pointer to Global MAC structure
6059 * @session: pointer to session
6060 *
6061 * This function will disbale bss color.
6062 *
6063 * Return: None
6064 */
6065static void obss_color_collision_process_color_disable(tpAniSirGlobal mac_ctx,
6066 tpPESession session)
6067{
6068 tUpdateBeaconParams beacon_params;
6069
6070 if (!session) {
6071 pe_err("Invalid session");
6072 return;
6073 }
6074
6075 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6076 pe_err("Invalid SystemRole %d",
6077 GET_LIM_SYSTEM_ROLE(session));
6078 return;
6079 }
6080
6081 if (session->bss_color_changing == 1) {
6082 pe_warn("%d: color change in progress", session->smeSessionId);
6083 /* Continue color collision detection */
6084 lim_send_obss_color_collision_cfg(mac_ctx, session,
6085 OBSS_COLOR_COLLISION_DETECTION);
6086 return;
6087 }
6088
6089 if (session->he_op.bss_col_disabled == 1) {
6090 pe_warn("%d: bss color already disabled",
6091 session->smeSessionId);
6092 /* Continue free color detection */
6093 lim_send_obss_color_collision_cfg(mac_ctx, session,
6094 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6095 return;
6096 }
6097
6098 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6099 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6100 session->he_op.bss_col_disabled = 1;
Arif Hussain05fb4872018-01-03 16:02:55 -08006101 beacon_params.bss_color_disabled = 1;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006102 beacon_params.bss_color = session->he_op.bss_color;
Arif Hussain05fb4872018-01-03 16:02:55 -08006103
6104 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006105 QDF_STATUS_SUCCESS) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006106 pe_err("Unable to set op mode IE in beacon");
6107 return;
6108 }
6109
6110 lim_send_beacon_params(mac_ctx, &beacon_params, session);
6111 lim_send_obss_color_collision_cfg(mac_ctx, session,
6112 OBSS_COLOR_FREE_SLOT_AVAILABLE);
6113}
6114
6115/**
6116 * obss_color_collision_process_color_change() - Process bss color change
6117 * @mac_ctx: Pointer to Global MAC structure
6118 * @session: pointer to session
6119 * @obss_color_info: obss color collision/free slot indication info
6120 *
6121 * This function selects new color ib case of bss color collision.
6122 *
6123 * Return: None
6124 */
6125static void obss_color_collision_process_color_change(tpAniSirGlobal mac_ctx,
6126 tpPESession session,
6127 struct wmi_obss_color_collision_info *obss_color_info)
6128{
6129 int i, num_bss_color = 0;
6130 uint32_t bss_color_bitmap;
6131 uint8_t bss_color_index_array[MAX_BSS_COLOR_VALUE];
6132 uint32_t rand_byte = 0;
6133 struct sir_set_he_bss_color he_bss_color;
6134 bool is_color_collision = false;
6135
6136
6137 if (session->bss_color_changing == 1) {
6138 pe_err("%d: color change in progress", session->smeSessionId);
6139 return;
6140 }
6141
6142 if (!session->he_op.bss_col_disabled) {
6143 if (session->he_op.bss_color < 32)
6144 is_color_collision = (obss_color_info->
6145 obss_color_bitmap_bit0to31 >>
6146 session->he_op.bss_color) & 0x01;
6147 else
6148 is_color_collision = (obss_color_info->
6149 obss_color_bitmap_bit32to63 >>
6150 (session->he_op.bss_color -
Arif Hussain9e8c5612018-04-12 16:35:48 -07006151 32)) & 0x01;
Arif Hussain05fb4872018-01-03 16:02:55 -08006152 if (!is_color_collision) {
6153 pe_err("%d: color collision not found, curr_color: %d",
6154 session->smeSessionId,
6155 session->he_op.bss_color);
6156 return;
6157 }
6158 }
6159
6160 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit0to31;
6161
6162 /* Skip color zero */
6163 bss_color_bitmap = bss_color_bitmap >> 1;
6164 for (i = 0; (i < 31) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6165 if (!(bss_color_bitmap & 0x01)) {
6166 bss_color_index_array[num_bss_color] = i + 1;
6167 num_bss_color++;
6168 }
6169 bss_color_bitmap = bss_color_bitmap >> 1;
6170 }
6171
6172 bss_color_bitmap = obss_color_info->obss_color_bitmap_bit32to63;
6173 for (i = 0; (i < 32) && (num_bss_color < MAX_BSS_COLOR_VALUE); i++) {
6174 if (!(bss_color_bitmap & 0x01)) {
6175 bss_color_index_array[num_bss_color] = i + 32;
6176 num_bss_color++;
6177 }
6178 bss_color_bitmap = bss_color_bitmap >> 1;
6179 }
6180
6181 if (num_bss_color) {
6182 qdf_get_random_bytes((void *) &rand_byte, 1);
6183 i = (rand_byte + qdf_mc_timer_get_system_ticks()) %
6184 num_bss_color;
6185 pe_debug("New bss color = %d", bss_color_index_array[i]);
6186 he_bss_color.session_id = obss_color_info->vdev_id;
6187 he_bss_color.bss_color = bss_color_index_array[i];
6188 lim_process_set_he_bss_color(mac_ctx,
6189 (uint32_t *)&he_bss_color);
6190 } else {
6191 pe_err("Unable to find bss color from bitmasp");
6192 if (obss_color_info->evt_type ==
6193 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY &&
6194 session->obss_color_collision_dec_evt ==
6195 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6196 /* In dot11BSSColorCollisionAPPeriod and
6197 * timer expired, time to disable bss color.
6198 */
6199 obss_color_collision_process_color_disable(mac_ctx,
6200 session);
6201 else
6202 /*
6203 * Enter dot11BSSColorCollisionAPPeriod period.
6204 */
6205 lim_send_obss_color_collision_cfg(mac_ctx, session,
6206 OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY);
6207 }
6208}
6209
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006210void lim_process_set_he_bss_color(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6211{
6212 struct sir_set_he_bss_color *bss_color;
6213 tpPESession session_entry = NULL;
6214 tUpdateBeaconParams beacon_params;
6215
6216 if (!msg_buf) {
6217 pe_err("Buffer is Pointing to NULL");
6218 return;
6219 }
6220
6221 bss_color = (struct sir_set_he_bss_color *)msg_buf;
6222 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
6223 bss_color->session_id);
6224 if (!session_entry) {
6225 pe_err("Session not found for given session_id %d",
6226 bss_color->session_id);
6227 return;
6228 }
6229
6230 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6231 pe_err("Invalid SystemRole %d",
6232 GET_LIM_SYSTEM_ROLE(session_entry));
6233 return;
6234 }
6235
6236 if (bss_color->bss_color == session_entry->he_op.bss_color) {
6237 pe_err("No change in BSS color, current BSS color %d",
6238 bss_color->bss_color);
6239 return;
6240 }
6241 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
6242 beacon_params.paramChangeBitmap |= PARAM_BSS_COLOR_CHANGED;
6243 session_entry->he_op.bss_col_disabled = 1;
6244 session_entry->he_bss_color_change.countdown =
6245 BSS_COLOR_SWITCH_COUNTDOWN;
6246 session_entry->he_bss_color_change.new_color = bss_color->bss_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08006247 beacon_params.bss_color_disabled = 1;
6248 beacon_params.bss_color = session_entry->he_op.bss_color;
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006249 session_entry->bss_color_changing = 1;
6250
6251 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006252 QDF_STATUS_SUCCESS) {
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006253 pe_err("Unable to set op mode IE in beacon");
6254 return;
6255 }
6256
6257 lim_send_beacon_params(mac_ctx, &beacon_params, session_entry);
Arif Hussain05fb4872018-01-03 16:02:55 -08006258 lim_send_obss_color_collision_cfg(mac_ctx, session_entry,
6259 OBSS_COLOR_COLLISION_DETECTION_DISABLE);
6260}
6261
6262void lim_send_obss_color_collision_cfg(tpAniSirGlobal mac_ctx,
6263 tpPESession session,
6264 enum wmi_obss_color_collision_evt_type
6265 event_type)
6266{
6267 struct wmi_obss_color_collision_cfg_param *cfg_param;
6268 struct scheduler_msg msg = {0};
6269
6270 if (!session) {
6271 pe_err("Invalid session");
6272 return;
6273 }
6274
6275 if (!session->he_capable ||
6276 !session->is_session_obss_color_collision_det_enabled) {
6277 pe_debug("%d: obss color det not enabled, he_cap:%d, sup:%d:%d",
6278 session->smeSessionId, session->he_capable,
6279 session->is_session_obss_color_collision_det_enabled,
6280 mac_ctx->lim.global_obss_color_collision_det_offload);
6281 return;
6282 }
6283
6284 cfg_param = qdf_mem_malloc(sizeof(*cfg_param));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006285 if (!cfg_param)
Arif Hussain05fb4872018-01-03 16:02:55 -08006286 return;
Arif Hussain05fb4872018-01-03 16:02:55 -08006287
6288 pe_debug("%d: sending event:%d", session->smeSessionId, event_type);
6289 qdf_mem_zero(cfg_param, sizeof(*cfg_param));
6290 cfg_param->vdev_id = session->smeSessionId;
6291 cfg_param->evt_type = event_type;
6292 if (LIM_IS_AP_ROLE(session))
6293 cfg_param->detection_period_ms =
6294 OBSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS;
6295 else
6296 cfg_param->detection_period_ms =
6297 OBSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS;
6298
6299 cfg_param->scan_period_ms = OBSS_COLOR_COLLISION_SCAN_PERIOD_MS;
6300 if (event_type == OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY)
6301 cfg_param->free_slot_expiry_time_ms =
6302 OBSS_COLOR_COLLISION_FREE_SLOT_EXPIRY_MS;
6303
6304 msg.type = WMA_OBSS_COLOR_COLLISION_REQ;
6305 msg.bodyptr = cfg_param;
6306 msg.reserved = 0;
6307
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306308 if (QDF_IS_STATUS_ERROR(scheduler_post_message(QDF_MODULE_ID_PE,
6309 QDF_MODULE_ID_WMA,
6310 QDF_MODULE_ID_WMA,
6311 &msg))) {
Arif Hussain05fb4872018-01-03 16:02:55 -08006312 pe_err("Failed to post WMA_OBSS_COLOR_COLLISION_REQ to WMA");
6313 qdf_mem_free(cfg_param);
6314 } else {
6315 session->obss_color_collision_dec_evt = event_type;
6316 }
6317}
6318
6319void lim_process_obss_color_collision_info(tpAniSirGlobal mac_ctx,
6320 uint32_t *msg_buf)
6321{
6322 struct wmi_obss_color_collision_info *obss_color_info;
6323 tpPESession session;
6324
6325 if (!msg_buf) {
6326 pe_err("Buffer is Pointing to NULL");
6327 return;
6328 }
6329
6330 obss_color_info = (struct wmi_obss_color_collision_info *)msg_buf;
6331 session = pe_find_session_by_sme_session_id(mac_ctx,
6332 obss_color_info->vdev_id);
6333 if (!session) {
6334 pe_err("Session not found for given session_id %d",
6335 obss_color_info->vdev_id);
6336 return;
6337 }
6338
6339 pe_debug("vdev_id:%d, evt:%d:%d, 0to31:0x%x, 32to63:0x%x, cap:%d:%d:%d",
6340 obss_color_info->vdev_id,
6341 obss_color_info->evt_type,
6342 session->obss_color_collision_dec_evt,
6343 obss_color_info->obss_color_bitmap_bit0to31,
6344 obss_color_info->obss_color_bitmap_bit32to63,
6345 session->he_capable,
6346 session->is_session_obss_color_collision_det_enabled,
6347 mac_ctx->lim.global_obss_color_collision_det_offload);
6348
6349 if (!session->he_capable ||
6350 !session->is_session_obss_color_collision_det_enabled) {
6351 return;
6352 }
6353
6354 switch (obss_color_info->evt_type) {
6355 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
6356 pe_err("%d: FW disabled obss color det. he_cap:%d, sup:%d:%d",
6357 session->smeSessionId, session->he_capable,
6358 session->is_session_obss_color_collision_det_enabled,
6359 mac_ctx->lim.global_obss_color_collision_det_offload);
6360 session->is_session_obss_color_collision_det_enabled = false;
6361 return;
6362 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
6363 case OBSS_COLOR_COLLISION_DETECTION:
6364 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
6365 if (session->valid && !LIM_IS_AP_ROLE(session)) {
6366 pe_debug("Invalid System Role %d",
6367 GET_LIM_SYSTEM_ROLE(session));
6368 return;
6369 }
6370
6371 if (session->obss_color_collision_dec_evt !=
6372 obss_color_info->evt_type) {
6373 pe_debug("%d: Wrong event: %d, skiping",
6374 obss_color_info->vdev_id,
6375 obss_color_info->evt_type);
6376 return;
6377 }
6378 obss_color_collision_process_color_change(mac_ctx, session,
6379 obss_color_info);
6380 break;
6381 default:
6382 pe_err("%d: Invalid event type %d",
6383 obss_color_info->vdev_id, obss_color_info->evt_type);
6384 return;
6385 }
Kiran Kumar Lokeree6476b22017-10-16 23:40:32 -07006386}
6387#endif
Abhishek Singh20a8e442018-09-12 15:50:44 +05306388
6389#ifdef CONFIG_VDEV_SM
6390void lim_send_csa_restart_req(tpAniSirGlobal mac_ctx, uint8_t vdev_id)
6391{
6392 tpPESession session;
6393
6394 session = pe_find_session_by_sme_session_id(mac_ctx, vdev_id);
6395
6396 if (!session) {
6397 pe_err("session not found for vdev id %d", vdev_id);
6398 return;
6399 }
6400
6401 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
6402 WLAN_VDEV_SM_EV_CSA_RESTART,
6403 sizeof(*session), session);
6404}
6405#endif